:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d8dde5;
  --border-strong: #b6bfcc;
  --text: #16191d;
  --text-dim: #5a626e;
  --accent: #2f5fd0;

  --true: #1f7a4d;
  --true-bg: #e3f4ea;
  --false: #b02a2a;
  --false-bg: #fbe6e6;
  --unknown: #96650a;
  --unknown-bg: #fdf1dc;
  --inert: #8b93a1;
  --inert-bg: #eef0f3;

  --radius: 8px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1b1f26;
    --surface-2: #232830;
    --border: #2f3641;
    --border-strong: #454f5e;
    --text: #e7eaef;
    --text-dim: #9aa4b2;
    --accent: #7ba0f5;

    --true: #63c48d;
    --true-bg: #17301f;
    --false: #f08b8b;
    --false-bg: #34191a;
    --unknown: #e4b45c;
    --unknown-bg: #322616;
    --inert: #7a8493;
    --inert-bg: #242a33;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
}

a { color: var(--accent); }

header.site {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header.site h1 {
  margin: 0 0 4px;
  font-size: 19px;
  letter-spacing: -0.01em;
}

header.site p.tagline {
  margin: 0 0 6px;
  color: var(--text-dim);
  font-size: 13.5px;
  max-width: 70ch;
}
header.site p.tagline:last-of-type { margin-bottom: 0; }
header.site p.tagline.demo-note {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
}

nav.site {
  margin-top: 10px;
  display: flex;
  gap: 14px;
  font-size: 13px;
}

nav.site a[aria-current="page"] {
  font-weight: 600;
  text-decoration: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.controls label {
  font-size: 12.5px;
  color: var(--text-dim);
}

select, button, input[type="number"], input[type="password"], textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 5px 8px;
}

select { max-width: min(46ch, 70vw); }

button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.panes {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 0.95fr);
  gap: 14px;
  padding: 14px 20px 30px;
  align-items: start;
}

@media (max-width: 1100px) {
  .panes { grid-template-columns: 1fr; }
}

.pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}

.pane > h2 {
  margin: 0;
  padding: 10px 14px 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.pane-hint {
  margin: 4px 0 0;
  padding: 0 14px 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.pane > .body { padding: 12px 14px; }

/* ---------------------------------------------------------------- tree --- */

.tree-scroll {
  overflow: auto;
  max-height: 68vh;
  padding: 8px;
}

.node-box { cursor: pointer; }
.node-box rect {
  fill: var(--inert-bg);
  stroke: var(--border-strong);
  stroke-width: 1;
  rx: 6;
}
.node-box text { font-size: 11px; fill: var(--text); }
.node-box .node-sub { font-size: 9.5px; fill: var(--text-dim); }

.node-box.state-TRUE rect { fill: var(--true-bg); stroke: var(--true); }
.node-box.state-FALSE rect { fill: var(--false-bg); stroke: var(--false); }
.node-box.state-UNKNOWN rect { fill: var(--unknown-bg); stroke: var(--unknown); }

.node-box.blocking rect { stroke-width: 2.5; stroke-dasharray: 4 2; }
.node-box.selected rect { stroke-width: 2.5; }
.node-box.linked rect { stroke-width: 2.5; stroke: var(--accent); }

.edge { fill: none; stroke: var(--border-strong); stroke-width: 1.2; }
.edge.on-path { stroke: var(--text-dim); stroke-width: 2; }

.node-detail {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 13px;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.node-detail .muted { color: var(--text-dim); font-size: 12.5px; }

/* ---------------------------------------------------------------- note --- */

.note {
  font-family: var(--mono);
  font-size: 12.3px;
  line-height: 1.62;
  white-space: pre-wrap;
  max-height: 340px;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}

.note mark {
  background: var(--inert-bg);
  border-bottom: 2px solid var(--border-strong);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
  cursor: pointer;
}
.note mark.state-TRUE { background: var(--true-bg); border-color: var(--true); }
.note mark.state-FALSE { background: var(--false-bg); border-color: var(--false); }
.note mark.state-UNKNOWN { background: var(--unknown-bg); border-color: var(--unknown); }
.note mark.linked { outline: 2px solid var(--accent); }

.chips { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.chip {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 7px 9px;
  background: var(--surface-2);
}
.chip.linked { outline: 2px solid var(--accent); }
.chip.state-TRUE { border-left: 4px solid var(--true); }
.chip.state-FALSE { border-left: 4px solid var(--false); }
.chip.state-UNKNOWN { border-left: 4px solid var(--unknown); }
.chip.missing { opacity: 0.85; border-style: dashed; }

.chip .key {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  word-break: break-all;
}
.chip .row { display: flex; align-items: center; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.chip .edited { font-size: 11px; color: var(--accent); }
.chip input[type="number"] { width: 6.5em; }

/* ------------------------------------------------------------- verdict --- */

.verdict {
  border-radius: 6px;
  padding: 12px;
  border: 1px solid var(--border-strong);
}
.verdict.APPROVE { background: var(--true-bg); border-color: var(--true); }
.verdict.DENY { background: var(--false-bg); border-color: var(--false); }
.verdict.INDETERMINATE { background: var(--unknown-bg); border-color: var(--unknown); }

.verdict .decision { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.verdict .confidence { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

.blocking {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 13.5px;
}
.blocking .delta { font-family: var(--mono); font-size: 12.5px; }

ul.criteria { list-style: none; margin: 12px 0 0; padding: 0; font-size: 13px; }
ul.criteria li {
  display: flex;
  gap: 8px;
  padding: 5px 0;
  border-top: 1px solid var(--border);
}
ul.criteria li:first-child { border-top: none; }
ul.criteria .dot { flex: none; width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; }
.dot.state-TRUE { background: var(--true); }
.dot.state-FALSE { background: var(--false); }
.dot.state-UNKNOWN { background: var(--unknown); }
ul.criteria .reason { color: var(--text-dim); font-size: 12px; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}
.badge.warn { border-color: var(--unknown); color: var(--unknown); }

/* ---------------------------------------------------------------- live --- */

details.live { margin: 0 20px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
details.live > summary { padding: 10px 14px; cursor: pointer; font-size: 13.5px; }
details.live .body { padding: 0 14px 14px; }
details.live textarea { width: 100%; min-height: 150px; font-family: var(--mono); font-size: 12.3px; }
details.live input[type="password"] { width: min(420px, 100%); }
.key-notice { font-size: 12.5px; color: var(--text-dim); margin: 6px 0 0; }

/* -------------------------------------------------------------- charts --- */

.charts { padding: 14px 20px 30px; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.chart-card h3 { margin: 0 0 2px; font-size: 14.5px; }
.chart-card p.note-line { margin: 0 0 8px; font-size: 12.5px; color: var(--text-dim); }
.chart-card svg { width: 100%; height: auto; display: block; }

.axis line, .axis path { stroke: var(--border-strong); }
.axis text { font-size: 10.5px; fill: var(--text-dim); }
.grid line { stroke: var(--border); stroke-dasharray: 2 3; }
.bar-structured { fill: var(--accent); }
.bar-baseline { fill: var(--inert); }
.series-label { font-size: 11px; fill: var(--text-dim); }
.bar-value { font-size: 10.5px; fill: var(--text); }
.line-structured { fill: none; stroke: var(--accent); stroke-width: 2; }
.line-baseline { fill: none; stroke: var(--inert); stroke-width: 2; }
.line-diagonal { fill: none; stroke: var(--border-strong); stroke-dasharray: 4 3; stroke-width: 1.2; }

table.failures { width: 100%; border-collapse: collapse; font-size: 13px; }
table.failures th, table.failures td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.failures th { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
table.failures code { font-family: var(--mono); font-size: 12px; }

section.prose { padding: 0 20px 24px; max-width: 78ch; }
section.prose h2 { font-size: 16px; margin-bottom: 6px; }
section.prose p, section.prose li { font-size: 13.5px; color: var(--text); }
section.prose table { border-collapse: collapse; font-size: 13px; }
section.prose th, section.prose td { border: 1px solid var(--border); padding: 5px 9px; }

footer.site {
  border-top: 1px solid var(--border);
  padding: 14px 20px 26px;
  color: var(--text-dim);
  font-size: 12.5px;
  background: var(--surface);
}
footer.site p { margin: 3px 0; max-width: 90ch; }

.status { padding: 20px; color: var(--text-dim); }
.error { color: var(--false); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- tour --- */

.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}
.tour-overlay[hidden] { display: none; }

.tour-dialog {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 18px 20px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.tour-dialog h3 { margin: 0 0 8px; font-size: 16px; }
.tour-dialog p { margin: 0; font-size: 13.5px; color: var(--text-dim); line-height: 1.55; }

.tour-dots { display: flex; gap: 5px; margin: 14px 0; }
.tour-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.tour-dot.active { background: var(--accent); }

.tour-footer { display: flex; align-items: center; gap: 8px; }
.tour-footer button:first-child { margin-right: auto; }
