:root {
  --bg: #070b12;
  --bg2: #0b1019;
  --panel: #0f1623;
  --panel-2: #0b111c;
  --line: #1b2740;
  --text: #e6edfa;
  --dim: #8190ab;
  --faint: #4a5872;
  --cyan: #38bdf8;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #fb7185;
  --purple: #a78bfa;
  --orange: #fb923c;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --grad: linear-gradient(135deg, #38bdf8, #a78bfa);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #04070c;
  color: var(--text);
  font: 17px/1.5 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 1920x1080 locked stage ----------
   Everything lives inside a fixed 1920x1080 stage. app.js scales it to fit the
   window (transform: scale). Record the browser fullscreen at 1080p and the
   stage is pixel-perfect 1:1; on a laptop it scales down but keeps proportions. */
.stage-wrap {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1400px 700px at 80% -10%, rgba(56,189,248,.06), transparent 60%),
    radial-gradient(1100px 600px at 0% 110%, rgba(167,139,250,.06), transparent 55%),
    #04070c;
}
#stage {
  width: 1920px; height: 1080px; flex: none;
  transform-origin: center center;
  display: flex; flex-direction: column;
  background: var(--bg); overflow: hidden;
  box-shadow: 0 30px 120px rgba(0,0,0,.6);
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 36px; background: rgba(11,16,25,.7); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); flex: none;
}
.brand { display: flex; align-items: center; gap: 16px; text-decoration: none; color: inherit; transition: opacity .15s; }
.brand:hover { opacity: .82; }
.brand .chip { width: 34px; height: 34px; fill: none; stroke: var(--cyan); stroke-width: 1.6; filter: drop-shadow(0 0 9px rgba(56,189,248,.5)); }
.brand .word { font-weight: 800; font-size: 28px; letter-spacing: -.4px; }
.brand .g { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pill { font: 600 14px var(--sans); color: var(--dim); border: 1px solid var(--line); padding: 6px 14px; border-radius: 999px; letter-spacing: .3px; }

.controls { display: flex; align-items: center; gap: 14px; }
.controls select, .controls button {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 11px; padding: 12px 18px; font: 600 16px var(--sans); cursor: pointer;
  transition: border-color .15s, transform .05s;
}
.controls select { max-width: 360px; }
.controls select:hover, .controls button:hover { border-color: var(--cyan); }
.controls button:active { transform: translateY(1px); }
.controls button.primary { background: var(--grad); color: #06121f; border: none; font-weight: 800; box-shadow: 0 5px 22px rgba(56,189,248,.25); }
#liveBtn.on { border-color: var(--green); color: var(--green); box-shadow: 0 0 16px rgba(52,211,153,.3); }
#restartBtn { width: 52px; padding: 12px 0; font-size: 18px; }
.speed { color: var(--dim); font-size: 15px; display: flex; align-items: center; gap: 9px; }
.speed select { padding: 9px 12px; font-size: 14px; }

/* ---------- progress ---------- */
.progress-track { height: 4px; background: var(--line); flex: none; }
.progress-fill { height: 100%; width: 0; background: var(--grad); transition: width .4s ease; box-shadow: 0 0 12px rgba(56,189,248,.6); }

/* ---------- hook ---------- */
.hook {
  padding: 18px 36px; color: var(--text); font-size: 21px; font-style: italic;
  border-bottom: 1px solid var(--line); background: var(--bg2); flex: none;
  display: flex; align-items: center; min-height: 30px;
}
.hook::before { content: "“"; color: var(--cyan); font-size: 36px; margin-right: 8px; font-style: normal; line-height: 0; }
.hook #hook { flex: 1; }
.proof { display: flex; gap: 8px; margin-left: 16px; flex: none; }
.proof-chip { font: 700 12px var(--mono); padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); font-style: normal; white-space: nowrap; }
.proof-chip.formal { color: var(--green); border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.08); }
.proof-chip.simulation { color: var(--cyan); border-color: rgba(56,189,248,.4); background: rgba(56,189,248,.08); }
.proof-chip.structural { color: var(--purple); border-color: rgba(167,139,250,.4); background: rgba(167,139,250,.08); }

/* ---------- panels ---------- */
.panels { flex: 1; display: grid; grid-template-columns: 1fr 1.18fr 1fr; gap: 1px; background: var(--line); min-height: 0; }
.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.panel-head {
  display: flex; align-items: center; gap: 11px; padding: 15px 22px; overflow: hidden;
  border-bottom: 1px solid var(--line); color: var(--dim); font: 600 16px var(--mono); flex: none;
}
.panel-head span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font: 700 12px var(--mono); padding: 4px 10px; border-radius: 7px; letter-spacing: .6px; }
.tag.spec { background: rgba(56,189,248,.14); color: var(--cyan); }
.tag.rtl  { background: rgba(167,139,250,.14); color: var(--purple); }
.tag.agent{ background: rgba(52,211,153,.14); color: var(--green); }
.tok { margin-left: auto; font: 500 14px var(--mono); color: var(--faint); flex: none; white-space: nowrap; }
.badge {
  margin-left: auto; font: 700 12.5px var(--mono); color: #2a0a10; background: var(--red);
  padding: 5px 12px; border-radius: 7px; letter-spacing: .5px; opacity: 0; transform: scale(.7);
  transition: opacity .25s, transform .25s; box-shadow: 0 0 16px rgba(251,113,133,.6);
}
.badge.show { opacity: 1; transform: scale(1); animation: pulse 1.1s ease-in-out 2; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ---------- code panels ---------- */
.code { padding: 14px 0; overflow: auto; flex: 1; font: 500 16px/1.7 var(--mono); }
.code.spotlight .ln:not(.hl):not(.spec-hl):not(.bug) { opacity: .3; filter: saturate(.5); }
.ln { display: flex; padding: 1px 22px; white-space: pre; transition: background .25s, opacity .25s; border-left: 3px solid transparent; }
.ln .gutter { color: var(--faint); width: 36px; text-align: right; margin-right: 18px; user-select: none; flex: none; }
.ln .src { flex: 1; }
.ln.hl { background: rgba(251,191,36,.13); border-left-color: var(--yellow); }
.ln.spec-hl { background: rgba(56,189,248,.12); border-left-color: var(--cyan); }
.ln.bug { background: rgba(251,113,133,.17); border-left-color: var(--red); }

/* SystemVerilog token colors */
.t-kw { color: #c4b5fd; } .t-type { color: var(--cyan); } .t-com { color: var(--faint); font-style: italic; }
.t-num { color: var(--orange); } .t-op { color: #94a3b8; }
/* spec markdown-ish */
.sp-h { color: var(--text); font-weight: 700; }
.sp-q { color: #cbd5e1; } .ln.sp-quote { border-left: 3px solid var(--faint); }
.sp-code { color: var(--cyan); font-family: var(--mono); }
.sp-b { color: #fff; font-weight: 700; }

/* ---------- agent transcript ---------- */
.transcript { padding: 16px 22px; overflow: auto; flex: 1; font-size: 16.5px; line-height: 1.6; overflow-wrap: anywhere; }
.tline { margin-bottom: 15px; display: flex; gap: 11px; align-items: flex-start; opacity: 0; transform: translateY(5px); animation: rise .28s ease forwards; }
.tline .txt { min-width: 0; overflow-wrap: anywhere; }
@keyframes rise { to { opacity: 1; transform: none; } }
.tline .k {
  font: 700 11px var(--mono); padding: 3px 8px; border-radius: 6px; margin-top: 3px;
  background: var(--panel-2); color: var(--dim); flex: none; letter-spacing: .4px;
}
.tline .txt { flex: 1; }
.tline.read_spec .k { color: var(--cyan); background: rgba(56,189,248,.12); }
.tline.scan_rtl .k { color: var(--purple); background: rgba(167,139,250,.12); }
.tline.locate { color: var(--yellow); }
.tline.locate .k { color: #1c1403; background: var(--yellow); }
.tline.generate_sva .k { color: var(--green); background: rgba(52,211,153,.12); }
.tline.bug_card, .tline.traceability { color: var(--green); }
.tline.bug_card .k, .tline.traceability .k { color: #052015; background: var(--green); }
.cursor { display: inline-block; width: 8px; height: 18px; background: var(--cyan); margin-left: 3px; vertical-align: -3px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- artifacts ---------- */
.artifacts { border-top: 1px solid var(--line); background: var(--bg2); height: 320px; flex: none; overflow: auto; }
.artifact-rail { display: flex; gap: 20px; padding: 20px 36px; align-items: stretch; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px; min-width: 320px; max-width: 540px; flex: 1;
  opacity: 0; transform: translateY(8px); animation: rise .35s ease forwards;
}
.card h4 { margin: 0 0 12px; font: 700 13px var(--mono); text-transform: uppercase; letter-spacing: .7px; color: var(--dim); display: flex; align-items: center; gap: 8px; }
.card pre { margin: 0; font: 500 15px/1.55 var(--mono); color: var(--green); white-space: pre-wrap; }
.card .fail { color: var(--red); font: 700 15px var(--mono); margin-top: 9px; display: flex; gap: 8px; align-items: center; }
.card .pass { color: var(--green); font: 700 15px var(--mono); margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.card .fail::before { content: "✕"; } .card .pass::before { content: "✓"; }
.card.bug { border-color: rgba(251,113,133,.45); box-shadow: 0 0 30px rgba(251,113,133,.12); }
.card.bug h4 { color: var(--red); }
.card.bug h4::before { content: "●"; }
.card .row { margin: 6px 0; font-size: 15.5px; line-height: 1.5; }
.card .row .kv { color: var(--dim); font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .4px; margin-right: 7px; }
.chain { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font: 500 14px var(--mono); }
.chain .node { background: var(--panel-2); border: 1px solid var(--line); padding: 6px 11px; border-radius: 8px; color: var(--text); }
.chain .arr { color: var(--faint); }

/* ---------- statusbar ---------- */
.statusbar {
  display: flex; justify-content: space-between; align-items: center; flex: none;
  padding: 13px 36px; border-top: 1px solid var(--line); background: var(--panel);
  color: var(--dim); font: 500 15px var(--mono);
}
.statusbar a { color: var(--cyan); text-decoration: none; }
.statusbar .site { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; font-size: 17px; }

/* ---------- intro / hook title card ---------- */
.intro {
  position: absolute; inset: 0; background: rgba(7,11,18,.93); backdrop-filter: blur(16px);
  display: flex; align-items: center; justify-content: center; z-index: 50; transition: opacity .4s;
}
.intro.hide { opacity: 0; pointer-events: none; }
.landing { max-width: 1280px; width: 92%; text-align: center; padding: 40px; animation: rise .5s ease; }
.intro-brand { display: flex; align-items: center; justify-content: center; gap: 16px; font: 800 44px var(--sans); letter-spacing: -.5px; margin-bottom: 18px; }
.intro-brand .chip { width: 48px; height: 48px; fill: none; stroke: var(--cyan); stroke-width: 1.6; filter: drop-shadow(0 0 14px rgba(56,189,248,.6)); }
.intro-brand .g { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.landing .tagline { font-size: 22px; line-height: 1.5; color: var(--dim); margin: 0 auto 40px; max-width: 760px; }

.bug-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.bug-card-btn {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 24px; text-align: left; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; gap: 12px; transition: border-color .15s, transform .12s, box-shadow .15s;
}
.bug-card-btn:hover { border-color: var(--cyan); transform: translateY(-4px); box-shadow: 0 14px 40px rgba(0,0,0,.4); }
.bc-title { font: 700 19px var(--sans); line-height: 1.3; letter-spacing: -.2px; }
.bc-tag { font-size: 15px; color: var(--dim); line-height: 1.45; flex: 1; }
.bc-methods { display: flex; flex-wrap: wrap; gap: 7px; }
.bc-run { margin-top: 6px; font: 800 14px var(--sans); color: #06121f;
  background: var(--grad); padding: 10px 0; border-radius: 10px; text-align: center; }
.intro-foot { margin-top: 38px; font: 600 15px var(--mono); color: var(--faint); letter-spacing: .5px; }

/* scrollbars */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   MOBILE / NARROW (<= 900px) — responsive stacked layout.
   Desktop 1920x1080 recording mode above is untouched.
   ============================================================ */
@media (max-width: 900px) {
  html, body { height: auto; overflow: auto; -webkit-text-size-adjust: 100%; }
  .stage-wrap { position: static; display: block; min-height: 100vh; padding: 0; }
  #stage {
    width: 100%; height: auto; min-height: 100vh;
    transform: none !important; box-shadow: none; display: flex; flex-direction: column;
  }

  /* topbar wraps; drop the pill to save room */
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 14px; position: sticky; top: 0; z-index: 6; }
  .brand .word { font-size: 20px; }
  .brand .chip { width: 26px; height: 26px; }
  .pill { display: none; }
  .controls { width: 100%; flex-wrap: wrap; gap: 8px; }
  .controls select, .controls button { font-size: 13px; padding: 10px 12px; }
  .controls #bugSelect { flex: 1 1 100%; max-width: none; order: -1; }
  .speed { font-size: 12px; }

  .hook { font-size: 15px; line-height: 1.45; padding: 12px 14px; flex-wrap: wrap; }
  .hook::before { font-size: 26px; }
  .proof { margin-left: 0; margin-top: 8px; flex-wrap: wrap; }

  /* stack the three panels; each scrolls internally so the page doesn't jump */
  .panels { display: flex; flex-direction: column; gap: 1px; }
  .panel { flex: none; min-width: 0; }
  .panel-head { padding: 11px 14px; font-size: 13px; }
  .code { height: 40vh; flex: none; font-size: 13px; padding: 10px 0; }
  .code.spotlight .ln:not(.hl):not(.spec-hl):not(.bug) { opacity: 1; filter: none; } /* no dimming on mobile */
  .ln { padding: 1px 14px; }
  .ln .gutter { width: 26px; margin-right: 10px; }
  .transcript { height: 40vh; flex: none; font-size: 14px; padding: 12px 14px; }

  /* artifacts stack full-width */
  .artifacts { height: auto; max-height: none; }
  .artifact-rail { flex-direction: column; padding: 14px; gap: 12px; }
  .card { min-width: 0; max-width: none; }

  .statusbar { flex-wrap: wrap; gap: 6px 14px; padding: 11px 14px; font-size: 11px; }

  /* landing / bug picker: single column, scrollable */
  .intro { position: fixed; overflow-y: auto; align-items: flex-start; }
  .landing { width: 100%; padding: 28px 16px 40px; }
  .intro-brand { font-size: 30px; gap: 12px; margin-bottom: 14px; }
  .intro-brand .chip { width: 32px; height: 32px; }
  .landing .tagline { font-size: 17px; margin-bottom: 26px; }
  .bug-cards { grid-template-columns: 1fr; gap: 14px; }
  .bug-card-btn { padding: 18px 16px; }
  .bc-title { font-size: 17px; }
}
