:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #1b1b1b;
  --muted: #6f6f6f;
  --line: #e7e7e7;
  --soft: #f5f5f3;
  --purple-50: #f7f5ff;
  --purple-100: #e9e3ff;
  --purple-300: #a58dff;
  --purple-500: #7135ef;
  --purple-700: #531abd;
  --green: #0a8f55;
  --radius: 12px;
  --font: Inter, Geist, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; }
body { min-height: 100vh; margin: 0; background: white; color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, textarea { font: inherit; }
button { color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgb(113 53 239 / .22); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 9px 12px; border-radius: 8px; background: var(--ink); color: white; transform: translateY(-150%); transition: transform 120ms ease-out; }
.skip-link:focus { transform: translateY(0); }

.playground-shell { width: 100%; min-height: 100dvh; display: grid; grid-template-columns: minmax(340px, 390px) minmax(0, 1fr); }
.prompt-rail { position: sticky; top: 0; height: 100dvh; display: flex; min-height: 0; flex-direction: column; background: var(--bg); }
.prompt-panel { padding: 24px 20px 20px; }
.prompt-panel h1 { max-width: 340px; margin: 0; font-size: 21px; line-height: 1.18; letter-spacing: -.035em; text-wrap: balance; }
.prompt-panel form { margin-top: 16px; }
.prompt-box { position: relative; padding: 8px; border: 1px solid #d9d9d9; border-radius: 16px; background: white; box-shadow: 0 1px 3px rgb(0 0 0 / .04); }
.prompt-box:focus-within { border-color: var(--purple-300); box-shadow: 0 0 0 3px var(--purple-50); }
.prompt-box textarea { display: block; width: 100%; min-height: 92px; resize: none; border: 0; outline: 0; padding: 2px 4px 35px; background: transparent; color: var(--ink); font-size: 14px; line-height: 1.5; }
.prompt-box textarea::placeholder { color: #999; }
.prompt-box textarea:disabled { opacity: .65; }
.prompt-box button { position: absolute; right: 8px; bottom: 8px; display: grid; width: 28px; height: 28px; place-items: center; border: 0; border-radius: 999px; background: #171717; color: white; cursor: pointer; transition: opacity 120ms ease-out, transform 100ms ease-out; }
.prompt-box button img { width: 16px; height: 16px; filter: brightness(0) invert(1); }
.prompt-box button:hover:not(:disabled) { opacity: .88; }
.prompt-box button:active:not(:disabled) { transform: translateY(1px); }
.prompt-box button:disabled { cursor: default; opacity: .35; }
.quick-ideas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.quick-ideas button { min-height: 31px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; background: white; color: var(--muted); cursor: pointer; font-size: 12px; transition: border-color 120ms ease-out, background-color 120ms ease-out, color 120ms ease-out; }
.quick-ideas button:hover:not(:disabled) { border-color: var(--purple-300); background: var(--purple-50); color: var(--ink); }
.quick-ideas button:disabled { opacity: .5; }

.build-inspector { min-height: 0; flex: 1; overflow-y: auto; border-top: 1px solid var(--line); padding: 20px; }
.build-inspector[hidden] { display: none; }
.inspector-heading { margin: 0; font-size: 15px; letter-spacing: -.02em; }
.inspector-note { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.inspector-label { margin: 22px 0 0; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.inspector-label.first { margin-top: 14px; }
.record-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.record-pill { padding: 5px 8px; border: 1px solid var(--purple-100); border-radius: 999px; background: var(--purple-50); color: var(--purple-700); font-size: 11px; font-weight: 650; }
.tool-list { margin-top: 7px; border-top: 1px solid var(--line); }
.tool-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tool-icon { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; border-radius: 9px; background: var(--purple-50); color: var(--purple-700); font-family: var(--mono); font-size: 11px; font-weight: 700; }
.tool-row div { min-width: 0; }
.tool-row strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.tool-reason { display: block; margin: 3px 0 6px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.tool-row code { display: block; margin-top: 2px; overflow: hidden; color: #777; font-family: var(--mono); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.canvas-window { min-width: 0; min-height: calc(100dvh - 36px); margin: 18px; overflow: hidden; border: 1px solid #dfdfdd; border-radius: 20px; background: transparent; box-shadow: 0 18px 55px rgb(35 30 48 / .07), 0 2px 8px rgb(35 30 48 / .04); }
.canvas { min-height: calc(100dvh - 38px); overflow: hidden; background: white; }
.idle-canvas { min-height: calc(100dvh - 38px); display: grid; place-items: center; padding: 24px; text-align: center; }
.idle-content { max-width: 360px; }
.idle-mark { width: 32px; height: 32px; }
.idle-canvas h2 { margin: 18px 0 0; font-size: 20px; line-height: 1.2; letter-spacing: -.035em; }
.idle-canvas p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.generating { min-height: calc(100dvh - 38px); padding: 34px; background: white; }
.loading-part { border-radius: 10px; background: #f0efef; opacity: 0; animation: load-in 420ms ease forwards, pulse 1.2s 420ms ease-in-out infinite alternate; }
.loading-heading { width: min(520px, 72%); height: 34px; }
.loading-subheading { width: min(690px, 88%); height: 14px; margin-top: 14px; animation-delay: 90ms, 510ms; }
.loading-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 34px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--line); }
.loading-metric { height: 112px; border-radius: 0; background: #f7f7f6; }
.loading-metric:nth-child(1) { animation-delay: 160ms, 580ms; }
.loading-metric:nth-child(2) { animation-delay: 230ms, 650ms; }
.loading-metric:nth-child(3) { animation-delay: 300ms, 720ms; }
.loading-workspace { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(250px, .65fr); gap: 16px; margin-top: 18px; }
.loading-chart { height: 390px; animation-delay: 360ms, 780ms; }
.loading-list { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--line); }
.loading-row { min-height: 128px; border-radius: 0; background: #f7f7f6; }
.loading-row:nth-child(1) { animation-delay: 430ms, 850ms; }
.loading-row:nth-child(2) { animation-delay: 500ms, 920ms; }
.loading-row:nth-child(3) { animation-delay: 570ms, 990ms; }

.product-preview { min-height: calc(100dvh - 38px); padding: clamp(24px, 4vw, 48px); background: white; color: #171717; }
.product-preview > * { opacity: 0; transform: translateY(8px); animation: reveal 420ms ease forwards; }
.product-preview > :nth-child(2) { animation-delay: 80ms; }
.product-preview > :nth-child(3) { animation-delay: 160ms; }
.product-preview > :nth-child(4) { animation-delay: 240ms; }
.preview-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.preview-heading { max-width: 690px; }
.preview-eyebrow { margin: 0 0 8px; color: var(--purple-700); font-size: 10px; font-weight: 720; letter-spacing: .1em; text-transform: uppercase; }
.preview-header h1 { max-width: 680px; margin: 0; font-size: clamp(30px, 4vw, 48px); line-height: 1.01; letter-spacing: -.055em; text-wrap: balance; }
.preview-subtitle { max-width: 660px; margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.preview-filters { display: flex; max-width: 320px; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.preview-filters button { min-height: 30px; border: 1px solid var(--line); border-radius: 999px; background: white; padding: 5px 10px; color: #5f5c64; font-size: 11px; white-space: nowrap; }
.preview-metrics { display: grid; gap: 1px; margin-top: 30px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--line); }
.preview-metrics.metrics-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.preview-metrics.metrics-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.preview-metrics.metrics-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.preview-metrics.metrics-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.preview-metric { min-width: 0; background: white; padding: 17px 18px; }
.preview-metric span, .preview-metric small { display: block; color: var(--muted); font-size: 10px; line-height: 1.35; }
.preview-metric strong { display: block; margin: 6px 0 4px; font-size: 25px; line-height: 1; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.preview-metric.tone-positive strong { color: #087946; }
.preview-metric.tone-attention strong { color: #9b6215; }
.preview-workspace { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(270px, .65fr); gap: 16px; margin-top: 16px; }
.preview-panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; }
.panel-heading { min-height: 70px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 17px 18px 12px; }
.panel-heading h2 { margin: 0; font-size: 15px; letter-spacing: -.025em; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.illustrative-label { border-radius: 999px; background: var(--purple-50); padding: 4px 7px; color: var(--purple-700); font-size: 8px; font-weight: 720; letter-spacing: .07em; text-transform: uppercase; }
.preview-chart { width: 100%; min-height: 300px; padding: 4px 14px 14px; }
.preview-chart .vega-embed { width: 100%; }
.preview-chart .vega-embed summary { display: none; }
.chart-error { margin: 80px 20px; color: var(--muted); text-align: center; }
.preview-list { border-top: 1px solid var(--line); }
.preview-item { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 9px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.preview-item:last-child { border-bottom: 0; }
.item-rank { color: #9b98a0; font-family: var(--mono); font-size: 9px; padding-top: 2px; }
.item-copy { min-width: 0; }
.item-title-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.item-title-line h3 { min-width: 0; margin: 0; overflow: hidden; font-size: 12px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.item-title-line strong { flex: 0 0 auto; font-size: 11px; font-variant-numeric: tabular-nums; }
.item-copy small { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.item-copy p { margin: 7px 0 0; color: #5f5c64; font-size: 10px; line-height: 1.4; }
.score-track { display: block; width: 100%; height: 3px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: #eceaf0; }
.score-fill { display: block; height: 100%; border-radius: inherit; background: #7135ef; }
.preview-insight { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 20px; margin-top: 16px; border-radius: 14px; background: #f7f6fb; padding: 16px 18px; }
.preview-insight span { color: #6f6b75; font-size: 9px; font-weight: 720; letter-spacing: .08em; text-transform: uppercase; }
.preview-insight p { margin: 0; font-size: 12px; line-height: 1.45; }
.error-banner { padding: 12px 16px; border-bottom: 1px solid #ffd3cf; background: #fff3f1; color: #9d291f; font-size: 12px; }

@keyframes pulse { to { opacity: .45; } }
@keyframes load-in { to { opacity: 1; } }
@keyframes reveal { to { opacity: 1; transform: translateY(0); } }

@media (max-width: 780px) {
  .playground-shell { display: block; }
  .prompt-rail { position: static; height: auto; }
  .build-inspector { max-height: none; overflow: visible; }
  .canvas-window { margin: 10px; border-radius: 16px; }
  .canvas, .idle-canvas, .generating, .product-preview { min-height: 520px; }
  .loading-workspace, .preview-workspace { grid-template-columns: 1fr; }
  .preview-header { display: grid; }
  .preview-filters { justify-content: flex-start; }
  .preview-metrics.metrics-4, .preview-metrics.metrics-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-metrics.metrics-5 .preview-metric:last-child { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .prompt-panel { padding: 20px 14px 16px; }
  .prompt-panel h1 { font-size: 20px; }
  .product-preview, .generating { padding: 22px 18px; }
  .preview-metrics.metrics-2, .preview-metrics.metrics-3, .preview-metrics.metrics-4, .preview-metrics.metrics-5 { grid-template-columns: 1fr; }
  .preview-metrics.metrics-5 .preview-metric:last-child { grid-column: auto; }
  .preview-insight { grid-template-columns: 1fr; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
