:root {
  --bg: #f6f4ef;
  --bg-raise: #ffffff;
  --bg-sink: #eeebe3;
  --ink: #1c1b19;
  --ink-soft: #55524c;
  --ink-faint: #7d7a72;
  --line: #ddd8cc;
  --line-soft: #e9e5da;
  --accent: #1f5f5b;
  --accent-ink: #ffffff;
  --accent-soft: #e2efed;
  --durable: #2c6e49;
  --durable-bg: #e3f0e8;
  --drift: #9a6412;
  --drift-bg: #f7ecd8;
  --current: #a33a2a;
  --current-bg: #fbe6e1;
  --high: #a3282a;
  --high-bg: #fbe4e3;
  --warn: #8a5c0a;
  --warn-bg: #f8eeda;
  --info: #3f5a78;
  --info-bg: #e6ecf4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 27, 25, .06), 0 6px 20px rgba(28, 27, 25, .05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #17181a;
  --bg-raise: #202225;
  --bg-sink: #121315;
  --ink: #eceae6;
  --ink-soft: #b3afa8;
  --ink-faint: #85817a;
  --line: #34363a;
  --line-soft: #2a2c30;
  --accent: #6fc0b6;
  --accent-ink: #10201f;
  --accent-soft: #1e3230;
  --durable: #7cc79a;
  --durable-bg: #1c2c23;
  --drift: #d9ab5e;
  --drift-bg: #2f2718;
  --current: #e2897a;
  --current-bg: #33201d;
  --high: #e88b88;
  --high-bg: #33201f;
  --warn: #d9ab5e;
  --warn-bg: #2f2718;
  --info: #93aecd;
  --info-bg: #1d242e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.skip {
  position: absolute; left: -9999px; top: 0; padding: .6rem 1rem;
  background: var(--accent); color: var(--accent-ink); z-index: 50;
}
.skip:focus { left: 0; }

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--bg-raise);
  position: sticky; top: 0; z-index: 20;
}
.topbar-in {
  max-width: 1080px; margin: 0 auto; padding: .6rem 1.1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); }
.brand-mark { color: var(--accent); font-size: 1.15rem; letter-spacing: -.08em; }
.brand-name { font-weight: 650; letter-spacing: -.01em; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.nav-link { font-size: .85rem; color: var(--ink-soft); text-decoration: none; }
.nav-link:hover { color: var(--accent); text-decoration: underline; }
.credit-zone { display: inline-flex; align-items: center; gap: .5rem; font-size: .85rem; }
.credit-value {
  font-family: var(--mono); font-size: .8rem; padding: .15rem .45rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg-sink);
}

button {
  font: inherit; cursor: pointer; border-radius: 7px; padding: .5rem .9rem;
  border: 1px solid var(--line); background: var(--bg-raise); color: var(--ink);
  transition: background .12s ease, border-color .12s ease;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.small { padding: .32rem .6rem; font-size: .82rem; }
button.ghost { background: transparent; }

main { max-width: 1080px; margin: 0 auto; padding: 1.4rem 1.1rem 3rem; }

.intro h1 {
  font-family: var(--sans); font-size: clamp(1.8rem, 4.4vw, 2.6rem);
  line-height: 1.15; margin: .5rem 0 .7rem; letter-spacing: -.02em;
}
.lede { font-size: 1.03rem; color: var(--ink-soft); max-width: 62ch; margin: 0 0 .8rem; }
.lede-sub { font-size: .93rem; color: var(--ink-soft); max-width: 74ch; margin: 0 0 1.2rem; }

.chip {
  display: inline-block; font-size: .78rem; font-weight: 620; padding: .05rem .42rem;
  border-radius: 5px; white-space: nowrap; font-family: var(--ui);
}
.chip-durable { color: var(--durable); background: var(--durable-bg); }
.chip-drift { color: var(--drift); background: var(--drift-bg); }
.chip-current { color: var(--current); background: var(--current-bg); }
.chip-none { color: var(--high); background: var(--high-bg); }

.panel {
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.15rem; margin-bottom: 1.2rem;
  box-shadow: var(--shadow);
}

.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field { margin-bottom: .95rem; min-width: 190px; }
.field.grow { flex: 1 1 260px; }
.field label, .label-like {
  display: block; font-size: .84rem; font-weight: 620; margin-bottom: .3rem; color: var(--ink);
}
.opt { font-weight: 400; color: var(--ink-faint); font-size: .78rem; }
.hint { font-size: .78rem; color: var(--ink-faint); margin: .3rem 0 0; }

input[type="text"], input[type="search"], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px; padding: .5rem .65rem;
}
textarea { resize: vertical; min-height: 5rem; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}

.meter-field { display: flex; flex-direction: column; justify-content: flex-start; }
.meter {
  margin: 0; font-size: .84rem; color: var(--ink-soft); background: var(--bg-sink);
  border: 1px solid var(--line-soft); border-radius: 7px; padding: .5rem .65rem; min-height: 2.5rem;
}
.meter.short { color: var(--high); background: var(--high-bg); border-color: var(--high); }

.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .3rem; }
.run-note { font-size: .82rem; color: var(--ink-faint); margin: .6rem 0 0; }

.askflag {
  border: 1px solid var(--drift); background: var(--drift-bg);
  border-radius: var(--radius); padding: .85rem 1rem; margin: .2rem 0 1rem;
}
.askflag h3 { margin: 0 0 .5rem; font-size: .95rem; color: var(--drift); }
.askflag-list { margin: 0 0 .6rem; padding-left: 1.1rem; font-size: .87rem; }
.askflag-list li { margin-bottom: .4rem; }
.askflag-list code {
  font-family: var(--mono); font-size: .82rem; background: var(--bg-raise);
  padding: .05rem .3rem; border-radius: 4px;
}
.askflag-note { font-size: .85rem; margin: .3rem 0; color: var(--ink-soft); }
.askflag-rewrite {
  font-size: .89rem; background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: 7px; padding: .5rem .65rem; margin: .4rem 0 .6rem;
}

.progress-head { display: flex; align-items: baseline; gap: .8rem; }
.progress-head h2 { margin: 0; font-size: 1rem; }
.timer { font-family: var(--mono); font-size: .82rem; color: var(--ink-faint); margin-left: auto; }
.steps { list-style: none; margin: .8rem 0; padding: 0; }
.steps li {
  font-size: .87rem; color: var(--ink-faint); padding: .22rem 0 .22rem 1.5rem; position: relative;
}
.steps li::before {
  content: "○"; position: absolute; left: 0; color: var(--line);
}
.steps li.active { color: var(--ink); font-weight: 560; }
.steps li.active::before { content: "◔"; color: var(--accent); }
.steps li.done { color: var(--ink-soft); }
.steps li.done::before { content: "●"; color: var(--durable); }

.error { border-color: var(--high); background: var(--high-bg); }
.error h2 { margin: 0 0 .4rem; font-size: 1rem; color: var(--high); }

.result-head {
  display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.result-head h2 {
  font-family: var(--sans); font-size: 1.7rem; margin: 0; letter-spacing: -.015em;
}
.result-sub { margin: .2rem 0 0; color: var(--ink-soft); font-size: .9rem; }
.result-actions { margin-left: auto; display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
.badge {
  font-size: .76rem; padding: .18rem .5rem; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}

.card {
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.05rem 1.15rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 .6rem; font-size: 1.02rem; letter-spacing: -.01em; }
.card h4 { margin: .8rem 0 .35rem; font-size: .9rem; }
.card-note { font-size: .82rem; color: var(--ink-faint); margin: 0 0 .8rem; max-width: 76ch; }
.check-card { border-color: var(--current); }
.check-card h3 { color: var(--current); }

.notice {
  border: 1px solid var(--warn); background: var(--warn-bg); color: var(--warn);
  border-radius: 7px; padding: .55rem .8rem; font-size: .86rem; margin-bottom: 1rem;
}

.headline { font-size: 1.08rem; font-weight: 620; margin: 0 0 .7rem; line-height: 1.4; }
.prose { font-size: .96rem; max-width: 72ch; }
.prose p { margin: 0 0 .75rem; }
.prose p:last-child { margin-bottom: 0; }
.stability-line, .confidence-line, .axis {
  font-size: .84rem; color: var(--ink-soft); margin: .8rem 0 0;
  border-top: 1px solid var(--line-soft); padding-top: .6rem;
}
.axis { border-top: none; padding-top: 0; margin-top: .8rem; font-style: italic; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.anchors { border-collapse: collapse; width: 100%; font-size: .88rem; min-width: 520px; }
table.anchors th, table.anchors td {
  text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
table.anchors th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); }
table.anchors td.src { font-family: var(--mono); font-size: .8rem; }
.verdict { font-size: .78rem; font-weight: 620; padding: .08rem .42rem; border-radius: 5px; white-space: nowrap; }
.verdict.ok { color: var(--durable); background: var(--durable-bg); }
.verdict.bad { color: var(--high); background: var(--high-bg); }
.verdict.none { color: var(--info); background: var(--info-bg); }
.abstract-quote {
  font-size: .82rem; color: var(--ink-soft); background: var(--bg-sink);
  border-left: 3px solid var(--high); padding: .45rem .6rem; margin: .4rem 0 0;
  border-radius: 0 5px 5px 0;
}

.findings { list-style: none; margin: 0; padding: 0; }
.findings li {
  border-left: 3px solid var(--line); padding: .5rem .7rem; margin-bottom: .55rem;
  border-radius: 0 6px 6px 0; font-size: .88rem; background: var(--bg-sink);
}
.findings li.f-high { border-left-color: var(--high); background: var(--high-bg); }
.findings li.f-warn { border-left-color: var(--warn); background: var(--warn-bg); }
.findings li.f-info { border-left-color: var(--info); background: var(--info-bg); }
.findings .f-where { font-family: var(--mono); font-size: .78rem; opacity: .85; }
.findings .f-sev { font-weight: 700; text-transform: uppercase; font-size: .72rem; letter-spacing: .05em; }

.districts { display: grid; gap: .85rem; }
.district {
  border: 1px solid var(--line-soft); border-radius: 8px; padding: .75rem .85rem;
  background: var(--bg-sink);
}
.district h4 { margin: 0 0 .35rem; font-size: .95rem; }
.district p { margin: 0 0 .45rem; font-size: .9rem; }
.district dl { margin: .4rem 0 0; font-size: .86rem; }
.district dt { font-weight: 620; color: var(--ink-soft); font-size: .8rem; }
.district dd { margin: 0 0 .4rem; }

.claims, .checks, .misread, .declined, .plain, .sources, .history { list-style: none; margin: 0; padding: 0; }
.claims li, .misread li, .declined li {
  padding: .55rem 0; border-bottom: 1px solid var(--line-soft); font-size: .91rem;
}
.claims li:last-child, .misread li:last-child, .declined li:last-child { border-bottom: none; }
.checks li {
  padding: .6rem .75rem; margin-bottom: .5rem; border-radius: 7px;
  background: var(--current-bg); border: 1px solid var(--line-soft); font-size: .9rem;
}
.checks .who { display: block; font-size: .84rem; margin-top: .3rem; }
.checks .who strong { color: var(--current); }
.worth { display: grid; gap: .7rem; }
.worth-row { border: 1px solid var(--line-soft); border-radius: 8px; padding: .7rem .8rem; background: var(--bg-sink); }
.worth-row h4 { margin: 0 0 .25rem; font-size: .93rem; }
.worth-row .verdict-line { font-size: .89rem; font-weight: 560; margin: 0 0 .35rem; }
.worth-row p { margin: 0 0 .35rem; font-size: .88rem; }
.worth-row .local { color: var(--ink-soft); font-style: italic; }
.two-up { display: grid; gap: 1.2rem; }

.sources li {
  border: 1px solid var(--line-soft); border-radius: 8px; padding: .65rem .8rem;
  margin-bottom: .6rem; background: var(--bg-sink); font-size: .88rem;
}
.sources .src-id { font-family: var(--mono); font-size: .78rem; color: var(--ink-faint); }
.sources .src-abs { color: var(--ink-soft); margin: .35rem 0 0; font-size: .85rem; }
.sources .src-reads { font-size: .79rem; color: var(--ink-faint); margin: .35rem 0 0; }

.history-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; }
.history-head h2 { margin: 0; font-size: 1.05rem; }
.history-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.history-actions input { min-width: 240px; }
.history li {
  display: flex; gap: .8rem; align-items: center; flex-wrap: wrap;
  padding: .55rem 0; border-bottom: 1px solid var(--line-soft); font-size: .89rem;
}
.history li:last-child { border-bottom: none; }
.history .h-main { flex: 1 1 240px; min-width: 0; }
.history .h-city { font-weight: 620; }
.history .h-q { color: var(--ink-soft); display: block; font-size: .84rem; }
.history .h-meta { font-size: .78rem; color: var(--ink-faint); font-family: var(--mono); }

.foot { border-top: 1px solid var(--line); background: var(--bg-raise); margin-top: 2rem; }
.foot-in { max-width: 1080px; margin: 0 auto; padding: 1.4rem 1.1rem 2rem; font-size: .85rem; color: var(--ink-soft); }
.foot-links { display: flex; gap: 1rem; flex-wrap: wrap; margin: .6rem 0; }
.foot-fine { font-size: .78rem; color: var(--ink-faint); max-width: 78ch; }

.empty { color: var(--ink-faint); font-style: italic; font-size: .88rem; }

/* --- docs pages (api.html, tokens.html) --- */

code {
  font-family: var(--mono); font-size: .85em; background: var(--bg-sink);
  padding: .06rem .28rem; border-radius: 4px;
}
.step h2 { display: flex; align-items: baseline; gap: .6rem; font-size: 1.15rem; margin-top: 0; }
.stepnum {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-size: .82rem; font-weight: 700; flex: none;
}
.step p { max-width: 76ch; font-size: .93rem; }
.warnbox {
  border-left: 3px solid var(--current); background: var(--current-bg);
  padding: .6rem .8rem; border-radius: 0 6px 6px 0;
}
.tabs { margin: 1rem 0 .4rem; }
.tabrow { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .5rem; }
.tab {
  padding: .28rem .6rem; font-size: .8rem; border-radius: 6px;
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
}
.tab.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 620; }
.snip { display: none; }
.snip.on { display: block; }
pre {
  background: var(--bg-sink); border: 1px solid var(--line-soft); border-radius: 8px;
  padding: .8rem .9rem; overflow-x: auto; -webkit-overflow-scrolling: touch;
  font-family: var(--mono); font-size: .8rem; line-height: 1.55; margin: 0;
}
pre code { background: none; padding: 0; font-size: inherit; }
pre.contract { max-height: 30rem; overflow-y: auto; }

@media (min-width: 720px) {
  .two-up { grid-template-columns: 1fr 1fr; }
  .districts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .topbar-in { padding: .5rem .8rem; }
  main { padding: 1rem .8rem 2.4rem; }
  .result-actions { margin-left: 0; }
  .history-actions { margin-left: 0; width: 100%; }
  .history-actions input { min-width: 0; flex: 1; }
}

