/* Kenny — shared styles.
   Built to WCAG 2.1 AA / Section 508, which is procurement-gating for civil service:
   - every colour pairing below meets 4.5:1 on its background (3:1 for large text)
   - state is never colour alone — every badge carries a word
   - visible focus on every interactive element, 2px, non-colour-only
   - text is not truncated with JS; long strings wrap or clamp with CSS
   - honours prefers-reduced-motion                                              */

:root {
  --navy: #1f3a5f;   /* on white: 10.4:1 */
  --steel: #2c5282;  /* on white: 7.6:1  */
  --light: #eef2f7;
  --grey: #4a5568;   /* on white: 7.5:1  — body secondary text */
  --line: #cbd5e0;
  --flag: #8a2f0f;   /* on #fff4ed: 6.4:1 */
  --flagbg: #fff4ed;
  --ok: #14663c;     /* on white: 6.3:1  */
  --okbg: #f0f9f4;
  --warn: #7c4a03;   /* on #fff8ec: 6.1:1 */
  --warnbg: #fff8ec;
  --bg: #f7f9fc;
  --focus: #0b5fff;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0; background: var(--bg); color: #16202e; line-height: 1.5;
}

/* focus: visible on everything, never removed */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

/* ---------------- header ---------------- */
header {
  background: var(--navy); color: #fff; padding: 14px 22px;
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
}
header h1 { font-size: 18px; margin: 0; font-weight: 700; }
.hdr-sub { font-weight: 400; color: #b9c7db; }
.hdr-tag { color: #cfe0f5; font-size: 13px; margin: 0; }
header nav { margin-left: auto; display: flex; gap: 16px; }
header nav a { color: #dbe4ef; text-decoration: underline; font-size: 14px; padding: 2px 0; }
header nav a:hover { color: #fff; }
header nav a[aria-current="page"] { color: #fff; font-weight: 600; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 10px;
  background: #33517d; color: #e8f0fb; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 20px; }

/* Standing caveat on the hosted build. Full-bleed and above the fold on purpose: a
   shared link reads as a product, and nobody should take a dollar figure off a
   prototype without being told it is one. Colour is not carrying the meaning — the
   text says it. */
.demo-banner {
  margin: 0; padding: 10px 20px; text-align: center;
  background: var(--warnbg); color: var(--warn);
  border-bottom: 2px solid #e3b778;
  font-size: 14px; font-weight: 600; line-height: 1.45;
}

/* ---------------- tabs ---------------- */
.tabs {
  display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--line);
  margin-bottom: 18px;
}
.tab {
  background: none; border: 0; border-bottom: 3px solid transparent;
  color: var(--grey); font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 10px 14px; border-radius: 5px 5px 0 0;
}
.tab:hover { background: var(--light); color: var(--navy); }
.tab[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--navy); background: #fff; }
.pill {
  display: inline-block; min-width: 20px; margin-left: 5px; padding: 1px 6px;
  background: var(--light); color: var(--steel); border-radius: 9px;
  font-size: 11px; font-weight: 700;
}
.tab[aria-selected="true"] .pill { background: var(--navy); color: #fff; }

/* ---------------- panels & type ---------------- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.panel h2 { margin: 0 0 6px; font-size: 18px; color: var(--navy); }
.panel h3 { font-size: 14px; color: var(--navy); margin: 18px 0 6px; }
.lede { color: var(--grey); font-size: 14px; margin: 0 0 16px; max-width: 68ch; }
.help { color: var(--grey); font-size: 12.5px; margin: 4px 0 10px; max-width: 68ch; }
.muted { color: var(--grey); font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.id { font-size: 11px; color: var(--grey); margin: 2px 0 6px; word-break: break-all; }
.empty {
  color: var(--grey); background: var(--light); border: 1px dashed var(--line);
  border-radius: 8px; padding: 18px; text-align: center; font-size: 14px;
}

/* ---------------- toolbar / controls ---------------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.file-label { font-size: 13px; font-weight: 600; color: var(--navy); }
input[type="file"] { font-size: 13px; }
button {
  background: var(--navy); color: #fff; border: 1px solid var(--navy);
  padding: 9px 15px; border-radius: 7px; font-size: 14px; font-weight: 600; cursor: pointer;
}
button:hover { background: #16304f; }
button.ghost { background: #fff; color: var(--navy); }
button.ghost:hover { background: var(--light); }
button.small { padding: 4px 10px; font-size: 12px; font-weight: 600; }
button[disabled] { opacity: .5; cursor: not-allowed; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--navy); cursor: pointer; }

/* ---------------- cards ---------------- */
.dept { margin-bottom: 22px; }
.dept-head {
  font-size: 12px; font-weight: 700; color: var(--navy); text-transform: uppercase;
  letter-spacing: .06em; border-bottom: 1px solid var(--line);
  padding-bottom: 4px; margin: 0 0 8px;
}
.card {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
  margin: 8px 0; background: #fff;
}
.card h4 { margin: 0 0 2px; font-size: 14.5px; color: #16202e; }
.card.rule.ratified { border-left: 4px solid var(--ok); background: var(--okbg); }
.card.rule.invalid { border-left: 4px solid var(--flag); background: var(--flagbg); }
.card.warn-card { border-color: #e3b778; background: var(--warnbg); }
.rule-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.rule-head label { cursor: pointer; }
.rule-head > button { margin-left: auto; }
.expr { margin: 4px 0 0; display: flex; gap: 6px; flex-wrap: wrap; }
code {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  background: var(--light); color: var(--navy); padding: 2px 6px; border-radius: 4px;
  overflow-wrap: anywhere;
}
/* summaries wrap and clamp in CSS — never truncated with an ellipsis in JS */
.summary {
  color: var(--grey); font-size: 13px; margin: 8px 0 4px; max-width: 74ch;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.unlocks { margin: 6px 0 0; padding-left: 18px; }
.unlocks li { margin: 6px 0; font-size: 13px; }
.clause {
  margin: 10px 0; padding: 10px 12px; background: var(--light);
  border-left: 3px solid var(--steel); border-radius: 0 6px 6px 0;
  font-size: 13.5px; line-height: 1.55;
}

/* ---------------- identity chips (department > unit > type > version > dates) --- */
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.chip {
  display: inline-flex; gap: 4px; font-size: 11.5px; padding: 3px 8px; border-radius: 4px;
  border: 1px solid var(--line); background: #fff; color: var(--grey); white-space: nowrap;
}
.chip b { font-weight: 700; }
.chip.lvl0 { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip.lvl0 b { color: #b9c7db; }
.chip.lvl1 { background: var(--steel); color: #fff; border-color: var(--steel); }
.chip.lvl1 b { color: #cfe0f5; }
.chip.lvl2 { background: var(--light); color: var(--navy); }
.chip.lvl2 b { color: var(--steel); }
.tag {
  display: inline-block; background: var(--light); color: var(--steel);
  padding: 2px 9px; border-radius: 10px; font-size: 11.5px;
}

/* ---------------- coverage bar ---------------- */
.cov {
  display: flex; height: 10px; border-radius: 5px; overflow: hidden;
  background: var(--light); margin: 10px 0 6px; border: 1px solid var(--line);
}
.cov span { display: block; height: 100%; }
.cov-live { background: var(--ok); }
.cov-pending { background: var(--steel); }
.cov-blocked { background: #c2793a; }
.cov-narrative { background: #b8c2cf; }
.cov-key { display: flex; flex-wrap: wrap; gap: 12px; list-style: none; padding: 0; margin: 0;
  font-size: 12px; color: var(--grey); }
.cov-key i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.k-live { background: var(--ok); } .k-pending { background: var(--steel); }
.k-blocked { background: #c2793a; } .k-narrative { background: #b8c2cf; }

/* ---------------- extraction scorecard (OCR_TICKETS.md OCR-3) ----------------
   One strip per document card: parse-tier badge, counts, and conditional badges.
   Same AA discipline as the rest of the page — every badge carries a word, never
   colour alone, and each pairing below meets 4.5:1 on its background. */
.score {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin: 4px 0 6px; font-size: 12px;
}
.score-tier { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 9px; }
.tier-good { background: var(--ok); color: #fff; }                        /* 6.3:1 */
.tier-amber { background: var(--warnbg); color: var(--warn); border: 1px solid #e3b778; }
.tier-orange { background: #fff1e6; color: #93430c; border: 1px solid #e0a068; } /* 6.0:1 */
.tier-bad { background: var(--flagbg); color: var(--flag); border: 1px solid #eec0a6; }
.score-stat { color: var(--grey); font-weight: 600; }
.score-badge { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 9px; }
.score-recovered { background: #f3effa; color: #4c3092; border: 1px solid #c9b8ec; } /* 8.0:1 */
.score-empty { background: var(--light); color: var(--grey); border: 1px solid var(--line); }
.score-fail { background: var(--flagbg); color: var(--flag); border: 1px solid #eec0a6; }
.score-lowconf { background: #fdf3e2; color: #7b4a12; border: 1px solid #e3b778; } /* 7.9:1 */
.score-sha {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px;
  background: var(--light); color: var(--steel); padding: 1px 7px;
  border: 1px solid var(--line); border-radius: 4px;
}

/* ---------------- state: colour + a word, never colour alone ---------------- */
.ok { color: var(--ok); font-weight: 700; font-size: 12.5px; }
.bad { color: var(--flag); font-weight: 700; font-size: 12.5px; }
/* An outcome that is neither success nor failure: the ingest worked, but the library is
   incomplete and the reader has to be told which documents are missing and why. */
.warn-text { color: var(--warn); font-weight: 600; }

/* Available to a screen reader, invisible on screen. Not display:none — that would
   remove it from the accessibility tree, which is the opposite of the intent. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* WCAG 2.1: a link opening a new tab must say so. The arrow is the sighted cue and is
   aria-hidden; .sr-only carries the same fact to a screen reader. */
.ext { font-size: 0.8em; opacity: 0.7; }
.card h4 a { color: var(--navy); text-decoration: underline; text-underline-offset: 2px; }
.card h4 a:hover { color: var(--steel); }
.badge-ratified {
  background: var(--ok); color: #fff; font-size: 11px; padding: 2px 8px;
  border-radius: 9px; font-weight: 700;
}
.badge-type {
  background: var(--light); color: var(--steel); font-size: 11px; padding: 2px 8px;
  border-radius: 9px; font-weight: 700;
}
.warn-badge {
  background: var(--warnbg); color: var(--warn); border: 1px solid #e3b778;
  font-size: 11px; padding: 1px 8px; border-radius: 9px; font-weight: 700;
}
.flagline {
  color: var(--flag); background: var(--flagbg); border: 1px solid #eec0a6;
  padding: 9px 11px; border-radius: 7px; font-size: 13px; margin: 8px 0;
}
.notice {
  color: var(--warn); background: var(--warnbg); border: 1px solid #e3b778;
  padding: 9px 11px; border-radius: 7px; font-size: 13px; margin: 8px 0;
}
.notice.ok-notice { color: var(--ok); background: var(--okbg); border-color: #a6d5bd; }
.evt { border-bottom: 1px solid var(--light); padding: 7px 0; font-size: 12px; margin: 0; overflow-wrap: anywhere; }
.evt .t { color: var(--steel); font-weight: 700; }

/* ---------------- drawer (modal) ---------------- */
#drawer {
  position: fixed; top: 0; right: -580px; width: 560px; max-width: 100vw; height: 100%;
  background: #fff; border-left: 1px solid var(--line);
  box-shadow: -6px 0 24px rgba(0,0,0,.12); transition: right .2s ease;
  overflow-y: auto; z-index: 40;
}
#drawer.open { right: 0; }
#drawer .dh {
  background: var(--navy); color: #fff; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; position: sticky; top: 0;
}
#drawer .dh button { margin-left: auto; }
#drawer .db { padding: 16px; }
.cite { margin: 12px 0 0; }
.cite img { width: 100%; border: 1px solid var(--line); border-radius: 6px; }
/* citations-polish (C2/I12): crop first, whole page folded, PDF link last */
figure.cite-figure { margin: 12px 0 0; }
.cite-figure figcaption { margin-bottom: 4px; }
.cite-figure details.cite-full { margin-top: 6px; }
.cite-figure details.cite-full summary { cursor: pointer; color: var(--muted, #666); font-size: 0.9em; }
.cite-figure a.cite-open { display: inline-block; margin-top: 6px; font-size: 0.9em; }
figure { margin: 0; }

/* ---------------- document X-ray (OCR_TICKETS.md OCR-1) ---------------- */
#xray {
  position: fixed; inset: 0; background: rgba(22, 32, 46, .55); z-index: 50;
  overflow-y: auto; padding: 24px 16px;
}
#xray .xpanel {
  background: #fff; border-radius: 10px; max-width: 900px; margin: 0 auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}
#xray .xh {
  background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 10px 10px 0 0;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
#xray .xnav { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#xray .xpage { font-size: 13px; min-width: 96px; text-align: center; }
#xray .xb { padding: 12px 16px 16px; }
.xcounts { color: var(--grey); font-size: 13px; margin: 0 0 6px; }
.xlegend {
  list-style: none; display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 10px;
  padding: 0; font-size: 12px; color: var(--grey);
}
.xlegend i {
  display: inline-block; width: 12px; height: 12px; border: 1px solid;
  border-radius: 3px; margin-right: 5px; vertical-align: -2px;
}
/* The stage wraps the page image exactly (block img, 100% wide), so boxes placed in %
   of the stage land in % of the page regardless of the rendered pixel size. */
.xstage { position: relative; }
.xstage img { display: block; width: 100%; border: 1px solid var(--line); border-radius: 4px; }
.xbox { position: absolute; border: 1px solid; border-radius: 2px; }
.xbox:hover, .xbox:focus, .xbox.active { z-index: 3; }
/* Kind colours: translucent fill + solid border, opaque enough on hover to read as
   selected but never enough to hide the text underneath. `.active` is the same state
   set from the other pane of the Compare view (OCR-2). */
.xk-text { border-color: #2b6cb0; background: rgba(43, 108, 176, .16); }
.xbox.xk-text:hover, .xbox.xk-text:focus, .xbox.xk-text.active { background: rgba(43, 108, 176, .34); }
.xk-table { border-color: #b7791f; background: rgba(183, 121, 31, .18); }
.xbox.xk-table:hover, .xbox.xk-table:focus, .xbox.xk-table.active { background: rgba(183, 121, 31, .36); }
.xk-recovered { border-color: #6b46c1; background: rgba(107, 70, 193, .18); }
.xbox.xk-recovered:hover, .xbox.xk-recovered:focus, .xbox.xk-recovered.active { background: rgba(107, 70, 193, .36); }
.xk-page { border-color: #718096; background: rgba(113, 128, 150, .16); }
.xbox.xk-page:hover, .xbox.xk-page:focus, .xbox.xk-page.active { background: rgba(113, 128, 150, .34); }
/* Low OCR confidence (OCR-7): an amber HATCH layered over the kind fill, so a box
   keeps its kind colour and additionally says "docling's OCR was unsure on this
   page". A hatch, not a second flat tint — table rows are already amber, and a flat
   amber wash would be indistinguishable from them. The tooltip and the count strip
   carry the words; the hatch is the at-a-glance marker. */
.xbox.xlow, .xlegend i.xlow {
  background-image: repeating-linear-gradient(135deg,
    rgba(183, 121, 31, .38) 0 4px, transparent 4px 9px);
}
.xbox .xtip {
  display: none; position: absolute; left: 0; top: 100%; margin-top: 3px;
  background: #16202e; color: #fff; font-size: 12px; line-height: 1.45;
  padding: 6px 9px; border-radius: 6px; width: max-content; max-width: 360px;
  z-index: 4; pointer-events: none;
}
.xbox:hover .xtip, .xbox:focus .xtip { display: block; }

/* ---------------- side-by-side Compare (OCR_TICKETS.md OCR-2) ---------------- */
/* Compare reuses the X-ray dialog; `.compare` widens the panel and splits the body
   ~55/45 — rendered page left, extracted text right. min-width:0 on both flex items
   lets long extracted lines wrap instead of forcing the panel past the viewport, so
   nothing overflows at 1280px. */
#xray.compare .xpanel { max-width: 1240px; }
.xsplit { display: flex; gap: 14px; align-items: flex-start; }
.xsplit .xstage { flex: 1 1 55%; min-width: 0; }
.xtext {
  flex: 1 1 45%; min-width: 0; max-height: 78vh; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 4px; background: #fff;
}
.xrow {
  display: flex; gap: 8px; padding: 7px 10px; font-size: 13px; line-height: 1.5;
  border-bottom: 1px solid var(--line);
}
.xrow:last-child { border-bottom: 0; }
/* Rows carry the same xk-* kind classes as their boxes (for the dot's colour); the
   row itself stays neutral until hovered/actived, then tints in its kind's colour. */
.xtext .xrow { background: #fff; border-color: var(--line); }
.xtext .xrow.xk-text:hover, .xtext .xrow.xk-text.active { background: rgba(43, 108, 176, .13); }
.xtext .xrow.xk-table:hover, .xtext .xrow.xk-table.active { background: rgba(183, 121, 31, .15); }
.xtext .xrow.xk-recovered:hover, .xtext .xrow.xk-recovered.active { background: rgba(107, 70, 193, .15); }
.xtext .xrow.xk-page:hover, .xtext .xrow.xk-page.active { background: rgba(113, 128, 150, .13); }
/* Low OCR confidence (OCR-7): the row rests on an amber tint (unlike the kind
   colours, which only appear on hover — the reader must see the warning without
   pointing at anything); the hover/active kind tints above still win over it,
   carrying one more class/pseudo-class of specificity. */
.xtext .xrow.xlow, .xtable tr.xlow { background: #fdf3e2; }
.xdot { flex: none; width: 10px; height: 10px; border: 1px solid; border-radius: 50%; margin-top: 5px; }
.xrow-body { min-width: 0; overflow-wrap: anywhere; }
.xrow-no { font-weight: 600; color: var(--navy); }
.xrow-loose-head { font-size: 12px; margin: 8px 10px 0; }

/* ---------------- table X-ray (OCR_TICKETS.md OCR-5) ---------------- */
/* A majority-table page renders its rows as the grid they were on paper. Compact on
   purpose: these tables run to 27+ rows inside a pane that is ~45% of the panel. A
   wide salary table scrolls sideways in its wrapper instead of crushing the cells. */
.xtable-wrap { overflow-x: auto; }
.xtable { border-collapse: collapse; width: 100%; font-size: 12.5px; line-height: 1.45; }
.xtable caption { text-align: left; color: var(--grey); font-size: 12px; padding: 6px 10px 4px; }
.xtable th, .xtable td {
  border: 1px solid var(--line); padding: 4px 8px; text-align: left;
  vertical-align: top; overflow-wrap: anywhere;
}
.xtable th { background: var(--light); color: var(--navy); font-weight: 600; font-size: 11.5px; }
/* The bare xk-* kind classes carry the box fill; a table row stays neutral until
   hovered/actived (same convention as .xtext .xrow above). */
.xtable tbody tr { cursor: pointer; background: #fff; }
/* Rows tint in their kind's colour on hover/active — the same amber/purple language
   as their boxes on the page, and the same .active set from the stage side. */
.xtable tr.xk-table:hover, .xtable tr.xk-table:focus, .xtable tr.xk-table.active { background: rgba(183, 121, 31, .15); }
.xtable tr.xk-recovered:hover, .xtable tr.xk-recovered:focus, .xtable tr.xk-recovered.active { background: rgba(107, 70, 193, .15); }

@media (max-width: 900px) {
  .xsplit { flex-direction: column; }
  .xsplit .xstage, .xtext { flex: none; width: 100%; }
  .xtext { max-height: 42vh; }
}

/* ---------------- chat ---------------- */
#log { display: flex; flex-direction: column; gap: 14px; margin-bottom: 96px; }
.msg { padding: 12px 15px; border-radius: 12px; max-width: 92%; }
.msg.user { align-self: flex-end; background: var(--navy); color: #fff; }
.msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.route { font-size: 12.5px; color: var(--grey); margin-bottom: 8px; overflow-wrap: anywhere; }
.total { font-size: 24px; font-weight: 700; color: var(--navy); margin: 6px 0 10px; }
/* Phone-proof answer card (DEMO_TICKETS I2): no cell may force the bubble wider than
   the screen, and the only way into the audit drawer — the amount — is thumb-sized. */
.lines-wrap { overflow-x: auto; max-width: 100%; }
table.lines { border-collapse: collapse; width: 100%; margin-top: 6px; font-size: 14px; }
table.lines th, table.lines td {
  border: 1px solid var(--line); padding: 7px 9px; text-align: left; overflow-wrap: anywhere;
}
table.lines th { background: var(--navy); color: #fff; font-weight: 600; }
table.lines caption { text-align: left; font-size: 12.5px; color: var(--grey); padding-bottom: 4px; }
.amount {
  cursor: pointer; color: var(--steel); font-weight: 700;
  text-decoration: underline; text-underline-offset: 2px; background: none; border: 0;
  font-size: 14px; font-family: inherit;
  min-height: 44px; min-width: 44px; padding: 10px 4px;
  display: inline-flex; align-items: center;
}
.amount:hover { color: var(--navy); }
/* The headline figure is the same button, at headline size. */
.total .amount.total-btn { font-size: inherit; color: var(--navy); padding: 6px 0; }
.total .amount.total-btn:hover { color: var(--steel); }

/* Request lifecycle (DEMO_TICKETS I1): the pending bubble holds the answer's place. */
.msg.pending { display: flex; gap: 8px; align-items: center; color: var(--grey); }
.msg.pending .spin { flex: none; }
.msg.error .flagline { margin-top: 0; }

/* Refusal (DEMO_TICKETS I6): one plain paragraph and one link. */
.notice.refusal { font-size: 14px; }
.refusal-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.refusal-text { margin: 4px 0 8px; line-height: 1.55; }
.refusal-link { color: var(--warn); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* Home-page examples (DEMO_TICKETS I16): three buttons, one per behaviour. */
.examples { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; }
button.example {
  display: block; width: 100%; text-align: left; font-weight: 500; font-size: 14px;
  padding: 9px 12px; min-height: 44px; white-space: normal; line-height: 1.4;
}
button.example .ex-kind {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--steel); margin-right: 8px;
}

/* Drawer: ids live under a closed disclosure (DEMO_TICKETS I4). */
details.tech { margin-top: 12px; font-size: 12.5px; }
details.tech summary { color: var(--grey); cursor: pointer; }
details.tech .mono { font-size: 11.5px; overflow-wrap: anywhere; margin: 4px 0; }
.policy-answer { font-size: 15px; line-height: 1.6; margin: 6px 0 4px; max-width: 72ch; }
.source-chip {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; margin: 6px 0;
  cursor: pointer; font-size: 13px; background: #fff; display: block; width: 100%;
  text-align: left; color: inherit; font-family: inherit;
}
.source-chip:hover { border-color: var(--steel); background: var(--light); }
.source-chip .src-text {
  color: var(--grey); display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
/* extraction-tier chip (OCR-4): where the cited text came from — quiet on purpose,
   it annotates the citation rather than competing with it */
.tier-chip {
  display: inline-block; font-size: 10.5px; line-height: 1.5; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--grey);
  background: var(--light); white-space: nowrap; vertical-align: 1px; cursor: help;
}
.confirm { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.trace-step { border-left: 3px solid var(--line); padding: 5px 0 5px 10px; margin: 6px 0; font-size: 13px; }
.trace-step.chosen { border-color: var(--ok); }
.trace-step.flag { border-color: var(--flag); }
.trace-step .k { color: var(--grey); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
#bar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
  border-top: 1px solid var(--line); padding: 12px; }
#bar .inner { max-width: 1000px; margin: 0 auto; display: flex; gap: 10px; }
#prompt {
  flex: 1; min-width: 0; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 16px; font-family: inherit;   /* 16px: iOS zooms the page on smaller inputs */
}
#prompt[disabled] { background: var(--light); color: var(--grey); }

/* ---------------- live upload stages (OCR_TICKETS.md OCR-6) ----------------
   The async upload job walks parsing → tagging → indexing → done; this strip shows
   the walk. State is never colour alone: passed stages carry a ✓, the running stage
   a spinner, pending stages plain grey text. */
.stages {
  display: flex; align-items: center; flex-wrap: wrap; gap: 7px;
  margin: 8px 0; font-size: 12.5px;
}
.stages .stage { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.stage-done { color: var(--ok); }
.stage-active { color: var(--navy); }
.stage-todo { color: var(--grey); font-weight: 400; }
.stage-sep { color: var(--line); }
.stage-mark { font-weight: 700; }
.spin {
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--navy);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.upload-result { margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  /* With the rotation gone the spinner ring still marks the running stage. */
  .spin { border-color: var(--navy); border-top-color: var(--line); }
}
@media (max-width: 640px) {
  .wrap { padding: 12px; }
  .panel { padding: 14px; }
  #drawer { width: 100vw; right: -100vw; }
  .msg { max-width: 100%; }
  header { padding: 10px 12px; gap: 8px; }
}
.card.gap-actionable { border-left: 4px solid var(--steel); }

/* ---------------- guided demo tour (tour.js — both pages) ---------------- */
.tour-start {
  background: #33517d; color: #e8f0fb; border: 1px solid #587bab; border-radius: 10px;
  font-size: 12px; padding: 3px 10px; cursor: pointer;
}
.tour-start:hover { background: #3c5f92; color: #fff; }
/* The coach-mark card floats above every surface it points at (drawer z=40, X-ray z=50). */
.tour-card {
  position: fixed; z-index: 200; width: min(360px, calc(100vw - 24px));
  background: #fff; color: #16202e; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3); padding: 14px 16px;
}
.tour-card h3 { margin: 0 0 6px; font-size: 15px; color: var(--navy); }
.tour-card p { margin: 0 0 10px; font-size: 13px; color: var(--grey); }
.tour-card .tour-note {
  color: var(--warn); background: var(--warnbg); padding: 6px 8px; border-radius: 6px;
}
.tour-foot { display: flex; align-items: center; gap: 8px; }
.tour-progress { font-size: 12px; color: var(--grey); margin-right: auto; }
.tour-next {
  background: var(--steel); color: #fff; border: 0; border-radius: 6px;
  padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.tour-next:hover { background: var(--navy); }
.tour-next:disabled { opacity: .6; cursor: default; }
.tour-end {
  background: none; border: 1px solid var(--line); color: var(--grey);
  border-radius: 6px; padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.tour-end:hover { color: #16202e; }
/* Target highlight: a class, never inline styles, so ending the tour removes it fully. */
.tour-glow {
  outline: 3px solid var(--focus) !important; outline-offset: 3px;
  box-shadow: 0 0 0 7px rgba(11, 95, 255, .18) !important;
  border-radius: 4px;
}

/* ---------------- search tree + cited math line (DEMO_TICKETS.md L3, C1/I13) ----
   Audit drawer only. Plain indented lists: no fixed widths, wraps at 375px under the
   existing #drawer{width:100vw} rule. Rejected branches are greyed, never hidden —
   the reason stays readable; the badge says who decided each fork. */
.counts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--grey); margin: 8px 0 6px; }
.counts b { color: var(--navy); font-weight: 600; }
.tree, .tree ol { list-style: none; margin: 0; padding: 0; }
.tree > .node { margin: 6px 0; }
.tree ol { margin: 3px 0 0 6px; padding-left: 10px; border-left: 1px solid var(--line); }
.node { padding: 2px 0 2px 2px; font-size: 13px; overflow-wrap: anywhere; }
.node.fork > .nl { font-weight: 600; color: var(--navy); }
.node.rejected { color: var(--grey); opacity: .78; }
.node.rejected > .nl::before { content: "\2717\00a0"; color: var(--grey); }
.node.chosen > .nl::before { content: "\2713\00a0"; color: var(--ok); }
.node.info > .nl { font-style: italic; color: var(--grey); }
.node .why { color: var(--grey); font-style: italic; }
.node .tally { color: var(--grey); font-size: 11px; }
.node .badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; margin-right: 6px; vertical-align: 1px; font-weight: 600; letter-spacing: .02em; }
.badge.fixed { background: var(--light); color: var(--grey); border: 1px solid var(--line); }
.badge.ai { background: #eef3ff; color: #2a4a9a; border: 1px solid #c8d6f5; }
.badge.human { background: #edf7ee; color: #2b6a3a; border: 1px solid #c7e3cc; }
.badge.user { background: #fff6e5; color: #7a4b00; border: 1px solid #f0d9a8; }
.node details > summary { cursor: pointer; color: var(--grey); font-size: 12px; margin-top: 2px; }
.node details > summary:hover { color: var(--navy); }
.tree button.ref {
  background: none; border: 1px dashed var(--line); border-radius: 6px; padding: 0 6px;
  font: inherit; font-size: 12px; color: var(--steel); cursor: pointer; margin-left: 4px;
  max-width: 100%; overflow-wrap: anywhere; text-align: left;
}
.tree button.ref:hover { border-style: solid; color: var(--navy); }
.math-line .math-row { font-size: 15px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px; }
.math-line .op {
  font: inherit; font-size: 15px; background: none; border: 0; border-bottom: 2px solid var(--steel);
  color: var(--navy); cursor: pointer; padding: 0 2px; font-variant-numeric: tabular-nums;
}
.math-line .op:hover { background: var(--light); }
.math-line .op.unsourced { border-bottom-color: var(--warn); color: var(--warn); }
.math-line .x { color: var(--grey); margin: 0 4px; }
.math-line .eq { font-weight: 600; color: var(--navy); margin-left: 2px; }
.tree-host { margin-top: 8px; }

/* --- replay control (drawer header, F1 / KEN-102) ---------------------------- */
.replay { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; flex-wrap: wrap; }
.replay .replay-btn { font-size: 13px; padding: 4px 10px; }
.replay .replay-out { font-size: 13px; }
.replay .replay-ok { color: #1f7a3a; font-weight: 600; }
.replay .replay-bad { color: #b42318; font-weight: 600; }
.replay .replay-none { color: var(--grey, #777); }
