:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --app-bg: #eef2f5;
  --ink: #17202a;
  --muted: #617182;
  --line: #d9e0e7;
  --panel: #ffffff;
  --primary: #235789;
  --accent: #f2a541;
  --focus: #15847d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(320px, auto);
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: #14212e;
  color: #fff;
  border-bottom: 4px solid var(--accent);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: #9fc6ca;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.header-actions,
.preview-actions,
.code-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-self: end;
  max-width: 680px;
  width: 100%;
}

.button,
.tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
  white-space: normal;
}

.header-actions .button {
  min-width: 0;
  padding: 0 10px;
  font-size: 0.84rem;
  line-height: 1.15;
}

.button.full {
  width: 100%;
  margin-top: 12px;
}

.button.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.button.primary,
.preview-actions .primary-action {
  background: var(--accent);
  border-color: var(--accent);
  color: #151b20;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 20px;
  padding: 20px;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: center;
  align-items: center;
  padding: 0 20px 22px;
  color: #617182;
  font-size: 0.84rem;
  font-weight: 700;
  text-align: center;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #c8d3dd;
  border-radius: 999px;
  background: #ffffff;
  color: #14212e;
  font-weight: 900;
}

.panel,
.workspace {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.controls {
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow: auto;
}

.controls section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.controls section:last-child {
  border-bottom: 0;
}

h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.template-list {
  display: grid;
  gap: 10px;
}

.template-option {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 72px;
  padding: 12px;
  text-align: left;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.template-option.active {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(21, 132, 125, 0.16);
}

.template-option strong {
  font-size: 0.94rem;
}

.template-option span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.3;
}

.field,
.toggle {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.toggle {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
}

.field input:not([type="color"]),
.field select,
.field textarea {
  min-width: 0;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.field input:not([type="color"]),
.field select {
  height: 40px;
}

.field textarea {
  min-height: 88px;
  padding: 10px;
  resize: vertical;
  line-height: 1.4;
}

.field input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.check-list {
  display: grid;
  gap: 10px;
}

.component-toggle {
  min-height: 48px;
  margin: 0;
}

.component-toggle span {
  display: grid;
  gap: 2px;
}

.component-toggle small {
  color: var(--muted);
  font-weight: 600;
  line-height: 1.25;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status-text {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--focus);
  font-size: 0.82rem;
  font-weight: 800;
}

.capture-summary {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  overflow-wrap: anywhere;
}

.capture-summary strong {
  color: var(--ink);
}

.capture-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.capture-summary.empty {
  border-style: dashed;
}

.captured-workbench {
  display: grid;
  gap: 14px;
  max-width: 980px;
}

.captured-workbench h2 {
  margin: 0 0 6px;
}

.helper-text {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.captured-workbench textarea {
  min-height: 320px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.5;
}

.captured-live-preview,
.final-css-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.captured-live-preview iframe {
  width: 100%;
  min-height: 680px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f5;
}

.visual-css-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.visual-css-panel h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.visual-css-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.visual-important {
  align-self: end;
  min-height: 40px;
}

.workbench-actions {
  max-width: 420px;
}

.workspace {
  min-width: 0;
  overflow: hidden;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.tab.active {
  background: #14212e;
  border-color: #14212e;
  color: #fff;
}

.tab-pane {
  display: none;
  padding: 18px;
}

.tab-pane.active {
  display: block;
}

.preview-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.preview-compare h2 {
  margin: 0 0 10px;
}

.preview-shell {
  overflow: hidden;
  min-height: 600px;
  background: var(--preview-bg, #f5f7fa);
  border: 1px solid var(--line);
  border-radius: var(--preview-radius, 8px);
}

.default-preview {
  --preview-primary: #747f8a;
  --preview-accent: #d9e0e7;
  --preview-surface: #ffffff;
  --preview-bg: #f4f6f8;
  --preview-text: #2f3a45;
  --preview-radius: 4px;
  --preview-space: 14px;
  --preview-shadow: none;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: var(--preview-space, 16px) calc(var(--preview-space, 16px) * 1.3);
  background: var(--preview-primary, #235789);
  color: #fff;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--preview-accent, #f2a541);
  color: #151b20;
  font-weight: 900;
}

.preview-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.preview-header a {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.preview-body {
  display: grid;
  gap: var(--preview-space, 16px);
  padding: calc(var(--preview-space, 16px) * 1.5);
}

.preview-stepper {
  display: flex;
  gap: 10px;
}

.preview-stepper span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--preview-primary, #235789);
  border-radius: 999px;
  color: var(--preview-primary, #235789);
  font-weight: 800;
}

.preview-stepper .done,
.preview-stepper .active {
  background: var(--preview-primary, #235789);
  color: #fff;
}

.preview-stepper .active {
  outline: 3px solid color-mix(in srgb, var(--preview-accent, #f2a541) 45%, transparent);
}

.preview-card,
.preview-flex article {
  background: var(--preview-surface, #fff);
  color: var(--preview-text, #1d2630);
  border: 1px solid color-mix(in srgb, var(--preview-primary, #235789) 18%, #dfe6ed);
  border-radius: var(--preview-radius, 8px);
  box-shadow: var(--preview-shadow, 0 12px 30px rgba(23, 32, 42, 0.12));
}

.preview-card {
  display: grid;
  gap: var(--preview-space, 16px);
  max-width: 760px;
  padding: calc(var(--preview-space, 16px) * 1.4);
}

.preview-kicker {
  margin: 0;
  color: var(--preview-primary, #235789);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.preview-card h3 {
  margin: 0;
  font-size: 1.55rem;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.preview-grid label {
  display: grid;
  gap: 6px;
  color: #526272;
  font-weight: 700;
}

.preview-grid input,
.preview-grid select {
  height: 42px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: calc(var(--preview-radius, 8px) * 0.75);
  padding: 0 10px;
}

.preview-actions {
  justify-content: flex-end;
}

.preview-actions button {
  min-height: 40px;
  min-width: 86px;
  border: 1px solid var(--preview-primary, #235789);
  border-radius: calc(var(--preview-radius, 8px) * 0.75);
  background: #fff;
  color: var(--preview-primary, #235789);
  font-weight: 800;
}

.preview-actions .primary-action {
  background: var(--preview-primary, #235789);
  color: #fff;
}

.preview-flex {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--preview-space, 16px);
}

.preview-flex article {
  display: grid;
  gap: 12px;
  padding: var(--preview-space, 16px);
}

.preview-flex strong {
  color: #526272;
}

.preview-flex span {
  color: var(--preview-primary, #235789);
  font-size: 2rem;
  font-weight: 900;
}

.code-toolbar {
  justify-content: space-between;
  min-height: 32px;
  margin-bottom: 10px;
  color: var(--muted);
}

.tokens-gap {
  margin-top: 22px;
}

.tab-pane .helper-text {
  margin-top: 10px;
  font-size: 0.88rem;
}

.block-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

pre {
  overflow: auto;
  max-height: 68vh;
  margin: 0;
  padding: 16px;
  background: #101820;
  border-radius: 8px;
  color: #e7eef5;
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre;
}

.final-css-panel pre {
  max-height: 420px;
}

.instructions {
  display: grid;
  gap: 16px;
  max-width: 980px;
}

.instructions article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.instructions h3 {
  margin: 0 0 8px;
}

.instructions p,
.instructions li {
  color: #475767;
  line-height: 1.55;
}

.instructions code {
  background: #eef2f5;
  border-radius: 5px;
  padding: 2px 5px;
}

.safety-list {
  display: grid;
  gap: 12px;
  max-width: 980px;
}

.safety-item {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.safety-item.pass {
  border-left-color: #15847d;
}

.safety-item.note {
  border-left-color: #235789;
}

.safety-item.warn {
  border-left-color: #c75b12;
}

.safety-item strong {
  display: block;
  margin-bottom: 4px;
}

.safety-item p {
  margin: 0;
  color: #475767;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .app-header,
  .layout {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: flex-start;
  }

  .header-actions {
    justify-self: stretch;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
  }

  .layout {
    display: grid;
    padding: 12px;
  }

  .controls {
    max-height: none;
  }

  .preview-grid,
  .preview-flex,
  .preview-compare,
  .visual-css-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .header-actions {
    grid-template-columns: 1fr;
  }
}
