:root {
  --bg: #0a0c11;
  --rail: #0e1219;
  --panel: #141926;
  --panel-2: #1a2130;
  --line: #232c3d;
  --ink: #e9edf5;
  --muted: #8b95ab;
  --accent: #76e3a1;
  --accent-dim: #17301f;
  --warn: #f0c36d;
  --cold: #6f7d99;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --rail-w: 252px;
  --drawer-w: 360px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* .row is a flexbox and would ignore it */
/* min-height, not height: a body fixed to one screen confines the sticky rail and
   drawer to that screen, and they scroll away with the first page of content */
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: Inter, system-ui, sans-serif; line-height: 1.55; font-size: 15px;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }

.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.app.with-drawer { grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--drawer-w); }

/* ---- left rail ---- */
.rail {
  background: var(--rail); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 26px; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 0 6px; }
.brand .logo { font-size: 24px; color: var(--accent); }
.brand strong { display: block; font-size: 17px; }
.brand span { color: var(--muted); font-size: 12px; }
.rail nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.rail-label {
  margin: 14px 6px 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: #5d6780;
}
.mode {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%;
  background: none; border: 1px solid transparent; border-radius: 10px; color: var(--ink);
  padding: 9px 10px;
}
.mode:hover { background: var(--panel); }
.mode.active { background: var(--panel); border-color: var(--line); }
.mode-icon { color: #3c465c; font-size: 10px; line-height: 20px; }
.mode.active .mode-icon { color: var(--accent); }
.mode b { display: block; font-size: 14px; font-weight: 600; }
.mode i { display: block; font-style: normal; font-size: 12px; color: var(--muted); }
.rail-foot ul { list-style: none; margin: 0; padding: 0 6px; display: grid; gap: 5px; }
.rail-foot li { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.rail-foot b { color: var(--ink); font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.dot.off { background: var(--warn); }

/* ---- workspace ---- */
.workspace { display: flex; flex-direction: column; min-width: 0; }
.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 20px clamp(16px, 3vw, 34px) 14px; border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 20px; }
.bar p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.toggle {
  background: none; border: 1px solid var(--line); border-radius: 999px; color: var(--ink);
  padding: 7px 15px; font-size: 13.5px; white-space: nowrap;
}
.toggle:hover { border-color: var(--accent); }
.toggle[aria-pressed="true"] { background: var(--accent-dim); border-color: #2f7d55; color: var(--accent); }

.composer { padding: 18px clamp(16px, 3vw, 34px) 0; max-width: 1020px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row.col { flex-direction: column; align-items: flex-start; }
input[type=url], textarea {
  flex: 1; min-width: 240px; width: 100%; background: #0c1017; border: 1px solid var(--line);
  color: var(--ink); border-radius: 10px; padding: 12px 14px; font: 14px var(--mono); resize: vertical;
}
input[type=url]:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.primary {
  background: var(--accent); color: #07130c; border: 0; border-radius: 10px;
  padding: 12px 20px; font-weight: 600; white-space: nowrap;
}
.primary:disabled { opacity: .45; cursor: progress; }
.hint { color: var(--muted); font-size: 12.5px; margin: 9px 0 0; }
.hint button { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font: inherit; }
.error { color: #ff9b8f; margin: 10px 0 0; font-size: 14px; }

/* ---- timeline ---- */
.timeline { padding: 8px clamp(16px, 3vw, 34px) 60px; display: grid; gap: 14px; align-content: start; max-width: 1020px; }
.idle { padding: 44px 0; max-width: 60ch; }
.idle p { margin: 0 0 8px; }
.step { display: flex; gap: 12px; }
.step-mark {
  flex: none; width: 24px; height: 24px; border-radius: 7px; background: var(--panel);
  border: 1px solid var(--line); color: var(--muted); display: grid; place-items: center;
  font: 600 11px var(--mono); margin-top: 2px;
}
.step.live .step-mark { border-color: var(--accent); color: var(--accent); animation: pulse 1.2s infinite; }
.step-body { flex: 1; min-width: 0; }
.step h2 { font-size: 15px; font-weight: 600; }
.step .said { color: var(--muted); font-size: 13.5px; margin: 2px 0 0; }
@keyframes pulse { 50% { opacity: .4; } }

.files { list-style: none; padding: 0; margin: 9px 0 0; display: flex; flex-wrap: wrap; gap: 5px; }
.files li {
  font: 11.5px var(--mono); color: var(--muted); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px;
}
.panel-grid { display: grid; gap: 10px; margin-top: 10px; align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.model { background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; }
.model.done { border-color: #2c4536; }
.model.failed { opacity: .5; }
.model h3 { font: 600 12.5px var(--mono); word-break: break-all; }
.model .meta { color: var(--muted); font-size: 12.5px; margin: 3px 0 0; }
.model ul { margin: 8px 0 0; padding-left: 16px; font-size: 12.5px; color: #bcc6d9; }
.model li { margin-bottom: 4px; }

.claims { display: grid; gap: 10px; margin-top: 10px; }
.claim { background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 13px 15px; }
.claim.reproduced { border-color: #2f7d55; background: linear-gradient(180deg, #152218 0%, var(--panel) 65%); }
.claim-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.claim h3 { font-size: 14.5px; font-weight: 600; }
.chip {
  font: 600 10.5px var(--mono); letter-spacing: .04em; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.reproduced { background: var(--accent-dim); border-color: #2f7d55; color: var(--accent); }
.chip.not_reproduced { color: var(--cold); }
.chip.unverified { color: var(--warn); border-color: #4a4029; }
.chip.running { color: var(--ink); border-color: var(--accent); animation: pulse 1.1s infinite; }
.claim .why { color: #bcc6d9; font-size: 13.5px; margin: 6px 0 0; }
.claim .where { color: var(--muted); font: 11.5px var(--mono); margin: 5px 0 0; }
.votes { color: var(--muted); font-size: 12px; margin: 5px 0 0; }
.upstream { font-size: 12px; margin: 5px 0 0; color: var(--muted); }
.upstream:empty { display: none; }
.upstream.known, .upstream.fixed { color: var(--warn); }
.upstream.elsewhere { color: var(--muted); }
.upstream.new { color: var(--accent); }
.upstream.pending { animation: pulse 1.1s infinite; }
.upstream a { color: inherit; font-weight: 600; }
.upstream .why { color: var(--muted); font-weight: 400; }
details summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 8px; }
pre {
  background: #070a0f; border: 1px solid var(--line); border-radius: 8px; padding: 11px;
  overflow: auto; font: 11.5px/1.5 var(--mono); color: #b4bfd3; max-height: 300px; white-space: pre-wrap;
}
.verdict-line { font-size: 15.5px; }
.verdict-line b { color: var(--accent); }
.prompt-box { margin-top: 10px; }
.copy { margin-top: 10px; }

/* ---- sources drawer ---- */
.drawer {
  background: var(--rail); border-left: 1px solid var(--line); padding: 18px 16px 50px;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.drawer header { display: flex; justify-content: space-between; align-items: center; }
.drawer h2 { font-size: 16px; }
.close { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; }
.drawer-note { color: var(--muted); font-size: 12.5px; margin: 6px 0 16px; }
.cite { border-top: 1px solid var(--line); padding: 13px 0; }
.cite h3 { font-size: 13.5px; font-weight: 600; }
.cite .q { font: 11.5px var(--mono); color: var(--muted); margin: 5px 0 0; }
.cite .why { font-size: 12.5px; color: #bcc6d9; margin: 6px 0 0; }
.cite ol { margin: 8px 0 0; padding-left: 17px; }
.cite li { margin-bottom: 8px; font-size: 12.5px; }
.cite li a { font-weight: 600; text-decoration: none; }
.cite li a:hover { text-decoration: underline; }
.cite li p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.cite .pending { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

@media (max-width: 1100px) {
  .app, .app.with-drawer { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: column; }
  .rail nav { flex-direction: row; flex-wrap: wrap; }
  .mode { width: auto; }
  .drawer { position: static; height: auto; border-left: 0; border-top: 1px solid var(--line); }
}
.claim details.attempt { margin-left: 14px; }

/* ---- account, BYOK, your cases ---- */
.bar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.account { display: flex; gap: 8px; align-items: center; }
.account[hidden], .account [hidden] { display: none !important; }
.signin { text-decoration: none; display: inline-block; }
.me { display: inline-flex; gap: 7px; align-items: center; font-size: 13px; }
.me img { border-radius: 50%; border: 1px solid var(--line); }
.help {
  display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none;
  border: 1px solid var(--line); border-radius: 50%; color: var(--muted);
  font: 600 12px var(--mono); text-decoration: none;
}
.help:hover { color: var(--accent); border-color: var(--accent); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font-size: 12.5px; text-decoration: underline; }
.rail-foot .linkish { margin: 10px 6px 0; }
#byok-form { margin: 8px 6px 0; display: grid; gap: 6px; }
#byok-form[hidden] { display: none; }
#byok-key {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
  padding: 7px 9px; font: 12px var(--mono); width: 100%; box-sizing: border-box;
}
.byok-actions { display: flex; gap: 6px; align-items: center; }
.small {
  background: var(--accent); color: #07140c; border: 0; border-radius: 7px; padding: 5px 10px;
  font-size: 12px; font-weight: 600;
}
.small.ghost { background: none; color: var(--muted); border: 1px solid var(--line); }
.byok-note { color: var(--muted); font-size: 11.5px; margin: 0; }
#history { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.case {
  width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 9px;
  color: var(--ink); padding: 6px 10px;
}
.case:hover { background: var(--panel); }
.case b { display: block; font-size: 12.5px; font-weight: 600; word-break: break-all; }
.case i { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); }
#history .linkish { margin: 4px 10px; }
