/* ==========================================================================
   NanoBaseLib — site stylesheet
   Design tokens first, then primitives, layout, components, charts, print.
   Dark mode: OS preference by default, overridable via <html data-theme>.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;

  /* type */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --fs-0: 0.8125rem;  /* 13 */
  --fs-1: 0.875rem;   /* 14 */
  --fs-2: 1rem;       /* 16 */
  --fs-3: 1.125rem;   /* 18 */
  --fs-4: 1.375rem;   /* 22 */
  --fs-5: 1.75rem;    /* 28 */
  --fs-6: 2.25rem;    /* 36 */
  --fs-7: clamp(2.5rem, 2rem + 2.5vw, 3.75rem);
  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-body: 1.65;

  /* space & shape */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem; --sp-5: 1.5rem;
  --sp-6: 2rem; --sp-7: 3rem; --sp-8: 4rem; --sp-9: 6rem;
  --radius-s: 6px; --radius-m: 10px; --radius-l: 16px; --radius-pill: 999px;
  --content-w: 48rem;      /* prose measure */
  --page-w: 84rem;         /* overall shell */
  --sidebar-w: 16rem;
  --toc-w: 13rem;
  --header-h: 3.75rem;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --highlight: rgba(255, 255, 255, 0);

  /* surfaces & ink (light) */
  --bg: #f7f7f5;
  --bg-elev: #ffffff;
  --bg-sunken: #efefec;
  --bg-code: #f1f2f0;
  --ink: #15191e;
  --ink-2: #4b5560;
  --ink-3: #7a8591;
  --line: #e2e3df;
  --line-strong: #cfd2cc;

  /* brand: teal derived from the logo gradient (#0079cd → #19c6b3) */
  --accent: #0b7f8a;
  --accent-strong: #08636c;
  --accent-soft: #d8f0f1;
  --accent-ink: #065d66;
  --on-accent: #ffffff;
  --accent-grad: linear-gradient(135deg, #0079cd 0%, #19c6b3 100%);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  /* task categorical palette (validated: adjacent CVD ΔE ≥ 9, light & dark) */
  --task-bc: #2a78d6;  /* base calling */
  --task-pd: #eb6834;  /* polyA detection */
  --task-sa: #1baf7a;  /* segmentation & event alignment */
  --task-md: #4a3aa7;  /* modification detection */

  /* chart chrome */
  --chart-grid: #e1e0d9;
  --chart-axis: #c3c2b7;
  --chart-bar: #2a78d6;
  --chart-bar-muted: #9ec5f4;
  --chart-best: #0b7f8a;

  --shadow-s: 0 1px 2px rgba(21, 25, 30, 0.05), 0 1px 3px rgba(21, 25, 30, 0.06);
  --shadow-m: 0 2px 2px rgba(21, 25, 30, 0.04), 0 8px 16px -4px rgba(21, 25, 30, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1316;
    --bg-elev: #161b20;
    --bg-sunken: #0b0e11;
    --bg-code: #1b2127;
    --ink: #e8eaed;
    --ink-2: #aeb6bf;
    --ink-3: #7f8993;
    --line: #262d34;
    --line-strong: #353e47;
    --accent: #3fb7c0;
    --accent-strong: #6fd0d7;
    --accent-soft: #123a3e;
    --accent-ink: #9be0e5;
  --on-accent: #06282b;
    --on-accent: #06282b;
    --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
    --highlight: rgba(255, 255, 255, 0.06);
    --task-bc: #3987e5; --task-pd: #d95926; --task-sa: #199e70; --task-md: #9085e9;
    --chart-grid: #2c2c2a; --chart-axis: #383835;
    --chart-bar: #3987e5; --chart-bar-muted: #1c5cab; --chart-best: #3fb7c0;
    --shadow-s: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-m: 0 6px 24px rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1316;
  --bg-elev: #161b20;
  --bg-sunken: #0b0e11;
  --bg-code: #1b2127;
  --ink: #e8eaed;
  --ink-2: #aeb6bf;
  --ink-3: #7f8993;
  --line: #262d34;
  --line-strong: #353e47;
  --accent: #3fb7c0;
  --accent-strong: #6fd0d7;
  --accent-soft: #123a3e;
  --accent-ink: #9be0e5;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --highlight: rgba(255, 255, 255, 0.06);
  --task-bc: #3987e5; --task-pd: #d95926; --task-sa: #199e70; --task-md: #9085e9;
  --chart-grid: #2c2c2a; --chart-axis: #383835;
  --chart-bar: #3987e5; --chart-bar-muted: #1c5cab; --chart-best: #3fb7c0;
  --shadow-s: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-m: 0 6px 24px rgba(0, 0, 0, 0.45);
}

/* ---------- 2. Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 1rem); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-2);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}
img, svg, video { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 0.15em; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
h1, h2, h3, h4 { font-weight: 650; line-height: var(--lh-snug); letter-spacing: -0.012em; margin: 0 0 var(--sp-3); color: var(--ink); text-wrap: balance; }
h1 { font-size: var(--fs-6); line-height: 1.1; letter-spacing: -0.022em; }
h2 { font-size: var(--fs-5); margin-top: var(--sp-8); letter-spacing: -0.02em; }
h3 { font-size: var(--fs-4); margin-top: var(--sp-6); }
h4 { font-size: var(--fs-3); margin-top: var(--sp-5); }
p, ul, ol, table, figure, pre, blockquote { margin: 0 0 var(--sp-4); }
ul, ol { padding-left: 1.4rem; }
li + li { margin-top: var(--sp-1); }
small, .small { font-size: var(--fs-1); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-7) 0; }
code, kbd, pre { font-family: var(--font-mono); font-size: 0.875em; }
code { background: var(--bg-code); padding: 0.1em 0.35em; border-radius: 4px; }
pre { background: var(--bg-code); border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--sp-4) var(--sp-5); overflow-x: auto; line-height: 1.55; }
pre code { background: none; padding: 0; font-size: var(--fs-1); }
blockquote { border-left: 3px solid var(--accent); padding: var(--sp-2) var(--sp-4); color: var(--ink-2); background: var(--bg-elev); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
figure { margin: var(--sp-6) 0; }
figcaption { font-size: var(--fs-1); color: var(--ink-3); margin-top: var(--sp-3); text-align: center; }
.figure-plain img { display: block; margin: 0 auto; }
.figure-card img { display: block; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--sp-3); }
.figure-narrow img { max-width: 40rem; }
.prose { max-width: var(--content-w); }
.lede { font-size: var(--fs-3); color: var(--ink-2); max-width: 44rem; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: var(--sp-4); top: -3rem; background: var(--accent); color: #fff; padding: var(--sp-2) var(--sp-4); border-radius: var(--radius-s); z-index: 100; }
.skip-link:focus { top: var(--sp-2); }
.math { font-family: var(--font-mono); background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--sp-3) var(--sp-4); overflow-x: auto; display: block; margin: var(--sp-4) 0; }

/* ---------- 3. Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .inner { max-width: var(--page-w); margin: 0 auto; height: 100%; padding: 0 var(--sp-5); display: flex; align-items: center; gap: var(--sp-4); }
.brand { display: flex; align-items: center; gap: var(--sp-3); color: var(--ink); font-weight: 700; letter-spacing: -0.015em; font-size: 1.25rem; }
.brand:hover { text-decoration: none; }
.brand-name span { color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: var(--sp-1); margin-left: var(--sp-3); }
.site-nav a { color: var(--ink-2); font-weight: 500; font-size: var(--fs-1); padding: 0.4rem 0.7rem; border-radius: var(--radius-s); }
.site-nav a:hover { color: var(--ink); background: var(--bg-sunken); text-decoration: none; }
.site-nav a[aria-current="true"] { color: var(--accent-ink); background: var(--accent-soft); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; border-radius: var(--radius-s); border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--bg-sunken); color: var(--ink); text-decoration: none; }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .sun, .theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="light"] .theme-toggle .moon { display: block; }
:root:not([data-theme]) .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .theme-toggle .moon { display: none; } :root:not([data-theme]) .theme-toggle .sun { display: block; } }
.menu-btn { display: none; }

/* ---------- 4. Buttons, badges, chips ---------- */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.1rem; border-radius: var(--radius-s); font-weight: 600; font-size: var(--fs-1); border: 1px solid var(--line-strong); background: var(--bg-elev); color: var(--ink); cursor: pointer; transition: background .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease); line-height: 1.2; box-shadow: var(--shadow-s), inset 0 1px 0 var(--highlight); }
.btn:hover { text-decoration: none; background: var(--bg-sunken); transform: translateY(-1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.btn-lg { padding: 0.8rem 1.4rem; font-size: var(--fs-2); }
.btn-group { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.badge { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--fs-0); font-weight: 600; padding: 0.15rem 0.55rem; border-radius: var(--radius-pill); background: var(--bg-sunken); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; line-height: 1.5; }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.task-bc { --task: var(--task-bc); } .task-pd { --task: var(--task-pd); } .task-sa { --task: var(--task-sa); } .task-md { --task: var(--task-md); }
.badge-task { background: color-mix(in srgb, var(--task) 14%, var(--bg-elev)); border-color: color-mix(in srgb, var(--task) 35%, transparent); color: var(--ink); }
.badge-task .dot { background: var(--task); }
.eyebrow { font-size: var(--fs-0); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: var(--sp-2); }
.kbd { font-family: var(--font-mono); font-size: var(--fs-0); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 0.35rem; background: var(--bg-elev); }

/* ---------- 5. Layout ---------- */
/* grid/flex children must be allowed to shrink below their content (long <pre> lines) */
.hero .inner > *, .two-col > *, .cite-box > *, .cards > *, .steps > *, .stats > *, .docs > * { min-width: 0; }
.page { max-width: var(--page-w); margin: 0 auto; padding: 0 var(--sp-5); }
.docs { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); gap: var(--sp-7); align-items: start; padding-top: var(--sp-6); padding-bottom: var(--sp-9); }
.docs > main { min-width: 0; }
.sidebar, .toc { position: sticky; top: calc(var(--header-h) + var(--sp-5)); max-height: calc(100vh - var(--header-h) - var(--sp-6)); overflow-y: auto; font-size: var(--fs-1); }
.sidebar nav ul, .toc ul { list-style: none; padding: 0; margin: 0; }
.sidebar .group { margin-bottom: var(--sp-5); }
.sidebar .group-title { font-size: var(--fs-0); font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); margin: 0 0 var(--sp-2) 0.6rem; }
.sidebar a { display: block; padding: 0.35rem 0.6rem; border-radius: var(--radius-s); color: var(--ink-2); border-left: 2px solid transparent; }
.sidebar a:hover { background: var(--bg-sunken); color: var(--ink); text-decoration: none; }
.sidebar a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }
.sidebar li + li { margin-top: 1px; }
.toc .toc-title { font-size: var(--fs-0); font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); margin-bottom: var(--sp-2); }
.toc a { display: block; padding: 0.25rem 0 0.25rem 0.75rem; color: var(--ink-3); border-left: 2px solid var(--line); font-size: var(--fs-0); }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.active { color: var(--accent-ink); border-left-color: var(--accent); }
.toc li.depth-3 a { padding-left: 1.5rem; }
.page-header { margin-bottom: var(--sp-6); padding-bottom: var(--sp-5); border-bottom: 1px solid var(--line); }
.page-header h1 { margin-bottom: var(--sp-2); }
.page-header .lede { margin: 0; }
.page-header .meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.pager { display: flex; justify-content: space-between; gap: var(--sp-4); margin-top: var(--sp-8); padding-top: var(--sp-5); border-top: 1px solid var(--line); }
.pager a { display: block; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius-m); color: var(--ink); max-width: 48%; background: var(--bg-elev); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .dir { display: block; font-size: var(--fs-0); color: var(--ink-3); }
.pager .next { margin-left: auto; text-align: right; }

/* ---------- 6. Home ---------- */
.hero { position: relative; overflow: hidden; padding: var(--sp-9) 0 var(--sp-8); }
.hero .inner { max-width: var(--page-w); margin: 0 auto; padding: 0 var(--sp-5); display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--sp-7); align-items: start; }
.hero .btn-group .btn { white-space: nowrap; }
.hero h1 { font-size: var(--fs-7); margin: var(--sp-3) 0 var(--sp-4); }
.hero h1 em { font-style: normal; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lede { margin-bottom: var(--sp-6); }
.hero-bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.hero-bg .signal { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; opacity: 0.55; }
.hero-bg .glow { position: absolute; width: 60vw; height: 60vw; max-width: 900px; max-height: 900px; border-radius: 50%; filter: blur(80px); opacity: 0.22; background: var(--accent-grad); right: -15vw; top: -30vw; }
.hero-logo { display: block; width: min(100%, 560px); margin: 0 auto; filter: drop-shadow(0 12px 30px rgba(0, 121, 205, 0.18)); }
.hero-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-l); padding: var(--sp-5); box-shadow: var(--shadow-m), inset 0 1px 0 var(--highlight); }
.hero-card .label { font-size: var(--fs-0); font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.hero-card pre { margin: var(--sp-3) 0 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--sp-4); margin: var(--sp-6) 0; }
.stat { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-s), inset 0 1px 0 var(--highlight); }
.stat .value { font-size: var(--fs-5); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.stat .label { font-size: var(--fs-1); color: var(--ink-2); margin-top: var(--sp-1); }
.section { padding: var(--sp-8) 0; }
.section-alt { background: var(--bg-elev); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { max-width: 44rem; margin-bottom: var(--sp-6); }
.section-head h2 { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: var(--sp-4); }
.card { position: relative; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-l); padding: var(--sp-5); box-shadow: var(--shadow-s), inset 0 1px 0 var(--highlight); transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease); display: flex; flex-direction: column; gap: var(--sp-3); }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-m); border-color: var(--line-strong); }
.card h3 { margin: 0; font-size: var(--fs-3); }
.card p { margin: 0; color: var(--ink-2); font-size: var(--fs-1); flex: 1; }
.card .card-link { font-weight: 600; font-size: var(--fs-1); }
.card .card-link::after { content: " →"; }
.card > a.stretched::after { content: ""; position: absolute; inset: 0; }
.task-card { border-top: 3px solid var(--task); }
.task-card .task-num { font-family: var(--font-mono); font-size: var(--fs-0); color: var(--task); font-weight: 700; }
.task-card .task-io { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.6rem; font-size: var(--fs-0); color: var(--ink-3); margin-top: var(--sp-2); }
.task-card .task-io b { color: var(--ink-2); font-weight: 600; }
.steps { counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--sp-4); }
.step { position: relative; padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--bg); }
.step::before { counter-increment: step; content: counter(step); display: inline-flex; width: 1.75rem; height: 1.75rem; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: var(--fs-0); margin-bottom: var(--sp-2); }
.step h3 { font-size: var(--fs-2); margin: 0 0 var(--sp-1); }
.step p { margin: 0; font-size: var(--fs-1); color: var(--ink-2); }
.step .tool { display: block; margin-top: var(--sp-2); font-family: var(--font-mono); font-size: var(--fs-0); color: var(--accent-ink); }
.step.optional { border-style: dashed; }
.cite-box { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
.cite-box pre { margin: 0; }
.workflow-figure { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-l); padding: var(--sp-4); }
.workflow-figure img { display: block; margin: 0 auto; max-height: 34rem; }

/* venue / affiliation band under the hero: centered monochrome logos with tiny labels (Linear / Vercel pattern) */
.affil-band { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg-elev); }
.affil-band .inner { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: var(--sp-7); padding-top: var(--sp-5); padding-bottom: var(--sp-5); }
.affil { display: inline-flex; align-items: center; gap: var(--sp-4); color: var(--ink-2); }
.affil:hover { text-decoration: none; }
.affil-label { font-size: var(--fs-0); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
.affil img { height: 46px; width: auto; display: block; }
.affil img.lg { height: 40px; }
/* keep the venue/affiliation logos in their original colours; on the dark theme they sit on a white plate so the colours survive */
.affil .plate { display: inline-flex; align-items: center; padding: 0.4rem 0.7rem; border-radius: var(--radius-s); background: #fff; }
.affil-sep { width: 1px; height: 36px; background: var(--line-strong); }
.footer-logo { display: inline-block; margin-top: var(--sp-3); color: var(--ink); }
.footer-logo .footer-marks { height: 26px; width: auto; display: block; }
.footer-logo:hover { text-decoration: none; }
/* A: ink at reduced opacity; symbols: one uniform grey, their own colour on hover */
.site-footer .footer-logo .mark-a { fill: var(--ink); opacity: .55; transition: opacity .3s var(--ease); }
.site-footer .footer-logo .mark-s { fill: var(--ink-3); opacity: .7; transition: fill .3s var(--ease), opacity .3s var(--ease); }
.site-footer .footer-logo:hover .mark-a { opacity: 1; }
.site-footer .footer-logo:hover .mark-s { fill: var(--mark); opacity: 1; }
@media (max-width: 560px) { .affil-band .inner { gap: var(--sp-4); } .affil-sep { display: none; } .affil { flex-direction: column; gap: var(--sp-2); } }

/* links directory */
.cards-links { grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); margin-bottom: var(--sp-6); }
.link-card { padding: var(--sp-4) var(--sp-5); gap: var(--sp-2); }
.link-card .link-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.link-card h3 { font-size: var(--fs-2); margin: 0; }
.link-card h3 a { color: var(--ink); }
.link-card:hover h3 a { color: var(--accent); text-decoration: none; }
.link-card .badge { flex: none; }
.link-card .link-host { font-size: var(--fs-0); color: var(--ink-3); }

/* ---------- 7. Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--bg-elev); margin-bottom: var(--sp-5); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-1); }
.table-wrap table { margin: 0; }
th, td { padding: 0.6rem 0.8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th { font-size: var(--fs-0); font-weight: 600; color: var(--ink-2); background: var(--bg-sunken); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.group-cell { font-weight: 600; vertical-align: top; background: var(--bg-elev); }
tr.group-start td { border-top: 2px solid var(--line-strong); }
.table-wrap.dense th, .table-wrap.dense td { padding: 0.4rem 0.6rem; font-size: var(--fs-0); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: "↕"; opacity: 0.35; margin-left: 0.3rem; font-size: 0.8em; }
th.sortable[aria-sort="ascending"]::after { content: "↑"; opacity: 1; }
th.sortable[aria-sort="descending"]::after { content: "↓"; opacity: 1; }
.check { color: var(--task-sa); font-weight: 700; } .cross { color: var(--ink-3); }
.best { font-weight: 700; color: var(--accent-ink); }
.best::after { content: " ★"; font-size: 0.75em; }
.sub { font-size: var(--fs-0); color: var(--ink-3); }
.table-toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin-bottom: var(--sp-3); }
.table-toolbar .count { margin-left: auto; font-size: var(--fs-0); color: var(--ink-3); }
.input { font: inherit; font-size: var(--fs-1); padding: 0.45rem 0.7rem; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--bg-elev); color: var(--ink); min-width: 12rem; }
.input:focus { outline: none; box-shadow: var(--focus); border-color: var(--accent); }
select.input { padding-right: 1.8rem; }
.chip { font: inherit; font-size: var(--fs-0); font-weight: 600; padding: 0.3rem 0.7rem; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--bg-elev); color: var(--ink-2); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--task); margin-right: 0.35rem; vertical-align: middle; }
.dl-link { font-family: var(--font-mono); font-size: var(--fs-0); word-break: break-all; }
.dl-link svg { width: 12px; height: 12px; vertical-align: -1px; margin-right: 2px; }
.empty-row td { text-align: center; color: var(--ink-3); padding: var(--sp-6); }

/* inline bar cells (table-as-chart) */
.bar-cell { min-width: 9rem; }
.bar { display: flex; align-items: center; gap: 0.5rem; font-variant-numeric: tabular-nums; }
.bar .track { flex: 1; height: 10px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--chart-bar); border-radius: 0 3px 3px 0; }
.bar.is-best .fill { background: var(--chart-best); }
.bar .val { min-width: 3.2rem; text-align: right; font-size: var(--fs-0); }

/* ---------- 8. Inline SVG charts ---------- */
.chart { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--sp-4) var(--sp-4) var(--sp-3); margin-bottom: var(--sp-5); }
.chart-title { font-weight: 600; font-size: var(--fs-1); margin-bottom: 0.1rem; }
.chart-sub { font-size: var(--fs-0); color: var(--ink-3); margin-bottom: var(--sp-3); }
.chart svg { display: block; width: 100%; height: auto; font-family: var(--font-sans); }
.chart .grid line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis line, .chart .axis path { stroke: var(--chart-axis); stroke-width: 1; }
.chart text { fill: var(--ink-2); font-size: 12px; }
.chart text.val { fill: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart text.tick { fill: var(--ink-3); font-size: 11px; }
.chart .mark { fill: var(--chart-bar); }
.chart .mark.best { fill: var(--chart-best); }
.chart .mark.muted { fill: var(--chart-bar-muted); }
.chart .mark:hover { opacity: 0.85; }
.chart .legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--fs-0); color: var(--ink-2); margin-top: var(--sp-2); }
.chart .legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.35rem; vertical-align: -1px; }
.chart-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(28rem, 1fr)); gap: var(--sp-4); }

/* ---------- 9. Callouts, code toolbar, misc ---------- */
.callout { display: flex; gap: var(--sp-3); padding: var(--sp-4); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-m); background: var(--bg-elev); margin: var(--sp-5) 0; font-size: var(--fs-1); }
.callout svg { flex: none; width: 20px; height: 20px; color: var(--accent); margin-top: 2px; }
.callout p:last-child { margin-bottom: 0; }
.callout > div { min-width: 0; flex: 1; }
.callout-warn { border-left-color: var(--task-pd); } .callout-warn svg { color: var(--task-pd); }
.code-block { position: relative; }
.code-block pre { padding-top: var(--sp-5); padding-right: 4.5rem; }
.code-block .copy { position: absolute; top: 0.5rem; right: 0.5rem; font-size: var(--fs-0); padding: 0.25rem 0.55rem; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--bg-elev); color: var(--ink-2); cursor: pointer; opacity: 0.8; }
.code-block .copy:hover { opacity: 1; color: var(--ink); }
.code-block[data-lang]::before { content: attr(data-lang); position: absolute; top: 0.45rem; left: 0.9rem; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 var(--sp-4) var(--sp-5); margin: 0; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 0.45rem; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.timeline time { display: block; font-family: var(--font-mono); font-size: var(--fs-0); color: var(--ink-3); }
.people { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--sp-4); }
.person { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--sp-4); }
.person .name { font-weight: 600; }
.person .role { color: var(--ink-3); font-size: var(--fs-1); }
.dl-list { list-style: none; padding: 0; }
.dl-list li { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; justify-content: space-between; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--bg-elev); margin: 0 0 var(--sp-2); }
.dl-list .size { font-family: var(--font-mono); font-size: var(--fs-0); color: var(--ink-3); }
.tree { font-family: var(--font-mono); font-size: var(--fs-0); line-height: 1.5; }
.tree .c { color: var(--ink-3); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: var(--sp-5); align-items: start; }
.refs { font-size: var(--fs-1); color: var(--ink-2); }
.refs li { margin-bottom: var(--sp-2); }
.to-top { position: fixed; right: var(--sp-5); bottom: var(--sp-5); opacity: 0; pointer-events: none; transition: opacity .2s; background: var(--bg-elev); border: 1px solid var(--line-strong); box-shadow: var(--shadow-m); }
.to-top.show { opacity: 1; pointer-events: auto; }

/* ---------- 10. Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-elev); padding: var(--sp-7) 0 var(--sp-6); margin-top: var(--sp-8); font-size: var(--fs-1); color: var(--ink-2); }
.site-footer .inner { max-width: var(--page-w); margin: 0 auto; padding: 0 var(--sp-5); display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: var(--sp-6); }
.site-footer h4 { font-size: var(--fs-0); text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); margin: 0 0 var(--sp-3); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 0 0 var(--sp-2); }
.site-footer a { color: var(--ink-2); }
.site-footer a:hover { color: var(--accent); }
.site-footer .bottom { max-width: var(--page-w); margin: var(--sp-6) auto 0; padding: var(--sp-4) var(--sp-5) 0; border-top: 1px solid var(--line); font-size: var(--fs-0); color: var(--ink-3); display: flex; flex-wrap: wrap; gap: var(--sp-3); justify-content: space-between; }

/* ---------- 11. Responsive ---------- */
@media (max-width: 1180px) {
  .docs { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 900px) {
  .site-nav { display: none; }
  .menu-btn { display: inline-flex; }
  .docs { grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
  .sidebar { position: fixed; inset: var(--header-h) auto 0 0; width: min(85vw, 20rem); max-height: none; background: var(--bg-elev); border-right: 1px solid var(--line); padding: var(--sp-5); transform: translateX(-100%); transition: transform .22s ease; z-index: 40; box-shadow: var(--shadow-m); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 39; display: none; }
  .sidebar-backdrop.show { display: block; }
  .hero { padding: var(--sp-7) 0 var(--sp-6); }
  .hero .inner { grid-template-columns: 1fr; }
  .hero-logo { width: min(80%, 320px); }
  .cite-box { grid-template-columns: 1fr; }
  .site-footer .inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  :root { --fs-6: 1.9rem; --fs-5: 1.5rem; }
  .page, .site-header .inner, .hero .inner, .site-footer .inner, .site-footer .bottom { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .site-footer .inner { grid-template-columns: 1fr; }
  .pager { flex-direction: column; } .pager a { max-width: none; } .pager .next { text-align: left; }
  th, td { padding: 0.5rem 0.6rem; }
}

/* ---------- 12. Print ---------- */
@media print {
  .site-header, .sidebar, .toc, .site-footer, .to-top, .pager, .table-toolbar, .copy { display: none !important; }
  .docs { display: block; }
  body { background: #fff; color: #000; }
  a { color: inherit; text-decoration: underline; }
  .table-wrap { overflow: visible; border: 0; }
}
