:root {
  --bg: #f4f1ea;
  --bg-soft: #efebe2;
  --ink: #37332b;
  --ink-soft: #6e6759;
  --label: #928c7d;
  --hairline: #ddd7c9;
  --ok: #4c7a5a;
  --amber: #a07b33;
  --rust: #a34b32;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* content caps at 1180px and centers; section borders still run full-bleed */
  --gutter: max(22px, calc((100% - 1180px) / 2));
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body { padding-top: 46px; } /* clears the fixed nav */

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
}

a { color: var(--ink); text-decoration-color: var(--hairline); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
code { background: var(--bg-soft); padding: 1px 4px; border-radius: 3px; font-size: 0.92em; }

::selection { background: #d9d2bf; }

/* ---------------------------------------------------------------- nav */
#topnav {
  /* fixed, not sticky — the status readout must stay visible at every scroll
     position on every page, independent of ancestor overflow/stacking */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px var(--gutter);
  border-bottom: 1px solid var(--hairline);
  background: rgba(244, 241, 234, 0.94);
  backdrop-filter: blur(6px);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.nav-logo { display: block; width: 26px; height: 26px; }
.hero-logo { display: block; width: 96px; height: 96px; margin-bottom: 26px; }

.nav-links {
  display: flex;
  gap: 22px;
  font-size: 12px;
  color: var(--ink-soft);
}
.nav-links a { text-decoration: none; color: var(--ink-soft); }
.nav-links a:hover { color: var(--ink); }

.nav-status {
  color: var(--ink-soft);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-status .sep { margin: 0 6px; color: var(--label); }

/* ---------------------------------------------------------------- hero */
#top {
  padding: 66px var(--gutter) 54px;
  border-bottom: 1px solid var(--hairline);
}

#top h1 {
  font-size: 34px;
  font-weight: 500;
  line-height: 1.24;
  letter-spacing: -0.01em;
}

.lede {
  margin-top: 20px;
  max-width: 660px;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.7;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 46px;
  margin-top: 38px;
  padding-top: 26px;
  border-top: 1px solid var(--hairline);
}
.stat .n { font-size: 26px; font-weight: 500; letter-spacing: -0.01em; }
.stat .l { color: var(--label); font-size: 11px; letter-spacing: 0.1em; margin-top: 3px; }

.cta { display: flex; gap: 12px; margin-top: 34px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  padding: 9px 18px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-decoration: none;
}
.btn:hover { background: #2a271f; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--hairline); }
.btn.ghost:hover { border-color: var(--ink); }

/* ---------------------------------------------------------------- prose sections */
.prose, #live {
  padding: 52px var(--gutter);
  border-bottom: 1px solid var(--hairline);
}

.sec-label {
  color: var(--label);
  font-size: 11px;
  letter-spacing: 0.18em;
  margin-bottom: 20px;
}

.prose p {
  max-width: 700px;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.75;
  margin-bottom: 15px;
}
.prose p strong, .prose p em { color: var(--ink); }
.prose p em { font-style: italic; }

.sec-sub { max-width: 700px; color: var(--ink-soft); font-size: 13px; margin-bottom: 22px; }

p.caveat {
  border-left: 2px solid var(--hairline);
  padding-left: 14px;
  color: var(--label);
  font-size: 12.5px;
}

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 26px 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 46px; }

.card { border: 1px solid var(--hairline); padding: 16px 16px 6px; background: var(--bg-soft); }
.card-h { font-weight: 600; font-size: 12.5px; letter-spacing: 0.04em; margin-bottom: 7px; }
.grid-2 .card-h { margin-top: 20px; }
.grid-2 .card-h:first-child { margin-top: 0; }
.card p { font-size: 12.5px; line-height: 1.65; }

ul.api { list-style: none; font-size: 12.5px; color: var(--ink-soft); }
ul.api li { margin: 4px 0; }

.block-cursor {
  margin-left: 2px;
  animation: blink 1.15s steps(1) infinite;
  color: var(--ink);
}

@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .block-cursor { animation: none; } }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--label);
  margin-right: 8px;
  vertical-align: baseline;
}
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--amber); }
.dot.err { background: var(--rust); }

/* ---------------------------------------------------------------- live page */
.live-label { margin-bottom: 8px; }

.live-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  height: calc(100vh - 190px);
  min-height: 460px;
  border: 1px solid var(--hairline);
}

/* dedicated /live page: terminal fills the viewport under the fixed nav */
.live-page #live {
  padding-top: 26px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--hairline);
}
.live-page .live-head { max-width: 760px; margin-bottom: 18px; }
.live-page .live-grid { height: calc(100vh - 230px); min-height: 440px; }

.nav-links a.active { color: var(--ink); text-decoration: underline; text-decoration-color: var(--ink); }

/* home-page teaser linking to /live */
.live-teaser {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  border: 1px solid var(--hairline);
  background: var(--bg-soft);
  padding: 18px 20px;
  margin-top: 24px;
  max-width: 760px;
}
.teaser-status { color: var(--ink-soft); font-size: 12px; }
.teaser-status .sep { margin: 0 7px; color: var(--label); }

/* ---------------------------------------------------------------- terminal */
#terminal {
  min-width: 0;
  /* grid items default to min-height:auto — without this the log grows past its
     pane instead of scrolling inside it */
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--hairline);
}

#lines {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 10px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline) transparent;
}

#lines::-webkit-scrollbar { width: 10px; }
#lines::-webkit-scrollbar-track { background: transparent; }
#lines::-webkit-scrollbar-thumb {
  background: var(--hairline);
  border: 3px solid var(--bg);
  border-radius: 6px;
}
#lines::-webkit-scrollbar-thumb:hover { background: #cec6b3; }

/* "jump to live" pill — only shown once the reader scrolls off the tail */
#jump-live {
  position: absolute;
  right: 22px;
  bottom: 58px;
  z-index: 3;
  display: none;
  border: 1px solid var(--hairline);
  background: var(--bg-soft);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(55, 51, 43, 0.09);
}
#jump-live.show { display: block; }
#jump-live:hover { background: var(--bg); }

.ln {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 1px 0;
}

.ln .ts { color: var(--label); margin-right: 10px; font-size: 11px; }

.ln.sys   { color: var(--ink-soft); }
.ln.fetch { color: var(--ink-soft); }
.ln.fetch .pfx { color: var(--ok); }
.ln.warn  { color: var(--amber); }
.ln.err   { color: var(--rust); }
.ln.queue { color: var(--ink); }

.ln.stage {
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 12px;
  padding-top: 6px;
  border-top: 1px solid var(--hairline);
}
.ln.stage .pfx { color: var(--amber); }

.cycle-head {
  margin: 16px 0 8px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.06em;
}
.cycle-head .rule { color: var(--hairline); }

.sblock {
  margin: 8px 0 10px;
  border-left: 2px solid var(--hairline);
  padding-left: 14px;
}

.sblock .shead {
  color: var(--label);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.sblock .shead .model { color: var(--ink); font-weight: 600; }

.sblock pre {
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.sblock pre.thinking { color: var(--ink-soft); font-style: italic; }
.sblock pre.answer   { color: var(--ink); }
.sblock .aborted-note { color: var(--rust); font-size: 11px; margin-top: 2px; }

.stream-cursor {
  display: inline-block;
  width: 7px;
  height: 13px;
  background: var(--ink);
  vertical-align: text-bottom;
  animation: blink 1s steps(1) infinite;
}

/* queue input */
#queue-form {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--hairline);
  padding: 10px 22px;
  background: var(--bg);
}

#queue-form .prompt { color: var(--label); }

#queue-input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
}
#queue-input::placeholder { color: var(--label); }

.queue-submit {
  border: 0;
  background: transparent;
  color: var(--label);
  font-family: var(--mono);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
}
.queue-submit:hover { color: var(--ink); }

/* ---------------------------------------------------------------- results */
#results {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hairline);
  letter-spacing: 0.14em;
  font-size: 11px;
  color: var(--label);
}

.panel-head .count { color: var(--ink); font-weight: 600; }

#findings-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 0 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline) transparent;
}

.empty { color: var(--label); padding: 16px 18px; font-size: 12px; }

.finding {
  border-bottom: 1px solid var(--hairline);
  padding: 12px 18px;
  cursor: pointer;
}
.finding:hover { background: var(--bg-soft); }

.finding .f-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.finding .f-name {
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: lowercase;
}

.finding .f-ts { color: var(--label); font-size: 11px; white-space: nowrap; }

.finding .f-meta { color: var(--ink-soft); font-size: 11px; margin-top: 2px; }

.finding .f-summary { color: var(--ink-soft); font-size: 12px; margin-top: 6px; }

.finding .f-detail { display: none; margin-top: 10px; }
.finding.open .f-detail { display: block; }

.hypo { margin: 8px 0 10px; }
.hypo .h-title { color: var(--ink); font-weight: 600; font-size: 12px; }
.hypo .h-line  { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.hypo .h-line b { color: var(--ink); font-weight: 500; }

.conf { color: var(--ink); letter-spacing: 0.08em; }

.tag-repurpose {
  color: var(--ok);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.disc-head {
  color: var(--label);
  font-size: 10px;
  letter-spacing: 0.14em;
  margin: 14px 0 6px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
}
.hypo.disc .h-title { color: var(--ink-soft); text-decoration: line-through; font-weight: 500; }
.hypo.disc .h-line { color: var(--label); }

.f-links { margin-top: 8px; font-size: 11px; }
.f-links a { color: var(--ink); }
.f-status { color: var(--amber); font-size: 11px; letter-spacing: 0.08em; margin-top: 6px; }

/* ---------------------------------------------------------------- disease set */
.legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-bottom: 18px;
}
.legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border: 1px solid var(--label);
}
.sw.done { background: var(--ink); border-color: var(--ink); }
.sw.queued { background: transparent; }
.sw.followup { background: var(--hairline); }
.sw.control { background: var(--amber); border-color: var(--amber); }

.disease-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
}

.d-cell {
  background: var(--bg);
  padding: 11px 13px;
  min-height: 64px;
}
.d-cell.is-done { background: var(--bg-soft); }
.d-cell .d-name { font-size: 12.5px; letter-spacing: 0.02em; }
.d-cell .d-meta { color: var(--label); font-size: 10.5px; margin-top: 4px; letter-spacing: 0.06em; }
.d-cell .d-tag { color: var(--amber); }
.d-cell.is-done .d-meta { color: var(--ink-soft); }

/* ---------------------------------------------------------------- archive */
#archive-list { border-top: 1px solid var(--hairline); }
#archive-list .finding { border-bottom: 1px solid var(--hairline); padding: 14px 2px; }
#archive-list .finding:hover { background: transparent; }
#archive-list .f-summary { max-width: 760px; }

/* ---------------------------------------------------------------- footer */
footer {
  padding: 34px var(--gutter) 26px;
  background: var(--bg);
}

.cols {
  display: flex;
  gap: 56px;
  flex-wrap: wrap;
}

.col .label {
  color: var(--label);
  font-size: 11px;
  letter-spacing: 0.16em;
  margin-bottom: 8px;
}

.col .kv {
  color: var(--ink-soft);
  font-size: 12.5px;
  margin: 2px 0;
}
.col .kv span { color: var(--ink-soft); }

/* contract address: full value shown, wraps rather than truncating */
.ca {
  display: block;
  max-width: 216px;
  margin: 2px 0 6px;
  padding: 6px 8px;
  border: 1px solid var(--hairline);
  background: var(--bg-soft);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-align: left;
  word-break: break-all;
  cursor: pointer;
}
.ca:hover { border-color: var(--ink-soft); }
.ca.copied { border-color: var(--ok); color: var(--ok); }

.smallprint {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  color: var(--label);
  font-size: 10.5px;
  line-height: 1.6;
  max-width: 980px;
}

/* ---------------------------------------------------------------- mobile */
@media (max-width: 1000px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; gap: 26px; }
  .nav-links { display: none; }
}

@media (max-width: 900px) {
  .live-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 34vh; /* terminal takes the rest; both panes scroll */
    height: calc(100vh - 170px);
  }
  #terminal { border-right: 0; }
  #results { border-top: 1px solid var(--hairline); }
  #jump-live { bottom: 54px; right: 14px; }
  #top { padding: 44px 16px 38px; }
  #top h1 { font-size: 26px; }
  .stats { gap: 28px; }
  .stat .n { font-size: 21px; }
  .prose, #live { padding: 38px 16px; }
  .cols { gap: 28px; }
  .nav-status { font-size: 10.5px; }
  footer { padding: 26px 16px 20px; }
}
