/* ────────────────────────────────────────────────────────────
   MOX — design tokens
   Commit to: near-black #0f1115, warm gold oklch(.78 .12 82)
   ─────────────────────────────────────────────────────────── */
:root {
  /* Background scale, cool-neutral tuned */
  --bg-0: #0a0c10;         /* deepest — behind everything */
  --bg-1: #0f1115;         /* primary app surface */
  --bg-2: #151820;         /* card / elevated */
  --bg-3: #1c2029;         /* hover / pressed */
  --bg-4: #242934;         /* highest elevation */

  /* Ink */
  --ink-0: #f4ecd8;        /* parchment-warm primary text, slightly ivory */
  --ink-1: #d8d2c0;        /* body */
  --ink-2: #9a958a;        /* secondary */
  --ink-3: #676259;        /* tertiary / captions */
  --ink-4: #3a372f;        /* disabled */

  /* Gold — the MOX accent. Warm, not safety-yellow. */
  --gold-hi: #f2cd7a;      /* highlight / glow peak */
  --gold: #e6bd6a;         /* primary accent */
  --gold-mid: #c8962b;     /* mid tone */
  --gold-deep: #8a6420;    /* deep quiet gold */
  --gold-dim: #5a4417;     /* whisper / lines */

  /* Ruby for error/critical (Mox Ruby reference, used sparingly) */
  --ruby: #c8443b;
  --ruby-dim: #5a2220;

  /* Hairlines */
  --line: rgba(230, 189, 106, 0.12);       /* gold-tinted */
  --line-soft: rgba(230, 189, 106, 0.06);
  --line-hard: rgba(230, 189, 106, 0.28);

  /* Shadow */
  --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset,
                 0 12px 40px -12px rgba(0,0,0,0.6),
                 0 2px 6px rgba(0,0,0,0.4);
  --shadow-lift: 0 24px 60px -20px rgba(0,0,0,0.7),
                 0 8px 16px -8px rgba(0,0,0,0.5);

  /* Type */
  --font-ui: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text",
             "Segoe UI", Helvetica, Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
                "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Spacing */
  --pad-xs: 4px;
  --pad-s: 8px;
  --pad-m: 12px;
  --pad-l: 16px;
  --pad-xl: 24px;
  --pad-2xl: 40px;

  /* Radius — tight, tool-like */
  --r-xs: 3px;
  --r-s: 5px;
  --r-m: 8px;
  --r-l: 12px;

  /* Measure */
  --measure: 680px;

  /* Motion */
  --ease-breath: cubic-bezier(.4,.0,.4,1);
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  background: var(--bg-1);
  color: var(--ink-1);
  font: 14px/1.55 var(--font-ui);
  font-feature-settings: "ss01", "cv11", "tnum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  min-height: 100vh;
}

/* Subtle noise + vignette on the background for "leather" depth.
   Using layered radial gradients — no images, no SVG clutter. */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%,
      rgba(230, 189, 106, 0.04), transparent 60%),
    radial-gradient(ellipse 60% 80% at 50% 100%,
      rgba(0,0,0,0.4), transparent 60%);
  z-index: 0;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 1px solid var(--gold); outline-offset: 2px; }
input, textarea { font: inherit; color: inherit; background: none; border: 0; outline: 0; }
::selection { background: var(--gold-deep); color: var(--ink-0); }

/* Thin scrollbars */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(230,189,106,0.15); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(230,189,106,0.3); }

/* ────────────────────────────────────────────────────────────
   App chrome
   ─────────────────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  width: 100vw;
}

/* ── Header ────────────────────────────────────────────── */
.hdr {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--pad-l);
  padding: 0 var(--pad-xl);
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(to bottom, var(--bg-1), rgba(15,17,21,0.7));
  backdrop-filter: blur(8px);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--pad-m);
  user-select: none;
}
/* The brand mark now wraps an SVG (gem logo) — strip the letter-container
   styling that was meant for the italic "M". The SVG supplies its own
   bezel, glow, and border. */
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: brandPulse 3.2s ease-in-out infinite;
}
@keyframes brandPulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(230, 189, 106, 0.25)); }
  50%      { filter: drop-shadow(0 0 12px rgba(230, 189, 106, 0.55)); }
}
.brand-name {
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--ink-0);
  text-transform: uppercase;
}
.brand-sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
  margin-left: 2px;
}

/* View switcher (nav) */
.nav {
  display: flex;
  gap: 2px;
  justify-self: center;
  padding: 3px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-m);
}
.nav-btn {
  padding: 5px 12px;
  font-size: 12px;
  color: var(--ink-2);
  border-radius: var(--r-s);
  letter-spacing: 0.02em;
  transition: color .15s, background .15s;
}
.nav-btn:hover { color: var(--ink-0); }
.nav-btn.is-active {
  background: var(--bg-3);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* Status pill */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--pad-s);
  padding: 5px 10px 5px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--ink-2);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color .15s;
}
.status:hover { border-color: var(--line); }
.status-dot {
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(230,189,106,0.15);
  animation: status-breathe 3s var(--ease-breath) infinite;
}
.status.is-err .status-dot {
  background: var(--ruby);
  box-shadow: 0 0 0 2px rgba(200,68,59,0.2);
  animation: none;
}
.status.is-warn .status-dot {
  background: #d1a24a;
  animation: none;
}
.status-sep { color: var(--ink-4); }
.status-model { color: var(--ink-1); }

@keyframes status-breathe {
  0%, 100% { opacity: 0.85; box-shadow: 0 0 0 2px rgba(230,189,106,0.12); }
  50%      { opacity: 1; box-shadow: 0 0 0 4px rgba(230,189,106,0.05); }
}

.hdr-right {
  display: flex;
  align-items: center;
  gap: var(--pad-m);
}

.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  color: var(--ink-2);
  border-radius: var(--r-s);
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--gold); background: var(--bg-2); }
.icon-btn svg { width: 16px; height: 16px; }

/* ────────────────────────────────────────────────────────────
   Main
   ─────────────────────────────────────────────────────────── */
.main {
  position: relative;
  overflow: hidden;
}
.scroll {
  height: 100%;
  overflow-y: auto;
  padding: var(--pad-2xl) var(--pad-xl) 140px;
}
/* Empty state = gem only, nothing to scroll. Kill the scrollbar so the gem
   doesn't drift horizontally as the bar appears/disappears. */
/* Kill the scrollbar when the hero is at rest (gem-only empty state). During
   thinking the hero grows — question + gem + stages + boot-word row — so we
   re-enable scroll so nothing gets clipped. */
.scroll:has(.hero:not(.is-thinking)) { overflow: hidden; }
.scroll:has(.hero.is-thinking) { overflow-y: auto; }

/* Lift the hero upward on desktop to reclaim the dead space between the
   header and the gem. Applies to both idle and thinking states; thinking
   allows scrolling (set above) so even if content grows taller than the
   viewport, nothing gets clipped. */
@media (min-width: 561px) {
  .hero { transform: translateY(-90px); }
  .hero.is-thinking { transform: translateY(-40px); }
}

/* ── Hero / empty state ───────────────────────────────── */
.hero {
  max-width: var(--measure);
  margin: 40px auto 0;
  text-align: center;
  color: var(--ink-2);
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 20px;
}
.hero-thinking-q { grid-row: 1; align-self: start; }
.hero-mark { grid-row: 2; transition: filter 0.6s ease; }
.hero-stages { grid-row: 3; grid-column: 1; margin: 0 auto; min-width: 220px; }
.hero-boot-word { grid-row: 4; grid-column: 1; align-self: start; }
.hero-title { grid-row: 4; grid-column: 1; align-self: start; }

/* Thinking state (desktop): flex row — gem on left, text column on right,
   both centered in the viewport as a tight pair. Mobile falls back to the
   default block-flow layout. */
@media (min-width: 700px) {
  .hero.is-thinking {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 28px;
    width: fit-content;        /* shrink the pair to content, then center */
    max-width: 1000px;
    margin: 0 auto;
    padding-top: 40px;
    text-align: left;
  }
  .hero.is-thinking .hero-mark { flex: 0 0 auto; margin: 0; }
  .hero-thinking-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 620px;
    align-self: center;
    text-align: left;
  }
  .hero-thinking-col .hero-thinking-q { max-width: 100%; }
  .hero-thinking-col .hero-stages { margin: 0; min-width: 0; }
}

/* Thinking state — gem breathes with a warm gold glow that pulses around it.
   Replaces the old "onyx" text stencil / dots. The gem IS the indicator. */
.hero.is-thinking .hero-mark {
  animation: gemThink 2.2s ease-in-out infinite;
}
@keyframes gemThink {
  0%, 100% {
    filter: drop-shadow(0 0 10px rgba(230, 189, 106, 0.30))
            drop-shadow(0 0 4px rgba(230, 189, 106, 0.45));
  }
  50% {
    filter: drop-shadow(0 0 32px rgba(230, 189, 106, 0.70))
            drop-shadow(0 0 12px rgba(230, 189, 106, 0.85));
  }
}

.hero-thinking-q {
  font-family: var(--font-serif);
  font-style: italic;
  /* Font size is driven by JS (pickQuestionFontSize) based on question length
     so short questions read dramatic and long ones shrink to fit. This CSS
     value is a fallback only. */
  font-size: 24px;
  line-height: 1.25;
  max-width: min(90vw, 820px);
  text-wrap: balance;
  /* Muted while thinking — will shift to full ink color once the answer
     populates (the AnswerCard replaces this slot with a non-muted heading). */
  color: var(--ink-2);
  opacity: 0.55;
  max-width: 680px;
  padding: 0 16px;
  margin-bottom: 8px;
  transition: opacity 0.5s ease, color 0.5s ease;
}
/* .hero-mark now just centers the floating SVG gem — no frame, no rings. */
.hero-mark {
  margin: 0 auto var(--pad-xl);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 28px;
  font-weight: 400;
  color: var(--ink-0);
  margin: 0 0 var(--pad-s);
  letter-spacing: 0.01em;
}
.hero-sub {
  font-size: 14px;
  color: var(--ink-3);
  max-width: 440px;
  margin: 0 auto var(--pad-2xl);
  line-height: 1.5;
}

/* Suggestion chips */
.suggests {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pad-s);
  justify-content: center;
  max-width: 560px;
  margin: 0 auto;
}
.suggest {
  font-size: 12px;
  padding: 7px 12px;
  color: var(--ink-2);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  transition: all .15s;
  text-align: left;
}
.suggest:hover {
  color: var(--ink-0);
  border-color: var(--line-hard);
  background: var(--bg-3);
}
.suggest-cite {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--gold-mid);
  margin-left: 6px;
  letter-spacing: 0.02em;
}

/* ────────────────────────────────────────────────────────────
   Answer card — the hero surface
   ─────────────────────────────────────────────────────────── */
.answer-wrap {
  max-width: var(--measure);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--pad-xl);
}

.answer-question {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 22px;
  line-height: 1.3;
  color: var(--ink-0);
  letter-spacing: 0.005em;
  text-wrap: pretty;
  margin: 0;
}
.answer-question::before {
  content: "“";
  font-size: 28px;
  color: var(--gold-deep);
  margin-right: 4px;
  vertical-align: -4px;
}
.answer-question::after {
  content: "”";
  font-size: 28px;
  color: var(--gold-deep);
  margin-left: 4px;
  vertical-align: -4px;
}

.answer-meta {
  display: flex;
  align-items: center;
  gap: var(--pad-m);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.meta-dot { color: var(--ink-4); }
.meta-val { color: var(--ink-1); }

/* The verdict — first two sentences, sticky-visible */
.verdict {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.5;
  color: var(--ink-0);
  padding: var(--pad-l) var(--pad-xl);
  border-left: 2px solid var(--gold);
  background: linear-gradient(to right, rgba(230,189,106,0.06), transparent 70%);
  border-radius: 0 var(--r-s) var(--r-s) 0;
  text-wrap: pretty;
}
.verdict strong {
  color: var(--gold-hi);
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: 0.01em;
  font-size: 17px;
}

/* Answer body — markdown container */
.answer-body {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-1);
}
.answer-body .md-p {
  margin: 0 0 var(--pad-l);
  text-wrap: pretty;
}
.answer-body .md-h {
  font-family: var(--font-ui);
  font-weight: 600;
  color: var(--ink-0);
  margin: var(--pad-xl) 0 var(--pad-m);
  letter-spacing: 0.01em;
}
.answer-body .md-h1 { font-size: 20px; }
.answer-body .md-h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold-mid); font-size: 11px; margin-top: var(--pad-2xl); border-bottom: 1px solid var(--line-soft); padding-bottom: 6px; }
.answer-body .md-h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); font-size: 11px; margin-top: var(--pad-xl); padding-bottom: 0; border: 0; }
.answer-body .md-h4 { font-size: 15px; color: var(--ink-0); font-family: var(--font-serif); font-style: italic; font-weight: 400; margin-top: var(--pad-l); }

.answer-body .md-ul,
.answer-body .md-ol {
  margin: 0 0 var(--pad-l);
  padding-left: var(--pad-xl);
}
.answer-body .md-ul li,
.answer-body .md-ol li {
  margin-bottom: 6px;
  text-wrap: pretty;
}
.answer-body .md-ul { list-style: none; padding-left: var(--pad-m); }
.answer-body .md-ul li { position: relative; padding-left: var(--pad-l); }
.answer-body .md-ul li::before {
  content: "◆";
  position: absolute; left: 0; top: 0;
  color: var(--gold-deep);
  font-size: 10px;
  line-height: 1.8;
}
.answer-body .md-ol {
  list-style: none;
  counter-reset: step;
  padding-left: 0;
}
.answer-body .md-ol li {
  counter-increment: step;
  position: relative;
  padding-left: 38px;
}
.answer-body .md-ol li::before {
  content: counter(step);
  position: absolute; left: 0; top: 2px;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  border: 1px solid var(--line-hard);
  border-radius: 999px;
  background: var(--bg-2);
}

/* Blockquote — the "card text box" treatment. Original design: dark panel,
   gold hairline, small-caps label. Not a copy of any printed card frame. */
.answer-body .md-quote {
  position: relative;
  margin: var(--pad-l) 0 var(--pad-l);
  padding: var(--pad-l) var(--pad-xl) var(--pad-l);
  background:
    linear-gradient(to bottom,
      rgba(230,189,106,0.04) 0%,
      rgba(230,189,106,0.02) 100%),
    var(--bg-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold-deep);
  border-radius: var(--r-s);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-0);
  font-family: var(--font-serif);
  font-style: italic;
  text-wrap: pretty;
}
.answer-body .md-quote-label {
  position: absolute;
  top: -7px;
  left: 14px;
  padding: 0 8px;
  background: var(--bg-1);
  font-family: var(--font-ui);
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--gold);
  text-transform: uppercase;
}
.answer-body .md-quote-text { display: block; }

/* Inline rule citation — scholarly underlined gold serif.
   Tweak variants: .cite-pill, .cite-super, .cite-underline (default) */
.cite {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--gold);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--gold-deep);
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0 1px;
  transition: color .15s, background .15s;
  border-radius: 2px;
  white-space: nowrap;
}
.cite:hover {
  color: var(--gold-hi);
  text-decoration-color: var(--gold);
  background: rgba(230,189,106,0.08);
}

/* Tweak: pill */
body[data-cite-style="pill"] .cite {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 11px;
  padding: 1px 7px;
  background: var(--bg-3);
  color: var(--gold);
  border: 1px solid var(--line);
  text-decoration: none;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
body[data-cite-style="pill"] .cite:hover {
  background: var(--bg-4);
  border-color: var(--line-hard);
  color: var(--gold-hi);
}
/* Tweak: superscript */
body[data-cite-style="super"] .cite {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 10px;
  vertical-align: super;
  padding: 0 3px;
  text-decoration: none;
  color: var(--gold-mid);
}
body[data-cite-style="super"] .cite::before { content: "["; color: var(--ink-4); }
body[data-cite-style="super"] .cite::after  { content: "]"; color: var(--ink-4); }
body[data-cite-style="super"] .cite:hover { color: var(--gold-hi); }

/* Inline code for the rare `term` */
.answer-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gold);
  background: rgba(230,189,106,0.06);
  padding: 1px 5px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line-soft);
}

/* Action row under the answer */
.answer-actions {
  display: flex;
  gap: var(--pad-s);
  margin-top: var(--pad-m);
  padding-top: var(--pad-l);
  border-top: 1px solid var(--line-soft);
}
.action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-s);
  transition: all .15s;
}
.action:hover {
  color: var(--gold);
  border-color: var(--line);
  background: var(--bg-3);
}
.action.is-done {
  color: var(--gold);
  border-color: var(--line);
}
.action svg { width: 13px; height: 13px; }

/* ────────────────────────────────────────────────────────────
   Thinking indicator — THE moment of delight
   Gold stencil breathing — echoes the engraved MOX LED panel
   ─────────────────────────────────────────────────────────── */
.thinking {
  max-width: var(--measure);
  margin: 40px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--pad-xl);
  padding: var(--pad-2xl) 0;
}

.stencil {
  position: relative;
  width: 180px;
  height: 64px;
  display: grid;
  place-items: center;
}
.stencil::before {
  /* Outer frame — engraved bezel */
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--gold-deep);
  border-radius: var(--r-s);
  background:
    linear-gradient(to bottom,
      rgba(255,255,255,0.02),
      rgba(0,0,0,0.2));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    inset 0 -1px 0 rgba(0,0,0,0.4);
}
.stencil-text {
  position: relative;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 34px;
  letter-spacing: 0.18em;
  color: var(--gold);
  padding-left: 0.18em; /* compensate for italic overshoot */
  text-shadow:
    0 0 20px rgba(242, 205, 122, var(--glow, 0.4)),
    0 0 40px rgba(230, 189, 106, calc(var(--glow, 0.4) * 0.5));
  animation: stencil-breathe 2.8s var(--ease-breath) infinite;
}
.stencil-glow {
  position: absolute;
  inset: -20px;
  border-radius: var(--r-m);
  background: radial-gradient(ellipse at center,
    rgba(230,189,106,0.15),
    transparent 60%);
  animation: stencil-glow-pulse 2.8s var(--ease-breath) infinite;
  pointer-events: none;
}

@keyframes stencil-breathe {
  0%, 100% {
    --glow: 0.25;
    color: var(--gold);
    text-shadow:
      0 0 18px rgba(242, 205, 122, 0.25),
      0 0 38px rgba(230, 189, 106, 0.1);
  }
  50% {
    --glow: 0.7;
    color: var(--gold-hi);
    text-shadow:
      0 0 28px rgba(242, 205, 122, 0.7),
      0 0 55px rgba(230, 189, 106, 0.35);
  }
}
@keyframes stencil-glow-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.95); }
  50%      { opacity: 1; transform: scale(1.05); }
}

/* Progressive disclosure stages */
.stages {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  min-width: 240px;
  text-align: left;
}
.stage {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: var(--pad-s);
  padding: 4px 0;
  opacity: 0.4;
  transition: opacity .4s, color .4s;
}
.stage.is-active {
  opacity: 1;
  color: var(--gold);
  font-weight: 700;
  text-shadow: 0 0 5px rgba(230, 189, 106, 0.28);
  transform: scale(1.04);
  transform-origin: left center;
  animation: stage-pulse 1.4s ease-in-out infinite;
}
@keyframes stage-pulse {
  0%, 100% { text-shadow: 0 0 5px rgba(230, 189, 106, 0.22); }
  50%      { text-shadow: 0 0 9px rgba(230, 189, 106, 0.45); }
}
.stage.is-done { opacity: 0.7; color: var(--ink-2); }
.stage-indicator {
  width: 10px; height: 10px;
  border-radius: 999px;
  border: 1px solid var(--ink-4);
  position: relative;
}
.stage.is-active .stage-indicator {
  border-color: var(--gold);
  animation: stage-spin 1.2s linear infinite;
}
.stage.is-active .stage-indicator::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-top: 1.5px solid var(--gold);
  border-right: 1.5px solid transparent;
  border-bottom: 1.5px solid transparent;
  border-left: 1.5px solid transparent;
  border-radius: 999px;
}
.stage.is-done .stage-indicator {
  border-color: var(--gold-deep);
  background: var(--gold-deep);
}
.stage.is-done .stage-indicator::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  color: var(--bg-1);
  font-size: 8px;
  font-weight: 700;
  font-family: var(--font-ui);
}
.stage-ms { color: var(--ink-4); font-size: 10px; }

@keyframes stage-spin { to { transform: rotate(360deg); } }

/* Tweak: alt thinking — three dots */
.thinking-dots {
  display: flex;
  gap: 6px;
  margin-top: var(--pad-l);
}
.thinking-dots span {
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--gold);
  opacity: 0.3;
  animation: dot-pulse 1.4s infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ────────────────────────────────────────────────────────────
   Composer — persistent bottom bar (chat-style)
   ─────────────────────────────────────────────────────────── */
.composer-wrap {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: var(--pad-l) var(--pad-xl) var(--pad-xl);
  background: linear-gradient(to top,
    var(--bg-1) 60%,
    rgba(15,17,21,0.9) 80%,
    rgba(15,17,21,0) 100%);
  z-index: 5;
}
.composer {
  max-width: var(--measure);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: var(--pad-s);
  padding: var(--pad-s) var(--pad-s) var(--pad-s) var(--pad-l);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  box-shadow: var(--shadow-card);
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within {
  border-color: var(--line-hard);
  box-shadow: var(--shadow-card), 0 0 0 3px rgba(230,189,106,0.08);
}

.composer-input {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink-0);
  padding: 8px 0;
  resize: none;
  width: 100%;
  min-height: 24px;
  max-height: 120px;
}
.composer-input::placeholder {
  color: var(--ink-3);
  font-style: italic;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.composer-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  color: var(--ink-3);
  border-radius: var(--r-s);
  transition: all .15s;
}
.composer-btn:hover { color: var(--gold); background: var(--bg-3); }
.composer-btn svg { width: 15px; height: 15px; }
.composer-btn.is-primary {
  color: var(--bg-1);
  background: var(--gold);
  border: 1px solid var(--gold-hi);
}
.composer-btn.is-primary:hover { background: var(--gold-hi); }
.composer-btn.is-primary:disabled {
  background: var(--bg-3);
  color: var(--ink-4);
  border-color: var(--line-soft);
  cursor: not-allowed;
}

.composer-hint {
  max-width: var(--measure);
  margin: 6px auto 0;
  padding: 0 2px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
}
.composer-hint kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  color: var(--ink-3);
  background: var(--bg-2);
}

/* ────────────────────────────────────────────────────────────
   History — command-palette style bottom drawer
   ─────────────────────────────────────────────────────────── */
.history-trigger {
  position: absolute;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: var(--pad-s);
  padding: 4px 10px 4px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  transition: all .15s;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
}
/* actually float inside composer hint row instead — see jsx */

.palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 0 var(--pad-l) 10vh;
  animation: fade-in .15s;
}
@keyframes fade-in { from { opacity: 0; } }

.palette {
  width: 100%;
  max-width: 640px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  animation: palette-in .2s var(--ease-breath);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
@keyframes palette-in {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.palette-search {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: var(--pad-m);
  align-items: center;
  padding: var(--pad-m) var(--pad-l);
  border-bottom: 1px solid var(--line-soft);
}
.palette-search svg {
  width: 14px; height: 14px;
  color: var(--ink-3);
}
.palette-search input {
  font-size: 14px;
  color: var(--ink-0);
}
.palette-search input::placeholder { color: var(--ink-3); }
.palette-esc {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--line-soft);
  color: var(--ink-3);
  border-radius: 3px;
}

.palette-list {
  overflow-y: auto;
  padding: 6px;
}
.palette-section {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding: 10px 10px 6px;
}

.hist-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--pad-l);
  padding: 10px 12px;
  border-radius: var(--r-s);
  cursor: pointer;
  align-items: center;
  transition: background .1s;
}
.hist-item:hover,
.hist-item.is-focus {
  background: var(--bg-3);
}
.hist-item.is-focus .hist-q {
  color: var(--gold);
}
.hist-q {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-1);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.hist-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: var(--pad-s);
}
.hist-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 6px;
  border: 1px solid var(--line-soft);
  color: var(--ink-2);
  border-radius: 3px;
  letter-spacing: 0.04em;
}

.palette-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px var(--pad-l);
  border-top: 1px solid var(--line-soft);
  background: var(--bg-1);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
.palette-footer .shortcut {
  display: inline-flex; align-items: center; gap: 4px;
}
.palette-footer kbd {
  font-family: var(--font-mono);
  padding: 1px 5px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  color: var(--ink-2);
}
.palette-clear {
  color: var(--ruby);
  font-family: var(--font-ui);
  font-size: 11px;
}
.palette-clear:hover { color: #e8564e; }

/* ────────────────────────────────────────────────────────────
   Error banner
   ─────────────────────────────────────────────────────────── */
.errbar {
  max-width: var(--measure);
  margin: 0 auto var(--pad-l);
  display: flex;
  align-items: flex-start;
  gap: var(--pad-m);
  padding: var(--pad-m) var(--pad-l);
  background: linear-gradient(to right, rgba(200,68,59,0.08), transparent);
  border: 1px solid rgba(200,68,59,0.2);
  border-left: 2px solid var(--ruby);
  border-radius: var(--r-s);
}
.errbar-icon { color: var(--ruby); flex-shrink: 0; margin-top: 1px; }
.errbar-body { flex: 1; }
.errbar-title { color: var(--ink-0); font-weight: 500; font-size: 13px; }
.errbar-sub { color: var(--ink-2); font-size: 12px; margin-top: 2px; }

/* ────────────────────────────────────────────────────────────
   Side panels (Settings + Voice stubs)
   ─────────────────────────────────────────────────────────── */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 90;
  animation: fade-in .15s;
}
.panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  background: var(--bg-1);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lift);
  z-index: 95;
  display: flex;
  flex-direction: column;
  animation: panel-in .25s var(--ease-breath);
}
@keyframes panel-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.panel-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--pad-l) var(--pad-xl);
  border-bottom: 1px solid var(--line-soft);
}
.panel-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 20px;
  color: var(--ink-0);
}
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--pad-xl);
  display: flex;
  flex-direction: column;
  gap: var(--pad-xl);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-mid);
}
.field-help {
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.45;
}

.select {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-s);
}
.select-opt {
  flex: 1;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink-2);
  border-radius: var(--r-xs);
  text-align: center;
  transition: all .15s;
}
.select-opt.is-active {
  background: var(--bg-3);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--line);
}
.select-opt:hover:not(.is-active) { color: var(--ink-0); }

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--pad-m) 0;
  border-bottom: 1px solid var(--line-soft);
}
.toggle-text { flex: 1; padding-right: var(--pad-l); }
.toggle-title { color: var(--ink-0); font-size: 13px; }
.toggle-sub { color: var(--ink-3); font-size: 11px; margin-top: 2px; }
.toggle-sw {
  width: 36px; height: 20px;
  background: var(--bg-3);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0;
}
.toggle-sw::after {
  content: "";
  position: absolute;
  top: 1px; left: 1px;
  width: 16px; height: 16px;
  border-radius: 999px;
  background: var(--ink-2);
  transition: transform .2s;
}
.toggle-sw.is-on {
  background: rgba(230,189,106,0.15);
  border-color: var(--line-hard);
}
.toggle-sw.is-on::after {
  transform: translateX(16px);
  background: var(--gold);
}

.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--pad-s);
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  align-items: baseline;
}
.kv-k { color: var(--ink-3); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.kv-v { color: var(--ink-0); font-family: var(--font-mono); font-size: 11px; text-align: right; }

/* Voice mode */
.voice-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--pad-2xl);
  gap: var(--pad-xl);
  text-align: center;
}
.voice-halo {
  position: relative;
  width: 180px;
  height: 180px;
  display: grid;
  place-items: center;
}
.voice-halo::before,
.voice-halo::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid var(--gold-deep);
  animation: halo 3s var(--ease-breath) infinite;
}
.voice-halo::after { animation-delay: 1.5s; }
@keyframes halo {
  0%   { transform: scale(0.6); opacity: 0.8; }
  100% { transform: scale(1.2); opacity: 0; }
}
.voice-core {
  width: 80px; height: 80px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 30%, var(--gold-hi), var(--gold-mid) 60%, var(--gold-deep));
  box-shadow: 0 0 30px rgba(230,189,106,0.4);
  position: relative;
  z-index: 1;
  animation: voice-breathe 2.8s var(--ease-breath) infinite;
}
@keyframes voice-breathe {
  0%, 100% { transform: scale(0.94); }
  50%      { transform: scale(1.04); }
}
.voice-state {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 20px;
  color: var(--ink-0);
}
.voice-transcript {
  font-size: 13px;
  color: var(--ink-3);
  max-width: 320px;
  line-height: 1.5;
  font-family: var(--font-serif);
  font-style: italic;
}
.voice-wave {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 24px;
}
.voice-wave span {
  width: 3px;
  background: var(--gold);
  border-radius: 2px;
  animation: wave 1s infinite;
}
@keyframes wave {
  0%, 100% { height: 20%; }
  50%      { height: 100%; }
}

/* ────────────────────────────────────────────────────────────
   Tweaks panel
   ─────────────────────────────────────────────────────────── */
.tweaks {
  position: fixed;
  bottom: var(--pad-l);
  right: var(--pad-l);
  width: 280px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  box-shadow: var(--shadow-lift);
  font-size: 12px;
  z-index: 80;
  overflow: hidden;
}
.tweaks-hdr {
  padding: 10px var(--pad-l);
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-mid);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tweaks-body {
  padding: var(--pad-m) var(--pad-l);
  display: flex;
  flex-direction: column;
  gap: var(--pad-m);
}
.tweaks-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tweaks-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* Simulate button group inside tweaks */
.tweaks .select-opt { font-size: 10px; padding: 5px 8px; }

/* Gold hue swatches for accent-temperature tweak */
.swatches { display: flex; gap: 6px; }
.swatch {
  width: 24px; height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  cursor: pointer;
  transition: transform .1s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-active {
  border-color: var(--ink-0);
  box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3px currentColor;
}

/* ────────────────────────────────────────────────────────────
   Component inventory view
   ─────────────────────────────────────────────────────────── */
.inv {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--pad-xl) 0;
}
.inv-intro {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--ink-2);
  margin-bottom: var(--pad-2xl);
  max-width: 640px;
  text-wrap: pretty;
}
.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--pad-xl);
}
.inv-card {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-m);
  padding: var(--pad-l);
  display: flex;
  flex-direction: column;
  gap: var(--pad-m);
}
.inv-card-hdr {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.inv-card-name {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-0);
}
.inv-card-id {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--gold-mid);
  text-transform: uppercase;
}
.inv-card-demo {
  padding: var(--pad-m);
  background: var(--bg-1);
  border-radius: var(--r-s);
  border: 1px solid var(--line-soft);
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--pad-s);
}
.inv-card-desc {
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.45;
  text-wrap: pretty;
}

/* Moodboard view */
.mood {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--pad-xl) 0;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--pad-l);
}
.mood-tile {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-m);
  padding: var(--pad-l);
  position: relative;
  overflow: hidden;
  min-height: 140px;
}
.mood-tile-label {
  position: absolute;
  top: 12px; left: 12px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  z-index: 2;
}
.mood-tile-val {
  position: absolute;
  bottom: 12px; left: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
  z-index: 2;
}

.mood-span-3 { grid-column: span 3; }
.mood-span-4 { grid-column: span 4; }
.mood-span-5 { grid-column: span 5; }
.mood-span-6 { grid-column: span 6; }
.mood-span-7 { grid-column: span 7; }
.mood-span-8 { grid-column: span 8; }
.mood-span-9 { grid-column: span 9; }
.mood-span-12 { grid-column: span 12; }

.mood-big-gold {
  display: grid; place-items: center;
  min-height: 260px;
  background:
    radial-gradient(circle at 30% 30%, rgba(242,205,122,0.25), transparent 60%),
    linear-gradient(135deg, var(--bg-2), var(--bg-1));
  color: var(--gold);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 96px;
  letter-spacing: 0.18em;
  text-shadow: 0 0 40px rgba(242,205,122,0.4);
}
.mood-type-sample {
  min-height: 260px;
  padding: var(--pad-2xl);
}
.mood-type-sample h1 {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 36px;
  font-weight: 400;
  color: var(--ink-0);
  margin: 0;
  line-height: 1.15;
  text-wrap: balance;
}
.mood-type-sample h1 em {
  color: var(--gold);
  font-style: italic;
}
.mood-type-sample p {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-1);
  margin: var(--pad-l) 0 0;
}

.mood-palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  min-height: 100px;
}
.mood-palette > div {
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: var(--pad-s);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--ink-0);
  mix-blend-mode: difference;
}

/* A list of type specimens — for moodboard */
.type-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--pad-l);
  padding: var(--pad-m) 0;
  border-bottom: 1px solid var(--line-soft);
  align-items: baseline;
}
.type-row:last-child { border: 0; }
.type-row .lbl {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.delight-callout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--pad-xl);
  align-items: center;
  padding: var(--pad-2xl);
  background: linear-gradient(135deg,
    rgba(230,189,106,0.06),
    rgba(230,189,106,0.01));
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  grid-column: span 12;
}
.delight-callout h2 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 32px;
  color: var(--gold);
  margin: 0 0 var(--pad-m);
  letter-spacing: 0.01em;
}
.delight-callout p {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-1);
  margin: 0 0 var(--pad-m);
  text-wrap: pretty;
}

/* Reset button-defaults for .cite now that it's a <button>. */
button.cite {
  background: transparent;
  border: 0;
  font-size: inherit;
  line-height: inherit;
  padding: 0 1px;
  -webkit-appearance: none;
  appearance: none;
}
button.cite:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Rule popover — glassmorphic overlay. Backdrop: blurred scene behind.
   Panel: translucent gold-tinted glass with a soft inner gold ring. */
.rule-backdrop {
  position: fixed; inset: 0;
  background: rgba(8,10,14,0.45);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn 0.16s ease-out;
  cursor: pointer; /* click-anywhere-to-dismiss affordance */
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.rule-pop {
  background: rgba(23, 26, 33, 0.72);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(230,189,106,0.28);
  border-radius: 14px;
  box-shadow:
    0 24px 80px rgba(0,0,0,0.55),
    0 0 0 1px rgba(230,189,106,0.08),
    inset 0 1px 0 rgba(255,255,255,0.04);
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  cursor: default;
  animation: popIn 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.rule-pop-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(230,189,106,0.15);
  background: linear-gradient(180deg, rgba(230,189,106,0.04), transparent);
}
.rule-pop-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.5px;
}
.rule-pop-close {
  background: transparent; border: 0;
  color: var(--fg-dim, #8b94a4);
  font-size: 22px; line-height: 1;
  cursor: pointer; padding: 4px 10px;
  border-radius: 4px;
}
.rule-pop-close:hover { color: var(--fg, #e6e9ef); background: rgba(255,255,255,0.05); }
.rule-pop-body { padding: 18px 20px; overflow-y: auto; }
.rule-pop-loading, .rule-pop-hint {
  color: var(--fg-dim, #8b94a4);
  font-size: 13px;
  font-style: italic;
}
.rule-pop-hint { margin-top: 10px; font-size: 11px; }
.rule-pop-err {
  color: #ff8a8a;
  font-size: 13px;
}
.rule-pop-text {
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--fg, #e6e9ef);
  white-space: pre-wrap;
  margin: 0;
}

/* ──────────────────────────────────────────────────────────
   Mobile / iPhone — collapse to single column, full-width
   composer with safe-area padding for home-indicator, hide
   tablet-assumption chrome.
   ────────────────────────────────────────────────────────── */
@media (max-width: 880px) {
  .nav { display: none; }
  .brand-sub { display: none; }
  .tweaks { display: none; }
  .mood-span-3,.mood-span-4,.mood-span-5,.mood-span-6,
  .mood-span-7,.mood-span-8,.mood-span-9 { grid-column: span 12; }
}

@media (max-width: 560px) {
  /* Layout compaction for phones. Keep the viewport-height flex chain intact
     so the composer stays pinned at the bottom. CRITICAL: .main must flex:1 or
     its children (.scroll, .composer-wrap) collapse to zero-height invisible. */
  html, body { height: 100%; overflow: hidden; }
  .app {
    /* Use --app-h set by JS (window.innerHeight) instead of 100vh/100dvh —
       iOS Safari's URL-bar auto-hide makes viewport units flicker, causing
       the "have to pull down for layout to snap" bug. JS-driven height is
       the actual visible area and stays rock-solid. */
    height: var(--app-h, 100dvh);
    min-height: var(--app-h, 100dvh);
    display: flex; flex-direction: column;
    grid-template-rows: none; /* cancel desktop grid */
    overflow: hidden;
  }
  .hdr { flex: 0 0 auto; }
  .main { flex: 1; min-height: 0; position: relative; overflow: hidden; }
  .scroll { height: 100%; overflow-y: auto; padding-top: 0 !important; padding-bottom: 180px; }

  /* Header: tighter, no subtitle. */
  header, .header { padding: 10px 14px !important; gap: 8px !important; }
  .brand, .brand-main { font-size: 18px !important; }
  .status-sep, .status-model { display: none; }
  .status { padding: 4px 8px !important; font-size: 11px !important; }

  /* Drop to single column — sidebar was already hidden above 880px. */
  .main, .judge, .scroll { padding-left: 14px !important; padding-right: 14px !important; }

  /* Answer body: tighten the measure. */
  .answer-wrap, .answer-body { max-width: 100% !important; }
  .answer-body, .answer-verdict { font-size: 16px !important; line-height: 1.55 !important; }
  .answer-question { font-size: 18px !important; }

  /* Hero in block flow with comfortable breathing room below the header.
     Splash padding-top matches (see .splash above) so the gem doesn't shift
     when the splash fades out. --hero-top-offset is the single knob. */
  .hero {
    padding-top: var(--hero-top-offset, 48px) !important;
    margin-top: 0 !important;
  }
  .hero h1 { font-size: 22px !important; }
  .hero-mark { margin-bottom: 20px !important; }

  /* Composer pinned to the bottom with safe-area for the home bar. */
  .composer, .composer-wrap {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    gap: 8px !important;
  }
  textarea, .composer textarea, textarea#question {
    font-size: 16px !important; /* prevents iOS auto-zoom on focus */
    min-height: 42px !important;
  }
  button, .btn, .composer button {
    padding: 10px 14px !important;
    font-size: 14px !important;
  }

  /* History palette (⌘K) — full-screen sheet on mobile. */
  .palette, .history-palette {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 12px 12px 0 0 !important;
    bottom: 0 !important;
    top: auto !important;
  }

  /* Rule popover — bottom sheet on mobile. */
  .rule-backdrop { padding: 0; align-items: flex-end; }
  .rule-pop {
    max-width: 100%;
    max-height: 88vh;
    border-radius: 14px 14px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .rule-pop-body { padding: 16px; }

  /* Settings / Voice side panels: full-width overlays. */
  .side-panel, .settings-panel, .voice-panel {
    width: 100% !important;
    max-width: 100% !important;
    right: 0 !important;
  }
}

@media (max-width: 400px) {
  /* iPhone SE / Mini range — gem size handled by the <MoxMark size={N}> prop. */
  .answer-body { font-size: 15.5px !important; }
}

/* ── Card reference inline (like .cite but with card-body treatment) ── */
button.card-ref {
  background: transparent;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  padding: 1px 6px;
  margin: 0 1px;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: var(--gold);
  background: rgba(230,189,106,0.08);
  border-radius: 4px;
  border-bottom: 1px dashed var(--gold-deep);
  transition: background 0.12s, color 0.12s;
}
button.card-ref:hover { background: rgba(230,189,106,0.18); color: var(--gold-hi); }
button.card-ref:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ── Card popover ── */
.card-pop {
  background: var(--bg-1, #171a21);
  border: 1px solid var(--gold-deep, #8a6a33);
  border-radius: 10px;
  box-shadow: 0 16px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(230,189,106,0.08);
  max-width: 460px;
  width: 100%;
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.card-pop-body {
  padding: 16px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  align-items: center;
}
.card-pop-img {
  max-width: 100%;
  width: 340px;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: block;
}
.card-pop-faces { display: grid; gap: 12px; width: 100%; }
.card-pop-face { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.card-pop-face-label {
  font-size: 11px;
  color: var(--fg-dim, #8b94a4);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.card-pop-meta {
  display: flex; justify-content: space-between;
  width: 100%; gap: 12px;
  font-size: 13px;
  color: var(--fg-dim, #8b94a4);
  font-family: var(--font-serif);
  font-style: italic;
}
.card-pop-type { flex: 1; }
.card-pop-mana { font-family: var(--font-mono); color: var(--gold); }
.card-pop-oracle {
  font-family: var(--font-serif);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--fg, #e6e9ef);
  white-space: pre-wrap;
  margin: 0;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-2, #0f1115);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}
.card-pop-link {
  align-self: flex-start;
  font-size: 12px;
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid var(--gold-deep);
  padding-bottom: 1px;
}
.card-pop-link:hover { color: var(--gold-hi); border-color: var(--gold); }
.card-pop-candidates {
  list-style: none; padding: 0; margin: 8px 0; width: 100%;
}
.card-pop-cand {
  display: block; width: 100%;
  background: var(--bg-2, #0f1115);
  border: 1px solid var(--line-soft);
  color: var(--fg, #e6e9ef);
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 6px;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 14px;
}
.card-pop-cand:hover { border-color: var(--gold-deep); color: var(--gold); }

/* ── Related section (rabbit hole) ── */
.related {
  margin: 28px 0 0;
  padding: 20px 0 0;
  border-top: 1px solid var(--line-soft);
}
.related-title {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 12px;
  font-family: var(--font-mono);
}
.related-list {
  display: grid;
  gap: 8px;
}
.related-item {
  text-align: left;
  background: var(--bg-2, #0f1115);
  border: 1px solid var(--line-soft);
  color: var(--fg, #e6e9ef);
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  display: grid;
  gap: 4px;
  transition: border-color 0.12s, background 0.12s;
}
.related-item:hover {
  border-color: var(--gold-deep);
  background: rgba(230,189,106,0.04);
}
.related-framing {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.2px;
}
.related-question {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--fg, #e6e9ef);
  line-height: 1.4;
}

/* ── Mobile UX fixes ── */
@media (max-width: 560px) {
  /* Give the answer-actions breathing room from the composer. */
  .answer-actions {
    gap: 10px !important;
    padding: 12px 0 20px !important;
    flex-wrap: wrap !important;
  }
  .answer-actions .action,
  .answer-actions button {
    min-height: 42px !important;
    padding: 8px 12px !important;
  }

  /* Visible grab-handle + hint above the composer so the pull-up gesture is
     discoverable. Keep `position: absolute; bottom: 0` from desktop — the
     ::before/::after pseudo-elements still anchor to it correctly. */
  .composer-wrap {
    /* DON'T override to position:relative — that pushes the composer below
       .scroll and out of the viewport. Keep the desktop absolute-bottom. */
  }
  .composer-wrap::before {
    content: "";
    display: block;
    width: 44px;
    height: 4px;
    background: var(--gold-deep);
    border-radius: 2px;
    margin: 10px auto 6px;
    opacity: 0.6;
  }

  /* Shrink the card popover image on tiny screens so it fits. */
  .card-pop-img { width: 280px; max-width: 100%; }
  .card-pop { max-width: 100%; border-radius: 14px 14px 0 0; }
  .card-pop-body { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}

/* Composer mode pills — persistent-state selector beneath the textarea.
   Clicking sets the mode; it does NOT submit. Submission is via the arrow
   icon inside the composer, or via Enter. */
.mode-pills {
  max-width: var(--measure);
  margin: 8px auto 0;
  display: flex;
  gap: 8px;
  justify-content: center;
}
.mode-pill {
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  background: transparent;
  color: var(--ink-3);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.mode-pill:hover:not(:disabled) { color: var(--ink-1); border-color: var(--line-hard); }
.mode-pill:disabled { opacity: 0.38; cursor: not-allowed; }
.mode-pill.is-active {
  background: rgba(230,189,106,0.12);
  color: var(--gold);
  border-color: var(--gold);
}

/* Submit arrow button — gold circle with up-arrow to the right of the mic. */
.composer-btn.is-submit {
  background: var(--gold);
  color: #1a1208;
  border-radius: 50%;
}
.composer-btn.is-submit:hover:not(:disabled) { background: var(--gold-hi); }
.composer-btn.is-submit:disabled {
  background: var(--bg-3);
  color: var(--ink-3);
  cursor: not-allowed;
}
.composer-btn.is-submit svg { width: 16px; height: 16px; }

/* Header history icon badge — small chip showing count of saved questions. */
.hdr-history { position: relative; }
.hdr-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--gold);
  color: #1a1208;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

/* Mic button states — recording (red pulse) and transcribing (gold pulse). */
.composer-btn.is-recording {
  color: #ff6b6b !important;
  background: rgba(255,107,107,0.12);
  animation: micPulseRed 1.2s ease-in-out infinite;
}
.composer-btn.is-transcribing {
  color: var(--gold) !important;
  background: rgba(230,189,106,0.15);
  animation: micPulseGold 1.2s ease-in-out infinite;
}
@keyframes micPulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,107,0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(255,107,107,0); }
}
@keyframes micPulseGold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230,189,106,0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(230,189,106,0); }
}

/* ────────────────────────────────────────────────────────────
   Boot cross-fade — single layout, gem never moves.
   During `data-boot="boot"` the header/title/sub/composer are invisible
   and a large ONYX wordmark sits in the title slot. On `data-boot="done"`
   the wordmark fades out as everything else fades in. The gem renders at
   its final hero position from frame zero, so there's no Y shift ever.
   ─────────────────────────────────────────────────────────── */
.app .hdr,
.app .hero-title,
.app .hero-sub,
.app .composer-wrap,
.app .hero-boot-word {
  transition: opacity 0.7s ease-in-out;
}
/* Header + composer overlay the fixed hero (which is centered at viewport
   center). Solid/gradient backgrounds hide the parts of the gem that would
   otherwise peek out at top and bottom. */
.app .hdr { position: relative; z-index: 10; background: var(--bg-1); }
.app .composer-wrap { z-index: 10; }
/* Boot: only the gem + boot wordmark are visible. */
.app[data-boot="boot"] .hdr,
.app[data-boot="boot"] .hero-title,
.app[data-boot="boot"] .hero-sub,
.app[data-boot="boot"] .composer-wrap {
  opacity: 0;
  pointer-events: none;
}
.app[data-boot="boot"] .hero-boot-word { opacity: 1; }
.app[data-boot="done"] .hero-boot-word { opacity: 0; pointer-events: none; }

/* The boot wordmark sits in the same slot as the hero title, so nothing
   reflows between boot and done — pure cross-fade. */
.hero-boot-word {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(40px, 7vw, 72px);
  letter-spacing: 0.26em;
  color: var(--gold);
  text-align: center;
  text-shadow:
    0 0 22px rgba(230, 189, 106, 0.40),
    0 0 40px rgba(230, 189, 106, 0.20);
  pointer-events: none;
}
@media (max-width: 560px) {
  .hero-boot-word { font-size: clamp(36px, 11vw, 58px); letter-spacing: 0.28em; }
}

/* Respect OS reduced-motion for the breathing stencil and fades. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
