/* Discrepancy — shared styles for the write-up and the demo.
 *
 * Set like a technical document rather than a product page: one column, generous measure, and a
 * monospace face wherever the page is showing something the system actually produced (a notice, a
 * page of a document, a row of the audit record). The distinction is load-bearing — a reader
 * should be able to tell at a glance which words are mine and which are the system's output.
 */

:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --ink: #1b1a17;
  --ink-soft: #55524c;
  --ink-faint: #85817a;
  --rule: #e2ded7;
  --rule-strong: #cdc7bd;
  --accent: #7a4b1e;
  --accent-soft: #f4ece2;
  --bad: #8c2f24;
  --bad-soft: #f9ebe8;
  --good: #2c5d3f;
  --good-soft: #e9f2ec;
  --warn: #7a5c15;
  --warn-soft: #f8f0da;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: ui-serif, Georgia, Cambria, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16161a;
    --panel: #1e1e23;
    --ink: #eceae5;
    --ink-soft: #b5b1a9;
    --ink-faint: #85817a;
    --rule: #33333b;
    --rule-strong: #4a4a54;
    --accent: #d9a066;
    --accent-soft: #2a2219;
    --bad: #e08076;
    --bad-soft: #2e1d1a;
    --good: #7fc09b;
    --good-soft: #17251d;
    --warn: #d8bb6b;
    --warn-soft: #292312;
  }
}

:root[data-theme="dark"] {
  --bg: #16161a;
  --panel: #1e1e23;
  --ink: #eceae5;
  --ink-soft: #b5b1a9;
  --ink-faint: #85817a;
  --rule: #33333b;
  --rule-strong: #4a4a54;
  --accent: #d9a066;
  --accent-soft: #2a2219;
  --bad: #e08076;
  --bad-soft: #2e1d1a;
  --good: #7fc09b;
  --good-soft: #17251d;
  --warn: #d8bb6b;
  --warn-soft: #292312;
}

* { box-sizing: border-box; }

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

.wrap { max-width: 50rem; margin: 0 auto; padding: 2.5rem 1.25rem 6rem; }
.wrap.wide { max-width: 72rem; }

/* ---- masthead ---------------------------------------------------------------------------- */

.masthead { border-bottom: 1px solid var(--rule); padding-bottom: 1.25rem; margin-bottom: 2.5rem; }
.masthead h1 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  line-height: 1.15;
  margin: 0 0 .4rem;
  letter-spacing: -0.01em;
}
.masthead .standfirst { color: var(--ink-soft); font-size: 1.08rem; margin: 0 0 1rem; max-width: 44rem; }
.masthead nav { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .92rem; }
.masthead nav a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.masthead nav a:hover { border-bottom-color: currentColor; }
.masthead nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---- prose ------------------------------------------------------------------------------- */

h2 {
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 3rem 0 .75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}
h3 { font-size: 1.06rem; margin: 2rem 0 .5rem; letter-spacing: .01em; }
p { margin: 0 0 1.1rem; }
a { color: var(--accent); }
strong { font-weight: 650; }
ul, ol { margin: 0 0 1.1rem; padding-left: 1.35rem; }
li { margin-bottom: .45rem; }
li > ul, li > ol { margin-top: .45rem; }

.lede { font-size: 1.12rem; color: var(--ink-soft); }

blockquote {
  margin: 1.5rem 0;
  padding: .1rem 0 .1rem 1.15rem;
  border-left: 3px solid var(--rule-strong);
  color: var(--ink-soft);
}

/* ---- callouts ---------------------------------------------------------------------------- */

.note {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  background: var(--panel);
  padding: 1rem 1.15rem;
  margin: 1.75rem 0;
  border-radius: 3px;
}
.note > :last-child { margin-bottom: 0; }
.note .label {
  display: block;
  font-size: .72rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .4rem;
  font-weight: 650;
}
.note.bad { border-left-color: var(--bad); background: var(--bad-soft); }
.note.bad .label { color: var(--bad); }

/* ---- figures: the system's own output ---------------------------------------------------- */

figure { margin: 1.75rem 0; }
figcaption { font-size: .85rem; color: var(--ink-faint); margin-top: .5rem; }

pre, .output {
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.55;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
code { font-family: var(--mono); font-size: .88em; }
p code, li code, td code {
  background: var(--accent-soft);
  padding: .1em .35em;
  border-radius: 3px;
}

/* ---- tables ------------------------------------------------------------------------------ */

.table-scroll { overflow-x: auto; margin: 1.5rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: .74rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); font-weight: 650; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- demo layout ------------------------------------------------------------------------- */

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: .9rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1.1rem;
  margin-bottom: 1.5rem;
}
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label { font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); font-weight: 650; }
.field .hint { font-size: .78rem; color: var(--ink-faint); line-height: 1.4; }
select, input[type="text"], input[type="date"], button {
  font: inherit;
  font-size: .9rem;
  padding: .45rem .55rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  min-width: 0;
}
input[type="text"] { font-family: var(--mono); font-size: .82rem; }
button { cursor: pointer; background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
button:hover { filter: brightness(1.08); }
button.secondary { background: var(--panel); color: var(--ink); border-color: var(--rule-strong); font-weight: 500; }
button:disabled { opacity: .5; cursor: default; }

.panes { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 1.5rem; align-items: start; }
@media (max-width: 60rem) { .panes { grid-template-columns: 1fr; } }

.pane {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1.1rem 1.15rem;
  margin-bottom: 1.25rem;
}
.pane > h3 { margin-top: 0; display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.pane > h3 .tag { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }

.doc-edit { margin-bottom: 1.1rem; }
.doc-edit > .doc-name {
  font-size: .74rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); font-weight: 650; margin-bottom: .5rem;
}
.doc-edit .row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: .5rem; align-items: center; margin-bottom: .35rem; }
.doc-edit .row .k { font-size: .78rem; color: var(--ink-soft); font-family: var(--mono); overflow-wrap: anywhere; }
.doc-edit .row input { width: 100%; }
.doc-edit .row input.changed { border-color: var(--accent); background: var(--accent-soft); }

.finding {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--bad);
  background: var(--bad-soft);
  border-radius: 3px;
  padding: .75rem .9rem;
  margin-bottom: .75rem;
  font-size: .9rem;
}
.finding .where { font-family: var(--mono); font-size: .8rem; color: var(--ink-soft); margin-bottom: .3rem; }
.finding .what { margin-bottom: .4rem; }
.finding .cite {
  display: inline-block;
  font-size: .74rem;
  font-weight: 650;
  letter-spacing: .03em;
  color: var(--bad);
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: .05rem .35rem;
}
.finding .clause { font-size: .8rem; color: var(--ink-soft); margin-top: .4rem; }

.review { border-left-color: var(--warn); background: var(--warn-soft); }
.review .cite { color: var(--warn); }

.verdict { font-size: .95rem; padding: .8rem .95rem; border-radius: 3px; margin-bottom: 1rem; }
.verdict.clean { background: var(--good-soft); border: 1px solid var(--good); color: var(--good); }
.verdict.refused { background: var(--bad-soft); border: 1px solid var(--bad); color: var(--bad); }
.verdict.blocked { background: var(--warn-soft); border: 1px solid var(--warn); color: var(--warn); }

.chain { font-family: var(--mono); font-size: .76rem; }
.chain .ev { display: grid; grid-template-columns: minmax(0, 1fr); gap: .15rem; padding: .5rem 0; border-bottom: 1px dashed var(--rule); }
.chain .ev:last-child { border-bottom: none; }
.chain .ev .name { color: var(--accent); font-weight: 650; }
.chain .ev .h { color: var(--ink-faint); overflow-wrap: anywhere; }
.chain-status { padding: .6rem .8rem; border-radius: 3px; margin-bottom: .75rem; font-family: var(--sans); font-size: .85rem; }
.chain-status.ok { background: var(--good-soft); color: var(--good); border: 1px solid var(--good); }
.chain-status.broken { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad); }

.scope { font-size: .85rem; color: var(--ink-soft); border-top: 1px dashed var(--rule); padding-top: .75rem; margin-top: .75rem; }

.error-box { background: var(--bad-soft); border: 1px solid var(--bad); color: var(--bad); padding: .8rem .95rem; border-radius: 3px; margin-bottom: 1rem; font-size: .9rem; }

.muted { color: var(--ink-faint); font-size: .85rem; }
.stat-row { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: .5rem 0 0; }
.stat { min-width: 6rem; }
.stat .v { font-family: var(--mono); font-size: 1.3rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .k { font-size: .7rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); }

footer { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-size: .85rem; color: var(--ink-faint); }
footer p { margin-bottom: .6rem; }

/* The server's CSP is style-src 'self' with no 'unsafe-inline', so a style attribute in the
 * markup is inert. These two replace the ones that were silently doing nothing. */
.tight { margin-bottom: 0; }
.tight-top { margin-top: .75rem; margin-bottom: 0; }
