/* =============================================================================
   styles.css - Firm Vault Portal
   -----------------------------------------------------------------------------
   FOREST DARK theme, shared with the Memento product surfaces. This is a legal
   document reader, so it is still laid out like paper: solid surfaces, hairline
   rules, no glass, no glow, essentially no gradients. Only the ground inverted.

   Contrast: every body-text/background pair below is >= 4.5:1 (WCAG AA), and
   every border that identifies an interactive control is >= 3:1. Measured
   ratios are noted beside each token.

   The page is theme-locked: dark everywhere, no panel inverts.
   ========================================================================== */

/* ------------------------------------------------------------------ Fonts -- */
/* Self-hosted, shared with the rest of the site. Relative paths, so the page is
   still identical online, offline and from file://. */
@font-face {
  font-family: "Geist";
  src: url("../../assets/fonts/geist-var.woff2") format("woff2-variations"),
       url("../../assets/fonts/geist-var.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("../../assets/fonts/geist-mono-var.woff2") format("woff2-variations"),
       url("../../assets/fonts/geist-mono-var.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("../../assets/fonts/eb-garamond-var.woff2") format("woff2-variations"),
       url("../../assets/fonts/eb-garamond-var.woff2") format("woff2");
  font-weight: 400 800; font-style: normal; font-display: swap;
}

:root {
  /* ---- Forest ground ---------------------------------------------------- */
  --paper:       #0f1a16;   /* page ground - deep forest                     */
  --paper-2:     #131f1a;   /* sunken: audit log, code, meta strip           */
  --surface:     #17241f;   /* raised: panels and cards                      */
  --surface-2:   #1d2c26;   /* inset inside a panel                          */

  /* ---- Rules ------------------------------------------------------------ */
  --line:        #24352d;   /* decorative hairline (hr, table cells)         */
  --line-ui:     #6e8479;   /* control borders - 4.44:1 paper / 3.64 inset   */
  --line-strong: #8ba297;   /* hover / open - 6.54:1 on paper                */

  /* ---- Type ------------------------------------------------------------- */
  --ink:         #ede9df;   /* 14.68:1 on paper - bone                       */
  --ink-2:       #c8d0c7;   /* 11.28:1 on paper                              */
  --muted:       #93a29a;   /*  6.68:1 on paper                              */
  --muted-2:     #8b9a92;   /*  6.05:1 on paper, 5.76:1 on paper-2           */

  /* ---- Signal colours that survive the dark ground ----------------------
     Two families only, so the screen never carries more than two accents:
       terracotta = something is wrong (STALE, DENIED)
       lit sage   = something is informational (updates, ok)                 */
  --warn:        #e8795a;   /* STALE   - 6.20:1 paper, 5.82:1 on --warn-bg   */
  --warn-bg:     #2a1a15;
  --info:        #a8c48a;   /* updates - 9.26:1 paper, 8.31:1 on --info-bg   */
  --info-bg:     #1c2418;
  --deny:        #f08a72;   /* DENIED / walled - 7.28:1 paper, 6.82 on bg    */
  --deny-bg:     #2e1815;
  --ok:          #9dc07f;   /* entitled - 8.71:1 paper, 7.86:1 on --ok-bg    */
  --ok-bg:       #1a2416;
  --accent:      #d9a441;   /* links, kickers, focus - 7.91:1 on paper       */
  --mark:        #4a3a12;   /* search highlight - ink on it is 9.09:1        */

  /* ---- Type stacks ------------------------------------------------------ */
  --font-ui: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-read: "EB Garamond", "Iowan Old Style", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* ---- Layout ----------------------------------------------------------- */
  --container: 1240px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);       /* very soft; no glow        */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root { color-scheme: dark; }

/* ----------------------------------------------------------------- Reset -- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 200;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

code, kbd { font-family: var(--font-mono); font-size: 0.88em; color: var(--ink-2); }

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 5px;
  text-align: center;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line-ui);
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* -------------------------------------------------------- App header ----- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--paper);          /* solid — no backdrop-filter           */
  border-bottom: 1px solid var(--line);
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: var(--container);
  margin-inline: auto;
  padding: 10px clamp(14px, 4vw, 32px);
}

.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 650; letter-spacing: -0.01em; font-size: 0.98rem; line-height: 1.25; }
.brand-sub { color: var(--muted-2); font-size: 0.76rem; line-height: 1.3; }

.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px; height: 32px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--paper);
  background: var(--ink);
}

.identity { display: inline-flex; align-items: center; gap: 9px; }
.identity-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.identity-select {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-ui);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease);
}
.identity-select:hover { border-color: var(--line-strong); }

/* Entitlement readout — secondary chrome: quiet, small, one line where it fits */
.entitlement-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  max-width: var(--container);
  margin-inline: auto;
  padding: 0 clamp(14px, 4vw, 32px) 9px;
}
.entitlement-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--muted-2);
}
.entitlement-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.part-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 1px 8px;
  border-radius: 4px;
  border: 1px solid var(--line-ui);
  background: var(--ok-bg);
  color: var(--ok);
  white-space: nowrap;
}
.part-chip.walled {
  background: var(--deny-bg);
  color: var(--deny);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}
.entitlement-note { color: var(--muted-2); font-size: 0.76rem; }

/* ------------------------------------------------------------- Search ---- */
main { max-width: var(--container); margin-inline: auto; padding: 0 clamp(14px, 4vw, 32px) 48px; }

.search-band { padding: clamp(20px, 3.2vw, 30px) 0 clamp(14px, 2vw, 20px); }

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 5px 5px 40px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line-ui);
  box-shadow: var(--shadow);
  transition: border-color 0.2s var(--ease);
}
.search-field:focus-within { border-color: var(--accent); }
.search-icon {
  position: absolute;
  left: 14px;
  display: grid;
  place-items: center;
  width: 18px; height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.search-icon svg { width: 18px; height: 18px; }

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  padding: 9px 2px;
}
.search-input::placeholder { color: var(--muted-2); }
.search-input:focus { outline: none; }

/* -------------------------------------------------------------- Buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid var(--line-ui);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

.btn-primary { color: var(--paper); background: var(--accent); border-color: var(--accent); }  /* 7.91:1 */
.btn-primary:hover { background: #e8bc63; border-color: #e8bc63; }

.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-strong); }

.search-submit { flex: none; }

/* Small inline control (score toggle, compare, audit clear) */
.mini-btn {
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line-ui);
  border-radius: 5px;
  padding: 2px 9px;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.mini-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.mini-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* Example query chips */
.chips {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.chips-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--muted-2);
}
.chips-list { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-ui);
  color: var(--ink-2);
  font-family: var(--font-ui);
  font-weight: 550;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.chip:hover { background: var(--surface-2); border-color: var(--line-strong); }
.chip.active { color: var(--paper); background: var(--ink); border-color: var(--ink); }

/* Keyboard shortcut hint — quiet, one line */
.shortcut-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 12px;
  margin: 12px 0 0;
  font-size: 0.76rem;
  color: var(--muted);
}
.shortcut-hint span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

/* Honesty notes — the two caveats that must stay surfaced in the UI */
.honesty {
  margin: 16px 0 0;
  padding: 10px 0 10px 14px;
  border-left: 2px solid var(--line-ui);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}
.honesty p { margin: 0; }
.honesty p + p { margin-top: 7px; }
.honesty strong { color: var(--ink-2); }

/* --------------------------------------------------------- Workspace ----- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(14px, 1.8vw, 20px);
  align-items: start;
}

/* Paper card. No glass, no gradient hairline — a border-colour shift is enough. */
.panel {
  position: relative;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line-ui);
  box-shadow: var(--shadow);
  padding: clamp(14px, 2vw, 20px);
}

.panel-head { margin-bottom: 14px; }
.section-kicker {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted-2);
}
.section-title {
  font-weight: 650;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  margin: 3px 0 0;
}
.panel-sub { color: var(--muted); font-size: 0.8rem; margin: 4px 0 0; }

.head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.head-tools { display: inline-flex; align-items: center; gap: 7px; flex: none; }

/* ------------------------------------------------------------ Results ---- */
/* More breathing room between results than the old 12px grid. */
.results { display: flex; flex-direction: column; }

.result {
  position: relative;
  padding: 16px 2px 18px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  transition: background 0.18s var(--ease);
}
.results > .result:first-child { border-top: 0; padding-top: 4px; }

.result::before {
  /* left status rule; only painted for flagged rows */
  content: "";
  position: absolute;
  left: -14px; top: 12px; bottom: 12px;
  width: 3px;
  border-radius: 2px;
  background: transparent;
}
.result.is-stale::before { background: var(--warn); }
.result.is-injected::before, .result.is-reordered::before { background: var(--info); }
.result.is-open::before { background: var(--ink); }

.result.is-open { background: var(--surface-2); }
.result.is-selected { background: var(--surface-2); }

.result-title { font-size: 0.98rem; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 3px; }
.result-open {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
/* Stretched hit area: the whole row opens the note, while the action buttons
   below stay independently clickable (they sit above it on the z axis). */
.result-open::after { content: ""; position: absolute; inset: 0; }
.result-open:hover { color: var(--accent); }
.result:hover { background: var(--surface-2); }

.result-meta {
  font-family: var(--font-mono);
  font-size: 0.71rem;
  color: var(--muted-2);
  margin: 0 0 7px;
  word-break: break-all;
}
.result-excerpt { color: var(--muted); font-size: 0.85rem; margin: 0; }
.result-excerpt mark { background: var(--mark); color: var(--ink); border-radius: 2px; padding: 0 2px; }

.result-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 10px;
}
.result-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.result-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted-2);
  border: 1px solid var(--line);
  padding: 0 6px;
  border-radius: 4px;
}
.result-actions { position: relative; z-index: 1; display: inline-flex; gap: 6px; }
/* Debug-ish and only an approximation — hidden behind the "scores" toggle. */
.result-score {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted-2);
  margin-left: auto;
  white-space: nowrap;
}

/* Freshness badges — the only place a signal colour appears at full strength */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 7px;
  border-radius: 4px;
  margin: 0 0 6px;
}
.badge-stale    { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.badge-updated  { background: var(--info-bg); color: var(--info); border: 1px solid var(--line-ui); }
/* Solid fill, same olive hue — distinguished from ⓘ by weight, not by a third colour. */
.badge-surfaced { background: var(--info); color: var(--paper); border: 1px solid var(--info); }
.badge-note { display: block; color: var(--muted); font-size: 0.78rem; margin: 0 0 7px; }

.results-empty {
  padding: 16px 0 4px;
  color: var(--muted);
  font-size: 0.86rem;
}
.results-empty strong { color: var(--ink); }
.results-empty .wall-explain {
  margin: 10px 0 0;
  padding: 11px 13px;
  border-radius: var(--radius);
  background: var(--deny-bg);
  border: 1px solid var(--line-ui);
  border-left: 3px solid var(--deny);
  color: var(--deny);
  font-size: 0.82rem;
}

/* ------------------------------------------------------------- Reader ---- */
.reader-panel { position: sticky; top: 96px; max-height: calc(100vh - 124px); display: flex; flex-direction: column; }
.reader { overflow-y: auto; padding-right: 4px; }

.reader-placeholder { color: var(--muted); font-size: 0.86rem; }

.reader-title { font-size: 1.12rem; font-weight: 650; letter-spacing: -0.015em; margin: 0 0 3px; }
.reader-path {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted-2);
  margin: 0 0 12px;
  word-break: break-all;
}

/* Frontmatter metadata strip */
.meta-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px 14px;
  margin: 0 0 14px;
  padding: 11px 13px;
  border-radius: var(--radius);
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.meta-strip div { min-width: 0; }
.meta-strip dt {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-2);
}
.meta-strip dd { margin: 2px 0 0; font-size: 0.81rem; font-weight: 600; color: var(--ink-2); }

/* Freshness banner on a direct read — mirrors gateway bannerFor() */
.fresh-banner {
  margin: 0 0 14px;
  padding: 11px 13px;
  border-radius: var(--radius);
  font-size: 0.84rem;
  line-height: 1.5;
  border: 1px solid var(--line-ui);
}
.fresh-banner.strong { background: var(--warn-bg); border-left: 3px solid var(--warn); color: var(--warn); }
.fresh-banner.soft   { background: var(--info-bg); border-left: 3px solid var(--info); color: var(--info); }
.fresh-banner .banner-actions { display: inline-flex; gap: 6px; margin-left: 4px; }

/* Denial card — the gateway's replyErr surface */
.deny-card {
  padding: 15px 17px;
  border-radius: var(--radius);
  background: var(--deny-bg);
  border: 1px solid var(--line-ui);
  border-left: 3px solid var(--deny);
}
.deny-card h3 { font-size: 0.96rem; margin: 0 0 7px; color: var(--deny); }
.deny-msg {
  font-family: var(--font-mono);
  font-size: 0.79rem;
  color: var(--deny);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 9px 11px;
  border-radius: 5px;
  margin: 0 0 9px;
  word-break: break-word;
}
.deny-why { color: var(--muted); font-size: 0.81rem; margin: 0; }

/* Rendered markdown — serif, because it is a document */
.md { font-family: var(--font-read); font-size: 0.95rem; line-height: 1.65; color: var(--ink-2); }
.md h1, .md h2, .md h3 {
  font-family: var(--font-ui);
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 20px 0 7px;
  line-height: 1.3;
}
.md h1 { font-size: 1.08rem; }
.md h2 { font-size: 0.98rem; }
.md h3 { font-size: 0.9rem; }
.md h1:first-child, .md h2:first-child { margin-top: 0; }
.md p { margin: 0 0 11px; }
.md ul, .md ol { margin: 0 0 11px; padding-left: 20px; }
.md li { margin: 0 0 4px; }
.md strong { color: var(--ink); font-weight: 650; }
.md em { color: var(--ink-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.md blockquote {
  margin: 0 0 11px;
  padding: 7px 12px;
  border-left: 2px solid var(--line-ui);
  background: var(--surface-2);
  border-radius: 0 5px 5px 0;
  color: var(--muted);
}
.md code { background: var(--paper-2); border: 1px solid var(--line); padding: 0 4px; border-radius: 4px; }
.md pre {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  overflow-x: auto;
  margin: 0 0 11px;
}
.md pre code { background: none; border: 0; padding: 0; }
.md table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin: 0 0 12px; font-family: var(--font-ui); }
.md th, .md td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }
.md th { background: var(--paper-2); font-weight: 650; }
.md .table-scroll { overflow-x: auto; }

/* Wikilinks — real buttons that issue a read_note call */
.wikilink {
  font-family: var(--font-ui);
  font-size: 0.9em;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line-ui);
  border-radius: 4px;
  padding: 0 6px;
  cursor: pointer;
  transition: background 0.18s var(--ease);
}
.wikilink:hover { background: var(--mark); }

/* -------------------------------------------------------------- Audit ---- */
/* Secondary chrome: collapsible, so it is available without competing. */
.audit-panel { margin-top: clamp(14px, 1.8vw, 20px); }
.audit-panel > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.audit-panel > summary::-webkit-details-marker { display: none; }
.audit-panel > summary::before {
  content: "▸";
  color: var(--muted-2);
  font-size: 0.8rem;
  transition: transform 0.18s var(--ease);
}
.audit-panel[open] > summary::before { content: "▾"; }
.summary-title { font-weight: 650; font-size: 0.94rem; }
.summary-meta { color: var(--muted-2); font-size: 0.78rem; }
.audit-panel > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.audit-body { margin-top: 12px; }
.audit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}
.audit {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.65;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.audit-line { display: block; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.audit-line + .audit-line { margin-top: 2px; }
.audit-line .k { color: var(--muted-2); }
.audit-line .v { color: var(--ink-2); }
.audit-line .parts { color: var(--ok); }
/* A DENIED line must be findable at a glance in a wall of monospace. */
.audit-line.is-deny {
  color: var(--deny);
  font-weight: 700;
  background: var(--deny-bg);
  border-left: 3px solid var(--deny);
  padding: 1px 6px;
  margin-left: -6px;
  border-radius: 3px;
}
.audit-line.is-deny .k, .audit-line.is-deny .v, .audit-line.is-deny .parts { color: var(--deny); }
.audit-line.is-boot { color: var(--ink-2); }
.audit-empty { color: var(--muted-2); font-family: var(--font-ui); font-size: 0.82rem; }

/* ------------------------------------------------------------- Overlay --- */
/* Hosts both interactive comparisons: identity A/B, and stale vs corrector. */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vw, 32px);
  background: rgba(0, 0, 0, 0.62);
}
.overlay[hidden] { display: none; }
.overlay-panel {
  width: min(1120px, 100%);
  max-height: calc(100vh - 2 * clamp(10px, 3vw, 32px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-ui);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 44px -20px rgba(0, 0, 0, 0.8);
}
.overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px clamp(14px, 2vw, 22px) 12px;
  border-bottom: 1px solid var(--line);
}
.overlay-body { overflow-y: auto; padding: 14px clamp(14px, 2vw, 22px) 20px; }

.overlay-summary {
  margin: 0 0 14px;
  padding: 10px 13px;
  border-radius: var(--radius);
  background: var(--info-bg);
  border: 1px solid var(--line-ui);
  border-left: 3px solid var(--info);
  color: var(--info);
  font-size: 0.83rem;
  line-height: 1.5;
}
.overlay-summary.is-warn { background: var(--warn-bg); border-left-color: var(--warn); color: var(--warn); }

.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 1.6vw, 18px); align-items: start; }
.compare-col { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.compare-col.is-primary { background: var(--surface); }
.compare-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.compare-who { font-family: var(--font-mono); font-size: 0.84rem; font-weight: 700; color: var(--ink); }
.compare-sub { font-size: 0.75rem; color: var(--muted); margin: 3px 0 0; }
.compare-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.compare-list { padding: 4px 12px 10px; }
.compare-body { padding: 10px 12px 14px; max-height: 46vh; overflow-y: auto; }

.compare-row { padding: 9px 0; border-top: 1px solid var(--line); }
.compare-list > .compare-row:first-child { border-top: 0; }
.compare-row-title { font-size: 0.86rem; font-weight: 600; margin: 0; }
.compare-row-path { font-family: var(--font-mono); font-size: 0.69rem; color: var(--muted-2); margin: 2px 0 0; word-break: break-all; }
.compare-row.is-only { background: var(--ok-bg); margin-inline: -12px; padding-inline: 12px; }
.compare-only-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ok);
  border: 1px solid var(--line-ui);
  border-radius: 3px;
  padding: 0 5px;
  margin-bottom: 3px;
}
.compare-empty { color: var(--muted); font-size: 0.83rem; padding: 10px 0; }
.compare-empty strong { color: var(--ink); }

/* ------------------------------------------------------------- Footer ---- */
.app-footer {
  border-top: 1px solid var(--line);
  padding: 18px clamp(14px, 4vw, 32px);
  max-width: var(--container);
  margin: 0 auto;
}
.footer-note { color: var(--muted-2); font-size: 0.77rem; margin: 0; }
.noscript-note { color: var(--muted); padding: 20px clamp(14px, 4vw, 32px); }

/* --------------------------------------------------------- Responsive ---- */
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .reader-panel { position: static; max-height: none; }
  .reader { max-height: 600px; }
}

@media (max-width: 880px) {
  .identity { width: 100%; }
  .identity-select { flex: 1 1 auto; min-width: 0; }
  .search-field { flex-wrap: wrap; padding: 6px 8px 8px 38px; }
  .search-icon { top: 19px; left: 13px; }
  .search-input { flex: 1 1 100%; }
  .search-submit { width: 100%; justify-content: center; }
  .reader { max-height: 500px; }
  .compare-grid { grid-template-columns: 1fr; }
  .compare-body { max-height: none; }
}

@media (max-width: 560px) {
  .brand-sub { display: none; }
  .entitlement-note { flex-basis: 100%; }
  .panel { padding: 14px; }
  .meta-strip { grid-template-columns: 1fr 1fr; padding: 10px; }
  .audit { font-size: 0.7rem; }
  .chip { font-size: 0.78rem; padding: 4px 10px; }
  .result::before { left: -8px; }
}

@media (max-width: 420px) {
  .app-bar { padding-inline: 12px; }
  .entitlement-bar { padding-inline: 12px; }
  main { padding-inline: 12px; }
  .panel { padding: 12px; }
  .meta-strip { grid-template-columns: 1fr; }
  .result::before { left: -6px; }
  .result-score { margin-left: 0; flex-basis: 100%; }
  .overlay { padding: 0; }
  .overlay-panel { max-height: 100vh; border-radius: 0; border: 0; }
}
