@font-face {
  font-family: 'Petrona';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/petrona-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Petrona';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/petrona-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/publicsans.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/plexmono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/plexmono-500.woff2') format('woff2');
}

:root {
  --ink: #2b2a28;
  --ink-soft: #5c584f;
  --ink-faint: #8c877b;
  --marble-base: #f3f0ea;
  --marble-vein: 90, 85, 72;
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.85);
  --glass-sunken: rgba(255, 255, 255, 0.42);
  --glass-border: rgba(255, 255, 255, 0.8);
  --glass-shadow: 0 10px 34px rgba(60, 50, 35, 0.12);
  --line: rgba(43, 42, 40, 0.13);
  --line-strong: rgba(43, 42, 40, 0.24);
  --accent: #b3872e;
  --accent-strong: #8f6a1d;
  --accent-soft: rgba(179, 135, 46, 0.16);
  --accent-contrast: #fffdf7;
  --logo: #2f6f5a;
  --data-1: #9c7220;
  --data-2: #1f8f68;
  --focus: 0 0 0 3px rgba(179, 135, 46, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2efe7;
    --ink-soft: #cdc7b9;
    --ink-faint: #928c7d;
    --marble-base: #17181a;
    --marble-vein: 205, 199, 186;
    --glass: rgba(255, 255, 255, 0.06);
    --glass-strong: rgba(255, 255, 255, 0.1);
    --glass-sunken: rgba(255, 255, 255, 0.045);
    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-shadow: 0 10px 36px rgba(0, 0, 0, 0.5);
    --line: rgba(242, 239, 231, 0.12);
    --line-strong: rgba(242, 239, 231, 0.22);
    --accent: #e0b64a;
    --accent-strong: #f0cc72;
    --accent-soft: rgba(224, 182, 74, 0.2);
    --accent-contrast: #241c08;
    --logo: #4fae91;
    --data-1: #bd8934;
    --data-2: #369873;
    --focus: 0 0 0 3px rgba(224, 182, 74, 0.45);
  }
}
:root[data-theme="dark"] {
  --ink: #f2efe7; --ink-soft: #cdc7b9; --ink-faint: #928c7d;
  --marble-base: #17181a; --marble-vein: 205, 199, 186;
  --glass: rgba(255, 255, 255, 0.06); --glass-strong: rgba(255, 255, 255, 0.1); --glass-sunken: rgba(255, 255, 255, 0.045);
  --glass-border: rgba(255, 255, 255, 0.14); --glass-shadow: 0 10px 36px rgba(0, 0, 0, 0.5);
  --line: rgba(242, 239, 231, 0.12); --line-strong: rgba(242, 239, 231, 0.22);
  --accent: #e0b64a; --accent-strong: #f0cc72; --accent-soft: rgba(224, 182, 74, 0.2); --accent-contrast: #241c08;
  --logo: #4fae91; --data-1: #bd8934; --data-2: #369873; --focus: 0 0 0 3px rgba(224, 182, 74, 0.45);
}
:root[data-theme="light"] {
  --ink: #2b2a28; --ink-soft: #5c584f; --ink-faint: #8c877b;
  --marble-base: #f3f0ea; --marble-vein: 90, 85, 72;
  --glass: rgba(255, 255, 255, 0.62); --glass-strong: rgba(255, 255, 255, 0.85); --glass-sunken: rgba(255, 255, 255, 0.42);
  --glass-border: rgba(255, 255, 255, 0.8); --glass-shadow: 0 10px 34px rgba(60, 50, 35, 0.12);
  --line: rgba(43, 42, 40, 0.13); --line-strong: rgba(43, 42, 40, 0.24);
  --accent: #b3872e; --accent-strong: #8f6a1d; --accent-soft: rgba(179, 135, 46, 0.16); --accent-contrast: #fffdf7;
  --logo: #2f6f5a; --data-1: #9c7220; --data-2: #1f8f68; --focus: 0 0 0 3px rgba(179, 135, 46, 0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink); font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; position: relative;
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* Whimsical gradient-mesh backdrop */
/* Marble backdrop — layered gradients standing in for veining + cloud, one effect, tuned subtle */
.bg-mesh {
  position: fixed; inset: 0; z-index: -1; background-color: var(--marble-base);
  background-image:
    radial-gradient(ellipse 55% 38% at 12% 18%, rgba(var(--marble-vein), 0.10), transparent 62%),
    radial-gradient(ellipse 48% 34% at 88% 12%, rgba(var(--marble-vein), 0.08), transparent 65%),
    radial-gradient(ellipse 65% 48% at 78% 88%, rgba(var(--marble-vein), 0.09), transparent 60%),
    radial-gradient(ellipse 42% 30% at 20% 85%, rgba(var(--marble-vein), 0.07), transparent 60%),
    radial-gradient(ellipse 30% 22% at 50% 45%, rgba(var(--marble-vein), 0.05), transparent 65%),
    linear-gradient(114deg, transparent 41.5%, rgba(var(--marble-vein), 0.16) 42.1%, rgba(var(--marble-vein), 0.05) 42.6%, transparent 43.4%),
    linear-gradient(71deg, transparent 67.2%, rgba(var(--marble-vein), 0.12) 67.7%, transparent 68.6%),
    linear-gradient(155deg, transparent 22%, rgba(var(--marble-vein), 0.08) 22.5%, transparent 23.1%);
  background-repeat: no-repeat; background-size: cover; background-attachment: fixed;
}

h1, h2, h3 { font-family: 'Petrona', Georgia, serif; margin: 0; text-wrap: balance; color: var(--ink); }
p { margin: 0 0 1em; max-width: 65ch; }
a { color: var(--accent-strong); }
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: none; box-shadow: var(--focus); border-radius: 6px;
}

.eyebrow {
  font-family: 'Public Sans', sans-serif; font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.11em; text-transform: uppercase; color: var(--accent-strong);
}

button { font: inherit; cursor: pointer; }

/* Glass surface — the one effect system, applied consistently */
.glass {
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ---------- App shell ---------- */
/* minmax(0, 1fr) stops the implicit column from being stretched by wide content
   (a plain `1fr` resolves to min-content and lets the topbar push the page sideways). */
.shell { display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); height: 100vh; min-height: 640px; padding: 14px; gap: 14px; }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 14px 22px; border-radius: 20px;
}
.mark { display: flex; align-items: center; gap: 12px; }
.mark-badge {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow);
}
.mark-badge img { display: block; transition: filter 0.2s ease; }
@media (prefers-color-scheme: dark) { .mark-badge img { filter: invert(1); } }
:root[data-theme="dark"] .mark-badge img { filter: invert(1); }
:root[data-theme="light"] .mark-badge img { filter: none; }
.mark svg { flex-shrink: 0; }
.mark-text { display: flex; flex-direction: column; line-height: 1.15; }
.mark-title { font-family: 'Petrona', serif; font-weight: 700; font-size: 1.25rem; letter-spacing: 0.01em; }
.mark-sub { font-family: 'Petrona', serif; font-style: italic; font-weight: 500; font-size: 0.8125rem; color: var(--ink-soft); }
.topbar-spacer { flex: 1; }

.delegate-tag {
  display: flex; align-items: center; gap: 8px; font-family: 'IBM Plex Mono', monospace; font-size: 0.75rem;
  color: var(--ink-soft); padding: 7px 12px; border-radius: 999px; background: var(--glass-sunken); border: 1px solid var(--line);
}
.delegate-tag .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

.lang-toggle { display: flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; background: var(--glass-sunken); }
.lang-toggle button {
  border: none; background: transparent; color: var(--ink-soft); font-family: 'IBM Plex Mono', monospace; font-size: 0.75rem;
  font-weight: 600; padding: 7px 15px; letter-spacing: 0.04em; transition: background 0.2s ease, color 0.2s ease;
}
.lang-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }

.theme-toggle {
  border: 1px solid var(--line-strong); background: var(--glass-sunken); color: var(--ink-soft);
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; transition: transform 0.25s ease, color 0.2s ease;
}
.theme-toggle:hover { color: var(--accent-strong); transform: rotate(20deg) scale(1.08); }

.icon-btn {
  border: 1px solid var(--line-strong); background: var(--glass-sunken); color: var(--ink-soft);
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  transition: color 0.15s ease, transform 0.15s ease;
}
.icon-btn:hover { color: var(--accent-strong); transform: scale(1.06); }

/* ---------- Search ---------- */
.search-overlay {
  display: none; position: fixed; inset: 0; z-index: 50; background: rgba(20, 15, 5, 0.35);
  padding: 10vh 16px 0; justify-content: center; align-items: flex-start;
}
.search-overlay.open { display: flex; }
.search-box { width: min(560px, 92vw); border-radius: 20px; overflow: hidden; max-height: 70vh; display: flex; flex-direction: column; }
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--ink-faint); }
.search-input-row input { flex: 1; border: none; background: none; font: inherit; font-size: 0.9375rem; color: var(--ink); outline: none; }
.search-input-row input::placeholder { color: var(--ink-faint); }
.search-kbd { font-family: 'IBM Plex Mono', monospace; font-size: 0.625rem; border: 1px solid var(--line-strong); border-radius: 4px; padding: 2px 6px; color: var(--ink-faint); }
.search-results { overflow-y: auto; padding: 8px; }
.search-result { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 12px; border: none; background: none; cursor: pointer; }
.search-result:hover, .search-result.active { background: var(--accent-soft); }
.search-result .sr-panel { font-family: 'IBM Plex Mono', monospace; font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-strong); }
.search-result .sr-snippet { font-size: 0.8125rem; color: var(--ink-soft); margin-top: 3px; line-height: 1.5; }
.search-result mark { background: var(--accent-soft); color: var(--ink); border-radius: 2px; padding: 0 1px; }
.search-empty { padding: 24px 12px; text-align: center; font-size: 0.8125rem; color: var(--ink-faint); }
.search-highlight-flash { animation: searchFlash 1.8s ease; }
@keyframes searchFlash { 0%, 100% { background: transparent; } 20% { background: var(--accent-soft); } }

/* ---------- Speech timer ---------- */
.timer-pop {
  display: none; position: fixed; top: 66px; right: 16px; z-index: 40; width: 220px; border-radius: 18px;
  padding: 18px; text-align: center;
}
.timer-pop.open { display: block; }
.timer-display {
  font-family: 'IBM Plex Mono', monospace; font-size: 2.25rem; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums; margin-bottom: 12px; transition: color 0.2s ease;
}
.timer-display.warn { color: var(--data-1); }
.timer-display.danger { color: #b34747; }
.timer-presets { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; }
.timer-presets button {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.6875rem; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--glass-sunken); color: var(--ink-soft);
}
.timer-presets button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.timer-controls { display: flex; gap: 8px; }
.timer-btn { flex: 1; padding: 9px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--glass-sunken); color: var(--ink-soft); font-weight: 600; font-size: 0.8125rem; }
.timer-btn.primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .search-highlight-flash { animation: none; } }

/* ---------- Body grid ---------- */
.body-grid { display: grid; grid-template-columns: 252px 1fr 360px; gap: 14px; min-height: 0; }
@media (max-width: 1180px) {
  .body-grid { grid-template-columns: 220px 1fr; }
  .chat-panel { position: fixed; inset: 14px; z-index: 10; transform: translateX(110%); transition: transform 0.3s ease; }
  .chat-panel.open { transform: translateX(0); }
}

.menu-toggle { display: none; }

@media (max-width: 760px) {
  .shell { padding: 10px; gap: 10px; }
  /* The toolbar gained the search + timer buttons; at this width everything must
     shrink or the header forces the page to scroll sideways. */
  .topbar { padding: 8px 10px; gap: 6px; }
  .mark-sub { display: none; }
  .delegate-tag { display: none; }
  .mark { gap: 8px; min-width: 0; }
  .mark-badge { width: 34px; height: 34px; flex-shrink: 0; }
  .mark-badge img { width: 24px; height: 22px; }
  /* min-width:0 + ellipsis so the wordmark truncates instead of spilling over
     the language toggle when the toolbar runs out of room. */
  .mark-text { min-width: 0; overflow: hidden; }
  .mark-title { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lang-toggle button { padding: 6px 9px; }
  .icon-btn, .theme-toggle { width: 32px; height: 32px; }
}

/* Below ~430px the wordmark cannot fit alongside the full toolbar — the emblem
   alone carries the identity there. */
@media (max-width: 430px) {
  .mark-title { display: none; }
  .menu-toggle {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid var(--line-strong); background: var(--glass-sunken); color: var(--ink-soft); flex-shrink: 0;
  }
  .body-grid { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 10px; bottom: 10px; left: 10px; width: min(78vw, 300px);
    z-index: 20; transform: translateX(-115%); transition: transform 0.28s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim {
    display: none; position: fixed; inset: 0; z-index: 15; background: rgba(20, 15, 5, 0.32);
  }
  .sidebar-scrim.open { display: block; }
  .doc { padding: 28px 20px 60px; }
  .stat-row { grid-template-columns: 1fr; }
  .term { grid-template-columns: 1fr; }
  .tl-row { grid-template-columns: 68px 1fr; }
}

.sidebar { border-radius: 22px; padding: 20px 14px; overflow-y: auto; }
.nav-group { margin-top: 20px; }
.nav-group:first-child { margin-top: 0; }
.nav-section-label {
  font-family: 'Public Sans', sans-serif; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-faint); padding: 4px 12px; margin-bottom: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none;
  color: var(--ink-soft); padding: 10px 14px; border-radius: 999px; font-size: 0.875rem; margin: 2px 0;
  transition: background 0.18s ease, color 0.18s ease, transform 0.15s ease;
}
.nav-item:hover { background: var(--glass-sunken); color: var(--ink); transform: translateX(2px); }
.nav-item[aria-current="true"] { background: var(--accent); color: var(--accent-contrast); font-weight: 600; box-shadow: 0 4px 14px -4px var(--accent-soft); }
.sidebar-footer { margin-top: 24px; padding: 12px 12px 4px; border-top: 1px dashed var(--line-strong); }
.sidebar-footer a { font-size: 0.75rem; color: var(--ink-faint); text-decoration: none; }
.sidebar-footer a:hover { color: var(--accent-strong); }
.nav-item .chip {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.6875rem; border: 1px solid currentColor; border-radius: 999px;
  padding: 1px 7px; flex-shrink: 0; opacity: 0.85;
}

/* ---------- Main content ---------- */
/* min-width:0 is required: as a grid item, .main defaults to min-width:auto and refuses
   to shrink below its widest unbreakable content (the 480px min-width tables), which
   pushed the whole page sideways on narrow screens. */
.main { overflow-y: auto; border-radius: 22px; padding: 0; min-width: 0; }
.doc { max-width: 760px; margin: 0 auto; padding: 40px 44px 70px; }
.doc-header { margin-bottom: 26px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.doc-kicker { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.doc h1 { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.doc-dek { font-family: 'Petrona', serif; font-style: italic; font-weight: 500; color: var(--ink-soft); font-size: 1.0625rem; max-width: 62ch; }
.doc-meta { display: flex; gap: 18px; margin-top: 16px; flex-wrap: wrap; }
.doc-meta div { font-family: 'IBM Plex Mono', monospace; font-size: 0.75rem; color: var(--ink-faint); }
.doc-meta strong { color: var(--ink-soft); font-weight: 500; }
.doc h2 { font-size: 1.375rem; font-weight: 600; margin-top: 2.2em; margin-bottom: 0.7em; }
.doc h3 {
  font-family: 'Public Sans', sans-serif; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent-strong); margin-top: 1.8em; margin-bottom: 0.6em;
}
.doc p, .doc li { color: var(--ink); font-size: 0.9375rem; line-height: 1.7; }
.doc ul, .doc ol { padding-left: 1.3em; }
.doc li { margin-bottom: 0.5em; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 1.4em 0; }
.stat-cell { padding: 16px 16px 14px; border-radius: 16px; background: var(--glass-sunken); border: 1px solid var(--line); }
.stat-num { font-family: 'IBM Plex Mono', monospace; font-size: 1.375rem; font-weight: 600; color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.75rem; color: var(--ink-soft); margin-top: 4px; line-height: 1.4; }

.callout { border-left: 4px solid var(--logo); padding: 14px 18px; margin: 1.6em 0; border-radius: 4px 16px 16px 4px; background: var(--glass-sunken); }
.callout .eyebrow { color: var(--logo); margin-bottom: 6px; display: block; }
.callout p:last-child { margin-bottom: 0; }

.term-list { display: grid; gap: 12px; margin: 1.2em 0; }
.term { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--glass-sunken); }
.term dt { font-family: 'IBM Plex Mono', monospace; font-size: 0.8125rem; font-weight: 600; color: var(--ink); }
.term dd { margin: 0; font-size: 0.875rem; color: var(--ink-soft); line-height: 1.6; }
@media (max-width: 720px) { .term { grid-template-columns: 1fr; gap: 4px; } }

.sources { list-style: none; padding: 0; margin: 1em 0; display: flex; flex-direction: column; gap: 8px; }
.sources li { display: flex; gap: 10px; align-items: baseline; font-size: 0.8125rem; margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--glass-sunken); }
.sources .num { font-family: 'IBM Plex Mono', monospace; color: var(--ink-faint); flex-shrink: 0; }
.sources a { color: var(--ink); text-decoration: none; }
.sources a:hover { color: var(--accent-strong); text-decoration: underline; }
.sources svg { flex-shrink: 0; opacity: 0.5; margin-left: 4px; }

.timeline { margin: 1.4em 0; display: flex; flex-direction: column; gap: 2px; }
.tl-row { display: grid; grid-template-columns: 92px 1fr; gap: 16px; padding: 12px 14px; border-radius: 14px; background: var(--glass-sunken); }
.tl-year { font-family: 'IBM Plex Mono', monospace; font-size: 0.8125rem; color: var(--accent-strong); font-weight: 600; }
.tl-row p { font-size: 0.875rem; margin: 0; color: var(--ink-soft); }
.tl-row.is-current { background: var(--accent-soft); }
.tl-row.is-current .tl-year { color: var(--logo); }
.tl-row.is-current p { color: var(--ink); }

/* Rubric / matrix table */
.wide-scroll { overflow-x: auto; margin: 1.4em 0; border-radius: 16px; background: var(--glass-sunken); border: 1px solid var(--line); }
.matrix { width: 100%; border-collapse: collapse; font-size: 0.8125rem; min-width: 480px; }
.matrix th, .matrix td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.matrix th { font-family: 'Public Sans', sans-serif; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 700; }
.matrix td.status { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.matrix svg.yes { color: var(--accent-strong); flex-shrink: 0; }
.matrix svg.no { color: var(--ink-faint); flex-shrink: 0; }

.code-block {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.75rem; line-height: 1.7; border-radius: 16px;
  padding: 18px 20px; white-space: pre-wrap; color: var(--ink-soft); margin: 1.2em 0; overflow-x: auto;
  background: var(--glass-sunken); border: 1px solid var(--line);
}
.code-block strong { color: var(--accent-strong); font-weight: 700; }
.doc pre {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.75rem; line-height: 1.7; border-radius: 16px;
  padding: 18px 20px; color: var(--ink-soft); margin: 1.2em 0; overflow-x: auto;
  background: var(--glass-sunken); border: 1px solid var(--line);
}
.doc pre code { background: none; padding: 0; font-size: inherit; white-space: pre-wrap; }

.severity {
  display: inline-flex; align-items: center; gap: 5px; font-family: 'IBM Plex Mono', monospace; font-size: 0.6875rem;
  font-weight: 700; padding: 3px 10px; border-radius: 999px; color: var(--ink-soft); background: var(--glass-sunken); border: 1px solid var(--line-strong);
}
.severity.high { color: var(--logo); border-color: var(--logo); }
.severity.med { color: var(--accent-strong); border-color: var(--accent); }

.drill { border-radius: 18px; padding: 18px 20px; margin: 1.2em 0; background: var(--glass-sunken); border: 1px solid var(--line); }
.drill-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.drill-country { font-family: 'Petrona', serif; font-weight: 700; font-size: 0.9375rem; }
.drill p { font-size: 0.875rem; margin-bottom: 0.6em; }
.drill .label { font-family: 'IBM Plex Mono', monospace; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); display: block; margin-bottom: 3px; margin-top: 0.8em; }
.drill .label:first-of-type { margin-top: 0; }
.drill blockquote { margin: 4px 0 0; padding-left: 12px; border-left: 3px solid var(--accent); font-style: italic; color: var(--ink); font-size: 0.875rem; }

.sensitive-note { font-size: 0.75rem; color: var(--ink-faint); border-top: 1px dashed var(--line-strong); margin-top: 1.6em; padding-top: 10px; }

/* ---------- Chat panel ---------- */
.chat-panel { border-radius: 22px; display: flex; flex-direction: column; min-height: 0; }
.chat-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-head svg { color: var(--accent-strong); flex-shrink: 0; }
.chat-head-text { flex: 1; }
.chat-head .eyebrow { display: block; margin-bottom: 2px; }
.chat-head strong { font-family: 'Petrona', serif; font-size: 1rem; font-weight: 700; }
.chat-close { display: none; background: none; border: none; color: var(--ink-soft); padding: 4px; border-radius: 50%; }
.mode-pill {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em;
  border: 1px solid var(--line-strong); background: var(--glass-sunken); color: var(--ink-faint);
  padding: 5px 11px; border-radius: 999px; flex-shrink: 0; transition: background 0.15s ease, color 0.15s ease;
}
.mode-pill[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.topic-filter { display: flex; gap: 6px; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.topic-filter button {
  flex: 1; font-family: 'IBM Plex Mono', monospace; font-size: 0.6875rem; font-weight: 600; padding: 6px 8px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--glass-sunken); color: var(--ink-faint);
}
.topic-filter button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
@media (max-width: 1180px) { .chat-close { display: block; } }

.chat-scroll { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.bubble { max-width: 92%; font-size: 0.875rem; line-height: 1.6; padding: 12px 16px; border-radius: 18px; }
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-contrast); border-bottom-right-radius: 5px; }
.bubble.bot { align-self: flex-start; background: var(--glass-strong); color: var(--ink); border-bottom-left-radius: 5px; border: 1px solid var(--line); }
.bubble.bot .cite { display: block; margin-top: 8px; font-family: 'IBM Plex Mono', monospace; font-size: 0.6875rem; color: var(--ink-faint); }
.bubble.bot .cite a { color: var(--accent-strong); }
.bubble p { margin: 0 0 0.6em; max-width: none; }
.bubble p:last-child { margin-bottom: 0; }

.chat-suggest { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 14px; }
.chat-suggest button { border: 1px solid var(--line-strong); background: var(--glass-sunken); color: var(--ink-soft); border-radius: 999px; padding: 7px 14px; font-size: 0.75rem; transition: transform 0.15s ease; }
.chat-suggest button:hover { border-color: var(--accent); color: var(--accent-strong); transform: translateY(-1px); }

.chat-input-row { display: flex; gap: 8px; padding: 16px; border-top: 1px solid var(--line); }
.chat-input-row input { flex: 1; border: 1px solid var(--line-strong); background: var(--glass-sunken); border-radius: 999px; padding: 11px 16px; font: inherit; font-size: 0.875rem; color: var(--ink); }
.chat-input-row input::placeholder { color: var(--ink-faint); }
.chat-send { width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--accent); color: var(--accent-contrast); display: grid; place-items: center; flex-shrink: 0; transition: transform 0.15s ease; }
.chat-send:hover { transform: scale(1.08); }

.chat-fab {
  display: none; position: fixed; bottom: 26px; right: 26px; z-index: 5; width: 54px; height: 54px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--accent-contrast); box-shadow: var(--glass-shadow); align-items: center; justify-content: center;
}
@media (max-width: 1180px) { .chat-fab { display: flex; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* Content-page extras */
.doc hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }
.section-divider { margin-top: 2.4em; padding-top: 1.2em; border-top: 2px solid var(--line-strong); }
.doc table.matrix code { font-family: 'IBM Plex Mono', monospace; font-size: 0.8em; }
.doc code { font-family: 'IBM Plex Mono', monospace; font-size: 0.85em; background: var(--glass-sunken); padding: 1px 5px; border-radius: 4px; }
.loading-dots { display: inline-flex; gap: 4px; }
.loading-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); animation: loadPulse 1.2s infinite ease-in-out; }
.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes loadPulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); } 40% { opacity: 1; transform: scale(1); } }
.chat-error { color: #b34747; font-size: 0.8125rem; padding: 8px 12px; }

/* ---------- Data & charts panel ---------- */
.chart-card { border-radius: 18px; padding: 22px 24px 20px; margin-bottom: 22px; background: var(--glass-sunken); border: 1px solid var(--line); }
.chart-title { font-size: 0.9375rem; font-weight: 700; color: var(--ink); margin-bottom: 2px; font-family: 'Petrona', serif; }
.chart-sub { font-size: 0.75rem; color: var(--ink-faint); margin-bottom: 18px; }
.chart-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); font-family: 'IBM Plex Mono', monospace; font-size: 0.6875rem; color: var(--ink-faint); flex-wrap: wrap; gap: 6px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 22px; }
.stat-tile { background: var(--glass-sunken); border: 1px solid var(--line); border-radius: 16px; padding: 16px 16px 14px; }
.stat-value { font-family: 'Public Sans', sans-serif; font-weight: 700; font-size: 1.5rem; color: var(--data-1); font-variant-numeric: tabular-nums; }
.stat-caption { font-size: 0.75rem; color: var(--ink-soft); margin-top: 4px; line-height: 1.4; }
.stat-source { font-family: 'IBM Plex Mono', monospace; font-size: 0.625rem; color: var(--ink-faint); margin-top: 6px; }

.chart-legend { display: flex; gap: 18px; margin-bottom: 16px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 0.75rem; color: var(--ink-soft); }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.legend-swatch.d1 { background: var(--data-1); }
.legend-swatch.d2 { background: var(--data-2); }

.hgroup { display: flex; flex-direction: column; gap: 18px; }
.hgroup-row { display: grid; grid-template-columns: 130px 1fr; gap: 12px; align-items: center; }
.hgroup-label { font-size: 0.8125rem; color: var(--ink-soft); text-align: right; }
.hgroup-bars { display: flex; flex-direction: column; gap: 5px; }
.hbar-track { position: relative; height: 20px; background: var(--glass); border-radius: 5px; overflow: visible; }
.hbar-fill { height: 100%; border-radius: 5px; display: flex; align-items: center; }
.hbar-fill.d1 { background: var(--data-1); }
.hbar-fill.d2 { background: var(--data-2); }
.hbar-value { font-family: 'IBM Plex Mono', monospace; font-size: 0.6875rem; font-weight: 600; color: var(--ink); margin-left: 8px; white-space: nowrap; }

.pair-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.pair-col { text-align: center; }
.pair-bar-wrap { height: 160px; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 10px; }
.pair-bar { width: 64px; border-radius: 8px 8px 4px 4px; display: flex; align-items: flex-start; justify-content: center; padding-top: 8px; }
.pair-bar .val { font-family: 'IBM Plex Mono', monospace; font-size: 0.8125rem; font-weight: 700; color: var(--accent-contrast); }
.pair-caption { font-size: 0.75rem; color: var(--ink-soft); }
.pair-caption strong { display: block; font-size: 0.8125rem; color: var(--ink); margin-bottom: 2px; }

.rank-list { display: flex; flex-direction: column; gap: 12px; }
.rank-row { display: grid; grid-template-columns: 170px 1fr 56px; gap: 12px; align-items: center; }
.rank-label { font-size: 0.8125rem; color: var(--ink-soft); }
.rank-track { height: 18px; background: var(--glass); border-radius: 5px; }
.rank-fill { height: 100%; background: var(--data-1); border-radius: 5px; }
.rank-value { font-family: 'IBM Plex Mono', monospace; font-size: 0.75rem; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .rank-row { grid-template-columns: 110px 1fr 46px; } }

.meter-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.meter-track { flex: 1; min-width: 160px; height: 26px; background: var(--glass); border-radius: 13px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--data-2); border-radius: 13px 0 0 13px; display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; }
.meter-fill span { font-family: 'IBM Plex Mono', monospace; font-size: 0.6875rem; color: var(--accent-contrast); font-weight: 700; }
.meter-label { font-size: 0.8125rem; color: var(--ink-soft); white-space: nowrap; }

/* ---------- Panic grid (live counters) ---------- */
.panic-filters { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.panic-filter {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.75rem; font-weight: 600; padding: 7px 15px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--glass-sunken); color: var(--ink-soft);
}
.panic-filter[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.panic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.panic-card {
  text-align: left; border: 1px solid var(--line); background: var(--glass-sunken); border-radius: 16px;
  padding: 16px 18px; cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; width: 100%;
}
.panic-card:hover { transform: translateY(-2px); box-shadow: var(--glass-shadow); }
.panic-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.panic-who { font-family: 'Petrona', serif; font-weight: 700; font-size: 0.875rem; color: var(--ink); }
.panic-attack { font-size: 0.8125rem; color: var(--ink-soft); line-height: 1.5; margin: 0; }
.panic-reveal { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }
.panic-card.open .panic-reveal { display: block; }
.panic-reveal .label { font-family: 'IBM Plex Mono', monospace; font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); display: block; margin-bottom: 3px; }
.panic-reveal blockquote { margin: 0 0 10px; padding-left: 10px; border-left: 3px solid var(--accent); font-style: italic; font-size: 0.875rem; color: var(--ink); }
.panic-reveal .panic-source { font-family: 'IBM Plex Mono', monospace; font-size: 0.6875rem; color: var(--ink-faint); }
.panic-hint { text-align: center; font-size: 0.6875rem; color: var(--ink-faint); margin-top: 6px; }
