/* ═══════════════════════════════════════════════════════════════════════════
   MI-5 Knowledge Prototype — "Deep Blue Authority"
   Implements mockups/option-2-deep-blue.html as the live application skin.

   Palette is brand-adjacent-neutral per docs/appendix-d-brand-notes.md: no ICF
   brand hexes, no Plus Jakarta Sans. Gold is rationed to grounding / citation
   semantics only. WCAG 2.1 AA: body/UI text pairs >= 4.5:1.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --navy: #262A5E;
  --navy-deep: #1E2141;
  --blue: #3644A8;
  --blue-deep: #2B3688;
  --canvas: #FAF6ED;
  --panel: #FFFFFF;
  --panel-warm: #FCFBF8;
  --ink: #1E2141;
  --muted: #565A74;
  --gold: #B8922A;
  --gold-bright: #F2D264;

  --on-navy: #DCDEEC;
  --on-navy-soft: #B9BCD8;
  --hair: rgba(30, 33, 65, .12);
  --hair-strong: rgba(30, 33, 65, .20);
  --blue-wash: #EDEFF9;
  --blue-wash-line: #D3D8F0;

  --warn: #8A2B12;
  --warn-bg: #FBEDE8;
  --warn-line: #EFCFC4;

  --display: "Sora", "Sora Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", "Inter Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --shell: 1100px;
  --r: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
h1, h2, h3, h4 { font-family: var(--display); margin: 0; letter-spacing: -.012em; color: var(--ink); font-weight: 600; }
p { margin: 0; }
a { color: var(--blue); }
a:hover { color: var(--blue-deep); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 4px; }
.on-navy :focus-visible, .masthead :focus-visible, .footer :focus-visible { outline-color: var(--gold-bright); }

.shell { max-width: var(--shell); margin: 0 auto; padding: 0 32px; width: 100%; }
main { flex: 1; }
.muted { color: var(--muted); }
.fine-print { color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.visually-hidden, .sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
[hidden] { display: none !important; }
/* crawled text carries bare URLs and DOIs — never let one blow out a column */
.result__snip, .src__snip, .doc__summary, .answer, .abstain__body, .finding__list li,
.meta-grid dd, .steps span.d { overflow-wrap: anywhere; }

/* ───────────────────────────────── masthead ─────────────────────────────── */
.masthead { background: var(--navy); color: #fff; }
/* NB: vertical padding on .shell rows uses longhand + a two-class selector so
   the responsive `.shell { padding: 0 20px }` shorthand can't wipe it out. */
.masthead .masthead__row { display: flex; align-items: center; gap: 28px; min-height: 74px; }
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: 6px; text-decoration: none; }
.brand__mark { font-family: var(--display); font-weight: 700; font-size: 21px; letter-spacing: -.02em; color: #fff; }
.brand__sub {
  font-size: 11.5px; font-weight: 500; letter-spacing: .10em; text-transform: uppercase;
  color: var(--on-navy-soft);
}
.brand:hover .brand__sub { color: #fff; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  position: relative; display: block; padding: 8px 12px 9px;
  font-size: 13.5px; font-weight: 500; color: #E4E5F2; text-decoration: none; border-radius: 6px;
}
.nav a:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.nav a[aria-current] { color: #fff; font-weight: 600; }
.nav a[aria-current]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px;
  background: var(--gold-bright); border-radius: 2px;
}
.who {
  display: flex; align-items: center; gap: 12px;
  padding-left: 22px; margin-left: 6px; border-left: 1px solid rgba(255, 255, 255, .16);
}
.who__name { font-size: 13.5px; font-weight: 500; color: #fff; white-space: nowrap; }
.who form { margin: 0; }
.who__switch {
  font-size: 12px; color: var(--on-navy-soft); text-decoration: none;
  border: 0; border-bottom: 1px solid rgba(185, 188, 216, .5);
  background: none; font-family: inherit; padding: 0; cursor: pointer; white-space: nowrap;
}
.who__switch:hover { color: #fff; border-color: #fff; }

/* role chip — on navy */
.rolechip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(242, 210, 100, .14); border: 1px solid rgba(242, 210, 100, .42);
  color: var(--gold-bright);
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  white-space: nowrap;
}
/* role chip — on light */
.rolechip--light {
  background: var(--blue-wash); border-color: var(--blue-wash-line); color: var(--blue);
}

/* transparency band */
.notice { background: var(--navy-deep); color: var(--on-navy); border-top: 1px solid rgba(255, 255, 255, .08); }
.notice .notice__row {
  display: flex; gap: 14px; align-items: flex-start;
  padding-top: 11px; padding-bottom: 11px;
  font-size: 12.5px; line-height: 1.5;
}
.notice__tag {
  flex: none; margin-top: 1px;
  font-size: 10px; font-weight: 600; letter-spacing: .10em; text-transform: uppercase;
  color: #CBCEE2; padding: 2px 8px; border: 1px solid rgba(255, 255, 255, .24); border-radius: 4px;
}
.notice em, .notice strong { font-style: normal; color: #fff; font-weight: 500; }
.notice .chip--seeded { border-color: rgba(255, 255, 255, .34); color: #CBCEE2; }

/* ───────────────────────────────── sections ─────────────────────────────── */
.sec { padding: 44px 0 56px; }
.eyebrow { display: block; margin-bottom: 14px; }
.eyebrow__label {
  display: block;
  font-family: var(--body); font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted);
}
.eyebrow__rule {
  display: block; margin-top: 9px; height: 2px;
  background:
    linear-gradient(to right, var(--gold) 0 44px, transparent 44px),
    linear-gradient(to right, var(--hair) 0 100%);
  background-repeat: no-repeat;
  background-size: 100% 2px, 100% 1px;
  background-position: 0 0, 0 0;
}
.sec__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.sec__title { font-size: 25px; font-weight: 600; }
.sec__note { font-size: 13px; color: var(--muted); max-width: 36ch; text-align: right; }
.sec__sub { font-size: 13.5px; color: var(--muted); margin-bottom: 22px; max-width: 74ch; }
.sec__sub strong { color: var(--ink); font-weight: 600; }
h2.block-title {
  font-size: 15px; font-weight: 600; letter-spacing: .10em; text-transform: uppercase;
  margin: 34px 0 14px;
}

/* ───────────────────────────── chips & badges ───────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 5px;
  background: #F4F4F8; border: 1px solid var(--hair);
  font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap;
  max-width: 42ch; overflow: hidden; text-overflow: ellipsis;
}
.chip--src { background: var(--blue-wash); border-color: var(--blue-wash-line); color: var(--blue); font-weight: 600; }
.chip--ok { background: #EFF1FA; border-color: var(--blue-wash-line); color: var(--blue); }
.chip--page { font-family: var(--mono); font-size: 10.5px; }
.chip--seeded {
  border-style: dashed; border-color: var(--hair-strong); background: transparent; color: var(--muted);
  font-size: 9.5px; font-weight: 600; letter-spacing: .10em; text-transform: uppercase; padding: 2px 7px;
}
.chip--warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.chip--wrap { white-space: normal; max-width: none; overflow: visible; text-align: left; }
.chip--live {
  background: var(--blue-wash); border-color: var(--blue-wash-line); color: var(--blue); font-weight: 600;
  font-size: 9.5px; letter-spacing: .10em; text-transform: uppercase; padding: 2px 7px;
}
.chip--live .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); flex: none; }

/* ───────────────────────────────── askbar ───────────────────────────────── */
.askbar {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--panel); border: 1px solid var(--hair-strong); border-radius: 12px;
  padding: 13px 14px 13px 18px;
  box-shadow: 0 1px 2px rgba(30, 33, 65, .05), 0 10px 26px -22px rgba(30, 33, 65, .5);
  margin-bottom: 14px;
}
.askbar:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
.askbar__icon { flex: none; color: var(--blue); padding-top: 7px; }
.askbar textarea {
  flex: 1; min-width: 0; border: 0; background: transparent; resize: none;
  font-family: var(--body); font-size: 17px; font-weight: 500; color: var(--ink);
  letter-spacing: -.005em; line-height: 1.45; padding: 5px 0 4px; margin: 0;
  max-height: 180px; overflow-y: auto;
}
.askbar textarea::placeholder { color: #8A8FA8; font-weight: 400; }
.askbar textarea:focus { outline: none; }
.askbar__hint { flex: none; font-size: 11px; color: var(--muted); letter-spacing: .03em; padding-top: 11px; white-space: nowrap; }
.kbd {
  font-family: var(--mono); font-size: 10.5px;
  padding: 2px 6px; border: 1px solid var(--hair-strong); border-bottom-width: 2px; border-radius: 4px;
  background: #F7F7FB; color: var(--muted);
}
.btn-ask {
  flex: none; background: var(--navy); color: #fff; border: 0; border-radius: 8px;
  font-family: var(--body); font-size: 13.5px; font-weight: 600; letter-spacing: .01em;
  padding: 10px 18px; cursor: pointer;
}
.btn-ask:hover { background: var(--blue); }
.btn-ask[disabled] { background: #8A8FA8; cursor: progress; }
.askfoot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 26px; font-size: 12.5px; color: var(--muted); }
.askfoot strong { color: var(--ink); font-weight: 600; }

/* thinking strip */
.ask-status {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r);
  padding: 14px 18px; margin-bottom: 26px;
  font-size: 13.5px; color: var(--muted);
}
.ask-status::before {
  content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold); animation: pulse 1.2s ease-in-out infinite;
}
.ask-status[data-error]::before { background: var(--warn); animation: none; }
.ask-status[data-error] { color: var(--warn); border-color: var(--warn-line); background: var(--warn-bg); }
@keyframes pulse { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }

/* ─────────────────────────── ask grid & answer card ────────────────────── */
.ask-grid { display: grid; grid-template-columns: minmax(0, 1fr) 334px; gap: 26px; align-items: start; }
.ask-rail { grid-column: 2; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 18px; }

/* pre-question hero: what the instrument can return */
.card.card--empty { box-shadow: none; background: transparent; border: 1px dashed var(--hair-strong); }
.card--empty .card__body { padding: 22px 24px 24px; }
.empty__h { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.outcomes { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-top: 14px; }
.outcome { background: var(--panel); border: 1px solid var(--hair); border-radius: 8px; padding: 14px 15px 15px; }
.outcome__k {
  display: flex; align-items: center; gap: 7px;
  font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.outcome__k::before { content: ""; width: 22px; height: 5px; border-radius: 999px; background: linear-gradient(90deg, #D9B348, var(--gold-bright)); flex: none; }
.outcome--no .outcome__k::before { background: linear-gradient(90deg, #9CA1C0, #C2C6DC); }
.outcome p { margin-top: 8px; font-size: 12.8px; line-height: 1.6; color: var(--muted); }
.empty__lbl {
  margin-top: 20px; font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.example {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--hair-strong); border-radius: 999px;
  padding: 7px 14px; font-family: var(--body); font-size: 12.8px; color: var(--ink);
  cursor: pointer; text-align: left;
}
.example:hover { border-color: var(--blue); color: var(--blue); }
.example .tag {
  font-size: 9.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); border: 1px dashed var(--hair-strong); border-radius: 4px; padding: 1px 6px;
}

/* upload: what happens next */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 12px; padding: 13px 18px; border-top: 1px solid var(--hair); font-size: 13px; line-height: 1.55; }
.steps li:first-child { border-top: 0; }
.steps .rank {
  flex: none; width: 20px; height: 20px; border-radius: 6px; margin-top: 1px;
  background: var(--navy); color: var(--gold-bright);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10.5px;
}
.steps b { display: block; font-weight: 600; }
.steps span.d { color: var(--muted); font-size: 12.5px; }

.card {
  background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(30, 33, 65, .05), 0 22px 44px -34px rgba(30, 33, 65, .55);
}
.card__strip { background: var(--navy); color: #fff; padding: 14px 22px 16px; }
.strip__top { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; flex-wrap: wrap; }
.strip__title { font-family: var(--display); font-size: 15px; font-weight: 600; letter-spacing: .005em; color: #fff; flex: none; }
.badge-live {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .11); border: 1px solid rgba(255, 255, 255, .22);
  font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: #fff;
}
.badge-live .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold-bright); flex: none; }
.strip__time { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--on-navy-soft); letter-spacing: .02em; }

/* ══ SIGNATURE: grounding gauge ══ */
.gauge { display: flex; align-items: flex-start; gap: 20px; }
.gauge__lead { flex: none; display: flex; flex-direction: column; gap: 1px; min-width: 74px; }
.gauge__label { font-size: 9.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--on-navy-soft); }
.gauge__value {
  font-family: var(--display); font-size: 22px; font-weight: 600; line-height: 1.05;
  color: var(--gold-bright); letter-spacing: -.012em; font-variant-numeric: tabular-nums;
}
.gauge__instrument { flex: 1; min-width: 170px; padding-top: 7px; }
.gauge__track {
  position: relative; height: 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .13);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .10);
}
.gauge__fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--fill); border-radius: 999px;
  background: linear-gradient(90deg, #D9B348 0%, var(--gold-bright) 100%);
}
.gauge--fill-anim .gauge__fill { animation: gaugeFill 1150ms cubic-bezier(.22, .75, .2, 1) 180ms both; }
@keyframes gaugeFill { from { width: 0; } to { width: var(--fill); } }
.gauge__tick {
  position: absolute; left: var(--at); top: -6px; bottom: -6px; width: 2px;
  transform: translateX(-1px);
  background: #F3F1EA; border-radius: 2px;
  box-shadow: 0 0 0 1.5px rgba(38, 42, 94, .85);
}
.gauge__scale { position: relative; height: 15px; margin-top: 8px; font-size: 9.5px; letter-spacing: .05em; color: var(--on-navy-soft); }
.gauge__scale span { position: absolute; top: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.gauge__min { left: 0; }
.gauge__max { right: 0; }
.gauge__ticklabel { left: var(--at); transform: translateX(-50%); color: #EDEBE3; font-weight: 600; letter-spacing: .03em; }
.gauge__meta {
  flex: none; width: 132px; padding-top: 8px;
  font-size: 11.5px; line-height: 1.5; color: var(--on-navy); text-align: right;
}
.gauge__meta strong { display: block; color: #fff; font-weight: 600; }

/* answer body */
.card__body { padding: 24px 26px 22px; }
.answer { font-size: 15.5px; line-height: 1.72; color: var(--ink); letter-spacing: -.002em; }
.answer > p:first-child { font-weight: 500; }
.answer p + p, .answer ul { margin-top: 13px; }
.answer ul { padding-left: 20px; }
.answer li + li { margin-top: 6px; }
.cite {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 4px; margin: 0 0 0 3px;
  transform: translateY(-2px);
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; line-height: 1;
  color: var(--blue); text-decoration: none;
  background: var(--blue-wash); border: 1px solid var(--blue-wash-line); border-radius: 4px;
  vertical-align: baseline;
}
.cite:hover, .cite:focus-visible { background: var(--blue); border-color: var(--blue); color: #fff; }
.card__foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 26px; border-top: 1px solid var(--hair); background: var(--panel-warm);
}
.foot__ask { font-size: 12.5px; color: var(--muted); margin-right: auto; }
.iconbtn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border: 1px solid var(--hair-strong); border-radius: 7px;
  background: #fff; color: var(--ink);
  font-family: var(--body); font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.iconbtn:hover { border-color: var(--blue); color: var(--blue); }
.iconbtn svg { color: var(--muted); }
.iconbtn:hover svg { color: var(--blue); }
.iconbtn[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-wash); color: var(--blue); }
.iconbtn[aria-pressed="true"] svg { color: var(--blue); }
.foot__done { font-size: 12.5px; font-weight: 600; color: var(--blue); }
.feedback { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* timings ledger under the answer */
.timings {
  display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center;
  margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--hair);
}
.timings .lbl { font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-right: 2px; }

/* ───────────────────────────── sources panel ───────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r); overflow: hidden; }
.panel__head {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 18px; border-bottom: 1px solid var(--hair); background: var(--panel-warm);
}
.panel__title { font-family: var(--display); font-size: 12px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; color: var(--ink); }
.panel__count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.panel__empty { padding: 16px 18px; font-size: 12.8px; color: var(--muted); line-height: 1.6; }
.sources-list { list-style: none; margin: 0; padding: 0; }
.src { display: block; padding: 15px 18px 16px; border-top: 1px solid var(--hair); text-decoration: none; color: inherit; }
.sources-list > li:first-child .src { border-top: 0; }
.src:hover, .src.is-lit { background: #F7F8FD; }
.src.is-lit { box-shadow: inset 3px 0 0 var(--gold); }
.src__row { display: flex; gap: 10px; align-items: flex-start; }
.src__num {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 19px; height: 19px; border-radius: 5px; margin-top: 1px;
  background: var(--navy); color: var(--gold-bright);
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
}
.src__title { font-family: var(--display); font-size: 13.5px; font-weight: 600; line-height: 1.4; color: var(--ink); letter-spacing: -.005em; }
.src:hover .src__title { color: var(--blue); }
.src__meta { margin: 7px 0 0 29px; display: flex; flex-wrap: wrap; gap: 6px; }
.src__snip { display: block; margin: 9px 0 0 29px; font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.src__title { display: block; }
.panel__foot { padding: 11px 18px; border-top: 1px solid var(--hair); background: var(--panel-warm); font-size: 11.5px; line-height: 1.5; color: var(--muted); }

/* ───────────────────────────────── abstain ─────────────────────────────── */
.card--abstain .card__strip { background: var(--navy-deep); }
.card--abstain .gauge__value { color: #EDEBE3; }
.card--abstain .gauge__fill { background: linear-gradient(90deg, #7C81A6 0%, #A3A8C6 100%); }
.card--abstain .badge-live { background: transparent; border-color: rgba(255, 255, 255, .28); color: var(--on-navy); }
.card--abstain .badge-live .dot { background: #A3A8C6; }
.abstain__q { font-size: 13px; color: var(--muted); margin-bottom: 9px; }
.abstain__q b { color: var(--ink); font-weight: 600; }
.abstain__body { font-size: 15px; line-height: 1.65; color: var(--ink); }
.abstain__body strong { font-weight: 600; }
.abstain__layer {
  margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--hair);
  font-size: 12.5px; line-height: 1.6; color: var(--muted);
}
.abstain__layer b { color: var(--ink); font-weight: 600; }
.abstain__rule {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  padding: 2px 7px; border: 1px solid var(--hair-strong); border-radius: 4px; white-space: nowrap;
}

/* gold-ruled aside */
.aside { padding: 18px 20px; border: 1px solid var(--hair); border-left: 3px solid var(--gold); border-radius: 8px; background: #FDFCF9; }
.aside h3 { font-size: 13px; font-weight: 600; letter-spacing: .10em; text-transform: uppercase; margin-bottom: 9px; }
.aside p { font-size: 12.8px; line-height: 1.6; color: var(--muted); }
.aside p + p { margin-top: 9px; }
.aside strong { color: var(--ink); font-weight: 600; }

/* ───────────────────────────────── search ──────────────────────────────── */
.searchbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--hair-strong); border-radius: 10px;
  padding: 10px 12px 10px 16px; margin-bottom: 22px;
  box-shadow: 0 1px 2px rgba(30, 33, 65, .04);
}
.searchbar:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
.searchbar__icon { flex: none; color: var(--blue); display: flex; }
.searchbar input[type="search"] {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 4px 0;
  font-family: var(--body); font-size: 15px; font-weight: 500; color: var(--ink);
}
.searchbar input[type="search"]:focus { outline: none; }
.searchbar input[type="search"]::placeholder { color: #8A8FA8; font-weight: 400; }
.searchbar__n { flex: none; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

.search-grid { display: grid; grid-template-columns: 252px minmax(0, 1fr); gap: 26px; align-items: start; }
.facets {
  background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r); overflow: hidden;
  position: sticky; top: 18px;
}
.facet { padding: 15px 17px; border-top: 1px solid var(--hair); }
.facet:first-child { border-top: 0; }
.facet__h {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 10px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; color: var(--ink);
}
.facet ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.facet ul.is-scroll { max-height: 216px; overflow-y: auto; margin-right: -6px; padding-right: 6px; }
.facet li { display: flex; }
.opt {
  display: flex; align-items: center; gap: 9px; width: 100%;
  font-size: 12.8px; color: var(--ink); cursor: pointer;
  padding: 3px 4px; margin: 0 -4px; border-radius: 5px; font-weight: 400;
}
.opt:hover { background: #F7F8FD; }
.opt input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.box {
  flex: none; width: 14px; height: 14px; border: 1.5px solid var(--hair-strong); border-radius: 3.5px; background: #fff;
  display: flex; align-items: center; justify-content: center; color: transparent;
}
.opt input:checked ~ .box { background: var(--blue); border-color: var(--blue); color: #fff; }
.opt input:focus-visible ~ .box { outline: 2px solid var(--blue); outline-offset: 2px; }
.opt .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt input:checked ~ .t { font-weight: 600; }
.opt .n { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.facet__input {
  width: 100%; font-family: var(--body); font-size: 12.8px; color: var(--ink); background: #fff;
  border: 1px solid var(--hair-strong); border-radius: 6px; padding: 6px 9px;
}
.facet__input::placeholder { color: #8A8FA8; }
.yearrow { display: flex; align-items: center; gap: 8px; }
.yearrow .facet__input { text-align: center; font-family: var(--mono); font-size: 12px; }
.yearrow span { color: var(--muted); }
.rangeval { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 8px; }
.locked {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px; background: var(--blue-wash); border: 1px solid var(--blue-wash-line);
  font-size: 12.5px; color: var(--blue); font-weight: 600;
}
.locked svg { flex: none; }
.facet__note { margin-top: 8px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.facet--actions { display: flex; align-items: center; gap: 12px; background: var(--panel-warm); }

.results { display: flex; flex-direction: column; gap: 12px; }
.results__head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.results__head h2 { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.results__head .n { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-left: auto; }
.result {
  background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r);
  padding: 17px 20px 16px; display: block; text-decoration: none; color: inherit;
}
.result:hover { border-color: var(--blue-wash-line); box-shadow: 0 10px 24px -20px rgba(30, 33, 65, .6); }
.result__title { font-family: var(--display); font-size: 16px; font-weight: 600; letter-spacing: -.008em; color: var(--ink); }
.result:hover .result__title { color: var(--blue); }
.result__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.result__snip { margin-top: 10px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.result__tags {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--hair);
}
.result__tags .lbl { font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-right: 2px; }
.empty {
  background: var(--panel); border: 1px dashed var(--hair-strong); border-radius: var(--r);
  padding: 28px 24px; text-align: center; color: var(--muted); font-size: 13.5px;
}

/* ───────────────────────────── document detail ─────────────────────────── */
.docwrap { display: grid; grid-template-columns: minmax(0, 1fr) 334px; gap: 26px; align-items: start; }
.doc__head { margin-bottom: 22px; }
.doc__title { font-size: 25px; font-weight: 600; line-height: 1.25; }
.doc__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.doc__summary {
  margin-top: 16px; font-size: 14.5px; line-height: 1.68; color: var(--muted);
  padding-left: 14px; border-left: 3px solid var(--gold);
}
.panel__body { padding: 16px 18px 18px; }
.meta-grid { display: grid; grid-template-columns: minmax(120px, 168px) minmax(0, 1fr); gap: 0; }
.meta-grid dt {
  font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
  padding: 10px 14px 10px 0; border-top: 1px solid var(--hair); display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.meta-grid dd { margin: 0; font-size: 13.5px; padding: 10px 0; border-top: 1px solid var(--hair); overflow-wrap: anywhere; }
.meta-grid dt:first-of-type, .meta-grid dd:first-of-type { border-top: 0; }
.meta-grid dd .chip, .meta-grid dd .rolechip { margin: 0 4px 4px 0; }
.lineage {
  background: var(--navy-deep); color: #E4E5F2; border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 11.5px; line-height: 1.6; margin: 0;
}
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 0; border-radius: 8px; font-family: var(--body); font-size: 13.5px; font-weight: 600;
  cursor: pointer; padding: 10px 18px; text-decoration: none;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--blue); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--hair-strong); }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn[disabled] { background: #8A8FA8; cursor: not-allowed; }
.linkish {
  background: none; border: 0; padding: 0; font: inherit; font-size: 12.8px; font-weight: 500;
  color: var(--blue); text-decoration: underline; cursor: pointer;
}

/* ───────────────────────────────── upload ──────────────────────────────── */
.upload-grid { display: grid; grid-template-columns: 334px minmax(0, 1fr); gap: 26px; align-items: start; }
.upload-rail { grid-column: 1; display: flex; flex-direction: column; gap: 18px; }
.upload-grid > .panel, .upload-grid > .metacard { grid-column: 2; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; min-height: 200px; padding: 24px 20px;
  border: 2px dashed var(--hair-strong); border-radius: var(--r); background: var(--panel);
  cursor: pointer; color: var(--ink);
}
.dropzone:hover, .dropzone:focus-within { border-color: var(--blue); background: #F7F8FD; }
.dropzone.dragover { border-color: var(--blue); background: var(--blue-wash); }
.dropzone__icon { color: var(--blue); }
.dropzone__main { font-family: var(--display); font-size: 14px; font-weight: 600; }
.dropzone__sub { font-size: 12.5px; color: var(--muted); }
.dropzone__types { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.metacard { background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r); overflow: hidden; }
.metacard__body { padding: 20px 24px 22px; }
.field { margin-top: 18px; }
.field:first-child { margin-top: 0; }
.field > label, .field__legend, fieldset legend {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 6px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase; color: var(--ink);
}
.field__hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.req {
  font-size: 9.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--gold); border: 1px solid rgba(184, 146, 42, .4); border-radius: 4px; padding: 1px 6px;
}
input, select, textarea {
  font-family: var(--body); font-size: 14px; color: var(--ink); background: #fff;
  border: 1px solid var(--hair-strong); border-radius: 8px; padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-wash); }
select[multiple] { padding: 4px; }
select[multiple] option { padding: 5px 8px; border-radius: 5px; }
select[multiple] option:checked {
  background: linear-gradient(var(--blue-wash), var(--blue-wash));
  color: var(--blue); font-weight: 600;
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 18px; margin-top: 18px; }
.field-row .field { margin-top: 0; }
fieldset { border: 1px solid var(--hair); border-radius: 8px; padding: 12px 14px 14px; margin: 18px 0 0; }
fieldset legend { padding: 0 6px; margin-bottom: 0; }
.checkrow { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: auto; }
.metacard__foot {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 15px 24px; border-top: 1px solid var(--hair); background: var(--panel-warm);
}
.save-status { font-size: 12.8px; color: var(--muted); }
.save-status a { font-weight: 600; }
.save-status[data-error] { color: var(--warn); font-weight: 500; }
.save-status[data-ok] { color: var(--blue); }

/* ───────────────────────────────── census ──────────────────────────────── */
.census-grid { display: grid; grid-template-columns: minmax(0, 1fr) 334px; gap: 26px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r); padding: 20px 20px 19px; }
.stat__n {
  font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -.028em;
  color: var(--navy); line-height: 1.05; font-variant-numeric: tabular-nums; display: block;
}
.stat__l { margin-top: 7px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.stat__src {
  margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--hair);
  font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.ledger { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ledger th, .ledger td { text-align: left; padding: 10px 18px; border-top: 1px solid var(--hair); }
.ledger thead th {
  border-top: 0; background: var(--panel-warm);
  font-family: var(--body); font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.ledger td.num, .ledger th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ledger tbody tr:hover { background: #F7F8FD; }
.ledger tfoot td { border-top: 1px solid var(--hair-strong); font-weight: 600; background: var(--panel-warm); }

.findings { display: flex; flex-direction: column; gap: 12px; }
.finding { background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r); overflow: hidden; }
.finding__head { padding: 14px 20px 15px; border-bottom: 1px solid var(--hair); background: var(--panel-warm); }
.finding__head h3 { font-size: 15px; font-weight: 600; }
.finding__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.finding__body { padding: 16px 20px 18px; }
.finding__list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.finding__list li { position: relative; padding-left: 16px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.finding__list li::before { content: ""; position: absolute; left: 0; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.implications { margin: 0; padding: 0; list-style: none; }
.implications li {
  display: flex; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--hair);
  font-size: 13px; line-height: 1.6;
}
.implications li:first-child { border-top: 0; }
.implications .rank {
  flex: none; width: 18px; height: 18px; border-radius: 5px; margin-top: 2px;
  background: #F4F4F8; border: 1px solid var(--hair);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px; color: var(--muted);
}

/* ─────────────────────────────── gate / login ──────────────────────────── */
.auth-shell {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 56px 24px 72px;
  background:
    radial-gradient(1100px 520px at 50% -8%, rgba(54, 68, 168, .30), transparent 70%),
    var(--navy-deep);
}
.auth-card {
  background: var(--panel); border-radius: 14px; width: 100%; max-width: 460px; overflow: hidden;
  box-shadow: 0 30px 70px -34px rgba(0, 0, 0, .6), 0 2px 4px rgba(0, 0, 0, .18);
}
.auth-card--wide { max-width: 760px; }
.auth-card__rule { height: 3px; background: linear-gradient(to right, var(--gold) 0 64px, var(--hair) 64px); }
.auth-card__body { padding: 30px 34px 34px; }
.auth-kicker {
  font-family: var(--body); font-size: 10.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 12px;
}
.auth-brand { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.auth-brand .m { font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: -.02em; color: var(--navy); }
.auth-brand .s { font-size: 11px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase; color: var(--muted); }
.auth-title { font-size: 21px; font-weight: 600; margin-bottom: 10px; }
.auth-lede { font-size: 13.5px; line-height: 1.65; color: var(--muted); }
.auth-lede em { font-style: normal; color: var(--ink); font-weight: 500; }
.auth-form { margin-top: 22px; }
.auth-form .btn { margin-top: 16px; width: 100%; }
.form-error {
  margin-top: 12px; padding: 9px 12px; border-radius: 7px;
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn);
  font-size: 12.8px; font-weight: 500;
}
.auth-foot {
  padding: 14px 34px; border-top: 1px solid var(--hair); background: var(--panel-warm);
  font-size: 11.5px; line-height: 1.55; color: var(--muted);
}
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 22px; }
.account-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  border: 1px solid var(--hair); border-radius: var(--r); padding: 16px 16px 15px; background: var(--panel-warm);
  margin: 0;
}
.account-card:hover { border-color: var(--blue-wash-line); background: #F7F8FD; }
.account-card strong { font-family: var(--display); font-size: 14.5px; font-weight: 600; }
.account-card .account-user { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.account-card .btn { margin-top: 6px; width: 100%; padding: 8px 14px; font-size: 12.5px; }

/* ───────────────────────────────── footer ──────────────────────────────── */
.footer { background: var(--navy); color: var(--on-navy); }
.footer__rule { height: 2px; background: linear-gradient(to right, var(--gold) 0 44px, rgba(255, 255, 255, .14) 44px); }
.footer .footer__row {
  display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: flex-start;
  padding-top: 30px; padding-bottom: 34px;
}
.footer__brand { display: flex; align-items: baseline; gap: 9px; }
.footer__brand .m { font-family: var(--display); font-weight: 700; font-size: 16px; color: #fff; }
.footer__brand .s { font-size: 10.5px; font-weight: 500; letter-spacing: .10em; text-transform: uppercase; color: var(--on-navy-soft); }
.footer__txt { flex: 1; min-width: 280px; max-width: 620px; font-size: 12.5px; line-height: 1.65; }
.footer__txt strong { color: #fff; font-weight: 600; }

/* ───────────────────────────────── motion ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .gauge--fill-anim .gauge__fill { animation: none; }
  .ask-status::before { animation: none; opacity: 1; }
  * { transition: none !important; }
}

/* ─────────────────────────────── responsive ────────────────────────────── */
@media (max-width: 1040px) {
  .ask-grid, .search-grid, .upload-grid, .census-grid, .docwrap { grid-template-columns: minmax(0, 1fr); }
  .ask-rail, .upload-rail, .upload-grid > .panel, .upload-grid > .metacard { grid-column: auto; }
  .ask-rail, .facets, .upload-rail { position: static; }
  /* deviation from the single-page mockup: the app needs its nav at every
     width, so it wraps under the brand instead of disappearing. */
  .masthead .masthead__row { flex-wrap: wrap; gap: 10px 20px; padding-top: 12px; padding-bottom: 12px; min-height: 0; }
  .nav { margin-left: 0; order: 3; flex-basis: 100%; flex-wrap: wrap; }
  .nav a { padding-left: 0; padding-right: 14px; }
  .nav a[aria-current]::after { left: 0; right: 14px; }
  .who { margin-left: auto; }
  .sec__note { display: none; }
  .sec__head { display: block; }
}
@media (max-width: 720px) {
  .shell { padding: 0 20px; }
  .who { padding-left: 0; margin-left: 0; border-left: 0; }
  .gauge { flex-wrap: wrap; gap: 14px; }
  .gauge__meta { text-align: left; width: auto; padding-top: 0; }
  .gauge__meta strong { display: inline; margin-right: 5px; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .askbar { flex-wrap: wrap; }
  .askbar textarea { flex-basis: 100%; }
  .askbar__hint, .searchbar__n { display: none; }
  .meta-grid { grid-template-columns: minmax(0, 1fr); }
  .meta-grid dd { border-top: 0; padding-top: 0; }
}
