/* Second Line: an audit ledger for a control function.
   Ground is cool and light, ink is near-black with a blue cast, one accent (oxblood) for breaches,
   a muted green-grey for agreement. Serif for what people read; sans for the instrument. */

:root {
  --ground: #f4f6f4;
  --paper: #fbfcfb;
  --ink: #1c2229;
  --ink-soft: #4c5660;
  --muted: #6d7883;
  --rule: #d3d9d3;
  --rule-strong: #a9b3ab;
  --breach: #7a1f2e;
  --breach-wash: #f4e4e4;
  --agree: #4a6a5b;
  --agree-wash: #e5ece7;
  --amber: #8a5a14;
  --mark: #efd9d6;
  --focus: #2b4f8a;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --measure: 66ch;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

h1, h2, h3, .narrative, .summary, .finding, .clause-text, .quote, .lede-text p, .prose p, .prose li, .step-why {
  font-family: var(--serif);
}
h1 { font-size: 2rem; font-weight: 500; line-height: 1.15; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; font-weight: 500; margin: 0 0 .75rem; }
h3 { font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 .5rem; }
.rule-head { border-top: 1px solid var(--ink); padding-top: .5rem; margin-top: 2.5rem; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.rule-head a { font-family: var(--sans); font-weight: 400; }

/* ---------- chrome */
.masthead {
  display: flex; align-items: baseline; gap: 2rem; flex-wrap: wrap;
  padding: 1rem 2rem; border-bottom: 1px solid var(--ink);
}
.wordmark { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.masthead nav { display: flex; gap: 1.25rem; }
.masthead nav a { text-decoration: none; color: var(--ink-soft); padding-bottom: 2px; border-bottom: 2px solid transparent; }
.masthead nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.masthead-meta { margin-left: auto; color: var(--muted); font-size: .85rem; }
.page { max-width: 1180px; margin: 0 auto; padding: 2rem 2rem 4rem; }
.colophon { max-width: 1180px; margin: 0 auto; padding: 1.5rem 2rem 3rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--rule); }
.crumb { color: var(--muted); font-size: .85rem; margin: 0 0 1rem; }
.crumb a { color: var(--muted); }

/* ---------- type helpers */
.id { font-family: var(--sans); letter-spacing: .04em; font-weight: 500; font-size: .86em; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.n { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-style: italic; }
.agree { color: var(--agree); font-weight: 600; }
.disagree { color: var(--breach); font-weight: 600; }
.alert-line { color: var(--breach); border-left: 3px solid var(--breach); padding: .4rem .8rem; background: var(--breach-wash); }
.seal {
  font-family: var(--serif); font-size: 1.05rem;
  border-top: 3px double var(--ink); border-bottom: 3px double var(--ink);
  padding: .7rem 0; margin: 1.5rem 0;
}
.sev { font-size: .75rem; letter-spacing: .04em; padding: .05rem .4rem; border: 1px solid currentColor; border-radius: 2px; white-space: nowrap; }
.sev-high { color: var(--breach); background: var(--breach-wash); }
.sev-medium { color: var(--amber); }
.sev-low { color: var(--muted); }
.status { font-size: .8rem; letter-spacing: .03em; padding: .1rem .45rem; border: 1px solid var(--rule-strong); border-radius: 2px; white-space: nowrap; }
.status-signed { border-color: var(--agree); color: var(--agree); }
.status-awaiting_qa { border-color: var(--amber); color: var(--amber); }
.status-error { border-color: var(--breach); color: var(--breach); }
.status-reviewing, .status-sampling, .status-aggregating { border-style: dashed; }

/* ---------- facts list */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 1rem 0; }
.facts div { display: contents; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts.tight { gap: .2rem 1rem; font-size: .9rem; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
.ledger { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ledger th { text-align: left; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--ink); padding: .4rem .6rem .4rem 0; white-space: nowrap; }
.ledger th.n { text-align: right; }
.ledger td { padding: .5rem .6rem .5rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ledger tr:last-child td { border-bottom-color: var(--rule-strong); }
.ledger.compact td, .ledger.compact th { padding-top: .3rem; padding-bottom: .3rem; }
.chips { max-width: 18rem; }
.chip {
  display: inline-block; font-size: .78rem; letter-spacing: .04em; font-weight: 500;
  padding: 0 .4rem; margin: 0 .25rem .25rem 0; border: 1px solid var(--breach); color: var(--breach); border-radius: 2px;
}
.chip.unbound { border-style: dashed; color: var(--muted); border-color: var(--muted); }
.chip.dismissed { text-decoration: line-through; color: var(--muted); border-color: var(--rule-strong); }
.chip.upheld { background: var(--breach); color: #fff; }
.chip.amended { background: var(--breach-wash); }

/* ---------- home */
.lede { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 3rem; align-items: start; }
.lede-text h1 { font-size: 2.4rem; max-width: 20ch; }
.lede-text p { font-size: 1.12rem; line-height: 1.55; max-width: var(--measure); color: var(--ink); }
.start { border-top: 1px solid var(--ink); padding-top: 1rem; }
.start h2 { margin-bottom: 1rem; }
.choice { display: grid; grid-template-columns: 1.2rem 1fr; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--rule); cursor: pointer; }
.choice input[type="radio"] { margin: .25rem 0 0; accent-color: var(--ink); }
.choice span { line-height: 1.45; }
.text { font: inherit; padding: .35rem .5rem; border: 1px solid var(--rule-strong); background: var(--paper); color: var(--ink); width: 100%; margin-top: .35rem; }
.text::placeholder { color: var(--muted); }
button { font: inherit; font-weight: 500; padding: .55rem 1.1rem; margin-top: 1rem; background: var(--ink); color: #fff; border: 1px solid var(--ink); cursor: pointer; }
button:hover { background: #000; }
.hint { color: var(--muted); font-size: .85rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; align-items: start; }
.prose p { max-width: var(--measure); line-height: 1.6; }
.prose.small p { font-size: .95rem; }
.prose h2, .prose h3, .prose h4 { margin-top: 1.5rem; }
.prose table { font-size: .9rem; }
.prose ul { padding-left: 1.2rem; }

/* ---------- run page */
.run-head .sub { color: var(--ink-soft); max-width: var(--measure); margin: 0; }
.stepper { list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; padding: 0; margin: 2rem 0 1rem; border-top: 1px solid var(--rule-strong); }
.stepper li { padding: .6rem .75rem .6rem 0; border-top: 3px solid transparent; margin-top: -2px; color: var(--muted); }
.stepper li.done { color: var(--ink-soft); border-top-color: var(--rule-strong); }
.stepper li.current { color: var(--ink); border-top-color: var(--ink); }
.step-label { display: block; font-weight: 500; }
.step-why { display: block; font-size: .92rem; line-height: 1.4; color: var(--ink-soft); margin-top: .25rem; max-width: 34ch; }
.live { margin: 1rem 0 2rem; }
.progress { font-weight: 500; }
.log { list-style: none; padding: 0; margin: .5rem 0 0; max-height: 14rem; overflow-y: auto; border-top: 1px solid var(--rule); font-size: .85rem; }
.log li { padding: .2rem 0; border-bottom: 1px solid var(--rule); }
.log time { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); margin-right: .6rem; font-size: .8rem; }
.coverage { display: flex; flex-wrap: wrap; gap: .3rem; margin: .5rem 0; }
.coverage .cell {
  text-decoration: none; font-size: .78rem; letter-spacing: .04em; padding: .15rem .45rem;
  border: 1px solid var(--rule-strong); color: var(--muted); border-radius: 2px; display: inline-flex; gap: .35rem; align-items: baseline;
}
.coverage .cell.cited { border-color: var(--breach); color: var(--breach); background: var(--breach-wash); }
.coverage .cell b { font-weight: 600; }
.aggregate .two-col { margin-top: 1.5rem; }

/* ---------- QA gate */
.gate-alert { border: 0; border-top: 1px solid var(--rule-strong); padding: 1rem 0 .5rem; margin: 1rem 0 0; }
.gate-alert legend { padding: 0 .5rem 0 0; font-weight: 500; }
.gate-item { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, 1fr); gap: 2rem; padding: .9rem 0; border-bottom: 1px solid var(--rule); }
.clause-ref { margin: 0 0 .4rem; }
.clause-ref .id { margin-right: .3rem; }
.quote { margin: .4rem 0; padding: .1rem 0 .1rem .9rem; border-left: 3px solid var(--breach); font-style: italic; color: var(--ink-soft); }
.gate-controls { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-content: start; }
.gate-controls label { white-space: nowrap; }
.gate-controls input[type="radio"] { accent-color: var(--breach); }
.gate-controls .text { flex-basis: 100%; }
.gate-controls .amend { display: none; }
.gate-item:has(input[value="amended"]:checked) .amend { display: block; }
.sign { display: flex; gap: 1.5rem; align-items: end; margin-top: 1.5rem; flex-wrap: wrap; }
.sign label { flex: 1 1 18rem; }
.sign button { margin: 0; }

/* ---------- case page */
.case { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3rem; align-items: start; }
.case.single { grid-template-columns: minmax(0, 760px); }
.id-head { font-family: var(--sans); letter-spacing: .04em; font-weight: 500; font-size: 1.3rem; }
.narrative {
  margin: 0; padding: 1rem 1.25rem; background: var(--paper); border: 1px solid var(--rule);
  font-size: 1.02rem; line-height: 1.65; white-space: pre-line; max-width: var(--measure);
}
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.case-verdict h2 { font-size: 1.5rem; }
.summary { font-size: 1.15rem; line-height: 1.5; margin: 0 0 .25rem; }
.challenge { border-top: 1px solid var(--ink); padding: 1rem 0 1.25rem; }
.challenge.unbound { border-top-style: dashed; border-top-color: var(--rule-strong); color: var(--ink-soft); }
.challenge header { display: flex; flex-wrap: wrap; gap: .5rem .7rem; align-items: baseline; margin-bottom: .6rem; }
.challenge header > .id:first-child { color: var(--muted); }
.clause-title { font-weight: 500; }
.bind-flag { font-size: .75rem; letter-spacing: .04em; color: var(--muted); border: 1px dashed var(--muted); padding: .05rem .4rem; border-radius: 2px; }
.qa { font-size: .75rem; letter-spacing: .04em; padding: .05rem .4rem; border-radius: 2px; border: 1px solid; }
.qa-upheld { color: #fff; background: var(--breach); border-color: var(--breach); }
.qa-amended { color: var(--breach); background: var(--breach-wash); border-color: var(--breach); }
.qa-dismissed { color: var(--muted); border-color: var(--rule-strong); text-decoration: line-through; }
.clause-text { white-space: pre-line; line-height: 1.6; color: var(--ink-soft); margin: 0 0 .6rem; font-size: .98rem; }
.clause-text mark { background: var(--mark); color: var(--ink); box-shadow: inset 0 -2px 0 var(--breach); padding: 0 .1em; }
.finding { font-size: 1.05rem; line-height: 1.5; margin: .4rem 0; }
.bind-note { color: var(--amber); font-size: .88rem; margin: .3rem 0 0; }
.qa-reason { font-size: .92rem; border-left: 3px solid var(--rule-strong); padding-left: .7rem; }
.obs { padding-left: 1.2rem; }
.trace { padding-left: 1.4rem; font-size: .86rem; }
.trace li { padding: .25rem 0; border-bottom: 1px solid var(--rule); }
.trace summary { cursor: pointer; }
.trace .tool { font-weight: 600; }
.trace code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .8rem; color: var(--ink-soft); word-break: break-all; }
.trace pre { white-space: pre-wrap; word-break: break-word; font-size: .78rem; background: var(--paper); border: 1px solid var(--rule); padding: .6rem; margin: .4rem 0 .2rem; max-height: 14rem; overflow: auto; }
.cost-line { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--rule-strong); padding-top: .6rem; margin-top: 1.5rem; }

/* ---------- policy */
.search { display: flex; gap: .75rem; max-width: 42rem; margin: 1rem 0 .5rem; align-items: end; }
.search .text { margin: 0; }
.search button { margin: 0; }
.hits { padding-left: 1.2rem; margin: .5rem 0 0; }
.manual-section { margin-top: 2.5rem; }
.manual-section h2 { border-top: 1px solid var(--ink); padding-top: .5rem; }
.clause { padding: .9rem 0; border-bottom: 1px solid var(--rule); max-width: 76ch; }
.clause header { display: flex; gap: .7rem; align-items: baseline; margin-bottom: .3rem; }
.clause header .id { text-decoration: none; }
.cite-count { margin-left: auto; font-size: .8rem; color: var(--breach); border: 1px solid var(--breach); padding: 0 .4rem; border-radius: 2px; }
.clause-body p { margin: .3rem 0; line-height: 1.6; font-family: var(--serif); font-size: 1rem; color: var(--ink-soft); }
.clause-body table td, .clause-body table th { padding: .2rem .8rem .2rem 0; border-bottom: 1px solid var(--rule); font-family: var(--sans); font-size: .9rem; }

/* ---------- responsive */
@media (max-width: 900px) {
  .lede, .two-col, .case, .gate-item, .pair { grid-template-columns: 1fr; gap: 1.5rem; }
  .stepper { grid-template-columns: 1fr; border-top: 0; border-left: 1px solid var(--rule-strong); margin-left: .25rem; }
  .stepper li { border-top: 0; border-left: 3px solid transparent; margin: 0 0 0 -2px; padding: .4rem .75rem; }
  .stepper li.done { border-left-color: var(--rule-strong); }
  .stepper li.current { border-left-color: var(--ink); }
  .page, .masthead, .colophon { padding-left: 1rem; padding-right: 1rem; }
  .masthead { gap: 1rem; }
  .masthead-meta { margin-left: 0; flex-basis: 100%; }
  h1 { font-size: 1.6rem; }
  .lede-text h1 { font-size: 1.8rem; }
  .facts { grid-template-columns: 1fr; gap: .1rem; }
  .facts dt { margin-top: .5rem; font-size: .85rem; }
  .chips { max-width: none; }
}
