/* ==========================================================================
   LGU Citizens' Charter Doctoral Research Portal
   Academic design system — warm paper, deep navy, one teal accent, ochre for caveats; high contrast, print-friendly
   ========================================================================== */

:root {
  /* Institutional green + warm gold palette, matched to /grades.
     These tokens live only in the main portal stylesheet; /grades remains independent. */
  --ink:            #1f2730;
  --ink-2:          #3c4650;
  --ink-3:          #505b65;
  --ink-4:          #6b7580;
  --rule:           #e5e1d8;
  --rule-2:         #eeebe3;
  --paper:          #ffffff;
  --paper-2:        #f6f4ef;
  --paper-3:        #fcfbf7;

  --navy:           #143a28;     /* legacy token name retained to avoid structural changes */
  --navy-2:         #22653f;
  --navy-light:     #eaf2ec;
  --accent:         #8a6a24;     /* warm institutional gold */
  --accent-light:   #f4ead3;

  /* Evidence badge colours: muted, readable, and coordinated with green/gold */
  --ev-legal-bg:    #eaf2ec;  --ev-legal-fg: #143a28;
  --ev-verified-bg: #e7f1e9;  --ev-verified-fg: #17533a;
  --ev-finding-bg:  #edf2ee;  --ev-finding-fg: #244b35;
  --ev-synth-bg:    #f3ecf7;  --ev-synth-fg: #513063;
  --ev-proposed-bg: #f4ead3;  --ev-proposed-fg: #6f5018;
  --ev-hypo-bg:     #fdeee9;  --ev-hypo-fg: #7d3418;
  --ev-rec-bg:      #eaf2ec;  --ev-rec-fg: #17533a;
  --ev-warn-bg:     #faeeda;  --ev-warn-fg: #7a5a15;
  --ev-gap-bg:      #f1f1ee;  --ev-gap-fg: #5e6670;

  --sidebar-w: 276px;
  --read: 72ch;
  --teal-tint:      #eaf2ec;
  --sand:           #f6f4ef;

  --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(20,40,28,.05), 0 2px 6px rgba(20,40,28,.04);
  --sh-2: 0 6px 18px rgba(14,42,28,.09);
  --radius: 10px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--fs-sans);
  font-size: 17px;
  line-height: 1.7;
  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;
  box-shadow: 0 0 0 5px var(--paper);
}
.sidebar :focus-visible { outline-color: #d9c58f; box-shadow: none; }

.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(--navy);
  color: #d9e6dc;
  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: #bfd2c5; 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: .8rem; color: #bfd2c5; margin: .4rem 0 0; }

.sidebar nav { padding: .75rem 0 2rem; flex: 1; }
.sidebar__group {
  font-size: .7rem; letter-spacing: .14em; text-transform: uppercase;
  color: #bfd2c5; font-weight: 700; padding: 1rem 1.25rem .35rem; margin: 0;
}
.sidebar nav a {
  display: flex; align-items: baseline; gap: .6rem;
  padding: .5rem 1.25rem; color: #d9e6dc; text-decoration: none;
  font-size: .92rem; 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(214,181,106,.14); color: #fff;
  border-left-color: #a5812f; font-weight: 600;
}
.sidebar nav a .num {
  font-variant-numeric: tabular-nums; font-size: .75rem; color: #bfd2c5;
  min-width: 1.3rem; font-weight: 600;
}
.sidebar nav a[aria-current="page"] .num { color: #e4d5ac; }

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

/* mobile nav toggle */
.navbar {
  display: none;
  position: sticky; top: 0; z-index: 50;
  background: var(--navy); 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: 1px solid var(--rule); border-top: 4px solid var(--navy-2); padding: 1.3rem 0 1.3rem; margin-bottom: 2rem; position: relative; }
.pagehead::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 84px; height: 3px; background: var(--accent); }
.pagehead__eyebrow {
  font-size: .76rem; letter-spacing: .14em; 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.12rem; color: var(--ink-3); margin: 0; max-width: var(--read); }

h2 {
  font-family: var(--fs-serif); font-size: 1.55rem; color: var(--ink);
  margin: 2.8rem 0 1rem; 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(34,101,63,.35); }
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.5rem 1.6rem; 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: .98rem;
}
.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: .8rem;
  letter-spacing: .1em; text-transform: uppercase;
}
.notice--warn { border-left-color: #a5812f; background: var(--ev-warn-bg); }
.notice--warn .notice__title { color: var(--ev-warn-fg); }
.notice--limit { border-left-color: #8a6a24; 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);
}
.grid > .stat:nth-child(4n+2) { border-top-color: var(--accent); }
.stat__num {
  font-family: var(--fs-serif); font-size: 2.4rem; line-height: 1;
  color: var(--navy); font-weight: 600; font-variant-numeric: tabular-nums;
  display: block; margin-bottom: .3rem;
}
.stat__label { font-size: .88rem; color: var(--ink-3); line-height: 1.38; display: block; }
.stat__note { font-size: .8rem; 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: .74rem; font-weight: 700;
  letter-spacing: .055em; text-transform: uppercase;
  padding: .2rem .55rem; border-radius: 4px; 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: .93rem; min-width: 560px; }
caption {
  caption-side: top; text-align: left; padding: .85rem 1rem .55rem;
  font-size: .86rem; 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: 700; border-bottom: 2px solid var(--rule);
  font-size: .76rem; letter-spacing: .055em; text-transform: uppercase;
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
tbody tr:nth-child(even) td { background: rgba(246,244,239,.7); }
tbody tr:hover td { background: var(--teal-tint); }
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: .84rem; 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: .75rem; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700;
}
.field input, .field select {
  font-family: inherit; font-size: .95rem; padding: .55rem .7rem;
  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: .9rem; 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-2); color: #fff; border-color: var(--navy-2); }
.btn--primary:hover { background: var(--navy); color: #fff; }

.resultcount {
  font-size: .88rem; 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(--teal-tint); }
.record__head:focus-visible { outline-offset: -3px; }
.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: .88rem; color: var(--ink-3); margin: 0 0 .45rem; max-width: none; }
.record__body { padding: 1.2rem 1.3rem 1.3rem; font-size: .96rem; }
.record__body[hidden] { display: none; }
.record__chev { float: right; color: var(--ink-4); font-size: .8rem; margin-left: .6rem; }

.dl { margin: 0; font-size: .95rem; }
.dl > div { display: grid; grid-template-columns: 170px 1fr; gap: .6rem;
            padding: .55rem 0; border-bottom: 1px dotted var(--rule); }
.dl > div:last-child { border-bottom: 0; }
.dl dt { font-weight: 650; color: var(--ink); font-size: .8rem;
         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; }

/* Reassessment rows inside a record's <dl>. The rule marks the point where a
   record stops describing the gap and starts describing its 2026-10-30
   re-examination. */
.dl > div.dl__rule { border-top: 2px solid var(--rule); margin-top: .5rem; padding-top: .7rem; }

/* Five-level evidence-verification ladder. A reached rung is NOT a claim that
   the research question was answered — the last rung is the only one that says
   that, and it is deliberately styled no more prominently than the others. */
.ladder { list-style: none; margin: 0; padding: 0; counter-reset: rung; }
.ladder__step {
  display: grid; grid-template-columns: 1.1rem 1fr auto; gap: .45rem;
  align-items: baseline; padding: .25rem 0; font-size: .88rem;
  border-bottom: 1px dotted var(--rule-2);
}
.ladder__step:last-child { border-bottom: 0; }
.ladder__mark { font-weight: 700; text-align: center; }
.ladder__state { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }
.ladder__step.is-met .ladder__mark,
.ladder__step.is-met .ladder__state { color: var(--ev-verified-fg); }
.ladder__step.is-met .ladder__label { color: var(--ink-2); }
.ladder__step.is-unmet .ladder__mark,
.ladder__step.is-unmet .ladder__state { color: var(--ink-4); }
.ladder__step.is-unmet .ladder__label { color: var(--ink-4); }

@media (max-width: 640px) {
  .ladder__step { grid-template-columns: 1.1rem 1fr; }
  .ladder__state { grid-column: 2; }
}

/* ---------- 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: .88rem; 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: .84rem; 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: .78rem; 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: .95rem; 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: .96rem; 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: .82rem; 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: .97rem; 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 1.1rem; font-size: .95rem; }
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: .84rem; 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: .78rem; 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: .93rem; }
.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: .86rem; color: var(--ink-3);
}
.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: .93rem; font-weight: 600; }

/* ---------- Key-value strip ---------- */
.kv { display: flex; flex-wrap: wrap; gap: .4rem 1.6rem; font-size: .88rem;
      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: .88rem; min-width: 480px; }
  th, td { padding: .5rem .6rem; }
  .tablewrap { position: relative; }
  .tablewrap::after {
    content: "Scroll horizontally →"; position: sticky; left: 0; display: block;
    font-size: .76rem; color: var(--ink-3); 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 (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (forced-colors: active) {
  .badge { border: 1px solid CanvasText; }
  .record__head, .notice { border-left-width: 4px; }
}

@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; }
}
