/* ==========================================================================
   LGU Citizens' Charter Doctoral Research Portal
   Academic design system — restrained palette, high contrast, print-friendly
   ========================================================================== */

:root {
  /* Core palette: deep slate-blue academic + warm parchment */
  --ink:            #11161d;
  --ink-2:          #2b3440;
  --ink-3:          #4d5969;
  --ink-4:          #6f7d8e;
  --rule:           #d9dee5;
  --rule-2:         #e9edf2;
  --paper:          #ffffff;
  --paper-2:        #f6f8fa;
  --paper-3:        #eef2f6;

  --navy:           #1b3a5c;
  --navy-2:         #27527f;
  --navy-light:     #e7eef5;
  --accent:         #8a5a2b;      /* ochre — citations, links-visited */
  --accent-light:   #f6eee3;

  /* Evidence badge colours (WCAG AA on their light backgrounds) */
  --ev-legal-bg:    #e8eef7;  --ev-legal-fg:    #1b3a5c;
  --ev-verified-bg: #e4f0e8;  --ev-verified-fg: #1f5131;
  --ev-finding-bg:  #e9eef4;  --ev-finding-fg:  #24405c;
  --ev-synth-bg:    #f3ecf7;  --ev-synth-fg:    #513063;
  --ev-proposed-bg: #fdf1e3;  --ev-proposed-fg: #76491b;
  --ev-hypo-bg:     #fdeee9;  --ev-hypo-fg:     #7d3418;
  --ev-rec-bg:      #e6f1f4;  --ev-rec-fg:      #11505f;
  --ev-warn-bg:     #fdf3d7;  --ev-warn-fg:     #6b5306;
  --ev-gap-bg:      #f0eee9;  --ev-gap-fg:      #4b453a;

  --sidebar-w: 268px;
  --read: 74ch;

  --fs-sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --fs-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Source Serif Pro", Georgia, "Times New Roman", serif;
  --fs-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --sh-1: 0 1px 2px rgba(17,22,29,.06), 0 1px 3px rgba(17,22,29,.05);
  --sh-2: 0 4px 14px rgba(17,22,29,.09);
  --radius: 7px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  font-family: var(--fs-sans);
  font-size: 16px;
  line-height: 1.62;
  color: var(--ink-2);
  background: var(--paper-2);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Skip link / a11y ---------- */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--navy); color: #fff; padding: .7rem 1.2rem;
  border-radius: 0 0 var(--radius) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

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

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Layout shell ---------- */
.shell { display: flex; min-height: 100vh; align-items: flex-start; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--ink);
  color: #c7d0db;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar__brand {
  padding: 1.4rem 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar__brand a { text-decoration: none; display: block; }
.sidebar__eyebrow {
  font-size: .625rem; letter-spacing: .16em; text-transform: uppercase;
  color: #7f93aa; font-weight: 700; margin: 0 0 .3rem;
}
.sidebar__title {
  font-family: var(--fs-serif);
  font-size: 1.07rem; line-height: 1.3; color: #fff; margin: 0; font-weight: 600;
}
.sidebar__sub { font-size: .72rem; color: #8698ad; margin: .4rem 0 0; }

.sidebar nav { padding: .75rem 0 2rem; flex: 1; }
.sidebar__group {
  font-size: .62rem; letter-spacing: .14em; text-transform: uppercase;
  color: #6b7f96; font-weight: 700; padding: 1rem 1.25rem .35rem; margin: 0;
}
.sidebar nav a {
  display: flex; align-items: baseline; gap: .6rem;
  padding: .46rem 1.25rem; color: #c7d0db; text-decoration: none;
  font-size: .845rem; border-left: 3px solid transparent; line-height: 1.35;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a[aria-current="page"] {
  background: rgba(89,140,196,.17); color: #fff;
  border-left-color: #5f93cc; font-weight: 600;
}
.sidebar nav a .num {
  font-variant-numeric: tabular-nums; font-size: .68rem; color: #6b7f96;
  min-width: 1.1rem; font-weight: 600;
}
.sidebar nav a[aria-current="page"] .num { color: #8fb6e0; }

.sidebar__foot {
  padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.1);
  font-size: .68rem; color: #7f93aa; line-height: 1.5;
}

/* mobile nav toggle */
.navbar {
  display: none;
  position: sticky; top: 0; z-index: 50;
  background: var(--ink); color: #fff;
  padding: .6rem .85rem; align-items: center; gap: .7rem;
}
.navbar__title { font-family: var(--fs-serif); font-size: .95rem; font-weight: 600; margin:0; }
.navtoggle {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
  color: #fff; border-radius: 6px; padding: .45rem .6rem; cursor: pointer;
  font-size: 1rem; line-height: 1; display: flex; align-items: center;
}

/* ---------- Main ---------- */
.main { flex: 1 1 auto; min-width: 0; }

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2.4rem 2.2rem 5rem;
}

.pagehead { border-bottom: 2px solid var(--ink); padding-bottom: 1.1rem; margin-bottom: 1.8rem; }
.pagehead__eyebrow {
  font-size: .68rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--navy-2); font-weight: 700; margin: 0 0 .5rem;
}
.pagehead h1 {
  font-family: var(--fs-serif); font-size: clamp(1.65rem, 3.4vw, 2.3rem);
  line-height: 1.17; color: var(--ink); margin: 0 0 .6rem; font-weight: 600;
  letter-spacing: -.012em;
}
.pagehead__lede { font-size: 1.035rem; color: var(--ink-3); margin: 0; max-width: var(--read); }

h2 {
  font-family: var(--fs-serif); font-size: 1.44rem; color: var(--ink);
  margin: 2.6rem 0 .85rem; font-weight: 600; line-height: 1.27;
  letter-spacing: -.008em;
}
h2:first-child { margin-top: 0; }
h3 { font-size: 1.1rem; color: var(--ink); margin: 1.9rem 0 .6rem; font-weight: 650; line-height: 1.35; }
h4,
/* Semantic h3 that must *look* like an h4. Used where a sub-heading sits
   directly inside an h2 section: jumping h2 -> h4 is a heading-level skip
   that screen-reader users hear as a missing level, but the small uppercase
   treatment is the right visual weight. Keep the level, borrow the style. */
.h-sub { font-size: .94rem; color: var(--ink-2); margin: 1.4rem 0 .45rem; font-weight: 650;
     text-transform: uppercase; letter-spacing: .05em; }

p, li { max-width: var(--read); }
p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1.1rem; padding-left: 1.3rem; }
li { margin-bottom: .42rem; }

a { color: var(--navy-2); text-decoration: underline; text-underline-offset: 2px;
    text-decoration-thickness: .055em; text-decoration-color: rgba(39,82,127,.42); }
a:hover { text-decoration-color: currentColor; color: var(--navy); }

/* external source link styling */
a.src::after {
  content: "↗"; font-size: .72em; margin-left: .22em; vertical-align: super;
  text-decoration: none; display: inline-block; opacity: .68;
}

strong { color: var(--ink); font-weight: 650; }
code { font-family: var(--fs-mono); font-size: .86em; background: var(--paper-3);
       padding: .1em .35em; border-radius: 3px; color: var(--ink); }

hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4rem 0; }

/* ---------- Cards & panels ---------- */
.card {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 1.3rem 1.4rem; margin-bottom: 1.2rem;
  box-shadow: var(--sh-1);
}
.card > :last-child { margin-bottom: 0; }
.card__title { font-family: var(--fs-serif); font-size: 1.1rem; color: var(--ink);
               margin: 0 0 .6rem; font-weight: 600; }

.grid { display: grid; gap: 1.1rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }

/* Notices */
.notice {
  border-left: 4px solid var(--navy-2); background: var(--navy-light);
  padding: 1rem 1.2rem; border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.3rem 0; font-size: .925rem;
}
.notice > :last-child { margin-bottom: 0; }
.notice p { max-width: none; }
.notice__title {
  font-weight: 700; color: var(--navy); margin: 0 0 .4rem; font-size: .76rem;
  letter-spacing: .1em; text-transform: uppercase;
}
.notice--warn { border-left-color: #b8921a; background: var(--ev-warn-bg); }
.notice--warn .notice__title { color: var(--ev-warn-fg); }
.notice--limit { border-left-color: #8a5a2b; background: var(--accent-light); }
.notice--limit .notice__title { color: var(--accent); }
.notice--gap { border-left-color: #6b6050; background: var(--ev-gap-bg); }
.notice--gap .notice__title { color: var(--ev-gap-fg); }

/* ---------- Stat tiles ---------- */
.stat {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 1rem 1.05rem; box-shadow: var(--sh-1);
  border-top: 3px solid var(--navy-2);
}
.stat__num {
  font-family: var(--fs-serif); font-size: 2.05rem; line-height: 1;
  color: var(--navy); font-weight: 600; font-variant-numeric: tabular-nums;
  display: block; margin-bottom: .3rem;
}
.stat__label { font-size: .765rem; color: var(--ink-3); line-height: 1.38; display: block; }
.stat__note { font-size: .67rem; color: var(--ink-4); margin-top: .4rem; display: block;
              border-top: 1px dotted var(--rule); padding-top: .32rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-size: .655rem; font-weight: 700;
  letter-spacing: .055em; text-transform: uppercase;
  padding: .2rem .5rem; border-radius: 3px; line-height: 1.45;
  white-space: nowrap; vertical-align: baseline;
}
.b-legal    { background: var(--ev-legal-bg);    color: var(--ev-legal-fg); }
.b-verified { background: var(--ev-verified-bg); color: var(--ev-verified-fg); }
.b-finding  { background: var(--ev-finding-bg);  color: var(--ev-finding-fg); }
.b-synth    { background: var(--ev-synth-bg);    color: var(--ev-synth-fg); }
.b-proposed { background: var(--ev-proposed-bg); color: var(--ev-proposed-fg); }
.b-hypo     { background: var(--ev-hypo-bg);     color: var(--ev-hypo-fg); }
.b-rec      { background: var(--ev-rec-bg);      color: var(--ev-rec-fg); }
.b-warn     { background: var(--ev-warn-bg);     color: var(--ev-warn-fg); }
.b-gap      { background: var(--ev-gap-bg);      color: var(--ev-gap-fg); }
.b-muted    { background: var(--paper-3);        color: var(--ink-3); }

.badge-row { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .7rem; }

/* ---------- Tables ---------- */
.tablewrap {
  overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--paper); margin: 1rem 0 .5rem; -webkit-overflow-scrolling: touch;
}
table { border-collapse: collapse; width: 100%; font-size: .855rem; min-width: 560px; }
caption {
  caption-side: top; text-align: left; padding: .85rem 1rem .55rem;
  font-size: .78rem; color: var(--ink-3); border-bottom: 1px solid var(--rule-2);
}
caption b { color: var(--ink); display: block; font-size: .9rem; margin-bottom: .22rem;
            font-family: var(--fs-serif); font-weight: 600; }
th, td { padding: .62rem .8rem; text-align: left; vertical-align: top;
         border-bottom: 1px solid var(--rule-2); }
th {
  background: var(--paper-3); color: var(--ink); font-weight: 650;
  font-size: .715rem; letter-spacing: .055em; text-transform: uppercase;
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
tbody tr:hover { background: var(--paper-2); }
tbody tr:last-child td { border-bottom: 0; }
td p, td ul { max-width: none; }
td ul { padding-left: 1.05rem; margin-bottom: 0; }
.t-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t-nowrap { white-space: nowrap; }
.tnote { font-size: .745rem; color: var(--ink-4); margin: .45rem 0 1.6rem; max-width: var(--read); }

/* sortable headers */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: var(--navy-light); }
th.sortable::after { content: " ⇅"; opacity: .35; font-size: .9em; }
th.sortable[data-dir="asc"]::after  { content: " ▲"; opacity: .95; }
th.sortable[data-dir="desc"]::after { content: " ▼"; opacity: .95; }

/* ---------- Controls: search / filters ---------- */
.controls {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin: 1.2rem 0; box-shadow: var(--sh-1);
}
.controls__row { display: flex; flex-wrap: wrap; gap: .85rem; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: .28rem; min-width: 150px; flex: 1 1 150px; }
.field label {
  font-size: .665rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700;
}
.field input, .field select {
  font-family: inherit; font-size: .865rem; padding: .48rem .6rem;
  border: 1px solid var(--rule); border-radius: 5px; background: var(--paper);
  color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--navy-2); }
.field--wide { flex: 2 1 260px; }

.btn {
  font-family: inherit; font-size: .83rem; font-weight: 600; cursor: pointer;
  padding: .5rem .9rem; border-radius: 5px; border: 1px solid var(--rule);
  background: var(--paper-3); color: var(--ink-2); line-height: 1.4;
}
.btn:hover { background: var(--navy-light); border-color: var(--navy-2); color: var(--navy); }
.btn--primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn--primary:hover { background: var(--navy-2); color: #fff; }

.resultcount {
  font-size: .79rem; color: var(--ink-3); margin: .7rem 0 .3rem;
  font-variant-numeric: tabular-nums;
}
.resultcount b { color: var(--ink); }

/* ---------- Record list (repository / sources) ---------- */
.record {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  margin-bottom: .85rem; box-shadow: var(--sh-1); overflow: hidden;
}
.record__head {
  padding: .95rem 1.1rem; cursor: pointer; display: block; width: 100%;
  text-align: left; background: none; border: 0; font-family: inherit;
  border-left: 4px solid var(--navy-2);
}
.record__head:hover { background: var(--paper-2); }
.record__head[aria-expanded="true"] { background: var(--paper-2); border-bottom: 1px solid var(--rule-2); }
.record__title {
  font-family: var(--fs-serif); font-size: 1rem; color: var(--ink);
  font-weight: 600; margin: 0 0 .32rem; line-height: 1.34; max-width: none;
}
.record__meta { font-size: .79rem; color: var(--ink-3); margin: 0 0 .45rem; max-width: none; }
.record__body { padding: 1.1rem 1.15rem 1.2rem; font-size: .89rem; }
.record__body[hidden] { display: none; }
.record__chev { float: right; color: var(--ink-4); font-size: .8rem; margin-left: .6rem; }

.dl { margin: 0; font-size: .875rem; }
.dl > div { display: grid; grid-template-columns: 170px 1fr; gap: .6rem;
            padding: .42rem 0; border-bottom: 1px dotted var(--rule); }
.dl > div:last-child { border-bottom: 0; }
.dl dt { font-weight: 650; color: var(--ink); font-size: .775rem;
         text-transform: uppercase; letter-spacing: .04em; line-height: 1.5; }
.dl dd { margin: 0; color: var(--ink-2); }
.dl dd p:last-child { margin-bottom: 0; }

/* ---------- Charts (inline SVG) ---------- */
.figure {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 1.2rem 1.3rem 1.3rem; margin: 1.3rem 0; box-shadow: var(--sh-1);
}
.figure__title {
  font-family: var(--fs-serif); font-size: 1.02rem; color: var(--ink);
  margin: 0 0 .25rem; font-weight: 600;
}
.figure__sub { font-size: .8rem; color: var(--ink-3); margin: 0 0 .9rem; max-width: none; }
.figure__canvas { width: 100%; overflow-x: auto; }
.figure__canvas svg { display: block; max-width: 100%; height: auto; }
.figure__foot {
  margin-top: .85rem; padding-top: .7rem; border-top: 1px solid var(--rule-2);
  font-size: .765rem; color: var(--ink-3);
}
.figure__foot p { max-width: none; margin: 0 0 .4rem; }
.figure__foot p:last-child { margin-bottom: 0; }
.figure__foot b { color: var(--ink-2); }

/* conceptual diagram */
.diagram { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
           padding: 1.2rem; margin: 1.3rem 0; overflow-x: auto; box-shadow: var(--sh-1); }
.diagram svg { display: block; min-width: 680px; width: 100%; height: auto; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 1.2rem 0; max-width: none; }
.timeline li {
  position: relative; padding: 0 0 1.25rem 1.9rem; margin: 0;
  border-left: 2px solid var(--rule); max-width: none;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: .35rem; width: 12px; height: 12px;
  border-radius: 50%; background: var(--paper); border: 3px solid var(--navy-2);
}
.timeline__phase { font-weight: 650; color: var(--ink); display: block; font-size: .95rem; }
.timeline__when { font-size: .715rem; color: var(--navy-2); font-weight: 700;
                  letter-spacing: .07em; text-transform: uppercase; display: block; margin-bottom: .2rem; }
.timeline p { margin: .3rem 0 0; font-size: .875rem; max-width: none; }

/* ---------- Checklist ---------- */
.checklist { list-style: none; padding: 0; max-width: none; }
.checklist li {
  padding: .7rem .9rem .7rem 2.3rem; position: relative; background: var(--paper);
  border: 1px solid var(--rule); border-radius: 5px; margin-bottom: .5rem;
  font-size: .89rem; max-width: none;
}
.checklist li::before {
  content: "☐"; position: absolute; left: .85rem; top: .62rem;
  color: var(--navy-2); font-size: 1.05rem;
}

/* ---------- Ranked list ---------- */
.rank { display: flex; gap: .9rem; align-items: baseline; }
.rank__n {
  font-family: var(--fs-serif); font-size: 1.5rem; color: var(--navy-2);
  font-weight: 600; min-width: 1.6rem; font-variant-numeric: tabular-nums;
}

/* ---------- Scorebar ---------- */
.scorebar { display: flex; align-items: center; gap: .5rem; }
.scorebar__track {
  flex: 1; height: 7px; background: var(--paper-3); border-radius: 4px;
  overflow: hidden; min-width: 48px;
}
.scorebar__fill { height: 100%; background: var(--navy-2); border-radius: 4px; }
.scorebar__val { font-size: .74rem; font-variant-numeric: tabular-nums; color: var(--ink-3);
                 min-width: 1.9rem; text-align: right; font-weight: 600; }

/* ---------- Inline citation ---------- */
.cite {
  font-size: .8em; color: var(--accent); text-decoration: none;
  border-bottom: 1px dotted var(--accent); white-space: nowrap; font-weight: 600;
}
.cite:hover { background: var(--accent-light); color: var(--accent); }

/* ---------- Details / expandable ---------- */
details.exp {
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper);
  margin-bottom: .7rem; box-shadow: var(--sh-1);
}
details.exp > summary {
  padding: .75rem 1rem; cursor: pointer; font-weight: 600; color: var(--ink);
  font-size: .9rem; list-style: none; display: flex; justify-content: space-between; gap: .8rem;
}
details.exp > summary::-webkit-details-marker { display: none; }
details.exp > summary::after { content: "＋"; color: var(--navy-2); font-weight: 700; }
details.exp[open] > summary::after { content: "－"; }
details.exp[open] > summary { border-bottom: 1px solid var(--rule-2); background: var(--paper-2); }
details.exp > div { padding: 1rem; font-size: .885rem; }
details.exp > div > :last-child { margin-bottom: 0; }

/* ---------- Tooltip ---------- */
.tip { border-bottom: 1px dashed var(--ink-4); cursor: help; position: relative; }
.tip:hover::after, .tip:focus::after {
  content: attr(data-tip); position: absolute; left: 0; bottom: 135%;
  background: var(--ink); color: #fff; padding: .55rem .75rem; border-radius: 5px;
  font-size: .76rem; font-weight: 400; line-height: 1.45; width: max-content;
  max-width: 280px; z-index: 60; box-shadow: var(--sh-2); text-transform: none;
  letter-spacing: normal; white-space: normal;
}

/* ---------- Section nav (on-page TOC) ---------- */
.toc {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 1rem 1.2rem; margin-bottom: 1.6rem; box-shadow: var(--sh-1);
}
.toc h2 { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
          color: var(--ink-3); margin: 0 0 .6rem; font-family: var(--fs-sans); font-weight: 700; }
.toc ol { columns: 2; column-gap: 1.8rem; margin: 0; padding-left: 1.1rem; font-size: .855rem; }
.toc li { margin-bottom: .3rem; max-width: none; break-inside: avoid; }

/* ---------- Page footer ---------- */
.pagefoot {
  margin-top: 3.5rem; padding-top: 1.4rem; border-top: 2px solid var(--rule);
  font-size: .79rem; color: var(--ink-4);
}
.pagefoot p { max-width: var(--read); }
.pagenav { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
           margin-bottom: 1.4rem; }
.pagenav a { font-size: .86rem; font-weight: 600; }

/* ---------- Key-value strip ---------- */
.kv { display: flex; flex-wrap: wrap; gap: .4rem 1.6rem; font-size: .8rem;
      color: var(--ink-3); margin: 0 0 1rem; }
.kv span b { color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(17,22,29,.5); z-index: 90;
  }
  .navbar { display: flex; }
  .page { padding: 1.3rem 1.05rem 3.5rem; }
  .toc ol { columns: 1; }
  .dl > div { grid-template-columns: 1fr; gap: .15rem; }
  table { font-size: .8rem; min-width: 480px; }
  th, td { padding: .5rem .6rem; }
  .tablewrap { position: relative; }
  .tablewrap::after {
    content: "Scroll horizontally →"; position: sticky; left: 0; display: block;
    font-size: .68rem; color: var(--ink-4); padding: .35rem .7rem;
    background: var(--paper-3); border-top: 1px solid var(--rule-2);
  }
  .grid--4, .grid--3 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .stat__num { font-size: 1.7rem; }
  .controls__row { gap: .65rem; }
  .field { flex: 1 1 100%; min-width: 0; }
}

@media (max-width: 520px) {
  body { font-size: 15.5px; }
  .pagehead h1 { font-size: 1.42rem; }
  .grid--4, .grid--3, .grid--2 { grid-template-columns: 1fr 1fr; }
  .card { padding: 1rem; }
}

@media print {
  .sidebar, .navbar, .controls, .pagenav { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .page { max-width: none; padding: 0; }
  .card, .figure, .record, .tablewrap { break-inside: avoid; box-shadow: none; }
  a { color: #000; }
}
