:root {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --ink: #1d1c1a;
  --muted: #6b6760;
  --line: #e2dfd8;
  --accent: #b4542d;
  --ok: #2f7d4f;
  --err: #b3261e;
  --term-bg: #16150f;
  --term-ink: #e8e4da;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --panel: #1d1c19;
    --ink: #ece9e2;
    --muted: #9c978d;
    --line: #2f2d28;
    --accent: #e0835a;
    --ok: #6cc08e;
    --err: #f08a80;
    --term-bg: #0d0c09;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Gallery */
.gallery .hero, .gallery main { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.gallery .hero { padding-top: 56px; padding-bottom: 24px; }
.gallery h1 { font-size: 44px; letter-spacing: -0.02em; margin: 0 0 12px; }
.lede { font-size: 18px; max-width: 44em; margin: 0 0 8px; }
.cta { display: block; margin: 20px 0 4px; padding: 16px 18px; border: 1px solid var(--accent); border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, var(--panel)); color: inherit; text-decoration: none; max-width: 44em; transition: transform 0.15s; }
.cta:hover { transform: translateY(-1px); }
.cta strong { display: block; font-size: 18px; color: var(--accent); margin-bottom: 4px; }
.cta span { color: var(--muted); }
.cards { list-style: none; padding: 0; margin: 16px 0 40px; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.cards a { display: block; height: 100%; padding: 18px 18px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: inherit; text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
.cards a:hover { border-color: var(--accent); transform: translateY(-1px); }
.cards img { display: block; width: calc(100% + 36px); height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; margin: -18px -18px 14px; border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; background: #fff; }
.cards a { overflow: hidden; }
.cards h2 { font-size: 18px; margin: 0 0 6px; }
.cards .desc { margin: 0 0 10px; color: var(--muted); }
.cards .meta { margin: 0; font: 12px ui-monospace, Menlo, monospace; color: var(--muted); }
.how { border-top: 1px solid var(--line); padding: 24px 0 64px; max-width: 44em; }
.how h2 { font-size: 20px; }
.how li { margin-bottom: 8px; }
.small { font-size: 13px; color: var(--muted); }

/* Demo page */
.demo { display: flex; flex-direction: column; min-height: 100vh; }
.bar { display: flex; align-items: center; gap: 20px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 700; text-decoration: none; }
.heading { flex: 1; min-width: 0; }
.heading h1 { font-size: 17px; margin: 0; }
.heading p { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.clock #status { font-size: 13px; color: var(--muted); }
.clock #status[data-state="done"] { color: var(--ok); }
.clock #status[data-state="failed"] { color: var(--err); }
.clock #elapsed { font: 600 20px ui-monospace, Menlo, monospace; }
.steps { list-style: none; display: flex; gap: 6px; margin: 0; padding: 10px 16px; overflow-x: auto; }
.steps li { display: flex; gap: 8px; align-items: baseline; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.steps li::before { content: "○"; }
.steps li[data-state="active"] { color: var(--ink); border-color: var(--accent); }
.steps li[data-state="active"]::before { content: "◐"; color: var(--accent); }
.steps li[data-state="done"]::before { content: "●"; color: var(--ok); }
.steps li[data-state="failed"]::before { content: "✕"; color: var(--err); }
.steps .time { font: 12px ui-monospace, Menlo, monospace; }
.stage { flex: 1; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; padding: 0 16px 12px; min-height: 520px; }
.frame, .console { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.chrome { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.dots i { display: inline-block; width: 9px; height: 9px; margin-right: 4px; border-radius: 50%; background: var(--line); }
.url { font-family: ui-monospace, Menlo, monospace; }
#app { flex: 1; width: 100%; border: 0; background: #fff; }
.console { background: var(--term-bg); }
.console .chrome { border-color: #2a2822; color: #9c978d; }
#terminal { flex: 1; overflow: auto; padding: 10px 12px; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--term-ink); white-space: pre-wrap; word-break: break-word; max-height: calc(100vh - 190px); }
#terminal .err { color: #f0a58f; }
#terminal .ok { color: #8fd6a8; }
#terminal .dim { color: #8a8578; }
#overlay { position: absolute; inset: 36px 0 0; display: grid; place-items: center; background: color-mix(in srgb, var(--panel) 92%, transparent); padding: 16px; text-align: center; }
#overlay[hidden] { display: none; }
#overlay h2 { margin: 0 0 8px; font-size: 18px; }
.note { padding: 0 16px 20px; font-size: 13px; color: var(--muted); max-width: 70em; }
.note p { margin: 6px 0; }
@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 70vh 320px; }
  .heading p { white-space: normal; }
  #terminal { max-height: none; }
}

/* Generator */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spacer { flex: 1; }
.generator { height: 100vh; min-height: 0; }
.workbench { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 12px; padding: 12px 16px; }
.panel { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.settings { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.settings summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.settings[open] summary { margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.field-row { display: flex; gap: 8px; }
.field-row .field { min-width: 0; }
.grow { flex: 1; }
.with-button { display: flex; gap: 4px; }
.with-button select { flex: 1; min-width: 0; }
.check { display: flex; gap: 6px; align-items: center; font-size: 13px; margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.generator select, .generator input[type="password"], .generator textarea { font: inherit; font-size: 14px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.generator textarea { width: 100%; resize: vertical; min-height: 72px; }
.generator :is(select, input, textarea, button):focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.generator button { font: inherit; font-size: 14px; cursor: pointer; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 6px 14px; }
.generator button:disabled { opacity: 0.55; cursor: default; }
.generator button.quiet, .generator button.icon, .generator button.example, .generator .chip, .tabs button { background: transparent; color: var(--ink); border-color: var(--line); }
.generator button.quiet:hover, .generator button.icon:hover, .generator button.example:hover, .generator .chip:hover:not(:disabled) { border-color: var(--accent); }
.generator button.icon { padding: 4px 9px; }
.generator .chip { font-size: 12px; padding: 2px 9px; }
.conversation { flex: 1; min-height: 120px; overflow: auto; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.conversation > li { padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; }
.conversation p { margin: 0 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.conversation .user { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.conversation .error { border-color: var(--err); color: var(--err); }
.conversation .note { color: var(--muted); font-size: 13px; }
.conversation .intro { color: var(--muted); }
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.generator button.example { font-size: 13px; text-align: left; padding: 4px 10px; border-radius: 999px; }
.who { font: 12px ui-monospace, Menlo, monospace; color: var(--muted); }
.thinking { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.thinking summary { cursor: pointer; }
.thinking div { white-space: pre-wrap; max-height: 160px; overflow: auto; padding: 4px 0; }
.file-chips { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.file-chips li { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.file-chips li span { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.file-chips li::before { content: "●"; color: var(--ok); margin-right: 6px; }
.file-chips li[data-state="active"]::before { content: "◐"; color: var(--accent); }
.file-chips li[data-state="deleted"]::before { content: "✕"; color: var(--err); }
.file-chips li code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { font-size: 12px; color: var(--muted); }
#vault { display: block; width: 100%; height: 260px; border: 0; background: transparent; flex: none; }
.vault-slot { color: var(--muted); font-size: 13px; }
#placeholder button { margin-top: 12px; }
.output { display: grid; grid-template-rows: auto minmax(0, 3fr) minmax(140px, 1.3fr); gap: 10px; min-height: 0; }
.output .steps { padding: 0; }
.steps li[data-step="write"]:not([data-state]) { opacity: 0.8; }
.output .frame { min-height: 0; }
#placeholder { position: absolute; inset: 36px 0 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); background: var(--panel); }
#placeholder[hidden] { display: none; }
#placeholder h2 { color: var(--ink); font-size: 18px; margin: 0 0 6px; }
#placeholder p { max-width: 32em; margin: 0 auto; font-size: 14px; }
.output .console { min-height: 0; }
.output #terminal { max-height: none; }
.tabs { gap: 2px; padding: 4px 8px; }
.generator .tabs button { border: 0; border-radius: 4px; padding: 3px 10px; font-size: 12px; color: #9c978d; }
.generator .tabs button[aria-selected="true"] { background: #2a2822; color: var(--term-ink); }
#files { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(140px, 220px) 1fr; color: var(--term-ink); }
#files[hidden] { display: none; }
#file-list { list-style: none; margin: 0; padding: 6px; overflow: auto; border-right: 1px solid #2a2822; }
.generator #file-list button { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: #c9c4b8; font: 12px ui-monospace, Menlo, monospace; padding: 3px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.generator #file-list button[aria-current] { background: #2a2822; color: #fff; }
#file-view { margin: 0; padding: 8px 12px; overflow: auto; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
@media (max-width: 900px) {
  .generator { height: auto; }
  .workbench { grid-template-columns: 1fr; }
  .conversation { max-height: 50vh; }
  .output { grid-template-rows: auto 70vh 300px; }
}
