/* ICD-10-CM Explorer prototype. No build, no dependencies.
   Brand tokens: light theme :root of https://www.medicalcorecoding.com CSS, retrieved 2026-12-03
   (see docs/ui-design/workflows.md#brand-tokens). "--*-text" tokens are our darker variants for AA text contrast. */
:root {
  --paper: #faf8f4; --surface: #fff; --surface-2: #f2efe8;
  --line: #e4dfd4; --line-strong: #cfc8b8;
  --ink: #0f1b2d; --ink-2: #3c4a5e; --ink-3: #5f6b7e;
  --brand: #1d4e89; --brand-strong: #133766; --brand-soft: #e6eef8;
  --accent: #d9443a; --accent-soft: #fbe9e6;
  --success: #0f7a55; --success-soft: #e3f4ec;
  --warning: #a8650a; --warning-soft: #fdf1dc;
  --logo-navy: #01254f; --logo-teal: #0a9a87;
  /* ours, derived for text on soft backgrounds (site accent/warning fail 4.5:1 there) */
  --accent-text: #b3261e; --warning-text: #8a5208;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-brand: "Lexend", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.5 var(--font-sans); overflow-wrap: break-word; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-strong); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 2px; }
main:focus, h1:focus, h2:focus { outline: none; }
h1:focus-visible, h2:focus-visible { outline: 3px solid var(--brand); }
code, .code { font-family: var(--font-mono); font-size: .95em; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: .75rem 0 .5rem; }
h2 { font-size: 1.2rem; line-height: 1.3; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
h4 { font-size: .95rem; margin: .75rem 0 .3rem; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.wrap { max-width: 76rem; margin: 0 auto; padding: 0 1rem; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.skip { position: absolute; left: -9999px; top: .5rem; z-index: 50; background: var(--surface); padding: .5rem .75rem; border: 2px solid var(--brand); }
.skip:focus { left: .5rem; }

/* Header */
.site { background: var(--surface); border-bottom: 1px solid var(--line); }
.site__top { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; padding-top: .6rem; padding-bottom: .4rem; }
.brand { display: inline-flex; align-items: center; gap: .75rem; text-decoration: none; }
.brand__word { display: inline-flex; flex-direction: column; font: 600 1.1rem/1.02 var(--font-brand); letter-spacing: -.01em; }
/* Brand teal (#0a9a87) is about 3:1 on white; text uses a darker teal for WCAG AA (4.5:1). */
.brand__n { color: var(--logo-navy); } .brand__t { color: #077566; }
.brand__product { font-weight: 600; color: var(--ink-2); border-left: 1px solid var(--line-strong); padding-left: .75rem; }
.site__nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-left: auto; font-size: .95rem; }
.site__nav a { padding: .25rem 0; color: var(--ink-2); }
.site__nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.site__back::after { content: " \2197"; }

/* Search */
.search { position: relative; padding-bottom: .75rem; }
.search__label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .2rem; }
.search__box { display: flex; gap: .5rem; }
.search input { flex: 1; min-width: 0; font: inherit; font-size: 1.0625rem; padding: .55rem .7rem; border: 1px solid var(--ink-3); border-radius: .4rem; background: var(--surface); color: var(--ink); }
.btn { font: inherit; font-weight: 600; padding: .45rem .9rem; border-radius: .4rem; border: 1px solid var(--brand); background: var(--surface); color: var(--brand); cursor: pointer; min-height: 2.25rem; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-strong); }
.btn--small { font-size: .8125rem; padding: .2rem .55rem; min-height: 1.9rem; }
.search__list { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--ink-3); border-radius: .4rem; box-shadow: 0 8px 24px rgba(15,27,45,.15); }
.lb-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); background: var(--surface-2); padding: .3rem .7rem; }
.lb-opt { padding: .45rem .7rem; cursor: pointer; border-top: 1px solid var(--line); }
.lb-opt[aria-selected="true"] { background: var(--brand-soft); outline: 2px solid var(--brand); outline-offset: -2px; }
.lb-opt .code { font-weight: 700; margin-right: .4rem; }
.lb-more { padding: .45rem .7rem; border-top: 1px solid var(--line); font-weight: 600; color: var(--brand); }

/* Release banner */
.release { background: var(--brand-soft); border-top: 1px solid var(--line); color: var(--brand-strong); font-size: .9rem; }
.release__in { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem; padding-top: .4rem; padding-bottom: .4rem; }
.release__label { font-weight: 700; }
.release details { font-size: .875rem; }
.release summary { cursor: pointer; color: var(--brand); text-decoration: underline; }
.release__form { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: end; padding: .5rem 0; }
.release__form label { display: block; font-weight: 600; color: var(--ink); }
.release__form select, .release__form input { font: inherit; padding: .3rem .4rem; border: 1px solid var(--ink-3); border-radius: .3rem; background: var(--surface); color: var(--ink); }
.release__msg { flex-basis: 100%; margin: 0; color: var(--ink); }
.proto-flag { color: var(--warning-text); font-weight: 600; }

/* Breadcrumbs */
.crumbs ol { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .15rem; font-size: .875rem; }
.crumbs li:not(:last-child)::after { content: "\203A"; margin: 0 .35rem; color: var(--ink-3); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }

/* Status (always text) */
.status { display: inline-block; font-size: .8125rem; font-weight: 600; line-height: 1.4; padding: 0 .4rem; border: 1px solid; border-radius: .25rem; white-space: nowrap; }
.status--billable { color: var(--success); background: var(--success-soft); }
.status--need7 { color: var(--warning-text); background: var(--warning-soft); border-color: var(--warning); }
.status--header { color: var(--ink-2); background: var(--surface-2); border-color: var(--ink-3); }
.status--absent { color: var(--accent-text); background: var(--accent-soft); }

/* Notes */
.note { margin: .4rem 0; padding: .35rem .6rem .45rem; background: var(--surface); border: 1px solid var(--line-strong); border-left: 4px solid var(--ink-3); border-radius: .25rem; }
.note__label { margin: 0; font-size: .875rem; }
.note__tag { font-weight: 700; display: inline-block; margin-right: .15rem; }
.note ul { margin: .15rem 0 0; padding-left: 1.15rem; }
.note li { margin: .05rem 0; }
.note p.note__para { margin: .15rem 0 0; }
/* Excludes1: double-line box + filled label. Excludes2: dashed box + outlined label. Shape and label, not colour only. */
.note--excludes1 { border: 4px double var(--accent-text); }
.note--excludes1 .note__tag { background: var(--accent-text); color: #fff; padding: 0 .4rem; border-radius: .2rem; }
.note--excludes2 { border: 2px dashed var(--ink-2); }
.note--excludes2 .note__tag { border: 1px solid var(--ink-2); padding: 0 .35rem; border-radius: .2rem; }
.note--codeFirst, .note--useAdditionalCode, .note--codeAlso { border-left-color: var(--brand); }
.note--inclusionTerm, .note--includes { border-left-color: var(--success); }
.note--sevenChrNote { border-left-color: var(--warning); }
.note--other { border-left-color: var(--accent); }

.ngroup { margin: .6rem 0; }
.ngroup__src { margin: .6rem 0 .2rem; font-size: .875rem; color: var(--ink-2); }
.ngroup__src .code { color: var(--ink); }
.ngroup--inherited { padding-left: .6rem; border-left: 3px solid var(--line-strong); }

/* Category layout */
.cat-head h1 .code { margin-right: .4rem; }
.cat-layout { display: flex; flex-direction: column; gap: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--line-strong); border-radius: .5rem; padding: .75rem 1rem 1rem; }
.panel__eyebrow { margin: 0; font-size: .8125rem; color: var(--ink-2); }
.panel h2 { margin: .2rem 0 .1rem; font-size: 1.5rem; }
.panel__title { margin: .1rem 0 .4rem; font-size: 1.0625rem; }
.panel__short { margin: 0 0 .4rem; font-size: .875rem; color: var(--ink-2); }
.panel__actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .3rem 0 .5rem; }
.panel .crumbs ol { margin-top: .25rem; }
.treebox h2 { margin-top: .25rem; }
@media (min-width: 60rem) {
  .cat-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-areas: "tree panel"; align-items: start; gap: 1.5rem; }
  .panel { grid-area: panel; position: sticky; top: .5rem; max-height: calc(100vh - 1rem); overflow: auto; }
  .treebox { grid-area: tree; }
}

/* Tree (nested lists of links; codes are anchors) */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: .35rem; padding-left: clamp(.45rem, 2.2vw, 1.1rem); border-left: 1px solid var(--line-strong); }
.trow { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .5rem; padding: .2rem .3rem; border-radius: .25rem; }
.trow .code { font-weight: 700; }
.trow .desc { flex: 1 1 12rem; min-width: 0; }
.tnode.is-selected > .trow { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.tnode > .note, .tnode > .vis, .tnode > details { margin-left: .3rem; }
.tnode > .note { font-size: .9rem; }
.tdef summary { cursor: pointer; font-size: .875rem; color: var(--brand); margin: .1rem 0 .2rem .3rem; }

/* 7th characters */
.ext-list { list-style: none; margin: .3rem 0; padding: 0; border: 1px solid var(--line-strong); border-radius: .4rem; background: var(--surface); }
.ext { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: .1rem .5rem; padding: .45rem .55rem; border-top: 1px solid var(--line); }
.ext:first-child { border-top: 0; }
.ext__char { grid-row: span 3; font: 700 1.15rem/1.3 var(--font-mono); text-align: center; }
.ext__code { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; }
.ext__code a { font-weight: 700; }
.ext__title { font-size: .875rem; color: var(--ink-2); }
.ext.is-target { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.ext--note { display: block; font-size: .875rem; background: var(--surface-2); }
.ext--note .note__tag { margin-right: .3rem; }
.ext-src { font-size: .875rem; color: var(--ink-2); margin: .2rem 0; }

/* Visual impairment table (H54.8) */
.vis { margin: .4rem 0 .6rem; overflow-x: auto; max-width: 100%; }

/* Neoplasm and Drug tables: a real table on wide screens, labelled cards on phones (no sideways scrolling). */
.xtable th[scope="row"] { font-weight: 400; }
.xtable td a { font-family: var(--font-mono); white-space: nowrap; }
.xpath { color: var(--ink-3); font-size: .85em; }
.xtable .xpath { display: none; }
@media (max-width: 45rem) {
  .xtable, .xtable tbody, .xtable tr, .xtable th, .xtable td { display: block; width: 100%; }
  .xtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .xtable tr { border: 1px solid var(--line-strong); border-radius: .4rem; margin: .5rem 0; background: var(--surface); }
  .xtable th[scope="row"] { padding-left: .5rem !important; border: 0; border-bottom: 1px solid var(--line); font-weight: 600; }
  .xtable .xpath { display: inline; }
  .xtable td { border: 0; display: flex; justify-content: space-between; gap: 1rem; padding: .2rem .5rem; }
  .xtable td::before { content: attr(data-label); color: var(--ink-2); }
}
table { border-collapse: collapse; width: 100%; background: var(--surface); font-size: .9rem; }
th, td { border: 1px solid var(--line-strong); padding: .3rem .4rem; text-align: left; vertical-align: top; }
thead th { background: var(--surface-2); }

/* Lists and cards */
.plain { list-style: none; padding: 0; margin: .3rem 0; }
.plain > li { padding: .35rem 0; border-top: 1px solid var(--line); }
.plain > li:first-child { border-top: 0; }
.chap-list a { font-weight: 600; }
.cat-list { columns: 1; }
@media (min-width: 45rem) { .cat-list { columns: 2; } }
.cat-list li { break-inside: avoid; }
.unavail { color: var(--ink-3); }
.notice { background: var(--warning-soft); border: 1px solid var(--warning); border-radius: .4rem; padding: .5rem .75rem; margin: .75rem 0; color: var(--ink); }
.letters { display: flex; flex-wrap: wrap; gap: .25rem; list-style: none; padding: 0; margin: .5rem 0; }
.letters li > * { display: inline-block; min-width: 2rem; min-height: 2rem; text-align: center; line-height: 2rem; border: 1px solid var(--line-strong); border-radius: .25rem; }
.letters a { font-weight: 700; border-color: var(--brand); }
.letters span { color: var(--ink-3); }
.letters [aria-current] { background: var(--brand); color: #fff; }

/* Index */
.terms, .terms ul { list-style: none; margin: 0; padding: 0; }
.terms ul { margin-left: .3rem; padding-left: clamp(.4rem, 2vw, 1rem); border-left: 1px solid var(--line-strong); }
.term { padding: .12rem .25rem; border-radius: .2rem; }
.term .code { font-weight: 700; margin-left: .35rem; }
.nemod { color: var(--ink-2); }
.xref { font-style: italic; }
.term.is-target, .mainterm.is-target > h2 { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.mainterm h2 { font-size: 1.15rem; }
.manif { font-family: var(--font-mono); }

/* Search results */
.res-group h2 .count { font-weight: 400; color: var(--ink-2); font-size: .95rem; }
.res .path { color: var(--ink-2); }
.res .code { font-weight: 700; margin-right: .4rem; }
.jump { display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding: 0; list-style: none; }

/* About */
.prov { font-size: .8125rem; }
.prov { table-layout: fixed; }
.prov td { overflow-wrap: anywhere; }
.prov td:nth-child(2) { font-family: var(--font-mono); word-break: break-all; }
.prov th:nth-child(3), .prov td:nth-child(3) { width: 5.5rem; }
.quote { border-left: 4px solid var(--brand); padding: .25rem .75rem; background: var(--surface); }
.sitehelp { border: 1px dashed var(--ink-3); padding: .25rem .75rem; border-radius: .4rem; }

.site-foot { margin-top: 2.5rem; border-top: 1px solid var(--line); background: var(--surface-2); font-size: .8125rem; color: var(--ink-2); padding: .75rem 0 1.25rem; }
.foot__draft { font-weight: 600; color: var(--warning-text); }

@media (max-width: 30rem) {
  h1 { font-size: 1.3rem; }
  .brand__product { font-size: .9rem; }
  .site__nav { margin-left: 0; width: 100%; font-size: .875rem; gap: .25rem .9rem; }
  .site__back { display: none; } /* the link back stays in the footer on phones */
  .site__top { padding-top: .4rem; padding-bottom: .2rem; }
  .search { padding-bottom: .5rem; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media print {
  .site, .site-foot, .search, .tdef summary { display: none; }
  .panel { position: static; max-height: none; border: 0; }
}

/* Index navigation (ADR-011) */
.inav { margin: .5rem 0 1rem; }
.inav__groups { padding: .35rem; margin: .25rem 0; background: var(--surface); border: 1px solid var(--line-strong); border-radius: .4rem; }
.inav__groups li > * { min-width: 2.5rem; padding: 0 .4rem; }
.inav__groups .is-big { font-weight: 600; }
.inav__jumps li > * { min-width: 2.75rem; padding: 0 .3rem; font-size: .9rem; }
.inav__jumps::before { content: "Jump to:"; align-self: center; font-size: .875rem; color: var(--ink-2); margin-right: .25rem; }
.find { position: relative; max-width: 32rem; margin-top: .5rem; }
.find label { display: block; font-size: .875rem; font-weight: 600; }
.find input { width: 100%; font: inherit; padding: .4rem .6rem; border: 1px solid var(--ink-3); border-radius: .4rem; background: var(--surface); color: var(--ink); }
.find__list { position: absolute; left: 0; right: 0; z-index: 20; background: var(--surface); border: 1px solid var(--ink-3); border-radius: .4rem; max-height: 50vh; overflow: auto; margin: .2rem 0 0; }
.find__list li { padding: .3rem .6rem; }

/* Sticky header (ADR-011): brand row and search stay on screen; on phones only the search bar after scrolling. */
.site { position: sticky; top: 0; z-index: 40; box-shadow: 0 1px 0 var(--line); }
html { scroll-padding-top: calc(var(--header-h, 8.5rem) + .75rem); } /* default when JavaScript is off */
/* Tree codes are links: give each a target of at least 24 x 24 px (WCAG 2.2, 2.5.8). */
.trow a.code { display: inline-block; min-height: 24px; min-width: 24px; line-height: 24px; padding: 0 .15rem; }
@media (min-width: 60rem) {
  .panel { top: calc(var(--header-h, 0px) + .5rem); max-height: calc(100vh - var(--header-h, 0px) - 1rem); }
}
@media (max-width: 45rem) {
  body.is-scrolled .site__top { display: none; }
  body.is-scrolled .search { padding-top: .4rem; }
  body.is-scrolled .search__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
@media print { .site { position: static; } }

/* Multi-code check (REQ-023) */
.check-form label { display: block; font-weight: 600; margin-top: .5rem; }
.check-table td, .check-table th { vertical-align: top; }
.check-list > li { padding: .5rem 0; }
.check-pair { margin: 0 0 .2rem; }
.check-pair .code { font-weight: 700; }

/* Fixes after visual review: [hidden] must win over flex layouts; the current letter keeps its contrast; the check
   input fills the row like the main search box. */
[hidden] { display: none !important; }
.inav [aria-expanded="true"]:not([aria-current]) { background: var(--brand-soft); }
.check-form .search__box input { flex: 1; min-width: 0; font: inherit; font-size: 1.0625rem; padding: .55rem .7rem;
  border: 1px solid var(--ink-3); border-radius: .4rem; background: var(--surface); color: var(--ink); }
.check-broad { margin: .75rem 0; }
.check-broad summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.check-cond { color: var(--warning-text); font-weight: 600; }

/* Index path line: the levels the visible entries sit inside, pinned under the header while scrolling. */
.ipath { position: sticky; top: var(--header-h, 0px); z-index: 30; background: var(--brand-soft); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: .3rem; padding: .3rem .6rem; margin: .25rem 0; font-size: .9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ipath a { color: var(--brand-strong); font-weight: 600; }

/* Drill-down Index search (ADR-012) */
.drill { position: relative; max-width: 44rem; margin: .5rem 0 1rem; }
.drill label { display: block; font-weight: 600; }
.drill > p { margin: .1rem 0 .35rem; }
.drill__box { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; padding: .3rem .4rem; border: 1px solid var(--ink-3);
  border-radius: .4rem; background: var(--surface); }
.drill__box:focus-within { outline: 3px solid var(--brand); outline-offset: 2px; }
.drill__path { display: contents; list-style: none; margin: 0; padding: 0; }
.drill__path li::after { content: " ›"; color: var(--ink-3); }
.drill__chip { font: inherit; font-size: .9rem; border: 1px solid var(--brand); background: var(--brand-soft); color: var(--brand-strong);
  border-radius: .3rem; padding: .1rem .45rem; cursor: pointer; min-height: 24px; }
.drill__box input { flex: 1 1 10rem; min-width: 8rem; border: 0; outline: 0; font: inherit; font-size: 1.0625rem; padding: .3rem; background: transparent; color: var(--ink); }
.drill__list { position: absolute; left: 0; right: 0; z-index: 35; list-style: none; margin: .2rem 0 0; padding: 0; max-height: 60vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--ink-3); border-radius: .4rem; box-shadow: 0 8px 24px rgba(15,27,45,.15); }
.drill__list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .5rem; padding: .4rem .7rem; border-top: 1px solid var(--line); cursor: pointer; }
.drill__list li[aria-selected="true"] { background: var(--brand-soft); outline: 2px solid var(--brand); outline-offset: -2px; }
.drill__label { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.drill__label mark { background: transparent; color: inherit; font-weight: 700; text-decoration: underline; text-decoration-color: var(--brand); text-underline-offset: 2px; }
.drill__code { font-weight: 700; }
.drill__more { font-weight: 600; font-size: .85rem; color: var(--brand); white-space: nowrap; }
.drill__open { font-weight: 600; color: var(--brand-strong); }
/* ADR-018: which level is shown, and branch rows (have subterms, "n ›") apart from terminal rows (code, no arrow). */
.drill__list li.drill__head, .drill__list li.drill__empty { cursor: default; }
.drill__head { position: sticky; top: 0; z-index: 1; font-size: .75rem; font-weight: 700; letter-spacing: .03em; color: var(--ink-2);
  background: var(--surface-2); border-top: 0 !important; }
.drill__empty { color: var(--ink-2); }
.drill__opt--leaf .drill__label { color: var(--ink-2); }
.drill__opt--leaf[aria-selected="true"] .drill__label { color: var(--ink); }
.drill__reset { color: var(--brand); font-size: .9rem; }
.drill__chip--root { border-color: var(--ink-3); background: transparent; color: var(--ink-2); }
.drill__chip[aria-current="step"] { font-weight: 600; }
@media (max-width: 40rem) {
  .drill__list { max-height: 55vh; }
  .drill__list li { padding: .55rem .6rem; }
  .drill__label { flex: 1 1 0; }
}
.inav__more { margin: .4rem 0; }
.inav__more summary { cursor: pointer; color: var(--brand); font-weight: 600; }
/* Path line: stacked, one level per line (overrides the single-line style above). */
.ipath { white-space: normal; text-overflow: clip; padding: .25rem .6rem; }
.ipath__lvl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.45; }
/* On index pages, jumps land below the header and the stacked path line (up to about three lines). */
html:has([data-ipath]) { scroll-padding-top: calc(var(--header-h, 8.5rem) + 5.5rem); }
/* QA ADR-012 B1: the path line is an overlay under the header, out of the page flow, so showing, hiding or resizing
   it can never move the page (no scroll-anchoring feedback loop). Content scrolls under it. */
.ipath { position: fixed; top: var(--header-h, 0px); left: 0; right: 0; margin: 0; border-radius: 0; border-width: 0 0 1px;
  padding: .25rem max(1rem, calc((100vw - 76rem) / 2 + 1rem)); box-shadow: 0 2px 6px rgba(15,27,45,.08); }
/* Jumps land below the header and the path line (at most 4 lines). */
html:has([data-ipath]) { scroll-padding-top: calc(var(--header-h, 8.5rem) + 6.5rem); }

/* The printed Index shows a gap before nonessential modifiers; the XML has none. Presentation only. */
.term__l .nemod { margin-left: .25em; }

/* Neoplasm and Drug tables: the table name and the column headings stay pinned under the header while scrolling.
   Desktop: the whole <thead> (name row + headings) is sticky. Phones (cards, headings hidden): the name bar is sticky. */
.xname__eyebrow { display: block; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.xname__title { display: block; font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.xname { display: none; }
@media (min-width: 45.01rem) {
  .xtable thead { position: sticky; top: var(--header-h, 0px); z-index: 20; }
  .xtable thead th { background: var(--surface-2); box-shadow: inset 0 -1px 0 var(--line-strong); }
  .xtable__name th { background: var(--brand-soft); text-align: left; }
}
.xtable tbody tr { scroll-margin-top: calc(var(--header-h, 8.5rem) + 6rem); }
@media (max-width: 45rem) {
  .xname { display: block; position: sticky; top: var(--header-h, 0px); z-index: 20; margin: 0; padding: .3rem .6rem;
    background: var(--brand-soft); border-bottom: 1px solid var(--line-strong); }
  .xtable tbody tr { scroll-margin-top: calc(var(--header-h, 8.5rem) + 3.5rem); }
}

.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 1.5rem 0 .5rem; font-weight: 600; }
.pager a { padding: .3rem .6rem; border: 1px solid var(--brand); border-radius: .3rem; text-decoration: none; min-height: 24px; }

/* Ad boxes (ADR-014): labelled, reserved height (no layout shift), hidden when unfilled, never printed. */
.ad-slot { margin: 1.25rem 0; min-height: 120px; }
.ad-slot__label { margin: 0 0 .3rem; text-align: center; font-size: .65rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
@media (min-width: 45rem) { .ad-slot { min-height: 280px; } }
.ad-slot:has(ins[data-ad-status="unfilled"]), html[data-adfree] .ad-slot { display: none; }
@media print { .ad-slot, ins.adsbygoogle { display: none !important; } }

/* Ads at the sides (ADR-016): wide screens get a 300 px rail beside the content that stays in view below the header
   (AdSense: desktop only, <= 300 px wide, vertical movement, never overlapping content); narrower screens get one box
   at the end of the page. No ads inside the content. */
.ad-slot--rail { display: none; }
@media (min-width: 90rem) {
  .page-grid[data-ads] { display: grid; grid-template-columns: minmax(0, 76rem) 300px; justify-content: center; column-gap: 1.5rem; padding-right: 1rem; }
  .page-grid[data-ads] > main.wrap { margin: 0; max-width: none; width: 100%; }
  .ad-slot--rail { display: block; position: sticky; top: calc(var(--header-h, 8.5rem) + 1rem); align-self: start; width: 300px; min-height: 600px; margin-top: 1rem; }
  html:has([data-ipath]) .ad-slot--rail { top: calc(var(--header-h, 8.5rem) + 7rem); }
  .page-grid[data-ads] .ad-slot--end { display: none; }
  /* The index path line spans the content column only, so it never covers the rail. */
  html:has(.page-grid[data-ads]) .ipath { right: calc(300px + 2.5rem); }
}

/* Phones and narrow screens (ADR-016): one slim banner at the very end of the page only, never while reading. */
.ad-slot--end { min-height: 100px; max-width: 728px; margin: 2rem auto 1rem; }
@media (min-width: 45rem) { .ad-slot--end { min-height: 100px; } }

/* Category page: while no code is selected the panel is hidden, so the code list uses the full width. */
@media (min-width: 60rem) {
  .cat-layout:has(> .panel[hidden]) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tree"; }
}
/* With the side rail, the header and release bar span content + rail so everything lines up. */
@media (min-width: 90rem) {
  html:has(.page-grid[data-ads]) .site .wrap, html:has(.page-grid[data-ads]) .release .wrap { max-width: calc(76rem + 300px + 1.5rem); }
}
