/* ---------- fonts (bundled, SIL OFL — see fonts/LICENSE.txt) ---------- */
@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/inter-latin-400-italic.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url(fonts/inter-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-style: normal; font-display: swap; src: url(fonts/inter-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-weight: 500; font-style: normal; font-display: swap; src: url(fonts/source-serif-4-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-weight: 500; font-style: italic; font-display: swap; src: url(fonts/source-serif-4-latin-500-italic.woff2) format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-weight: 600; font-style: normal; font-display: swap; src: url(fonts/source-serif-4-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 700; font-style: normal; font-display: swap; src: url(fonts/jetbrains-mono-latin-700-normal.woff2) format("woff2"); }

:root {
  --bg: #FBFBF9;
  --surface: #FFFFFF;
  --ink: #1B1F24;
  --ink-2: #3A3F45;
  --muted: #5C6168;
  --line: #E4E4DF;
  --line-2: #D5D5CF;
  --chip: #EFEDE6;
  --accent: #0E6464;
  --accent-dark: #094848;
  --accent-soft: #E3F0EF;
  --band: #F1F6F5;
  --band-line: #DDE8E6;
  --bad: #9B2C2C;
  --bad-bg: #FBE3E3;
  --good: #1F6B3A;
  --good-bg: #DDF1E4;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --wrap: 1280px;
  --pad: 32px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-dark); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--pad); }

/* ---------- buttons, inputs, chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-small { height: 30px; padding: 0 10px; font-size: 12.5px; font-weight: 600; border-color: #B9D3CF; color: var(--accent); border-radius: 6px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-outline { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.btn[aria-current="page"], .btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 8px; color: var(--ink); }
.icon-btn:hover { background: var(--chip); }
.field { height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); font-size: 14px; min-width: 0; }
select.field { padding: 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; padding: 4px 10px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); font-size: 13px; text-decoration: none; color: var(--ink); }
a.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-soft { border-color: transparent; background: var(--chip); }
.chip-link { border-color: transparent; background: var(--accent-soft); color: var(--accent-dark); font-size: 12.5px; }
.chip-link:hover { background: #D2E8E6; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ---------- header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; gap: 20px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand:hover { color: var(--ink); }
.brand-name { font-family: var(--serif); font-size: 24px; font-weight: 600; }
.brand-sub { font-size: 13px; color: var(--muted); }
.search { flex: 1 1 240px; display: flex; justify-content: flex-end; }
.search input { width: 100%; max-width: 320px; height: 38px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); font-size: 14px; }
.top-nav { display: flex; gap: 20px; font-size: 14px; }
.top-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; text-decoration: none; }
.menu-btn, .search-btn, .close-btn { display: none; }

/* ---------- citation band ---------- */
.cite-band { background: var(--band); border-bottom: 1px solid var(--band-line); color: var(--ink-2); }
.cite-row { display: flex; align-items: center; gap: 14px; min-height: 40px; padding-top: 4px; padding-bottom: 4px; }
.cite-label { flex: 0 0 auto; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.cite-text { margin: 0; flex: 1 1 auto; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cite-short { display: none; }

/* ---------- layout ---------- */
.layout { display: flex; gap: 48px; align-items: flex-start; }
.sidebar { flex: 0 0 290px; position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 24px 4px 40px 0; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.main { flex: 1 1 auto; min-width: 0; padding: 28px 0 64px; max-width: 880px; outline: none; }
.main.wide { max-width: none; }

/* ---------- tree ---------- */
.tree { font-size: 14px; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree li { margin: 0; }
.tree .row { display: flex; align-items: flex-start; gap: 2px; }
.tree .tog { flex: 0 0 26px; height: 30px; border: 0; background: transparent; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; padding: 0; }
.tree .tog:hover { background: var(--chip); color: var(--ink); }
.tree .tog svg { transition: transform .15s; }
.tree .tog[aria-expanded="true"] svg { transform: rotate(90deg); }
.tree .gap { flex: 0 0 26px; }
.tree a { flex: 1; display: flex; gap: 8px; padding: 5px 8px; border-radius: 6px; text-decoration: none; color: var(--ink-2); line-height: 1.35; }
.tree a:hover { background: var(--chip); color: var(--ink); }
.tree a .ix { color: var(--muted); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.tree a .cnt { margin-left: auto; color: var(--muted); padding-left: 6px; }
.tree a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.tree a[aria-current="page"] .ix { color: var(--accent-dark); }
.tree .lvl1 > .row a { font-weight: 600; color: var(--ink); }
.tree .lvl1 { border-top: 1px solid #ECECE7; padding-top: 4px; margin-top: 4px; }
.tree .lvl1:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.tree ul ul { padding-left: 18px; }

/* ---------- content ---------- */
.crumbs { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.title { font-size: 32px; margin-bottom: 14px; }
.title .ix { color: var(--accent); }
.lead { font-family: var(--serif); font-size: 18px; line-height: 1.6; margin: 0 0 16px; max-width: 70ch; }
.syn { font-size: 14px; color: var(--ink-2); margin: 0 0 32px; max-width: 80ch; }
.syn strong { color: var(--ink); margin-right: 6px; }
.section { margin-top: 40px; }
.section h2 { font-size: 24px; margin-bottom: 12px; }
.section h2 .meta { font-family: var(--sans); font-size: 15px; font-weight: 400; color: var(--muted); }
.head-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 12px; }
.head-row h2 { margin: 0; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 4px; }
.controls .grow { flex: 1 1 260px; }
.controls select.field { max-width: 240px; text-overflow: ellipsis; }
.controls label.inline { font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); padding: 16px 0; }
.note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* ---------- code ---------- */
.examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.code-card { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); min-width: 0; }
.code-card figcaption { padding: 10px 16px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--line); }
.code-card.vul figcaption { color: var(--bad); }
.code-card.fix figcaption { color: var(--good); }
.code { margin: 0; padding: 12px 0; font: 12.5px/1.6 var(--mono); font-variant-ligatures: none; counter-reset: ln; tab-size: 4; }
.code .ln { display: grid; grid-template-columns: 2.6em minmax(0, 1fr); column-gap: 10px; padding-right: 14px; }
.code .ln::before { counter-increment: ln; content: counter(ln); text-align: right; color: #A3A7AD; user-select: none; }
.code .lc { white-space: pre-wrap; overflow-wrap: anywhere; text-indent: -2ch; }
.code strong { font-weight: 700; background: #FFF3C4; border-radius: 2px; }
.code .k { color: #8A3FA0; }
.code .ty { color: #0E6464; }
.code .s { color: #A24A12; }
.code .n { color: #1F55A8; }
.code .c { color: #6B6F76; font-style: italic; }
.ex-tabs { display: none; gap: 4px; padding: 4px; background: var(--chip); border-radius: 10px; margin-bottom: 10px; }
.ex-tabs button { flex: 1; height: 40px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font-size: 14px; color: var(--ink-2); }
.ex-tabs button[aria-selected="true"] { background: var(--surface); font-weight: 600; }
.ex-tabs button[data-tab="vul"][aria-selected="true"] { color: var(--bad); }
.ex-tabs button[data-tab="fix"][aria-selected="true"] { color: var(--good); }

/* ---------- references ---------- */
.refs { list-style: none; margin: 0 0 20px; padding: 0; }
.refs li { padding: 14px 0; border-bottom: 1px solid var(--line); display: flex; gap: 20px; }
.refs .src { flex: 0 0 140px; font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.refs .src span { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.refs .txt { flex: 1; min-width: 0; font-size: 14px; line-height: 1.55; color: var(--ink-2); overflow-wrap: anywhere; }
.refs .txt .chips { margin-top: 10px; gap: 6px; }
.refs .reports { margin: 10px 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
mark { background: #FFF0B3; color: inherit; border-radius: 2px; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; }
.pager .btn { min-width: 40px; padding: 0 12px; }
.pager .gap { color: var(--muted); padding: 0 4px; }
.pager .all { margin-left: 12px; }
.year-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 24px; }
.year-chips .btn { height: 36px; border-radius: 999px; font-size: 13px; padding: 0 12px; }
.year-chips .btn span { opacity: .75; margin-left: 4px; }


/* ---------- lists of nodes ---------- */
.node-list { list-style: none; margin: 0; padding: 0; }
.node-list li { border-bottom: 1px solid var(--line); }
.node-list a { display: block; padding: 14px 0; text-decoration: none; color: var(--ink); }
.node-list a:hover .nm { color: var(--accent); }
.node-list .nm { font-weight: 600; font-size: 15.5px; }
.node-list .nm .ix { color: var(--accent); margin-right: 8px; font-variant-numeric: tabular-nums; }
.node-list .sub { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); }
.node-list .why { display: block; margin-top: 3px; font-size: 13.5px; color: var(--ink-2); }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 24px; }
.cat { display: flex; flex-direction: column; gap: 6px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-decoration: none; color: var(--ink); }
.cat:hover { border-color: var(--accent); }
.cat .ix { font-size: 13px; color: var(--accent); font-weight: 600; }
.cat .nm { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.25; }
.cat .ds { font-size: 13.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cat .ct { font-size: 13px; color: var(--muted); margin-top: auto; }
.prevnext { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 48px; font-size: 13px; }
.prevnext a { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--muted); }
.prevnext a:hover { border-color: var(--accent); }
.prevnext a span { display: block; color: var(--ink); font-weight: 600; margin-top: 2px; }
.prevnext .next { text-align: right; grid-column: 2; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--band-line); background: var(--band); }
.footer-row { padding-top: 22px; padding-bottom: 22px; font-size: 13px; line-height: 1.6; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 32px; }
.footer-row p { margin: 0; }
.footer-row .updated { margin-left: auto; white-space: nowrap; }

/* ---------- dialog ---------- */
dialog { border: 0; border-radius: 14px; padding: 22px 24px; width: min(640px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink); }
dialog::backdrop { background: rgba(27, 31, 36, .45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dialog-head h2 { font-size: 22px; }
.dialog-cite { font-size: 14px; color: var(--ink-2); margin: 0 0 14px; overflow-wrap: anywhere; }
dialog pre { margin: 0; padding: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font: 12.5px/1.6 var(--mono); overflow-x: auto; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 14px; }
.copied { font-size: 13px; color: var(--good); }

/* ---------- tablet / mobile ---------- */
@media (max-width: 1100px) {
  .brand-sub { display: none; }
}
@media (max-width: 900px) {
  :root { --pad: 16px; }
  .header-row { gap: 4px; min-height: 56px; flex-wrap: nowrap; }
  .menu-btn, .search-btn { display: inline-flex; }
  .brand { flex: 1; }
  .brand-name { font-size: 22px; }
  .top-nav { display: none; }
  .search { display: none; }
  body.searching .header-row { flex-wrap: wrap; }
  body.searching .search { display: flex; order: 10; flex: 1 1 100%; padding-bottom: 10px; }
  body.searching .search input { max-width: none; height: 44px; font-size: 16px; }
  .cite-row { gap: 10px; }
  .cite-label, .cite-long { display: none; }
  .cite-short { display: inline; }
  .cite-text { white-space: normal; font-size: 12.5px; line-height: 1.4; }
  .btn-small { height: 36px; }

  .layout { display: block; }
  .sidebar { position: fixed; z-index: 40; top: 0; left: 0; bottom: 0; width: min(340px, 88vw); max-height: none; background: var(--surface); padding: 12px 12px 40px; box-shadow: 0 0 40px rgba(0,0,0,.2); transform: translateX(-105%); transition: transform .2s ease; }
  body.drawer .sidebar { transform: none; }
  .close-btn { display: inline-flex; }
  .scrim { position: fixed; inset: 0; z-index: 30; background: rgba(27,31,36,.4); }
  .tree { font-size: 15px; }
  .tree a { padding: 8px; }
  .tree .tog { height: 38px; flex-basis: 34px; }
  .tree .gap { flex-basis: 34px; }

  .main { padding: 20px 0 40px; }
  .title { font-size: 26px; }
  .lead { font-size: 17px; }
  .section { margin-top: 32px; }
  .section h2 { font-size: 22px; }
  .examples { display: block; }
  .ex-tabs { display: flex; }
  .examples[data-show="vul"] .code-card.fix, .examples[data-show="fix"] .code-card.vul { display: none; }
  .code-card figcaption { display: none; }
  .code { font-size: 12px; }
  .refs li { display: block; }
  .refs .src { margin-bottom: 4px; }
  .refs .src span { display: inline; margin-left: 4px; }
  .refs .src span::before { content: "· "; }
  .pager .all { margin-left: 0; }
  .field, .btn { height: 44px; }
  .controls .field { flex: 1 1 100%; }
  .controls select.field { max-width: none; }
  .controls label.inline { display: none; }
  .year-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .year-chips .btn { flex: 0 0 auto; }
  .footer-row .updated { margin-left: 0; }
}

/* ---------- decluttered meta ---------- */
.meta-line { margin: -4px 0 22px; font-size: 13.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 28px; }
.meta-line a { color: var(--muted); }
.meta-line a:hover { color: var(--accent); }
.meta-line .k { color: var(--ink-2); font-weight: 600; }
.side-link { display: block; margin: 0 0 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14px; font-weight: 600; text-decoration: none; }
.side-link:hover { border-color: var(--accent); }
.side-link[aria-current="page"] { background: var(--accent-soft); border-color: transparent; color: var(--accent-dark); }
body.on-refs .cite-band { display: none; }

/* ---------- footer ---------- */
.footer-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 24px; row-gap: 6px; align-items: center; padding-top: 14px; padding-bottom: 16px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.footer-grid p { margin: 0; }
.footer-grid .f-cite { color: var(--ink-2); }
.footer-grid .f-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-right: 6px; }
.footer-grid .f-btn, .footer-grid .updated { justify-self: end; }
.footer-grid .f-btn { height: 26px; padding: 0 10px; border: 1px solid #B9D3CF; border-radius: 5px; background: var(--surface); color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; }
.footer-grid .f-btn:hover { border-color: var(--accent); }
.footer-grid .updated { white-space: nowrap; }
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr; }
  .footer-grid .f-btn, .footer-grid .updated { justify-self: start; }
  .footer-grid .f-btn { height: 36px; }
}

/* ---------- two-level category pages ---------- */
.subgroup { margin: 22px 0 6px; padding: 16px 18px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.subgroup h3 { font-family: var(--sans); font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.subgroup h3 a { text-decoration: none; color: var(--ink); }
.subgroup h3 a:hover { color: var(--accent); }
.subgroup h3 .ix { color: var(--accent); margin-right: 8px; }
.subgroup h3 .meta { font-weight: 400; font-size: 13px; color: var(--muted); }
.subgroup .sg-desc { margin: 0 0 4px; font-size: 13.5px; color: var(--ink-2); max-width: 80ch; }
.node-list.nested li:last-child { border-bottom: 0; }
.node-list.nested a { padding: 10px 0 10px 18px; border-left: 2px solid var(--accent-soft); }
.node-list.nested .nm { font-size: 14.5px; }

/* ---------- home: categories in rows of four on wide screens ---------- */
.home { padding-bottom: 32px; }
.home .title { margin-bottom: 10px; }
.home .lead { max-width: none; margin-bottom: 4px; }
.home .cats { margin-top: 20px; }
.home .cat { padding: 14px 16px; gap: 4px; }
.home .cat .nm { font-size: 17px; }
.home .cat .ds { -webkit-line-clamp: 2; font-size: 13px; }
@media (min-width: 1200px) { .home .cats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---------- footer at the bottom of the window when content is short (not fixed) ---------- */
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body > .layout { flex: 1 0 auto; width: 100%; }
