/* ============================================================================
   Learn Guardrails with Railey — game styles (live, real backend).
   A standalone green-phosphor CRT arcade cabinet. Hand-built, no UI libs.
   Color encodes STATE, never decoration:
     phosphor green = healthy / pass / active
     amber          = caution / planned / redacted / rate-limited
     red            = hard block / refusal
   ========================================================================== */

:root {
  /* phosphor palette (P1 green) */
  --phos:        #5cf38a;
  --phos-bright: #c4ffd8;
  --phos-dim:    #2f9d5a;
  --phos-deep:   #123922;
  --amber:       #ffb44a;
  --amber-dim:   #7a531c;
  --red:         #ff5d5d;
  --red-dim:     #6e2526;

  /* surfaces */
  --room:    #050707;
  --room-2:  #0a0e0d;
  --screen:  #03150b;
  --screen-2:#04200f;
  --bezel:   #15110d;
  --bezel-2: #221a12;
  --bezel-hi:#3a2c1e;

  /* type */
  --font-screen: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --font-pixel:  "VT323", "IBM Plex Mono", monospace;

  /* glow helpers */
  --glow-soft: 0 0 1px currentColor, 0 0 7px rgba(92, 243, 138, .35);
  --glow-amber: 0 0 1px currentColor, 0 0 8px rgba(255, 180, 74, .4);
  --glow-red:  0 0 1px currentColor, 0 0 9px rgba(255, 93, 93, .45);

  --r: 6px;
}

* { box-sizing: border-box; }
/* the [hidden] attribute must always win over component `display` rules
   (e.g. .cost__via sets display:flex) so JS show/hide toggles work. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body.room {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-screen);
  color: var(--phos);
  background:
    radial-gradient(120% 90% at 50% 8%, #0c1411 0%, var(--room-2) 42%, var(--room) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 3vw, 44px) 16px 12px;
  /* faint room "dust" of light */
  background-attachment: fixed;
}

a { color: var(--phos-bright); }

/* ============================== CABINET ================================== */

.cabinet {
  width: min(1180px, 100%);
}

.bezel {
  position: relative;
  border-radius: 26px;
  padding: clamp(14px, 1.8vw, 26px);
  background:
    linear-gradient(180deg, var(--bezel-2), var(--bezel) 60%, #0c0a07);
  box-shadow:
    0 1px 0 rgba(255,255,255,.05) inset,
    0 0 0 2px #000,
    0 0 0 3px var(--bezel-hi),
    0 40px 90px -30px #000,
    0 14px 40px -20px rgba(0,0,0,.9);
}
/* riveted bezel corners */
.bezel::before, .bezel::after {
  content: "";
  position: absolute;
  width: 8px; height: 8px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6b563b, #1a130b 70%);
  box-shadow: 0 1px 1px rgba(0,0,0,.8);
}
.bezel::before { left: 12px; top: 12px; }
.bezel::after  { right: 12px; top: 12px; }

/* ============================== MARQUEE ================================= */

.marquee {
  text-align: center;
  padding: 4px 0 14px;
}
.marquee__title {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: clamp(26px, 4.6vw, 52px);
  line-height: .9;
  letter-spacing: 2px;
  color: var(--phos-bright);
  text-shadow: 0 0 6px rgba(92,243,138,.6), 0 0 22px rgba(92,243,138,.35);
}
.marquee__glyph { color: var(--amber); text-shadow: var(--glow-amber); }
.marquee__sub {
  margin-top: 6px;
  font-size: 12.5px;
  letter-spacing: .5px;
  color: var(--phos-dim);
}
.marquee__sub a { color: var(--phos); text-decoration: none; border-bottom: 1px dotted var(--phos-dim); }
.marquee__mock {
  margin-left: 10px;
  color: var(--amber);
  font-weight: 600;
  letter-spacing: 1px;
  font-size: 11px;
  vertical-align: 1px;
}
.marquee__mock::first-letter { font-size: 9px; }

/* ============================== SCREEN ================================== */

.screen {
  position: relative;
  border-radius: 14px / 18px;
  overflow: hidden;
  background:
    radial-gradient(130% 120% at 50% 18%, var(--screen-2) 0%, var(--screen) 58%, #010c06 100%);
  box-shadow:
    0 0 0 2px #000,
    0 0 0 5px #08110b,
    0 0 60px rgba(40,255,140,.06) inset,
    0 0 0 100vmax rgba(0,0,0,0) /* keep stacking ctx */;
  /* faint screen curvature */
  border: 1px solid #0c2a18;
}
/* scanlines + slow scan band */
.screen__overlay {
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background:
    repeating-linear-gradient(0deg,
      rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px,
      rgba(0,0,0,.16) 3px, rgba(0,0,0,.16) 3px);
  mix-blend-mode: multiply;
}
.screen__overlay::after {
  content: "";
  position: absolute; left: 0; right: 0; height: 38%;
  background: linear-gradient(180deg, rgba(120,255,180,.05), rgba(120,255,180,0));
  animation: scan 7.5s linear infinite;
}
/* vignette + flicker */
.screen__glow {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background:
    radial-gradient(120% 120% at 50% 50%, rgba(0,0,0,0) 55%, rgba(0,0,0,.55) 100%);
  animation: flicker 6s steps(60) infinite;
}
@keyframes scan   { from { transform: translateY(-120%); } to { transform: translateY(360%); } }
@keyframes flicker{ 0%,100%{opacity:.96} 50%{opacity:1} 53%{opacity:.93} 54%{opacity:.99} }

/* ============================== CRT GRID =============================== */

.crt {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 16px;
  padding: clamp(14px, 1.6vw, 22px);
  min-height: 540px;
}
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.col--side { gap: 12px; }

/* generic panel */
.panel {
  border: 1px solid var(--phos-deep);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(20,70,42,.16), rgba(8,30,18,.10));
  padding: 10px 12px 12px;
}
.panel__head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 1px dashed var(--phos-deep);
  padding-bottom: 7px; margin-bottom: 9px;
}
.panel__title {
  font-weight: 700; letter-spacing: 2.5px; font-size: 12px;
  color: var(--phos-bright); text-shadow: var(--glow-soft);
}
.panel__meta { font-size: 10.5px; letter-spacing: 1px; color: var(--phos-dim); }

/* ============================ RAILEY STAGE ============================= */

.railey-stage {
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--phos-deep); border-radius: var(--r);
  background:
    radial-gradient(80% 120% at 18% 30%, rgba(40,120,72,.18), rgba(6,24,14,.08));
  padding: 12px 16px;
}
.railey-stage__plate {
  font-size: 12px; letter-spacing: 1px; color: var(--phos);
  text-shadow: var(--glow-soft);
}
.railey-stage__plate #exprName { color: var(--phos-bright); text-transform: uppercase; }
.railey-stage__role {
  display: block; margin-top: 4px; font-size: 11px;
  color: var(--phos-dim); letter-spacing: .4px; text-shadow: none;
}
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--phos); box-shadow: 0 0 8px var(--phos); margin-right: 6px;
  vertical-align: 1px;
}

/* -------- the CSS-drawn paperclip character + expression states -------- */
.railey {
  position: relative;
  width: 116px; height: 150px;
  flex: 0 0 auto;
  transition: transform .25s ease;
  filter: drop-shadow(0 0 6px rgba(92,243,138,.35));
}
.railey__clip { position: absolute; inset: 0; }
/* ONE continuous SVG paperclip wire — replaces the old three separate border-loops, which read as
   detached pieces with gaps at the bends. Same continuous mark as the favicon + homepage peek, so all
   three Raileys match. drop-shadow glow lives on .railey; overflow visible keeps the round caps/glow. */
.railey__wire { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.railey__wire path { stroke: var(--phos); stroke-width: 10; }

.railey__face {
  position: absolute; top: 30px; left: 50%; transform: translateX(-50%);
  width: 72px; height: 44px; z-index: 2;
}
.eye {
  position: absolute; top: 9px; width: 24px; height: 28px; border-radius: 50%;
  background: var(--phos-bright);
  box-shadow: 0 0 6px rgba(196,255,216,.7);
  transition: transform .2s ease, height .12s ease;
  transform-origin: 50% 70%;
}
.eye--l { left: 1px; } .eye--r { right: 1px; }
.pupil {
  position: absolute; top: 8px; left: 7px;
  width: 11px; height: 13px; border-radius: 50%;
  background: #04140a;
  transition: transform .2s ease;
}
.brow {
  position: absolute; top: -1px; width: 24px; height: 5px; border-radius: 3px;
  background: var(--phos); box-shadow: var(--glow-soft);
  transition: transform .2s ease;
}
.brow--l { left: -1px; } .brow--r { right: -1px; }
.sweat {
  position: absolute; top: 4px; right: -13px;
  width: 9px; height: 13px; background: #8fd3ff;
  border-radius: 0 60% 55% 55%; transform: rotate(38deg);
  opacity: 0; transition: opacity .2s;
}
.sparkle {
  position: absolute; font-size: 14px; color: var(--phos-bright);
  opacity: 0; transition: opacity .2s;
}
.sparkle--a { top: -8px; right: -10px; }
.sparkle--b { bottom: -2px; left: -12px; font-size: 11px; }

/* idle — gentle blink */
.railey[data-expr="idle"] .eye { animation: blink 5.2s infinite; }
@keyframes blink { 0%,92%,100%{transform:scaleY(1)} 95%{transform:scaleY(.12)} }

/* smug — tilt, half-lidded, one brow up */
.railey[data-expr="smug"] { transform: rotate(-5deg); }
.railey[data-expr="smug"] .eye { transform: scaleY(.6); }
.railey[data-expr="smug"] .pupil { transform: translate(4px, -2px); }
.railey[data-expr="smug"] .brow--r { transform: translateY(-5px) rotate(-17deg); }
.railey[data-expr="smug"] .brow--l { transform: translateY(1px) rotate(-3deg); }

/* suspicious — lean in, narrowed, brows pinched down, side-eye */
.railey[data-expr="suspicious"] { transform: rotate(3deg) translateY(2px); }
.railey[data-expr="suspicious"] .eye { transform: scaleY(.46); }
.railey[data-expr="suspicious"] .pupil { transform: translate(-4px, 0); }
.railey[data-expr="suspicious"] .brow--l { transform: translateY(4px) rotate(13deg); }
.railey[data-expr="suspicious"] .brow--r { transform: translateY(4px) rotate(-13deg); }

/* rattled — wide eyes, raised brows, sweat, shake */
.railey[data-expr="rattled"] { animation: shake .35s ease-in-out infinite; }
.railey[data-expr="rattled"] .eye { transform: scale(1.14); }
.railey[data-expr="rattled"] .pupil { transform: scale(.8); }
.railey[data-expr="rattled"] .brow { transform: translateY(-5px); }
.railey[data-expr="rattled"] .sweat { opacity: 1; animation: drip 1.3s ease-in infinite; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-2.5px) rotate(-1deg)} 75%{transform:translateX(2.5px) rotate(1deg)} }
@keyframes drip { 0%{transform:rotate(38deg) translateY(0); opacity:1} 80%{opacity:1} 100%{transform:rotate(38deg) translateY(10px); opacity:0} }

/* impressed — wide open, brows up, sparkle, bounce */
.railey[data-expr="impressed"] { animation: bob 1.8s ease-in-out infinite; }
.railey[data-expr="impressed"] .eye { transform: scale(1.1); }
.railey[data-expr="impressed"] .brow--l { transform: translateY(-5px) rotate(7deg); }
.railey[data-expr="impressed"] .brow--r { transform: translateY(-5px) rotate(-7deg); }
.railey[data-expr="impressed"] .sparkle { opacity: 1; animation: twinkle 1.1s ease-in-out infinite; }
.railey[data-expr="impressed"] .sparkle--b { animation-delay: .4s; }
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
@keyframes twinkle { 0%,100%{opacity:.3; transform:scale(.7)} 50%{opacity:1; transform:scale(1.1)} }

/* Honest demo/rate-limit note above the CRT — reframes the tight limit as part of the lesson. */
.info-bar {
  display: flex; gap: 9px; align-items: flex-start;
  margin: 0 0 12px; padding: 9px 13px;
  border: 1px solid var(--phos-deep); border-radius: var(--r);
  background: rgba(20,70,42,.14);
  font-size: 12px; line-height: 1.5; color: var(--phos-dim); letter-spacing: .2px;
}
.info-bar b { color: var(--amber); font-weight: 700; }
.info-bar__dot { color: var(--phos); }
/* SEND-with-empty-box nudge — a brief amber flash on the input (nudgeEmpty() in railey.js). */
.input__field.is-nudge { border-color: var(--amber) !important; box-shadow: var(--glow-amber); }

/* ============================== TERMINAL =============================== */

.terminal {
  /* Content-sized (not stretched to fill the CRT row): the box hugs the chat so the input bar sits
     snug beneath the last line — no bottom-anchor void above a short conversation. A LONG chat is
     bounded by .terminal__body's max-height, which scrolls INTERNALLY instead of growing the page. */
  flex: 0 0 auto;
  border: 1px solid var(--phos-deep); border-radius: var(--r);
  background: rgba(4,22,12,.5);
  display: flex; flex-direction: column; min-height: 150px;
}
.terminal__head {
  display: flex; justify-content: space-between;
  font-size: 11px; letter-spacing: 1px; color: var(--phos-dim);
  padding: 6px 11px; border-bottom: 1px solid var(--phos-deep);
  background: rgba(20,70,42,.16);
}
.terminal__path { color: var(--amber); }
.terminal__head-right { display: flex; align-items: center; gap: 10px; }
/* "new chat" / clear — small terminal-styled control that resets ONLY the conversation. */
.terminal__clear {
  font-family: var(--font-screen); font-size: 10px; letter-spacing: 1px;
  color: var(--phos-dim); background: transparent;
  border: 1px solid var(--phos-deep); border-radius: 4px;
  padding: 2px 8px; cursor: pointer; line-height: 1.4;
  transition: color .2s, border-color .2s, background .2s;
}
.terminal__clear:hover { color: var(--phos-bright); border-color: var(--phos-dim); background: rgba(92,243,138,.08); }
.terminal__clear:focus-visible { outline: 2px solid var(--phos-bright); outline-offset: 2px; }
.terminal__body {
  padding: 11px 13px; font-size: 14px; line-height: 1.5;
  /* The log HUGS its content and grows downward, so the input sits snug right below the last line
     (no dead vertical space between the log and the input). min-height:0 keeps the flexbox overflow
     fix; max-height is a hard ceiling so a LONG chat scrolls INTERNALLY instead of ballooning the page. */
  overflow-y: auto; min-height: 0;
  max-height: 70vh;   /* hard ceiling so the log can never balloon the page (mobile overrides below) */
}
/* Scrollbar — match the CRT/phosphor theme (thin, green thumb, dark track), cross-browser. Firefox
   uses scrollbar-width/-color; WebKit/Blink use the ::-webkit-scrollbar pseudos. Internal scroll is
   unaffected (overflow-y: auto above). */
.terminal__body { scrollbar-width: thin; scrollbar-color: var(--phos-dim) rgba(4, 22, 12, .55); }
.terminal__body::-webkit-scrollbar { width: 9px; }
.terminal__body::-webkit-scrollbar-track { background: rgba(4, 22, 12, .55); border-radius: 6px; }
.terminal__body::-webkit-scrollbar-thumb {
  background: var(--phos-dim); border-radius: 6px;
  border: 2px solid rgba(4, 22, 12, .55);          /* inset border keeps the thumb reading as thin */
  box-shadow: 0 0 6px rgba(92, 243, 138, .25);     /* subtle phosphor glow */
}
.terminal__body::-webkit-scrollbar-thumb:hover { background: var(--phos); }
.line { margin: 0 0 8px; white-space: pre-wrap; word-break: break-word; }
.line--sys  { color: var(--phos-dim); }
.line--user { color: var(--phos); }
.line--user b { color: var(--amber); font-weight: 600; }
.line--clip {
  color: var(--phos-bright); text-shadow: var(--glow-soft);
  border-left: 2px solid var(--phos); padding-left: 9px;
}
.line--clip b { color: var(--amber); }
.cursor {
  display: inline-block; width: 9px; height: 1.05em; vertical-align: -2px;
  background: var(--phos-bright); margin-left: 2px;
  animation: caret 1s steps(2) infinite; box-shadow: var(--glow-soft);
}
@keyframes caret { 0%,49%{opacity:1} 50%,100%{opacity:0} }

/* offline-answers card — shown on a quota-degraded or server-down state (no model) */
.offline {
  margin: 4px 0 10px; padding: 9px 11px;
  border: 1px solid var(--amber-dim); border-left: 2px solid var(--amber);
  border-radius: var(--r); background: rgba(255, 180, 74, .05);
}
.offline__head {
  margin: 0 0 7px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--amber);
}
.offline__item { margin: 0 0 4px; }
.offline__item > summary {
  cursor: pointer; color: var(--phos-bright); list-style: none;
  padding: 2px 0; border-bottom: 1px dotted var(--phos-deep);
}
.offline__item > summary::before { content: "▸ "; color: var(--amber); }
.offline__item[open] > summary::before { content: "▾ "; }
.offline__item > summary:focus-visible { outline: 2px solid var(--phos); outline-offset: 2px; }
.offline__item > p { margin: 6px 0 9px; color: var(--phos); line-height: 1.5; }
.offline__item a, .offline__contact a { color: var(--phos-bright); border-bottom: 1px solid var(--phos-dim); }
.offline__contact { margin: 8px 0 0; color: var(--phos-bright); font-weight: 600; }

/* ============================== INPUT BAR ============================== */

.input {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--phos-dim); border-radius: var(--r);
  background: rgba(6,28,16,.6);
  padding: 8px 10px;
  box-shadow: 0 0 12px rgba(92,243,138,.08) inset;
}
.input__prompt { color: var(--amber); font-weight: 700; text-shadow: var(--glow-amber); }
.input__field {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--phos-bright); font: inherit; font-size: 14px; letter-spacing: .3px;
  text-shadow: var(--glow-soft);
}
.input__field::placeholder { color: var(--phos-dim); text-shadow: none; }
.input__send {
  font: inherit; font-weight: 700; letter-spacing: 1.5px; font-size: 12px;
  color: var(--screen); background: var(--phos);
  border: none; border-radius: 4px; padding: 6px 14px; cursor: pointer;
  box-shadow: 0 0 12px rgba(92,243,138,.5);
  transition: transform .08s, filter .15s;
}
.input__send:hover { filter: brightness(1.15); }
.input__send:active { transform: translateY(1px); }
.input__hint { margin: 7px 2px 0; font-size: 11px; color: var(--phos-dim); letter-spacing: .3px; }

/* ============================== PIPELINE =============================== */

.pipeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.pstage {
  border: 1px solid var(--phos-deep); border-left: 3px solid var(--phos-dim);
  border-radius: 5px; padding: 7px 9px;
  background: rgba(10,40,24,.25);
  opacity: .35; transform: translateX(-4px);
  transition: opacity .3s ease, transform .3s ease, border-color .3s;
}
.pstage.is-on { opacity: 1; transform: none; }
/* live "thinking" placeholder stages pulse while the real /inspect call is in flight */
.pstage.is-loading { opacity: .85; }
.pstage.is-loading .pstage__name, .pstage.is-loading .chip { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
/* Phase 4 thinking-walk: a pending stage shows its NAME (dim) but hides its result until
   it resolves; the stage being evaluated lights up; on is-on the real chip+detail appear. */
.pstage .chip, .pstage .pstage__detail { transition: opacity .25s ease; }
.pstage:not(.is-on) .chip, .pstage:not(.is-on) .pstage__detail { opacity: 0; }
.pstage.is-loading .chip { opacity: 1; }   /* the in-flight "…" indicator keeps its chip */
.pstage.is-evaluating {
  opacity: 1; transform: none;
  border-left-color: var(--phos-bright);
  box-shadow: 0 0 16px rgba(92, 243, 138, .22);
}
.pstage.is-evaluating .pstage__name { animation: pulse .85s ease-in-out infinite; }
.pstage--pass    { border-left-color: var(--phos); }
.pstage--soft    { border-left-color: var(--amber); }   /* redacted / flagged */
.pstage--blocked { border-left-color: var(--red); }
.pstage--idle    { border-left-color: var(--phos-dim); }
.pstage__top { display: flex; align-items: center; gap: 8px; }
.pstage__idx { color: var(--phos-dim); font-size: 11px; }
.pstage__name {
  font-weight: 600; letter-spacing: .5px; font-size: 12.5px;
  color: var(--phos-bright); text-shadow: var(--glow-soft); flex: 1;
}
.chip {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  padding: 2px 7px; border-radius: 999px; border: 1px solid currentColor;
  text-transform: uppercase;
}
.chip--ok    { color: var(--phos); }
.chip--soft  { color: var(--amber); text-shadow: var(--glow-amber); }
.chip--block { color: var(--red); text-shadow: var(--glow-red); }
.pstage__detail {
  margin-top: 5px; font-size: 11.5px; line-height: 1.45; color: var(--phos-dim);
}
.pstage__detail .k { color: var(--phos); }
/* live rate-limit countdown, shown INSIDE the blocked rate_limit stage (ticks via JS) */
.pstage__detail .rl-count { display: inline-block; margin-top: 3px; color: var(--amber); font-weight: 700; letter-spacing: .01em; }

/* pii blackout chips + flagged highlights inside details */
.redacted {
  background: #04140a; color: var(--amber); border: 1px solid var(--amber-dim);
  padding: 0 5px; border-radius: 3px; font-size: 11px; letter-spacing: .5px;
  text-shadow: var(--glow-amber);
}
.flagged {
  color: var(--red); text-shadow: var(--glow-red);
  border-bottom: 2px solid var(--red); padding-bottom: 1px;
  background: rgba(255,93,93,.08);
}
/* confidence meter */
.meter {
  margin-top: 6px; height: 7px; border-radius: 4px;
  background: var(--phos-deep); overflow: hidden;
}
.meter__fill {
  height: 100%; background: linear-gradient(90deg, var(--phos-dim), var(--phos));
  box-shadow: 0 0 8px rgba(92,243,138,.5);
  width: 0; transition: width .6s ease;
}
.meter--soft .meter__fill { background: linear-gradient(90deg, var(--amber-dim), var(--amber)); }
.remaining { letter-spacing: 3px; font-size: 13px; }
.remaining .used { color: var(--phos-deep); }

/* ============================== COST ================================== */

.cost { display: flex; flex-direction: column; gap: 4px; }
.cost__row { display: flex; justify-content: space-between; align-items: baseline; }
.cost__label { font-size: 11px; letter-spacing: 1px; color: var(--phos-dim); text-transform: uppercase; }
.cost__val {
  font-family: var(--font-pixel); font-size: 26px; line-height: 1;
  color: var(--phos-bright); text-shadow: var(--glow-soft);
  font-variant-numeric: tabular-nums;
}
.cost__row--cum .cost__val { font-size: 20px; color: var(--amber); text-shadow: var(--glow-amber); }
.cost__tokens { margin-top: 4px; font-size: 11px; color: var(--phos-dim); letter-spacing: .5px; }
/* honest "who answered" tag(s): "via Anthropic" / "via Groq (fallback)" / "cached".
   Same CRT pill as .chip; driven only by real response data, so it's hidden when absent. */
.cost__via { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 6px; }
.via {
  font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor;
}
.via--anthropic { color: var(--phos); }
.via--groq      { color: var(--amber); text-shadow: var(--glow-amber); }
.via--cached    { color: var(--phos-dim); }
/* honest "why it's this cheap" note — real Haiku pricing, no spin */
.cost__note {
  margin: 9px 0 0; padding-top: 7px; border-top: 1px dashed var(--phos-deep);
  font-size: 10px; line-height: 1.55; letter-spacing: .3px; color: var(--phos-dim);
}

/* ============================== DEFENSES ============================== */

.defenses { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.def {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 5px;
  border: 1px solid var(--phos-deep);
}
.def__led {
  width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; position: relative;
}
.def__name { flex: 1; font-size: 12.5px; letter-spacing: .5px; }
/* live lifetime stat from /metrics — subtle, sits before the ACTIVE/PLANNED state */
.def__stat { font-size: 10px; letter-spacing: .3px; font-variant-numeric: tabular-nums; color: var(--phos-dim); }
.def--active .def__stat { color: var(--phos); }
.def--planned .def__stat { color: var(--amber-dim); }
.def__state { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; min-width: 52px; text-align: right; }
/* active = lit green LED */
.def--active { background: rgba(20,70,42,.22); }
.def--active .def__led { background: var(--phos); box-shadow: 0 0 9px var(--phos), 0 0 2px #fff inset; }
.def--active .def__name { color: var(--phos-bright); text-shadow: var(--glow-soft); }
.def--active .def__state { color: var(--phos); }
/* planned = dark, hollow amber ring, honestly different */
.def--planned { background: repeating-linear-gradient(45deg, rgba(255,180,74,.05) 0 6px, transparent 6px 12px); }
.def--planned .def__led { background: transparent; border: 2px solid var(--amber-dim); box-shadow: none; }
.def--planned .def__name { color: var(--phos-dim); }
.def--planned .def__state { color: var(--amber-dim); }

/* ============================ CONCEPT DRAWER ========================== */

.card-toggle {
  position: absolute; right: 16px; bottom: 14px; z-index: 4;
  font: inherit; font-size: 11.5px; letter-spacing: .5px;
  color: var(--screen); background: var(--amber);
  border: none; border-radius: 5px; padding: 7px 12px; cursor: pointer;
  box-shadow: 0 0 14px rgba(255,180,74,.5); transition: transform .08s, filter .15s;
}
.card-toggle:hover { filter: brightness(1.1); }
.card-toggle:active { transform: translateY(1px); }

.drawer {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 7;
  background: linear-gradient(180deg, rgba(6,28,16,.97), rgba(3,18,10,.99));
  border-top: 2px solid var(--amber);
  box-shadow: 0 -18px 50px -10px #000;
  padding: 14px clamp(16px,2vw,26px) 20px;
  transform: translateY(101%);
  /* visibility:hidden when closed removes the off-screen close button from the tab order and the
     SR tree; delayed to the end of the slide so it doesn't cut the animation short. */
  visibility: hidden;
  transition: transform .42s cubic-bezier(.2,.8,.2,1), visibility 0s linear .42s;
  max-height: 80%; overflow-y: auto;   /* long concept cards scroll instead of clipping (mobile) */
  -webkit-overflow-scrolling: touch;
}
.drawer.is-open {
  transform: translateY(0);
  visibility: visible;
  transition: transform .42s cubic-bezier(.2,.8,.2,1), visibility 0s;
}
.drawer__head { display: flex; align-items: center; gap: 12px; }
.drawer__tag {
  font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--screen);
  background: var(--amber); padding: 3px 8px; border-radius: 3px;
}
.drawer__title {
  margin: 0; font-family: var(--font-pixel); font-size: 30px; line-height: 1;
  color: var(--phos-bright); text-shadow: var(--glow-soft); flex: 1; letter-spacing: 1px;
}
.drawer__close {
  font: inherit; font-size: 22px; line-height: 1; color: var(--phos-dim);
  background: none; border: 1px solid var(--phos-deep); border-radius: 5px;
  width: 34px; height: 34px; cursor: pointer;
}
.drawer__close:hover { color: var(--phos-bright); border-color: var(--phos-dim); }
.drawer__body { margin: 12px 0 0; font-size: 13.5px; line-height: 1.62; color: var(--phos); max-width: 78ch; }
.drawer__short {
  margin: 12px 0 0; font-size: 12px; color: var(--phos-dim);
  border-left: 2px solid var(--amber); padding-left: 10px; max-width: 78ch;
}

/* ============================== CONTROLS ============================== */

.controls {
  display: flex; flex-wrap: wrap; gap: 20px 34px;
  padding: 16px 6px 4px; margin-top: 4px;
}
.controls__group { display: flex; flex-direction: column; gap: 8px; }
.controls__label {
  font-size: 10px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--phos-dim);
}
.controls__row { display: flex; flex-wrap: wrap; gap: 8px; }
.switch {
  font: inherit; font-size: 11.5px; letter-spacing: .6px;
  color: var(--phos); background: linear-gradient(180deg, #14110b, #0c0a07);
  border: 1px solid var(--bezel-hi); border-radius: 5px;
  padding: 7px 12px; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 2px 4px rgba(0,0,0,.5);
  transition: color .15s, border-color .15s, box-shadow .15s, transform .07s;
}
.switch:hover { color: var(--phos-bright); border-color: var(--phos-dim); }
.switch:active { transform: translateY(1px); }
.switch.is-active {
  color: var(--screen); background: var(--phos); border-color: var(--phos-bright);
  box-shadow: 0 0 14px rgba(92,243,138,.55);
}
.switch--mood.is-active { background: var(--amber); box-shadow: 0 0 14px rgba(255,180,74,.55); }

/* ============================== FOOTER =============================== */

.credit {
  margin: 14px 0 6px; font-size: 11.5px; color: var(--phos-dim); letter-spacing: .4px;
  text-align: center;
}
.credit code { color: var(--amber); }
.credit a { color: var(--phos); text-decoration: none; border-bottom: 1px dotted var(--phos-dim); margin-left: 6px; }

/* ============================= RESPONSIVE ============================ */
/* Desktop is the design gate; below, the CRT reflows to ONE readable, tappable
   column. Recruiters open this from a LinkedIn link on a phone, so mobile is the
   priority: nothing overflows, and every control is thumb-sized. */

/* Touch devices (any width): a 16px input so iOS doesn't zoom-jank on focus, and
   WCAG-sized (>=42px) tap targets — independent of viewport width. */
@media (pointer: coarse) {
  .input__field { font-size: 16px; }
  .switch, .input__send, .card-toggle { min-height: 42px; }
  .drawer__close { width: 42px; height: 42px; }
}

/* Small tablet / large phone: collapse the two columns into one. */
@media (max-width: 860px) {
  .crt { grid-template-columns: 1fr; min-height: 0; }
  /* Stacked layout: no tall CRT row to fill, so the terminal is content-sized again; the body's
     max-height keeps a long chat scrolling INTERNALLY instead of growing the page (≤560px caps at 190px). */
  .terminal { flex: 1 1 auto; }
  .terminal__body { max-height: 46vh; }
}

/* Phones: reclaim width (thinner nesting), let the marquee wrap, size type down. */
@media (max-width: 560px) {
  body.room { padding: 12px 8px 10px; }
  .bezel { padding: 11px; border-radius: 16px; }
  .bezel::before { left: 9px; top: 9px; } .bezel::after { right: 9px; top: 9px; }
  .crt { padding: 11px; gap: 12px; }

  .marquee { padding: 2px 0 10px; }
  .marquee__title { font-size: 30px; letter-spacing: 1px; }   /* wraps at spaces (nbsp removed) */
  .marquee__sub { font-size: 11.5px; }
  .marquee__mock { display: inline-block; margin: 4px 0 0; }   /* LIVE badge drops under the line */

  .railey-stage { padding: 11px 12px; gap: 12px; }
  .terminal__body { font-size: 13.5px; max-height: 190px; }
  .cost__val { font-size: 22px; }
  .cost__row--cum .cost__val { font-size: 17px; }

  .controls { gap: 14px 20px; padding: 14px 2px 2px; }
  .switch { padding: 9px 13px; }

  .drawer__title { font-size: 26px; }
  .card-toggle { right: 12px; bottom: 12px; }
}

/* Narrowest target (~375px): tighten the hero so the marquee never overflows.
   (The Railey character is a fixed-pixel CSS drawing — its children sit at absolute
   offsets — so it is NOT resized here; at 116px it still fits beside the flexing plate.) */
@media (max-width: 400px) {
  .marquee__title { font-size: 25px; letter-spacing: .5px; }
  .cost__note { font-size: 9.5px; }
  .railey-stage__role { font-size: 10.5px; }
}

/* ===================== FOCUS (keyboard a11y) ======================= */
:focus-visible { outline: 2px solid var(--phos-bright); outline-offset: 2px; border-radius: 3px; }
.input:focus-within { border-color: var(--phos); box-shadow: 0 0 14px rgba(92,243,138,.16) inset; }
.input__field:focus-visible { outline-offset: 3px; }      /* the field clears its own outline:none */
.switch:focus-visible, .input__send:focus-visible,
.card-toggle:focus-visible, .drawer__close:focus-visible {
  outline: 2px solid var(--phos-bright); outline-offset: 2px;
}

/* ====================== TOOLTIPS (Part 6) ========================== */
/* Key controls carry .has-tip + data-tip; a single JS-positioned .tip-bubble (appended to <body>,
   so the CRT panels never clip it) shows the copy on hover, keyboard focus, and mobile tap. .has-tip
   gets a subtle help cursor + focus ring so it reads as "there's more here." */
.has-tip { cursor: help; }
.switch.has-tip { cursor: pointer; }        /* buttons still click; the tip is a hover/focus bonus */
.has-tip:focus-visible { outline: 2px solid var(--phos-bright); outline-offset: 2px; border-radius: var(--r); }
.tip-bubble {
  display: none;
  position: fixed;
  z-index: 200;
  max-width: 240px;
  padding: 8px 11px;
  font-family: var(--font-screen);
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--phos-bright);
  background: rgba(4, 20, 11, 0.97);
  border: 1px solid var(--phos-dim);
  border-radius: var(--r);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .5), 0 0 10px rgba(92, 243, 138, .18);
  pointer-events: none;                     /* the bubble never intercepts clicks/taps */
  white-space: normal;
}

/* ====================== REDUCED MOTION (a11y) ======================= */
/* Honor prefers-reduced-motion for ALL animation AND transition (WCAG 2.3.3):
   the scan/flicker band, Railey's blink/shake/bob/twinkle, expression transitions,
   the drawer slide, meter fills, button presses, and the JS-driven reveals all stop. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    transition-delay: 0ms !important;
  }
}
