/* Digits everywhere in sans: Inter, subset to 0-9 only and picked up through unicode-range */
@font-face { font-family: "Reforge Digits"; src: url("assets/reforge-digits.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0030-0039; size-adjust: 90%; }

/* ==========================================================================
   Reforge — UI
   Black, warm off-white ink, a single molten "ember" accent.
   Headings: Inter (sans) · Text: Newsreader · Code: JetBrains Mono
   ========================================================================== */
:root {
  --bg: #050505;
  --bg-2: #0b0b0a;
  --surface: #111110;
  --surface-2: #171715;
  --line: rgba(236, 233, 224, .12);
  --line-2: rgba(236, 233, 224, .22);
  --ink: #ecebe4;
  --ink-2: #d2d0c7;
  --muted: #a3a198;
  --ember: #ff6b2c;
  --ember-2: #ffb05a;
  --ember-soft: rgba(255, 107, 44, .14);
  --ok: #7fd49a;
  --bad: #ff7a6b;
  --warn: #f2c46b;
  --t-lightning: #9fd3ff;
  --t-super: #c9b0ff;
  --t-ultra: #ff8a4c;
  --display: "Reforge Digits", "Inter", "Helvetica Neue", Arial, system-ui, sans-serif;
  --serif: "Reforge Digits", "Newsreader", "Iowan Old Style", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 18px;
  --ease: cubic-bezier(.2, .7, .1, 1);
  --top: 68px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-variant-numeric: tabular-nums;
  letter-spacing: .012em;
  word-spacing: .04em;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.5;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
em { font-style: italic; }
::selection { background: var(--ember); color: #000; }

.grain {
  position: fixed; inset: -50%; z-index: 100; pointer-events: none; opacity: .025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.eyebrow {
  margin: 0 0 10px; font-size: 13.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
  font-weight: 450;
}
.ember-text { color: var(--ember-2); }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto; height: var(--top); z-index: 40;
  display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
  background: rgba(5,5,5,.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 6px 0;
  font-family: var(--display); font-size: 21px; font-weight: 600; letter-spacing: .06em;
}
.brand-mark { width: 24px; height: 24px; color: var(--ink); }
.topnav { display: flex; align-items: center; gap: 10px; }
.nav-btn {
  font-size: 15px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line-2);
  background: rgba(255,255,255,.02); text-decoration: none; transition: background .25s, border-color .25s, color .25s;
}
.nav-btn:hover { background: rgba(255,255,255,.07); border-color: rgba(236,233,224,.3); }
.nav-btn--solid { background: var(--ink); color: #0a0a0a; border-color: var(--ink); }
.nav-btn--solid:hover { background: #fff; color: #000; }

/* ---------- Views ---------- */
#app { position: relative; height: 100%; }
.view {
  position: absolute; inset: 0; overflow: hidden;
  opacity: 0; visibility: hidden; transform: translateY(14px) scale(.995); filter: blur(6px);
  transition: opacity .7s var(--ease), transform .8s var(--ease), filter .7s var(--ease), visibility 0s .8s;
}
.view.is-active {
  opacity: 1; visibility: visible; transform: none; filter: none;
  transition: opacity .7s var(--ease) .1s, transform .8s var(--ease) .1s, filter .7s var(--ease) .1s, visibility 0s;
}

/* ---------- Landing ---------- */
.view-landing { display: flex; flex-direction: column; align-items: center; padding: var(--top) 20px 48px; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.view-landing > * { flex-shrink: 0; }
.landing-main { width: 100%; min-height: calc(100vh - var(--top) - 150px); display: grid; place-items: center; padding: 24px 0 12px; }
.sparks { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.forge-glow {
  position: fixed; left: 50%; bottom: -46vh; width: 140vw; height: 80vh; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(255,107,44,.20), rgba(255,107,44,.06) 45%, transparent 75%);
  pointer-events: none; animation: breathe 7s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .7; transform: translateX(-50%) scale(1.04); } }

.hero { position: relative; width: min(820px, 100%); text-align: center; z-index: 1; }
.wordmark {
  font-family: var(--display); font-weight: 700; margin: 0; line-height: 1.16; padding: 0 .04em .08em;
  font-size: clamp(60px, 10vw, 136px); letter-spacing: .03em;
  background: linear-gradient(180deg, #fff 0%, #e9e6dc 55%, #a8a49a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { margin: 18px auto 34px; max-width: 560px; color: var(--ink-2); font-size: 19px; font-weight: 350; }
.tagline em { font-family: var(--serif); font-style: italic; font-size: 1.08em; color: var(--ember-2); }

.reveal { opacity: 0; transform: translateY(16px); animation: rise .9s var(--ease) forwards; animation-delay: calc(var(--d) * 110ms + 150ms); }
@keyframes rise { to { opacity: 1; transform: none; } }

.hints { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin-top: 18px; }
.hints-label { font-size: 13px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; margin-right: 4px; }
.chip {
  border: 1px solid var(--line); background: rgba(255,255,255,.025); color: var(--ink-2);
  border-radius: 999px; padding: 6px 14px; font-size: 14.5px; transition: all .25s;
}
.chip:hover { color: var(--ink); border-color: var(--line-2); background: rgba(255,255,255,.06); }

.landing-steps {
  position: relative; z-index: 1; flex-wrap: wrap; justify-content: center; margin: 0 0 22px !important;
  display: flex; gap: 12px 30px; list-style: none; margin: 0; padding: 0; color: var(--ink-2); font-size: 15px; white-space: nowrap;
}
.landing-steps li span { font-family: var(--mono); font-size: 12px; color: var(--ember-2); margin-right: 8px; }

.drop-veil {
  position: fixed; inset: 14px; border: 1.5px dashed var(--ember); border-radius: 26px; z-index: 5;
  display: grid; place-items: center; background: rgba(5,5,5,.82); backdrop-filter: blur(6px);
  font-family: var(--display); font-size: 32px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .25s;
}
.drop-veil em { color: var(--ember-2); }
.drop-veil.on { opacity: 1; }

/* ---------- Composer ---------- */
.composer {
  position: relative; text-align: left; border-radius: 22px; padding: 14px 14px 10px 18px;
  background: linear-gradient(180deg, rgba(23,23,21,.92), rgba(14,14,13,.92));
  border: 1px solid var(--line-2);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.9), 0 0 0 1px rgba(0,0,0,.6) inset;
  transition: border-color .3s, box-shadow .3s;
}
.composer::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: conic-gradient(from var(--a, 0deg), transparent 0 70%, var(--ember) 80%, var(--ember-2) 85%, transparent 92%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity .4s;
}
.composer:focus-within { border-color: rgba(236,233,224,.26); box-shadow: 0 30px 90px -30px rgba(255,107,44,.25), 0 0 0 1px rgba(0,0,0,.6) inset; }
.composer:focus-within::before { opacity: 1; animation: orbit 5s linear infinite; }
@property --a { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes orbit { to { --a: 360deg; } }
.composer.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.composer-input {
  width: 100%; border: 0; outline: 0; resize: none; background: transparent; font-size: 18px; line-height: 1.5;
  min-height: 30px; max-height: 240px; padding: 6px 0 10px; color: var(--ink);
}
.composer-input::placeholder { color: #94928a; font-style: italic; }
.composer-input.is-code { font-family: var(--mono); font-size: 13.5px; }
.composer-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.composer-tools, .composer-right { display: flex; align-items: center; gap: 8px; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 12px; font-size: 14.5px;
  border: 1px solid var(--line); background: rgba(255,255,255,.03); color: var(--ink-2); cursor: pointer; transition: all .2s;
}
.tool-btn svg { width: 16px; height: 16px; }
.tool-btn:hover { color: var(--ink); border-color: var(--line-2); background: rgba(255,255,255,.07); }
.composer-hint { font-size: 13.5px; color: var(--muted); }
.send-btn {
  width: 42px; height: 42px; border-radius: 13px; border: 0; display: grid; place-items: center;
  background: var(--ink); color: #000; transition: transform .2s, background .2s, box-shadow .3s;
}
.send-btn svg { width: 20px; height: 20px; }
.send-btn:hover { transform: translateY(-1px); background: #fff; box-shadow: 0 8px 30px -6px rgba(255,107,44,.55); }
.send-btn:disabled { opacity: .5; cursor: progress; }
.composer-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.composer-chips:not(:empty) { margin-bottom: 8px; }
.in-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 10px; border-radius: 11px; font-size: 14px;
  background: var(--ember-soft); border: 1px solid rgba(255,107,44,.35); color: #ffd7bf; animation: rise .35s var(--ease) both;
}
.in-chip b { font-weight: 500; }
.in-chip small { color: #c8957a; }
.in-chip button { border: 0; background: rgba(0,0,0,.25); width: 20px; height: 20px; border-radius: 6px; font-size: 11px; line-height: 1; }
.composer.compact { border-radius: 18px; padding: 10px 10px 8px 14px; }
.composer.compact .composer-input { font-size: 16.5px; }
.composer.compact .composer-hint { display: none; }

/* ---------- Trace ---------- */
.view-trace { padding: calc(var(--top) + 18px) 28px 56px; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.trace-wrap { transition: filter .8s var(--ease), opacity .8s var(--ease), transform .8s var(--ease); display: flex; flex-direction: column; max-width: 1360px; margin: 0 auto; }
.trace-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.trace-title { font-family: var(--display); font-weight: 600; font-size: clamp(28px, 3.4vw, 44px); margin: 0; line-height: 1.15; }
.trace-title em { color: var(--ember-2); }
.trace-mode { margin-left: 10px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line-2); letter-spacing: .1em; }
.trace-mode:empty { display: none; }
.clock-box { text-align: right; }
.clock { font-family: var(--mono); font-size: 30px; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.clock-sub { font-size: 13.5px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }

.rail { position: relative; margin: 28px 0 22px; }
.rail-track { position: absolute; left: calc(100% / 12); right: calc(100% / 12); top: 17px; height: 2px; background: var(--line); border-radius: 2px; }
.rail-fill {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 2px;
  background: linear-gradient(90deg, rgba(255,107,44,.2), var(--ember) 70%, var(--ember-2));
  box-shadow: 0 0 18px rgba(255,107,44,.6); transition: width 1.1s var(--ease);
}
.rail-spark {
  position: absolute; top: 50%; left: 0; width: 120px; height: 2px; transform: translateY(-50%);
  background: linear-gradient(90deg, transparent, #fff, transparent); opacity: .0; filter: blur(.4px);
}
.rail.running .rail-spark { opacity: .9; animation: zip 2.4s linear infinite; }
@keyframes zip { from { left: -10%; } to { left: 100%; } }
.rail-nodes { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); list-style: none; margin: 0; padding: 0; }
.rail-node { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.rail-dot {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-family: var(--mono); font-size: 12px;
  background: var(--bg); border: 1px solid var(--line-2); color: var(--muted); position: relative; transition: all .5s var(--ease);
}
.rail-node .rail-label { font-size: 16px; color: var(--muted); transition: color .4s; line-height: 1.2; }
.rail-node .rail-time { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); min-height: 14px; }
.rail-node.running .rail-dot { border-color: var(--ember); color: var(--ember-2); box-shadow: 0 0 0 6px var(--ember-soft), 0 0 30px rgba(255,107,44,.5); }
.rail-node.running .rail-dot::after {
  content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 1px solid var(--ember); animation: ping 1.6s var(--ease) infinite;
}
@keyframes ping { from { transform: scale(.8); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }
.rail-node.running .rail-label, .rail-node.done .rail-label { color: var(--ink); }
.rail-node.done .rail-dot { background: var(--ember); border-color: var(--ember); color: #160800; }
.rail-node.failed .rail-dot { background: var(--bad); border-color: var(--bad); color: #200; }

.trace-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr); gap: 22px; align-items: start; }
.stage-stack { padding: 2px 2px 20px; }
.stage-card {
  position: relative; border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px 16px 58px; margin-bottom: 12px;
  background: linear-gradient(180deg, var(--surface), var(--bg-2)); animation: cardIn .6s var(--ease) both; transition: border-color .4s, opacity .4s;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.985); } }
.stage-card::before { content: ""; position: absolute; left: 31px; top: 54px; bottom: -14px; width: 1px; background: var(--line); }
.stage-card:last-child::before { display: none; }
.stage-card.running { border-color: rgba(255,107,44,.45); box-shadow: 0 20px 60px -30px rgba(255,107,44,.45); }
.stage-card.done { opacity: 1; }
.stage-card.failed { border-color: rgba(255,122,107,.6); }
.stage-num {
  position: absolute; left: 16px; top: 18px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-2); color: var(--muted);
}
.stage-card.running .stage-num { border-color: var(--ember); color: var(--ember-2); }
.stage-card.done .stage-num { background: var(--ember); border-color: var(--ember); color: #160800; }
.stage-card.done .stage-num::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; background: var(--ember); border-radius: 50%; font-size: 13px; font-family: var(--serif); }
.stage-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.stage-name { font-family: var(--display); font-size: 21px; line-height: 1.25; margin: 0; font-weight: 600; }
.stage-module { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.stage-elapsed { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.stage-desc { margin: 4px 0 12px; color: var(--ink-2); font-size: 15.5px; }
.subs { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.sub { display: flex; align-items: center; gap: 10px; font-size: 16px; color: var(--muted); transition: color .3s; }
.sub i { width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid #3b3a36; flex: none; position: relative; transition: all .3s; }
.sub.active { color: var(--ink); }
.sub.active i { border-color: var(--ember); border-top-color: transparent; animation: spin .8s linear infinite; }
.sub.done { color: var(--ink-2); }
.sub.done i { border-color: var(--ok); background: var(--ok); }
.sub.done i::after { content: ""; position: absolute; left: 4px; top: 1.5px; width: 3px; height: 6px; border: solid #06210f; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
@keyframes spin { to { transform: rotate(360deg); } }
.shimmer { height: 2px; margin-top: 14px; border-radius: 2px; overflow: hidden; background: var(--line); }
.shimmer::after { content: ""; display: block; height: 100%; width: 40%; background: linear-gradient(90deg, transparent, var(--ember), transparent); animation: sweep 1.3s ease-in-out infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.stage-card:not(.running) .shimmer { display: none; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 14px; }
.fact { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: rgba(255,255,255,.015); animation: rise .5s var(--ease) both; }
.fact small { display: block; font-size: 13px; color: var(--muted); letter-spacing: .04em; }
.fact b { font-weight: 500; font-size: 16px; word-break: break-word; }
.err-box { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: rgba(255,122,107,.08); border: 1px solid rgba(255,122,107,.35); font-family: var(--mono); font-size: 12.5px; color: #ffc1b8; white-space: pre-wrap; }
.err-actions { display: flex; gap: 8px; margin-top: 12px; }

.trace-side { display: flex; flex-direction: column; gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: var(--r); background: linear-gradient(180deg, var(--surface), var(--bg-2)); padding: 16px 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.panel-head span { font-family: var(--display); font-size: 18px; font-weight: 600; }
.panel-head small { color: var(--muted); font-size: 13.5px; }
.tier { display: grid; grid-template-columns: 200px 1fr 34px; align-items: center; gap: 12px; padding: 7px 0; }
.tier-name b { display: block; font-weight: 500; font-size: 15.5px; }
.tier-name small { color: var(--muted); font-size: 13px; }
.tier-bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; position: relative; }
.tier-bar i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; transition: width 1.2s var(--ease); }
.tier[data-tier="lightning"] .tier-bar i { background: var(--t-lightning); }
.tier[data-tier="super"] .tier-bar i { background: var(--t-super); }
.tier[data-tier="ultra"] .tier-bar i { background: var(--t-ultra); }
.tier.pulse .tier-bar i { width: 30% !important; animation: slide 1.1s ease-in-out infinite alternate; }
@keyframes slide { from { transform: translateX(-30%); } to { transform: translateX(260%); } }
.tier-count { font-family: var(--mono); font-size: 14px; text-align: right; }
.cost-meter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.cost-meter small { display: block; font-size: 13px; color: var(--muted); }
.cost-meter b { font-family: var(--mono); font-weight: 500; font-size: 15px; }

.console { height: 420px; display: flex; flex-direction: column; overflow: hidden; }
.console-body { flex: 1; overflow-y: auto; font-family: var(--mono); font-size: 13px; line-height: 1.7; color: #d6d4cb; }
.log-line { display: flex; gap: 10px; animation: logIn .3s ease both; }
@keyframes logIn { from { opacity: 0; transform: translateX(-4px); } }
.log-line time { color: #8f8d86; flex: none; }
.log-line span { word-break: break-word; }
.log-line.stage span { color: var(--ember-2); }
.log-line.ok span { color: var(--ok); }
.log-line.err span { color: var(--bad); }

.finale { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: 0; z-index: 6; background: radial-gradient(circle at 50% 55%, rgba(255,107,44,.22), rgba(5,5,5,.985) 60%); transition: opacity .6s var(--ease); }
.finale.on { opacity: 1; }
.view-trace.finishing .trace-wrap { filter: blur(10px); opacity: .25; transform: scale(.98); }
.finale-inner { text-align: center; transform: scale(.94); transition: transform 1.4s var(--ease); }
.finale.on .finale-inner { transform: none; }
.finale-word { font-family: var(--display); font-weight: 700; font-size: clamp(70px, 11vw, 160px); line-height: 1.16; padding: 0 .04em .1em; background: linear-gradient(180deg, #fff, var(--ember-2) 70%, var(--ember)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.finale-sub { color: var(--ink-2); font-size: 19px; margin-top: 12px; }

/* ---------- Results ---------- */
.view-results { padding: var(--top) 24px 22px; }
.results { height: 100%; max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 22px; }
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-scroll { flex: 1; overflow-y: auto; }
.chat-inner { max-width: 820px; margin: 0 auto; padding: 18px 8px 30px; }
.chat-compose { max-width: 820px; width: 100%; margin: 0 auto; padding-top: 8px; }
.msg { display: flex; gap: 14px; margin: 0 0 26px; animation: rise .6s var(--ease) both; }
.msg-av { width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center; font-family: var(--display); font-size: 18px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px 18px 4px 18px; padding: 10px 16px; max-width: 78%; }
.msg.user pre { margin: 0; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; max-height: 160px; overflow: hidden; color: var(--ink-2); }
.msg.bot .msg-av { background: var(--ink); color: #000; }
.msg.bot .msg-av svg { width: 18px; height: 18px; }
.msg.bot .body { flex: 1; min-width: 0; font-size: 17.5px; line-height: 1.6; }
.msg.bot .body p { margin: 0 0 12px; }
.msg.bot .body h4 { font-family: var(--display); font-weight: 600; font-size: 24px; margin: 0 0 6px; line-height: 1.1; }
.msg.bot .body ul { margin: 0 0 12px; padding-left: 20px; }
.msg.bot .body li { margin-bottom: 4px; }
.msg.bot code { font-family: var(--mono); font-size: .8em; padding: 1px 6px; border-radius: 6px; background: rgba(255,255,255,.06); border: 1px solid var(--line); }
.typing { display: inline-flex; gap: 4px; padding: 10px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .2; } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0; }
.kpi { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: linear-gradient(180deg, var(--surface), var(--bg-2)); }
.kpi small { display: block; color: var(--muted); font-size: 13.5px; }
.kpi b { display: block; font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1.25; margin-top: 2px; }
.kpi span { font-size: 14px; color: var(--ink-2); }
.timeline { margin: 6px 0 14px; }
.tl-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; gap: 2px; }
.tl-bar i { display: block; height: 100%; background: var(--ember); opacity: .35; transition: opacity .2s; }
.tl-bar i:nth-child(even) { opacity: .6; }
.tl-bar i:hover { opacity: 1; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 14px; color: var(--muted); }
.tl-legend b { color: var(--ink); font-weight: 500; font-family: var(--mono); font-size: 13px; }
.suggests { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.verdict { font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
.verdict.pass { color: var(--ok); border-color: rgba(127,212,154,.4); background: rgba(127,212,154,.07); }
.verdict.warn { color: var(--warn); border-color: rgba(242,196,107,.4); background: rgba(242,196,107,.07); }
.verdict.fail { color: var(--bad); border-color: rgba(255,122,107,.4); background: rgba(255,122,107,.07); }

.outputs { border: 1px solid var(--line); border-radius: 22px; padding: 20px; background: linear-gradient(180deg, var(--surface), var(--bg-2)); display: flex; flex-direction: column; min-height: 0; overflow-y: auto; animation: slideIn .9s var(--ease) both .2s; }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } }
.outputs-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.outputs-head h3 { font-family: var(--display); font-weight: 600; font-size: 22px; margin: 0; line-height: 1.25; overflow-wrap: anywhere; }
.out-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 6px; }
.out-meta span { font-size: 14px; color: var(--ink-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; }
.out-group { margin-top: 18px; }
.out-label { font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.file-item {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 11px 12px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(255,255,255,.02); transition: all .25s var(--ease); animation: rise .5s var(--ease) both;
}
.file-item:hover { border-color: rgba(255,107,44,.45); background: var(--ember-soft); transform: translateX(-3px); }
.file-ico { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; font-family: var(--mono); font-size: 11px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--t-lightning); }
.file-ico.pdf { color: var(--ember-2); }
.file-ico.patch { color: var(--t-super); }
.file-main { flex: 1; min-width: 0; }
.file-main b { display: block; font-weight: 500; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-main small { color: var(--muted); font-size: 13.5px; display: block; overflow-wrap: anywhere; line-height: 1.35; }
.delta { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.delta .a { color: var(--ok); } .delta .r { color: var(--bad); margin-left: 6px; }
.dl-all { margin-top: 22px; align-self: stretch; padding: 11px 14px; }
.dl-all:disabled { opacity: .6; cursor: progress; }
.new-run { align-self: stretch; margin-top: 10px; padding: 10px 14px; }
.file-list > li { min-width: 0; }
.file-row { display: flex; gap: 8px; align-items: stretch; min-width: 0; animation: rise .5s var(--ease) both; }
.file-row .file-item { flex: 1; width: auto; min-width: 0; animation: none; }
.dl-btn { flex: none; width: 48px; border-radius: 14px; border: 1px solid var(--line-2); background: rgba(255,255,255,.03); color: var(--ink); display: grid; place-items: center; transition: all .2s; }
.dl-btn svg { width: 20px; height: 20px; }
.dl-btn:hover { background: var(--ink); color: #000; border-color: var(--ink); }
.empty-note { color: var(--muted); font-size: 14.5px; font-style: italic; }

/* ---------- Buttons ---------- */
.ghost-btn, .solid-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 11px; font-size: 14.5px;
  text-decoration: none; transition: all .2s; white-space: nowrap;
}
.ghost-btn { border: 1px solid var(--line-2); background: rgba(255,255,255,.02); color: var(--ink); }
.ghost-btn:hover { background: rgba(255,255,255,.08); }
.solid-btn { border: 0; background: var(--ink); color: #000; font-weight: 500; }
.solid-btn:hover { background: #fff; }
.icon-btn { width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line-2); background: rgba(255,255,255,.02); display: grid; place-items: center; font-size: 13px; }
.icon-btn:hover { background: rgba(255,255,255,.08); }

/* ---------- Overlays (sheet / drawer / modal) ---------- */
.sheet, .drawer, .modal { position: fixed; inset: 0; z-index: 60; visibility: hidden; pointer-events: none; }
.sheet.open, .drawer.open, .modal.open { visibility: visible; pointer-events: auto; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); opacity: 0; transition: opacity .4s; }
.open .sheet-scrim { opacity: 1; }
.sheet-panel {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(1040px, calc(100vw - 24px)); display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 22px; overflow: hidden;
  transform: translateX(105%); transition: transform .6s var(--ease); box-shadow: -40px 0 120px -40px #000;
}
.sheet.open .sheet-panel { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 16px; padding: 14px 16px 14px 18px; border-bottom: 1px solid var(--line); }
.sheet-title { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.sheet-title h4 { margin: 0; font-weight: 500; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-title small { color: var(--muted); font-size: 14px; }
.sheet-tabs { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.sheet-tabs:empty { display: none; }
.sheet-tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; font-size: 14px; color: var(--muted); }
.sheet-tabs button.on { background: var(--surface-2); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }
.sheet-actions { display: flex; gap: 8px; }
.sheet-body { flex: 1; overflow: auto; background: #070707; }
.sheet-body iframe { width: 100%; height: 100%; border: 0; background: #222; }

.code { margin: 0; font-family: var(--mono); font-size: 13.5px; color: #e6e4dc; line-height: 1.7; counter-reset: ln; padding: 14px 0 40px; min-width: max-content; }
.code .ln { display: flex; padding-right: 24px; }
.code .ln::before { counter-increment: ln; content: counter(ln); width: 56px; flex: none; text-align: right; padding-right: 18px; color: #7a7871; user-select: none; }
.code .ln:hover { background: rgba(255,255,255,.025); }
.diff .ln::before { content: none; }
.diff .no { width: 46px; flex: none; text-align: right; padding-right: 10px; color: #7a7871; user-select: none; }
.diff .mark { width: 22px; flex: none; text-align: center; color: #7a7871; user-select: none; }
.diff .add { background: rgba(127,212,154,.09); } .diff .add .mark { color: var(--ok); }
.diff .del { background: rgba(255,122,107,.09); } .diff .del .mark { color: var(--bad); }
.diff .hunk { color: var(--t-super); background: rgba(201,176,255,.06); padding: 4px 0 4px 18px; margin: 8px 0; }
.diff .meta { color: var(--muted); padding-left: 18px; }

/* highlight.js tokens */
.hljs-keyword, .hljs-built_in { color: #ff9a62; }
.hljs-string { color: #c3e88d; }
.hljs-number, .hljs-literal { color: #f2c46b; }
.hljs-comment { color: #8f8d86; font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-title.class_ { color: #9fd3ff; }
.hljs-meta { color: #c9b0ff; }
.hljs-params { color: #ecebe4; }
.hljs-attr, .hljs-variable { color: #e8d3a8; }

.drawer-panel {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(520px, calc(100vw - 24px)); background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: 22px; padding: 22px 24px; overflow-y: auto; transform: translateX(105%); transition: transform .55s var(--ease);
}
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.drawer-head h3 { font-family: var(--display); font-weight: 600; font-size: 27px; margin: 0; display: flex; align-items: center; gap: 10px; }
.drawer-head h3 em { color: var(--ember-2); }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-q { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 0; border: 0; background: none; text-align: left; font-size: 18px; }
.faq-q::after { content: "+"; font-family: var(--mono); color: var(--muted); transition: transform .3s; }
.faq-item.open .faq-q::after { transform: rotate(45deg); color: var(--ember); }
.faq-a { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s var(--ease); }
.faq-item.open .faq-a { grid-template-rows: 1fr; }
.faq-a > div { overflow: hidden; color: var(--ink-2); font-size: 16px; }
.faq-a > div > p { margin: 0 0 16px; }
.drawer-foot { color: var(--muted); font-size: 15px; margin-top: 18px; }
.drawer-foot a { color: var(--ember-2); }

.modal-panel {
  position: absolute; left: 50%; top: 14vh; width: min(600px, calc(100vw - 24px)); transform: translate(-50%, 20px) scale(.98); opacity: 0;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 22px; padding: 22px 24px; transition: all .45s var(--ease);
}
.modal.open .modal-panel { transform: translate(-50%, 0); opacity: 1; }
.modal-panel .drawer-head h3 { font-size: 23px; }
.gh-ico { width: 24px; height: 24px; }
.modal-copy { color: var(--ink-2); margin: 0 0 14px; font-size: 16px; }
.gh-form { display: flex; gap: 8px; }
.gh-form input { flex: 1; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); outline: 0; font-family: var(--mono); font-size: 13.5px; }
.gh-form input:focus { border-color: var(--ember); }
.gh-results { margin-top: 14px; max-height: 46vh; overflow-y: auto; display: grid; gap: 6px; }
.gh-repo { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.02); text-align: left; transition: all .2s; animation: rise .4s var(--ease) both; }
.gh-repo:hover { border-color: rgba(255,107,44,.5); background: var(--ember-soft); }
.gh-repo b { font-weight: 500; }
.gh-repo small { display: block; color: var(--muted); font-size: 14px; }
.gh-lang { font-size: 13px; font-family: var(--mono); color: var(--muted); white-space: nowrap; }
.gh-lang.py { color: var(--t-lightning); }
.gh-note { color: var(--muted); font-size: 14.5px; font-style: italic; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px); opacity: 0; z-index: 80; max-width: min(640px, calc(100vw - 32px));
  padding: 12px 18px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-2); font-size: 15.5px;
  transition: all .4s var(--ease); pointer-events: none; box-shadow: 0 20px 60px -20px #000;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(255,122,107,.5); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: #2a2926 transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .trace-grid { grid-template-columns: 1fr; }
  .console { height: 340px; }
  .results { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; }
  .view-results { overflow-y: auto; }
  .chat-scroll { overflow: visible; mask-image: none; }
  .outputs { overflow: visible; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .topbar { padding: 0 16px; background: rgba(5,5,5,.86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  .view-landing { padding: var(--top) 16px 32px; }
  .landing-steps { display: none; }
  .faq-toggle { padding: 16px; gap: 10px; }
  .faq-toggle-title { font-size: 18px; }
  .composer-hint, .tool-btn span { display: none; }
  .view-trace, .view-results { padding-left: 16px; padding-right: 16px; }
  .rail-node .rail-label { font-size: 13px; }
  .rail-dot { width: 30px; height: 30px; }
  .rail-track { top: 14px; }
  .tier { grid-template-columns: 1fr 90px 28px; }
  .sheet-head { flex-wrap: wrap; }
  .sheet-tabs { order: 3; width: 100%; }
  .clock { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Tall screens only: keep router + log in view while the stage list scrolls (never clips on short screens) */
@media (min-width: 1081px) and (min-height: 940px) {
  .trace-side { position: sticky; top: 12px; }
}


/* ---------- Letter spacing: display serif headings get room to breathe; code stays monospaced-tight ---------- */
.trace-title, .stage-name, .panel-head span, .outputs-head h3, .drawer-head h3, .msg.bot .body h4,
.kpi b, .tagline em, .drop-veil, .faq-toggle-title, .notice-panel h3 { letter-spacing: .02em; }
.finale-word { letter-spacing: .03em; }
.wordmark { padding-right: .03em; }
code, pre, .code, .console-body span, .composer-input.is-code, .file-ico, .stage-module, .gh-form input { letter-spacing: 0; word-spacing: 0; }

/* ---------- FAQ section (home page, below the chat bar) ---------- */
.faq-section { position: relative; z-index: 1; width: min(820px, 100%); margin-top: 6px; scroll-margin-top: calc(var(--top) + 12px); }
.faq-toggle {
  width: 100%; display: flex; align-items: center; gap: 16px; text-align: left; padding: 18px 22px; border-radius: 20px;
  border: 1px solid var(--line-2); background: linear-gradient(180deg, rgba(23,23,21,.9), rgba(14,14,13,.9)); transition: border-color .3s, background .3s;
}
.faq-toggle:hover { border-color: rgba(255,107,44,.5); }
.faq-toggle-kick { font-family: var(--mono); font-size: 12px; letter-spacing: .12em; color: var(--ember-2); border: 1px solid rgba(255,107,44,.4); border-radius: 8px; padding: 3px 8px; }
.faq-toggle-title { flex: 1; font-family: var(--display); font-weight: 600; font-size: 21px; line-height: 1.25; }
.faq-toggle-title em { color: var(--ember-2); }
.faq-toggle-meta { color: var(--muted); font-size: 14.5px; }
.faq-chev { width: 22px; height: 22px; color: var(--ink-2); transition: transform .4s var(--ease); flex: none; }
.faq-section.open .faq-chev { transform: rotate(180deg); color: var(--ember-2); }
.faq-section.open .faq-toggle { border-radius: 20px 20px 0 0; border-bottom-color: var(--line); }
.faq-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .55s var(--ease); }
.faq-section.open .faq-body { grid-template-rows: 1fr; }
.faq-body > div { overflow: hidden; border: 1px solid var(--line-2); border-top: 0; border-radius: 0 0 20px 20px; background: rgba(11,11,10,.92); padding: 0 22px; visibility: hidden; transition: visibility 0s .55s; }
.faq-section.open .faq-body > div { visibility: visible; padding-bottom: 16px; transition: visibility 0s; }

/* ---------- Notice (nothing to migrate) ---------- */
.notice-panel { text-align: center; padding: 30px 30px 24px; top: 20vh; }
.notice-ico { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-size: 30px; color: var(--ember-2); background: var(--ember-soft); border: 1px solid rgba(255,107,44,.45); }
.notice-ico.ok { color: var(--ok); background: rgba(127,212,154,.1); border-color: rgba(127,212,154,.45); }
.notice-panel h3 { font-family: var(--display); font-weight: 600; font-size: 26px; margin: 0 0 10px; line-height: 1.25; }
.notice-panel p { color: var(--ink-2); font-size: 17px; margin: 0 auto 22px; max-width: 460px; }
.notice-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Sans headings: accent words stay upright; digits get breathing room ---------- */
.trace-title em, .drawer-head h3 em, .faq-toggle-title em { font-style: normal; }
.wordmark, .finale-word { overflow: visible; }
.clock, .kpi b, .cost-meter b, .tier-count, .tl-legend b, .rail-time, .rail-dot, .stage-elapsed, .delta,
.log-line time { letter-spacing: .07em; font-variant-numeric: tabular-nums; }
.clock { letter-spacing: .1em; }
.kpi b { letter-spacing: .06em; }

/* numeric UI read-outs use sans digits too (code and diffs stay monospaced) */
.clock, .cost-meter b, .tier-count, .tl-legend b, .rail-time, .rail-dot, .stage-elapsed, .delta, .log-line time,
.stage-num, .landing-steps li span { font-family: "Reforge Digits", var(--mono); }

/* ---------- Judge key / limits / footer ---------- */
.judge-btn.is-on { color: var(--ember-2); border-color: rgba(255,107,44,.45); background: var(--ember-soft); }
.judge-clear { margin-top: 12px; }
#limitVideo { text-decoration: none; }
.site-foot { position: relative; z-index: 1; width: min(820px, 100%); margin: 28px auto 0; padding-top: 16px;
  border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: 13.5px; }
.secret-field { position: relative; flex: 1; display: flex; }
.secret-field input { flex: 1; padding-right: 44px; }
#judgeInput.masked { letter-spacing: .12em; }
.reveal-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.reveal-btn:hover, .reveal-btn.on { color: var(--ink); background: rgba(255,255,255,.06); }
.reveal-btn svg { width: 18px; height: 18px; }
.reveal-btn .eye-shut, .reveal-btn.on .eye-open { display: none; }
.reveal-btn.on .eye-shut { display: block; }

/* ---------- Continue to results (after a finished run) ---------- */
.continue-btn { position: fixed; right: 28px; bottom: 28px; z-index: 7; display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 22px; border-radius: 999px; font-size: 16px; box-shadow: 0 0 0 6px var(--ember-soft), 0 10px 40px rgba(255,107,44,.35);
  opacity: 0; transform: translateY(12px); transition: opacity .45s var(--ease), transform .45s var(--ease); }
.continue-btn.on { opacity: 1; transform: none; }
.continue-btn span { transition: transform .2s; }
.continue-btn:hover span { transform: translateX(3px); }
@media (max-width: 720px) { .continue-btn { right: 16px; bottom: 16px; } }
