/* NOISE · Encyclopedia — an acoustic laboratory reader.
   reader-motion.js draws the wave/particle field on the fixed .notes-scene canvas. The foreground is one bench laid
   under that field: the masthead (the workspace's frame), the category channels and the concept index are solid
   grounds (--field-occlude: 1), so the field never runs behind small controls; it shows in each entry's title
   window, where the title stands in it until the field settles into the reading surface.
   That surface starts 1.75rem above the summary and runs to the end of the entry, edge to edge of the entry pane, so
   it joins the index instead of floating as a sheet. No nested cards; plates are kept for formulas and diagrams only.
   Breakpoints are container queries in rem, so larger text recomposes and scrolls rather than shrinking.
   Window media queries are used only for what a page cannot measure: height, hover, motion, colour scheme, print. */

:root {
  color-scheme: light dark;
  /* grounds: the scene, the index, the reading surface, plates and raised controls */
  --void: light-dark(#e3e9e8, #05090b);
  --panel: light-dark(#edf1f0, #080f12);
  --sheet: light-dark(#fbfcfb, #0b1316);
  --plate: light-dark(#f3f6f5, #0f181c);
  --raised: light-dark(#ffffff, #121c20);
  --ink: light-dark(#0f1719, #e6eeec);
  --ink-read: light-dark(#1e2a2c, #cbd6d3);
  --ink-2: light-dark(#3a4749, #aab7b4);
  --ink-3: light-dark(#5a6669, #7f8d8a);
  --rule: light-dark(rgb(15 23 25 / .1), rgb(214 232 228 / .085));
  --rule-2: light-dark(rgb(15 23 25 / .2), rgb(214 232 228 / .17));
  --rule-3: light-dark(rgb(15 23 25 / .36), rgb(214 232 228 / .32));
  --wash: light-dark(rgb(15 23 25 / .05), rgb(214 232 228 / .055));
  --wash-2: light-dark(rgb(15 23 25 / .085), rgb(214 232 228 / .095));
  /* one accent, from the global display settings */
  --accent: var(--noise-accent, light-dark(#08765b, #6cdebd));
  --accent-ink: light-dark(#ffffff, #03130d);
  --accent-wash: color-mix(in oklab, var(--accent) 12%, transparent);
  --accent-line: color-mix(in oklab, var(--accent) 50%, transparent);
  --link-line: color-mix(in oklab, var(--accent) 46%, transparent);
  --signal: var(--accent);
  /* diagram keys */
  --teal: light-dark(#0b6f66, #5cc6bf); --violet: light-dark(#5a3fae, #b29dff); --amber: light-dark(#8a5300, #f0b440); --alert: light-dark(#b4400f, #ff8a5c);
  --tick: color-mix(in oklab, var(--ink-3) 75%, transparent);
  --focus: var(--accent);
  --lift: 0 1px 2px light-dark(rgb(15 23 25 / .07), rgb(0 0 0 / .45));
  --pop: 0 1.25rem 2.75rem -1rem light-dark(rgb(15 23 25 / .3), rgb(0 0 0 / .75));
  /* fonts arrive through the global reader settings; the stacks after each variable are the defaults */
  --cjk: "Hiragino Sans", "Yu Gothic UI", "Noto Sans CJK JP";
  --f-display: var(--noise-font-ui, "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", var(--cjk), system-ui, sans-serif);
  --f-ui: var(--noise-font-ui, "Segoe UI Variable Text", "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", var(--cjk), system-ui, sans-serif);
  --f-read: var(--noise-font-reading, "Iowan Old Style", Charter, "Source Serif 4", "Source Serif Pro", Cambria, Georgia, serif);
  --f-num: var(--noise-font-number, "Cascadia Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, Consolas, var(--cjk), monospace);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --hit: max(2.75rem, 44px);
  --row: 2.5rem;
  --r: 6px; --r-l: 8px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
:root:lang(ja) { --cjk: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", Meiryo; --f-read: var(--noise-font-reading, var(--f-ui)); }
:root:lang(zh) { --cjk: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", "Hiragino Sans GB"; --f-read: var(--noise-font-reading, var(--f-ui)); }
@media (pointer: coarse) { :root { --row: 2.75rem; } }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--void); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* body is the page-width container so the page frame itself can respond to it */
body { container: notes-page / inline-size; margin: 0; color: var(--ink); background: var(--void); font: 400 1rem/1.55 var(--f-ui); letter-spacing: 0; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a, button, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: color-mix(in oklab, var(--accent) 34%, transparent); color: var(--ink); }
.notes-icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.notes-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.notes-skip { position: absolute; z-index: 10; top: .75rem; inset-inline-start: .75rem; padding: .75rem 1rem; font-weight: 600; color: var(--accent-ink); background: var(--accent); border-radius: var(--r); text-decoration: none; }
.notes-skip:not(:focus) { width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- the scene: reader-motion.js reads its colours and strength from here ---------- */
/* grain = border-top-color, crest = color, crest lines = border-bottom-color */
.notes-scene { position: fixed; inset: 0 0 auto; z-index: 0; display: block; width: 100%; height: 100lvh; pointer-events: none;
  color: var(--accent); border-top-color: light-dark(#1f3236, #c3ddd8); border-bottom-color: color-mix(in oklab, var(--accent) 70%, var(--ink));
  --field-strength: 1; --field-halo: 1; }
/* light: graphite sand on a white plate, no glow */
:root[data-theme="light"] .notes-scene { --field-strength: .82; --field-halo: 0; }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .notes-scene { --field-strength: .82; --field-halo: 0; } }

.notes-page { position: relative; z-index: 1; min-height: 100dvh; display: flex; flex-direction: column; }
.notes-layout { flex: 1 0 auto; display: flex; flex-direction: column; min-width: 0; }

/* ---------- masthead: the workspace's frame, on the scene's own colour but solid ---------- */
/* a wrapped row of controls (narrow screens) settles at the end, under Back/Forward, so the mark keeps its column */
.notes-header { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .5rem .75rem; padding: .625rem 1.25rem .375rem; background: var(--void); border-bottom: 1px solid var(--rule);
  /* the shared workspace flow is appended here; give it this page's ink and rules */
  --workspace-line: var(--rule); --workspace-ink: var(--ink-2); --workspace-accent: var(--accent); --workspace-surface: var(--raised); --workspace-hit: var(--hit); }
.notes-brand { display: flex; align-items: center; gap: .75rem; min-width: 0; margin-inline-end: auto; }
.notes-mark { display: inline-flex; align-items: center; gap: .625rem; min-height: var(--hit); padding-inline: .125rem .25rem; color: var(--ink); text-decoration: none; border-radius: var(--r); }
.notes-mark::before { content: ""; flex: none; width: 3px; height: 1.125rem; background: var(--accent); border-radius: 1px; }
.notes-mark b { font: 650 .9375rem/1 var(--f-num); letter-spacing: 0; }
.notes-title { min-width: 0; margin: 0; padding-inline-start: .75rem; font: 500 1rem/1.25 var(--f-display); color: var(--ink-2); border-inline-start: 1px solid var(--rule-2); overflow-wrap: anywhere; }
/* workspace destinations are the app's places: plain links in the masthead, their signs receded. The encyclopedia's
   own chapters are the tabs below, on the index's ground, with an underline. */
.notes-header > .workspace-flow[data-embedded] { margin-top: .125rem; }
.notes-header .workspace-rail a:not([aria-current="page"]) .ui-icon { color: var(--ink-3); transition: color 160ms ease; }
/* back / forward: one segmented control, beside the settings */
.notes-steps { display: flex; align-items: center; }
.notes-steps .notes-tool:first-child:not(:only-child) { border-start-end-radius: 0; border-end-end-radius: 0; }
.notes-steps .notes-tool + .notes-tool { margin-inline-start: -1px; border-start-start-radius: 0; border-end-start-radius: 0; }
.notes-steps .notes-tool:focus-visible { z-index: 1; }
.notes-settings { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; max-width: 100%; }

.notes-tool { position: relative; display: inline-grid; place-items: center; width: var(--hit); height: var(--hit); padding: 0; color: var(--ink-2); text-decoration: none; background: transparent; border: 1px solid var(--rule-2); border-radius: var(--r); transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 140ms var(--ease-out); }
/* the global settings button joins the same row of tools */
.notes-settings .noise-settings-entry { width: var(--hit); height: var(--hit); min-width: 0; min-height: 0; padding: 0; color: var(--ink-2); background: transparent; border: 1px solid var(--rule-2); border-radius: var(--r); transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 140ms var(--ease-out); }
:is(.notes-tool .notes-icon, .notes-settings .noise-settings-entry > svg) { width: 1.25rem; height: 1.25rem; stroke-width: 1.75; }
.notes-tool:disabled { color: var(--ink-3); opacity: .5; cursor: not-allowed; }
.notes-settings:has(#notesTools:popover-open) #notesToolsToggle { color: var(--accent); background: var(--accent-wash); border-color: var(--accent-line); }

/* language: native select, globe inside, drawn caret */
.notes-language { position: relative; display: inline-flex; align-items: center; color: var(--ink-2); }
.notes-language > .notes-icon { position: absolute; inset-inline-start: .75rem; width: 1.125rem; height: 1.125rem; pointer-events: none; }
#notesLanguage { appearance: none; min-height: var(--hit); padding: 0 2.125rem 0 2.375rem; font: 600 .9375rem/1 var(--f-ui); color: var(--ink); cursor: pointer;
  background: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%) calc(100% - 1.0625rem) 50% / .3125rem .3125rem no-repeat,
              linear-gradient(135deg, var(--ink-2) 50%, transparent 50%) calc(100% - .75rem) 50% / .3125rem .3125rem no-repeat, transparent;
  border: 1px solid var(--rule-2); border-radius: var(--r); transition: background-color 160ms ease, border-color 160ms ease; }
#notesLanguage option { color: var(--ink); background: var(--raised); }

/* More: a small menu under the masthead; each tool shows its name */
#notesTools { position: fixed; inset: 4.5rem .75rem auto auto; margin: 0; min-width: 14rem; max-width: calc(100vw - 1.5rem); max-height: calc(100dvh - 5.5rem); overflow: auto; padding: .375rem; color: var(--ink); background: var(--raised); border: 1px solid var(--rule-2); border-radius: var(--r-l); box-shadow: var(--pop); transform-origin: 100% 0;
  opacity: 0; transform: translateY(-.25rem) scale(.98);
  transition: opacity 140ms var(--ease-out), transform 180ms var(--ease-out), overlay 180ms allow-discrete, display 180ms allow-discrete; }
#notesTools:popover-open { display: grid; gap: 2px; opacity: 1; transform: none; }
@starting-style { #notesTools:popover-open { opacity: 0; transform: translateY(-.25rem) scale(.98); } }
#notesTools .notes-tool { display: flex; align-items: center; justify-content: flex-start; gap: .75rem; width: 100%; height: auto; min-height: var(--hit); padding: .5rem 1rem .5rem .75rem; color: var(--ink-2); background: transparent; border-color: transparent; }
#notesTools .notes-tool::after { content: attr(title); font: 500 .9375rem/1.3 var(--f-ui); color: var(--ink); text-align: start; overflow-wrap: anywhere; }
#notesMotion[aria-pressed="true"] { color: var(--accent); }

/* ---------- category channels: the encyclopedia's own tabs, on the index's ground ---------- */
/* While the tabs overflow, a pager follows them in its own space and each clipped edge fades only on the side
   that has more. Focus still scrolls a tab into view, clear of the fade (scroll-padding). */
.notes-strip { flex: none; position: relative; display: flex; align-items: stretch; background: var(--panel); border-bottom: 1px solid var(--rule); }
#notesCategories { flex: 1 1 auto; min-width: 0; display: flex; gap: .125rem; padding-inline: .75rem; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; scroll-padding-inline: 2.75rem; }
#notesCategories::-webkit-scrollbar { display: none; }
.notes-strip[data-overflow] #notesCategories { --fade-from: #000; --fade-to: #000;
  -webkit-mask-image: linear-gradient(90deg, var(--fade-from), #000 2.5rem calc(100% - 2.5rem), var(--fade-to)); mask-image: linear-gradient(90deg, var(--fade-from), #000 2.5rem calc(100% - 2.5rem), var(--fade-to)); }
.notes-strip[data-more-start] #notesCategories { --fade-from: transparent; }
.notes-strip[data-more-end] #notesCategories { --fade-to: transparent; }
.notes-strip-step { display: none; flex: none; place-items: center; width: var(--hit); padding: 0; color: var(--ink-2); background: none; border: 0; transition: color 160ms ease, background-color 160ms ease, opacity 160ms ease; }
.notes-strip[data-overflow] .notes-strip-step { display: grid; }
.notes-strip-step:first-of-type { border-inline-start: 1px solid var(--rule); }
.notes-strip-step .notes-icon { width: 1.125rem; height: 1.125rem; }
.notes-strip-step[data-step="-1"] .notes-icon { transform: rotate(180deg); }
.notes-strip:not([data-more-start]) .notes-strip-step[data-step="-1"], .notes-strip:not([data-more-end]) .notes-strip-step[data-step="1"] { opacity: .32; pointer-events: none; }
#notesCategories button { position: relative; flex: none; display: inline-flex; align-items: center; gap: .5rem; min-height: 3rem; padding: .5rem .75rem; font: 500 .9375rem/1.2 var(--f-ui); color: var(--ink-2); white-space: nowrap; background: none; border: 0; border-radius: var(--r) var(--r) 0 0; transition: color 160ms ease, background-color 160ms ease; }
#notesCategories button .notes-icon { width: 1.125rem; height: 1.125rem; color: var(--ink-3); transition: color 160ms ease; }
#notesCategories button::after { content: ""; position: absolute; inset-inline: .5rem; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: 0; }
#notesCategories button[aria-pressed="true"] { font-weight: 650; color: var(--ink); }
#notesCategories button[aria-pressed="true"] .notes-icon { color: var(--accent); }
#notesCategories button[aria-pressed="true"]::after { opacity: 1; }
#notesCategories button:focus-visible { outline-offset: -2px; }

/* ---------- concept index ---------- */
/* one opaque panel at every width. Narrow: a single search row with Browse beside the field, the list behind
   Browse. Wide: a pane joined to the entry. */
.notes-directory { --field-occlude: 1; position: relative; min-width: 0; padding: .625rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--rule); }
.notes-search { min-width: 0; }
.notes-field { display: flex; align-items: center; gap: .5rem; min-height: var(--hit); padding-inline: .75rem .25rem; color: var(--ink-3); background: var(--raised); border: 1px solid var(--rule-2); border-radius: var(--r); transition: border-color 160ms ease, box-shadow 160ms ease; }
.notes-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.notes-field-icon { width: 1.125rem; height: 1.125rem; }
#notesSearch { flex: 1; min-width: 0; min-height: 2.5rem; padding: 0; font: 400 1rem/1.3 var(--f-ui); color: var(--ink); background: none; border: 0; outline: none; }
#notesSearch::placeholder { color: var(--ink-3); opacity: 1; }
#notesSearch::-webkit-search-cancel-button { display: none; }
#notesClear { flex: none; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0; color: var(--ink-2); background: none; border: 0; border-radius: 4px; transition: color 140ms ease, background-color 140ms ease; }
#notesClear .notes-icon { width: 1rem; height: 1rem; }
/* nothing to clear: give its width back to the search wording */
#notesClear:disabled { display: none; }
.notes-index-head { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .625rem; margin-top: .625rem; }
.notes-label { margin: 0; font: 600 .8125rem/1.3 var(--f-ui); color: var(--ink-2); }
#notesCount { font: 500 .8125rem/1.3 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink-3); }
#notesBrowse { display: inline-flex; align-items: center; gap: .5rem; min-height: var(--hit); margin-inline-start: auto; padding: .375rem .875rem .375rem .75rem; font: 600 .875rem/1.2 var(--f-ui); color: var(--ink); background: var(--raised); border: 1px solid var(--rule-2); border-radius: var(--r); transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 140ms var(--ease-out); }
#notesBrowse .notes-icon { width: 1.125rem; height: 1.125rem; color: var(--ink-2); }
#notesBrowse[aria-expanded="true"] { color: var(--accent); background: var(--accent-wash); border-color: var(--accent-line); }
#notesBrowse[aria-expanded="true"] .notes-icon { color: currentColor; }

#notesResults { display: none; min-width: 0; padding-block: .25rem 1rem; }
.notes-directory--expanded { max-height: min(78dvh, 46rem); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent; }
.notes-directory--expanded .notes-search { position: sticky; top: 0; z-index: 2; margin-inline: -1.25rem; padding: .75rem 1.25rem .5rem; background: var(--panel); }
.notes-directory--expanded #notesResults { display: grid; }
/* group heading: channel icon, name, and how many concepts it holds */
.notes-result-group { display: grid; grid-template-columns: 1rem minmax(0, 1fr) auto; align-items: center; column-gap: .625rem; margin: 1rem 0 .25rem; padding: .875rem .75rem .25rem; font: 650 .8125rem/1.3 var(--f-ui); color: var(--ink-2); border-top: 1px solid var(--rule); }
.notes-result-group:first-child { margin-top: 0; padding-top: .5rem; border-top: 0; }
.notes-result-group .notes-icon { width: 1rem; height: 1rem; color: var(--accent); }
.notes-result-count { font: 500 .75rem/1 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink-3); }
#notesResults a { position: relative; display: grid; grid-template-columns: 1.125rem minmax(0, 1fr); align-items: center; column-gap: .75rem; min-height: var(--row); padding: .4375rem .75rem; font: 400 .9375rem/1.35 var(--f-ui); color: var(--ink-2); text-decoration: none; border-radius: var(--r); transition: background-color 140ms ease, color 140ms ease; }
#notesResults a .notes-icon { width: 1.125rem; height: 1.125rem; color: var(--ink-2); transition: color 140ms ease, opacity 140ms ease; }
/* sign hierarchy: accent marks "here" (this entry, the chosen tab, the group); a concept that repeats its
   channel's sign keeps it, receded, so the concepts with a sign of their own lead the list */
#notesResults a.notes-link--channel .notes-icon { color: var(--ink-3); opacity: .6; }
#notesResults a:focus-visible { outline-offset: -2px; }
#notesResults a[aria-current="page"] { font-weight: 650; color: var(--ink); background: var(--accent-wash); }
#notesResults a[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: 0; top: .5rem; bottom: .5rem; width: 2px; background: var(--accent); border-radius: 2px; }
#notesResults a[aria-current="page"] .notes-icon { color: var(--accent); opacity: 1; }
.notes-link-text { min-width: 0; overflow-wrap: anywhere; }
.notes-empty { margin: .75rem; font: 400 .9375rem/1.5 var(--f-ui); color: var(--ink-3); }

/* ---------- the entry ---------- */
#notesArticle { container: notes-article / inline-size; position: relative; display: flex; flex-direction: column; min-width: 0; flex: 1 0 auto; }
#notesArticle:focus { outline: none; }
#notesArticle:focus-visible { outline: 2px solid var(--accent-line); outline-offset: -2px; }
/* Grid rows: meta, title, summary, reading. Columns: a gutter each side of the text track, so the surface
   (::before) spans the entry edge to edge while the type keeps its measure. */
#notesArticle > article {
  --gut: 1.25rem; --aperture: 2.25rem;
  position: relative; isolation: isolate; flex: 1 0 auto; display: grid;
  grid-template-columns: [sheet-start] var(--gut) [text-start] minmax(0, 1fr) [text-end] var(--gut) [sheet-end];
  grid-template-rows: auto auto auto 1fr;
  padding-top: var(--aperture);
}
#notesArticle > article > * { grid-column: text; min-width: 0; }
/* the reading surface: rises 1.75rem above the summary (the scene keeps clear from 1.5rem) to the end of the entry */
#notesArticle > article::before { content: ""; grid-column: sheet; grid-row: 3 / -1; z-index: -1; margin-top: -1.75rem; background: var(--sheet); pointer-events: none; }
/* the field settles into the surface instead of stopping at an edge */
#notesArticle > article::after { content: ""; grid-column: sheet; grid-row: 3; align-self: start; z-index: -1; height: 3rem; margin-top: -4.75rem; background: linear-gradient(transparent, var(--sheet)); pointer-events: none; }

/* title in the field: the channel named in words behind a short rule, then the concept with its instrument glyph,
   the one sign of the title block */
.notes-meta { grid-row: 1; display: flex; align-items: center; margin-bottom: .75rem; }
.notes-category { display: inline-flex; align-items: center; gap: .625rem; font: 650 .875rem/1.3 var(--f-ui); color: var(--accent); }
.notes-category::before { content: ""; flex: none; width: 1.25rem; height: 2px; background: currentColor; border-radius: 1px; }
/* the title-to-summary gap belongs to the title, so row 3 (and the surface) starts exactly at the summary */
#notesArticle > article > h2 { grid-row: 2; display: flex; align-items: flex-start; gap: .875rem; max-width: 48rem; margin: 0 0 2.75rem; font: 650 1.625rem/1.2 var(--f-display); color: var(--ink); text-wrap: balance; }
#notesArticle > article > :is(.notes-meta, h2), #notesArticle > .notes-state { text-shadow: 0 0 .25rem var(--void), 0 0 1rem var(--void); }
.notes-glyph { --size: 2.25rem; position: relative; flex: none; display: grid; place-items: center; width: var(--size); height: var(--size); margin-top: calc(.6em - var(--size) / 2); color: var(--accent); background: color-mix(in oklab, var(--void) 72%, transparent); border: 1px solid var(--accent-line); border-radius: var(--r-l); }
.notes-glyph .notes-icon { width: 55%; height: 55%; stroke-width: 1.6; }
/* one sonar ping when an entry arrives (full motion only) */
.notes-glyph::after { content: ""; position: absolute; inset: -1px; border: 1px solid var(--accent); border-radius: inherit; opacity: 0; pointer-events: none; }
.notes-heading-text { min-width: 0; overflow-wrap: anywhere; }

/* lede: the definition, the first thing on the surface */
.notes-summary { grid-row: 3; max-width: 42rem; margin: 0; font: 400 1.125rem/1.6 var(--f-read); line-height: var(--noise-line-height, 1.6); color: var(--ink); text-wrap: pretty; }

/* reading: contents (only when it has two or more places), the article column, related concepts */
.notes-reading { grid-row: 4; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; padding: 2rem 0 5rem; }
.notes-main { min-width: 0; max-width: 42rem; }
.notes-main > * + * { margin-top: 2.75rem; }
.notes-prose { --lead: var(--noise-line-height, 1.75); min-width: 0; overflow-wrap: anywhere; }
:lang(ja) .notes-prose, :lang(zh) .notes-prose { --lead: calc(var(--noise-line-height, 1.75) + .2); }
.notes-prose > p { margin: 0 0 1.125em; font: 400 1.0625rem/var(--lead) var(--f-read); color: var(--ink-read); text-wrap: pretty; }
.notes-prose > p:last-child { margin-bottom: 0; }
.notes-article-section { margin-top: 2.5rem; }
.notes-article-section:first-child { margin-top: 0; }
:is(.notes-article-section, .notes-formula-section, .notes-figure, .notes-sources) { scroll-margin-top: 1.5rem; }
#notesArticle .notes-main h3 { margin: 0 0 1rem; font: 650 1.1875rem/1.35 var(--f-display); color: var(--ink); text-wrap: balance; }
.notes-article-section :is(ul, ol) { margin: 0; }
.notes-article-section li { font: 400 1.0625rem/var(--lead) var(--f-read); color: var(--ink-read); }
.notes-article-section ul { padding-inline-start: 1.25rem; }
.notes-article-section ul > li { margin-block: .5em; padding-inline-start: .25rem; }
.notes-article-section ul > li::marker { color: var(--accent); }
/* procedure: native numbering only, hung in the margin, each step on a hairline */
.notes-procedure { padding-inline-start: 2.25rem; list-style: decimal; }
.notes-procedure > li { padding: .875rem 0 .875rem .25rem; border-top: 1px solid var(--rule); }
.notes-procedure > li:last-child { border-bottom: 1px solid var(--rule); }
.notes-procedure > li::marker { font: 650 .9375rem/1 var(--f-num); font-variant-numeric: tabular-nums; color: var(--accent); }

/* concept links: always visibly links, in the accent with a quiet underline */
.notes-term { font-weight: 500; color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .24em; text-decoration-color: var(--link-line); border-radius: 2px; transition: text-decoration-color 160ms ease, background-color 160ms ease; }
:lang(ja) .notes-term, :lang(zh) .notes-term { text-decoration-skip-ink: none; }
.notes-term:focus-visible { outline-offset: 1px; text-decoration-color: currentColor; }

/* contents and related share one label style */
#notesArticle :is(.notes-contents, .notes-related) h3 { margin: 0 0 .625rem; font: 650 .8125rem/1.3 var(--f-ui); color: var(--ink-2); }
.notes-contents { margin-bottom: 2.25rem; }
.notes-contents ul { margin: 0; padding: 0; list-style: none; border-inline-start: 1px solid var(--rule-2); }
.notes-contents a { display: flex; align-items: center; min-height: var(--row); margin-inline-start: -1px; padding: .375rem .75rem .375rem 1rem; font: 500 .9375rem/1.35 var(--f-ui); color: var(--ink-2); text-decoration: none; border-inline-start: 2px solid transparent; border-radius: 0 var(--r) var(--r) 0; transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease; }
.notes-contents a:focus-visible { outline-offset: -2px; }
.notes-contents-toggle { display: none; }

.notes-related { margin-top: 3.5rem; }
.notes-related ul { display: grid; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.notes-related li { border-bottom: 1px solid var(--rule); }
.notes-related-link { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: .875rem; min-height: 3.5rem; padding: .5rem .25rem; color: var(--ink); text-decoration: none; border-radius: var(--r); }
.notes-related-link:focus-visible { outline-offset: -2px; }
/* signs of other entries stay neutral until pointed at; the accent sign belongs to the entry being read */
.notes-related-glyph { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; color: var(--ink-2); background: var(--wash); border-radius: var(--r); transition: background-color 160ms ease, color 160ms ease; }
.notes-related-glyph .notes-icon { width: 1.125rem; height: 1.125rem; }
.notes-related-text { display: grid; gap: .125rem; min-width: 0; }
.notes-related-title { font: 600 .9375rem/1.35 var(--f-ui); color: var(--ink); overflow-wrap: anywhere; transition: color 160ms ease; }
.notes-related-kind { font: 400 .8125rem/1.3 var(--f-ui); color: var(--ink-3); }
.notes-related-link > .notes-icon { width: 1rem; height: 1rem; color: var(--ink-3); transition: color 160ms ease, transform 180ms var(--ease-out); }

/* ---------- calculation ---------- */
#notesArticle .notes-formula { display: block; max-width: 100%; padding: 1rem 1.25rem; font: 500 .9375rem/1.7 var(--f-num); color: var(--ink); background: var(--plate); border: 1px solid var(--rule); border-inline-start: 2px solid var(--accent); border-radius: 0 var(--r) var(--r) 0; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; }
#notesArticle .notes-formula:has(.katex) { padding-block: .625rem; font-size: 1rem; line-height: 1.5; white-space: normal; overflow-wrap: normal; }
.notes-formula .katex-display, .notes-formula > .katex { display: block; max-width: 100%; margin: 0; padding: .5rem 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; text-align: start; scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent;
  background:
    linear-gradient(90deg, var(--plate) 40%, transparent) left / 1.5rem 100% no-repeat local,
    linear-gradient(-90deg, var(--plate) 40%, transparent) right / 1.5rem 100% no-repeat local,
    linear-gradient(90deg, var(--rule-2), transparent) left / .5rem 100% no-repeat scroll,
    linear-gradient(-90deg, var(--rule-2), transparent) right / .5rem 100% no-repeat scroll; }
.notes-formula .katex-display > .katex { text-align: start; }
.notes-formula .katex-display + .katex-display, .notes-formula > .katex + .katex { margin-top: .25rem; border-top: 1px solid var(--rule); }
.notes-formula .katex { color: inherit; }

/* ---------- figures: original illustrations, hatched key = synthetic ---------- */
.notes-figure { margin: 0; }
/* the illustrative example sits on its own plate */
.notes-figure[data-diagram] { --sheet: var(--plate); padding: 1.25rem 1.25rem 1rem; background: var(--plate); border: 1px solid var(--rule); border-radius: var(--r-l); }
#notesArticle .notes-figure[data-diagram] > h3 { margin-bottom: 1rem; font: 650 .9375rem/1.3 var(--f-ui); color: var(--ink-2); }
.notes-figure figcaption { display: flex; align-items: baseline; gap: .5rem; margin-top: 1.25rem; padding-top: .625rem; font: 400 .8125rem/1.45 var(--f-ui); color: var(--ink-3); border-top: 1px solid var(--rule); }
.notes-figure figcaption::before { content: ""; flex: none; width: .75rem; height: .75rem; transform: translateY(.1em); border: 1px solid currentColor; background: repeating-linear-gradient(135deg, currentColor 0 1px, transparent 1px 4px); }
.notes-flow { margin: 0; padding: 0; list-style: none; }
/* tables scroll inside their frame; edge shadows appear only while more columns are hidden */
.notes-table-scroll { overflow-x: auto; max-width: 100%; margin-top: 1rem; overscroll-behavior-x: contain; border-radius: 2px;
  background:
    linear-gradient(90deg, var(--sheet) 40%, transparent) left / 1.5rem 100% no-repeat local,
    linear-gradient(-90deg, var(--sheet) 40%, transparent) right / 1.5rem 100% no-repeat local,
    linear-gradient(90deg, var(--rule-2), transparent) left / .5rem 100% no-repeat scroll,
    linear-gradient(-90deg, var(--rule-2), transparent) right / .5rem 100% no-repeat scroll; }
.notes-table-scroll:focus-visible { outline-offset: 2px; }
.notes-figure > .notes-table-scroll:first-child { margin-top: 0; }

/* energy: two equal windows, and where their energy-weighted level falls between them.
   The strip is a 55–75 dB(A) axis: A 60 → 25 %, B 70 → 75 %, result 67.4 → 62 %. */
[data-diagram="energy"] table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
[data-diagram="energy"] th { padding: 0 .75rem .5rem 0; font: 600 .8125rem/1.2 var(--f-ui); text-align: start; color: var(--ink-3); border-bottom: 1px solid var(--rule-2); }
[data-diagram="energy"] td { padding: .625rem .75rem .625rem 0; font: 500 .9375rem/1.3 var(--f-num); white-space: nowrap; border-bottom: 1px solid var(--rule); }
[data-diagram="energy"] td:first-child { font-weight: 700; }
[data-diagram="energy"] td:first-child::before { content: ""; display: inline-block; width: .625rem; height: .625rem; margin-inline-end: .5rem; vertical-align: .05em; background: var(--swatch, var(--ink-3)); border-radius: 50%; }
[data-diagram="energy"] :is(table > tr:nth-child(2), thead ~ tbody > tr:nth-child(1)) { --swatch: var(--teal); }
[data-diagram="energy"] :is(table > tr:nth-child(3), thead ~ tbody > tr:nth-child(2)) { --swatch: var(--violet); }
.notes-diagram-result { margin: 1.25rem 0 0; font: 600 1rem/1.35 var(--f-num); color: var(--ink); }
.notes-diagram-result::after { content: ""; display: block; height: 1.5rem; margin-top: .75rem;
  background:
    linear-gradient(90deg, transparent calc(25% - 1px), var(--teal) 0 calc(25% + 1px), transparent 0 calc(62% - 1.5px), var(--ink) 0 calc(62% + 1.5px), transparent 0 calc(75% - 1px), var(--violet) 0 calc(75% + 1px), transparent 0) 0 0 / 100% 100% no-repeat,
    linear-gradient(90deg, transparent 25%, color-mix(in oklab, var(--signal) 60%, transparent) 0 75%, transparent 0) 0 50% / 100% .4375rem no-repeat,
    repeating-linear-gradient(90deg, var(--rule-2) 0 1px, transparent 1px 5%) 0 100% / 100% .375rem no-repeat,
    linear-gradient(var(--rule-2), var(--rule-2)) 0 100% / 100% 1px no-repeat; }

/* window: three sequential, non-overlapping spans on one 13.5 s axis, in time order:
   warm-up 0–0.5 s, preparation 0.5–3.5 s, valid capture 3.5–13.5 s. One tick per second. */
[data-diagram="window"] .notes-flow { display: grid; gap: 1rem; }
[data-diagram="window"] .notes-flow::after { content: ""; height: .5rem; background: repeating-linear-gradient(90deg, var(--tick) 0 1px, transparent 1px 7.4074%) 0 0 / 100% 100% no-repeat, linear-gradient(var(--rule-2), var(--rule-2)) 0 0 / 100% 1px no-repeat; }
[data-diagram="window"] li { position: relative; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .125rem 1rem; padding-bottom: 1.5rem; --tint: color-mix(in oklab, var(--stage) 22%, transparent); }
[data-diagram="window"] li::before { content: ""; position: absolute; inset-inline: 0; bottom: .25rem; height: .75rem;
  background: linear-gradient(90deg, transparent var(--start), var(--tint) 0 calc(var(--start) + var(--span)), transparent 0) 0 0 / 100% 100% no-repeat,
              linear-gradient(var(--rule-2), var(--rule-2)) 0 50% / 100% 1px no-repeat; }
[data-diagram="window"] li::after { content: ""; position: absolute; bottom: .25rem; inset-inline-start: var(--start); width: max(var(--span), 3px); height: .75rem; background: var(--stage); border-radius: 1px; transform-origin: 0 50%; }
[data-diagram="window"] strong { display: inline-flex; align-items: center; gap: .5rem; font: 600 .9375rem/1.3 var(--f-ui); }
[data-diagram="window"] strong::before { content: ""; flex: none; width: .625rem; height: .625rem; background: var(--stage); border-radius: 1px; }
[data-diagram="window"] span { font: 500 .9375rem/1.3 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink-2); }
[data-diagram="window"] [data-stage="warmup"] { --start: 0%; --span: 3.704%; --stage: var(--amber); }
[data-diagram="window"] [data-stage="preparation"] { --start: 3.704%; --span: 22.222%; --stage: var(--ink-3); }
[data-diagram="window"] [data-stage="capture"] { --start: 25.926%; --span: 74.074%; --stage: var(--teal); }

/* holdout: a four-station line. Dashed while the correction is fitted, solid once it is frozen. */
[data-diagram="holdout"] .notes-flow { display: grid; counter-reset: stage; --dash: 180deg; }
[data-diagram="holdout"] li { position: relative; display: grid; align-content: start; justify-items: start; gap: .375rem; padding-block: 0 1.5rem; padding-inline: 2.25rem 0; counter-increment: stage; --dot: var(--ink); }
[data-diagram="holdout"] li::before { content: ""; position: absolute; top: .125rem; inset-inline-start: 0; width: 1rem; height: 1rem; background: var(--sheet); border: 2px solid var(--dot); border-radius: 50%; }
[data-diagram="holdout"] li::after { content: ""; position: absolute; top: 1.25rem; bottom: .125rem; inset-inline-start: calc(.5rem - 1px); width: 2px; background: var(--line, var(--ink)); }
[data-diagram="holdout"] li:last-child::after { display: none; }
[data-diagram="holdout"] strong { font: 600 .9375rem/1.3 var(--f-ui); }
[data-diagram="holdout"] strong::before { content: counter(stage, decimal-leading-zero); display: block; margin-bottom: .25rem; font: 500 .75rem/1 var(--f-num); color: var(--ink-3); }
[data-diagram="holdout"] span { padding: .125rem .5rem; font: 600 .875rem/1.4 var(--f-num); color: var(--dot); border: 1px solid currentColor; border-radius: 4px; }
[data-diagram="holdout"] span:empty { display: none; }
[data-diagram="holdout"] [data-stage="fit"] { --dot: var(--teal); --line: repeating-linear-gradient(var(--dash), var(--rule-2) 0 4px, transparent 4px 8px); }
[data-diagram="holdout"] [data-stage="freeze"]::before { background: var(--ink); border-radius: 2px; }
[data-diagram="holdout"] [data-stage="check"] { --dot: var(--violet); }
[data-diagram="holdout"] [data-stage="check"] strong { color: var(--violet); }

/* published evidence: the study, its table, and where in the source it sits */
.notes-evidence-figure { padding-top: 1.25rem; border-top: 1px solid var(--rule-2); }
:is(.notes-evidence-figure, .notes-science) table { width: 100%; border-collapse: collapse; font: 500 .9375rem/1.5 var(--f-num); font-variant-numeric: tabular-nums; }
:is(.notes-evidence-figure, .notes-science) :is(th, td) { padding: .75rem .625rem; text-align: start; vertical-align: top; border-bottom: 1px solid var(--rule); }
:is(.notes-evidence-figure, .notes-science) th { min-width: 7rem; font: 600 .875rem/1.4 var(--f-ui); color: var(--ink-2); border-bottom-color: var(--rule-2); }
.notes-evidence-figure td { white-space: nowrap; color: var(--ink); }
.notes-evidence-figure > p { max-width: 40rem; margin: .875rem 0 .25rem; font: 400 .9375rem/1.6 var(--f-ui); color: var(--ink-2); }
.notes-evidence-figure figcaption { flex-wrap: wrap; gap: .25rem .75rem; margin-top: 0; padding-top: 0; font: 500 .9375rem/1.45 var(--f-ui); color: var(--ink); border-top: 0; }
.notes-evidence-figure figcaption::before { display: none; }
.notes-evidence-kind { display: inline-flex; align-items: center; gap: .5rem; font: 650 .8125rem/1.2 var(--f-ui); color: var(--violet); }
.notes-evidence-kind::before { content: ""; flex: none; width: .625rem; height: .625rem; background: currentColor; }

/* ---------- references: native numbering hung in the margin, then source, locator, reason ---------- */
.notes-source-list { margin: 0; padding-inline-start: 2.25rem; list-style: decimal; }
.notes-source { padding: .25rem 0 1.125rem .25rem; border-top: 1px solid var(--rule); }
.notes-source:last-child { border-bottom: 1px solid var(--rule); }
.notes-source::marker { font: 500 .8125rem/1 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink-3); }
/* external sources: underlined ink with a north-east arrow, distinct from accent concept links */
.notes-source-link { display: block; min-height: var(--hit); padding-block: .625rem .25rem; font: 600 1rem/1.4 var(--f-ui); color: var(--ink); overflow-wrap: anywhere; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; text-decoration-color: var(--rule-3); transition: text-decoration-color 160ms ease; }
.notes-evidence-figure > .notes-source-link { font-size: .9375rem; text-decoration-color: color-mix(in oklab, var(--violet) 60%, transparent); }
.notes-external { display: inline-block; width: .875em; height: .875em; margin-inline-start: .3em; vertical-align: -.1em; color: var(--accent); transform: rotate(-45deg); }
.notes-evidence-figure .notes-external { color: var(--violet); }
.notes-source-location { display: block; font: 400 .8125rem/1.5 var(--f-num); color: var(--ink-3); overflow-wrap: anywhere; }
.notes-source p { max-width: 40rem; margin: .375rem 0 0; font: 400 .9375rem/1.6 var(--f-ui); color: var(--ink-2); }

/* ---------- states: a travelling hairline while loading, a still one otherwise ---------- */
#notesArticle > .notes-state { width: fit-content; max-width: min(40rem, 100% - 2.5rem); margin-inline: 1.25rem auto; padding-block: clamp(2.5rem, 12svh, 6rem) 2rem; }
#notesArticle .notes-state h2 { position: relative; margin: 0 0 1.5rem; padding-bottom: 1.25rem; overflow: hidden; font: 500 1.5rem/1.25 var(--f-display); color: var(--ink); }
#notesArticle .notes-state h2::before { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 1px; background: var(--rule-2); }
#notesArticle .notes-state:not(:has(button)) h2::after { content: ""; position: absolute; inset-inline-start: 0; bottom: 0; width: 35%; height: 1px; background: var(--accent); }
.notes-state button { display: inline-flex; align-items: center; gap: .5rem; min-height: var(--hit); padding: .625rem 1.125rem; font: 600 .9375rem/1.2 var(--f-ui); color: var(--accent-ink); background: var(--accent); border: 0; border-radius: var(--r); text-shadow: none; transition: opacity 160ms ease, transform 140ms var(--ease-out); }
#notesStatus { flex: none; margin: 0; padding: .5rem 1.25rem 1rem; font: 500 .8125rem/1.4 var(--f-num); color: var(--alert); }
#notesStatus:empty { padding: 0; }

:lang(ja) #notesArticle :is(h2, h3), :lang(zh) #notesArticle :is(h2, h3), :lang(ja) #notesCategories button, :lang(zh) #notesCategories button { word-break: auto-phrase; }
:lang(ja) .notes-summary, :lang(zh) .notes-summary { font-size: 1.0625rem; }

/* ---------- entry widths ---------- */
@container notes-article (min-width: 34rem) {
  #notesArticle > article { --gut: 2rem; --aperture: 2.75rem; }
  #notesArticle > article > h2 { gap: 1rem; font-size: 2rem; }
  .notes-glyph { --size: 2.75rem; }
  .notes-summary { font-size: 1.1875rem; }
  :lang(ja) .notes-summary, :lang(zh) .notes-summary { font-size: 1.125rem; }
  #notesArticle > .notes-state { margin-inline-start: 2rem; }
  .notes-related ul { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.5rem; }
  [data-diagram="holdout"] .notes-flow { grid-template-columns: repeat(4, minmax(0, 1fr)); --dash: 90deg; }
  [data-diagram="holdout"] li { padding-block: 1.75rem 0; padding-inline: 0 1rem; }
  [data-diagram="holdout"] li::before { top: 0; }
  [data-diagram="holdout"] li::after { top: calc(.5rem - 1px); bottom: auto; inset-inline: 1.375rem .375rem; width: auto; height: 2px; }
}
@container notes-article (max-width: 24rem) {
  .notes-figure[data-diagram] { padding-inline: .875rem; }
  .notes-procedure, .notes-source-list { padding-inline-start: 1.875rem; }
}
/* Entry beside its rail: the text track is offset slightly toward the index, the rail holds contents and
   related concepts. Main spans both rail rows, so the rail stacks at the top beside the reading. */
@container notes-article (min-width: 56rem) {
  #notesArticle > article { --aperture: 4rem; grid-template-columns: [sheet-start] minmax(2.5rem, 1fr) [text-start] minmax(0, 61rem) [text-end] minmax(2.5rem, 1.5fr) [sheet-end]; }
  #notesArticle > article > h2 { font-size: 2.375rem; }
  .notes-glyph { --size: 3rem; }
  .notes-summary { font-size: 1.25rem; }
  :lang(ja) .notes-summary, :lang(zh) .notes-summary { font-size: 1.1875rem; }
  #notesArticle > .notes-state { margin-inline-start: 3rem; }
  .notes-reading { grid-template-columns: minmax(0, 1fr) 15.5rem; grid-template-rows: auto 1fr; column-gap: 3.5rem; padding-top: 2.25rem; }
  .notes-main { grid-column: 1; grid-row: 1 / span 2; }
  .notes-contents { grid-column: 2; grid-row: 1; margin: 0 0 2.25rem; }
  .notes-related { grid-column: 2; grid-row: 2; align-self: start; margin-top: 0; }
  .notes-reading:not(.notes-reading--contents) .notes-related { grid-row: 1 / span 2; }
  .notes-related ul { grid-template-columns: minmax(0, 1fr); }
  .notes-related-link { column-gap: .75rem; min-height: 3.25rem; }
  .notes-related-glyph { width: 2rem; height: 2rem; }
}
/* Entry without the rail: the contents fold into one ruled row between the summary and the text, so the reading
   starts on the first screen. The same row opens the list in place and closes it again; the links, their names and
   the jump behaviour are unchanged, and the rail above shows the list as before. */
@container notes-article (width < 56rem) {
  #notesArticle .notes-contents > h3 { display: none; }
  .notes-contents { margin-bottom: 1.75rem; border-block: 1px solid var(--rule); }
  .notes-contents-toggle { display: flex; align-items: center; gap: .625rem; width: 100%; min-height: var(--hit); margin: 0; padding: .5rem .25rem; font: 600 .9375rem/1.3 var(--f-ui); color: var(--ink); text-align: start; background: none; border: 0; border-radius: var(--r); cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
  .notes-contents-name { flex: 1; min-width: 0; }
  .notes-contents-tally { font: 500 .8125rem/1 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink-3); }
  .notes-contents-toggle .notes-icon { flex: none; width: 1.125rem; height: 1.125rem; color: var(--ink-3); transition: transform 200ms var(--ease-out), color 140ms ease; }
  .notes-contents-toggle[aria-expanded="true"] .notes-icon { transform: rotate(180deg); }
  .notes-contents-toggle:focus-visible { outline-offset: -2px; }
  .notes-contents-toggle[aria-expanded="false"] + ul { display: none; }
  .notes-contents ul { margin-bottom: .75rem; }
}

/* ---------- narrow pages: one search row, then the entry ---------- */
/* Browse sits beside the field. While a query is typed the count joins the same row, between field and Browse,
   instead of opening a row of its own; with an empty field it stays a live status for assistive tech (the browsed
   list carries its own group counts). The visual "Articles" label is the Browse button's job here. Below 34rem
   Browse keeps its sign and accessible name only, so the search wording keeps the room. Larger text simply wraps. */
@container notes-page (width < 52rem) {
  .notes-search { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; }
  .notes-field { grid-row: 1; grid-column: 1; }
  .notes-index-head { display: contents; }
  .notes-label { display: none; }
  #notesCount { grid-row: 1; grid-column: 2; max-width: 6.5rem; margin: 0; margin-inline-start: .625rem; text-align: end; }
  #notesBrowse { grid-row: 1; grid-column: 3; margin: 0; margin-inline-start: .5rem; }
  .notes-search:has(#notesSearch:placeholder-shown) #notesCount { position: absolute; width: 1px; height: 1px; max-width: none; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@container notes-page (width < 34rem) {
  #notesBrowse { justify-content: center; width: var(--hit); padding: 0; }
  #notesBrowse > span { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ---------- page widths: index beside the entry ---------- */
@container notes-page (min-width: 52rem) {
  .notes-header { padding-inline: 1.5rem; }
  #notesCategories { padding-inline: 1.25rem; }
  .notes-layout { display: grid; grid-template-columns: var(--index-w, 18.5rem) minmax(0, 1fr); }
  .notes-directory { --field-occlude: 1; position: sticky; top: 0; align-self: start; height: 100dvh; max-height: 100dvh; overflow-y: auto; overscroll-behavior: contain; padding: 0 .75rem 1.5rem; background: var(--panel); border-block: 0; border-inline-end: 1px solid var(--rule); scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent; }
  .notes-search, .notes-directory--expanded .notes-search { position: sticky; top: 0; z-index: 2; margin-inline: -.75rem; padding: 1rem .75rem .5rem; background: var(--panel); }
  .notes-index-head { padding-inline: .75rem; }
  #notesBrowse { display: none; }
  #notesResults, .notes-directory--expanded #notesResults { display: grid; }
}
@container notes-page (min-width: 90rem) { .notes-layout { --index-w: 20rem; } }
/* tall enough: the masthead stays, index and entry scroll as panes */
@media screen and (min-height: 560px) {
  @container notes-page (min-width: 52rem) {
    .notes-page { height: 100dvh; min-height: 0; }
    .notes-layout { flex: 1 1 0; min-height: 0; grid-template-rows: minmax(0, 1fr); }
    .notes-directory { position: relative; align-self: stretch; height: auto; max-height: none; min-height: 0; }
    #notesArticle { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--rule-3) transparent; }
  }
}

/* ---------- feedback ---------- */
@media (hover: hover) and (pointer: fine) {
  .notes-tool:not(:disabled):hover, .notes-settings .noise-settings-entry:hover, #notesLanguage:hover, #notesBrowse:hover { color: var(--ink); background-color: var(--wash-2); border-color: var(--rule-3); }
  #notesTools .notes-tool:not(:disabled):hover { background-color: var(--wash-2); border-color: transparent; }
  #notesCategories button:not([aria-pressed="true"]):hover { color: var(--ink); background-color: var(--wash); }
  #notesCategories button:not([aria-pressed="true"]):hover .notes-icon { color: var(--ink-2); }
  .notes-strip-step:hover { color: var(--ink); background-color: var(--wash); }
  .notes-header .workspace-rail a:hover .ui-icon { color: inherit; }
  #notesClear:hover { color: var(--ink); background-color: var(--wash-2); }
  #notesResults a:not([aria-current]):hover { color: var(--ink); background-color: var(--wash); }
  #notesResults a:not([aria-current]):hover .notes-icon { color: var(--ink); opacity: 1; }
  .notes-contents a:hover { color: var(--ink); background-color: var(--wash); border-inline-start-color: var(--accent); }
  .notes-contents-toggle:hover { background-color: var(--wash); }
  .notes-contents-toggle:hover .notes-icon { color: var(--ink-2); }
  .notes-term:hover { text-decoration-color: currentColor; background-color: var(--accent-wash); }
  .notes-related-link:hover .notes-related-title { color: var(--accent); }
  .notes-related-link:hover .notes-related-glyph { color: var(--accent); background-color: var(--accent-wash); }
  .notes-related-link:hover > .notes-icon { color: var(--accent); transform: translateX(.1875rem); }
  .notes-source-link:hover { text-decoration-color: currentColor; }
  .notes-state button:hover { opacity: .88; }
}
:root[data-motion="full"] :is(.notes-tool:not(:disabled), .noise-settings-entry, #notesClear, #notesCategories button, .notes-strip-step, #notesBrowse, .notes-state button):active { transform: scale(.97); }
/* arrival: the title settles out of the field, the glyph pings once, the reading fades in without moving */
:root[data-motion="full"] #notesArticle > article > :is(.notes-meta, h2) { animation: notes-arrive 280ms var(--ease-out) both; }
:root[data-motion="full"] #notesArticle > article > h2 { animation-delay: 50ms; }
:root[data-motion="full"] #notesArticle > article > h2 .notes-glyph::after { animation: notes-ping 900ms var(--ease-out) 180ms both; }
:root[data-motion="full"] #notesArticle > article > :is(.notes-summary, .notes-reading) { animation: notes-fade 260ms ease-out 90ms both; }
@keyframes notes-arrive { from { opacity: 0; transform: translateY(.375rem); } }
@keyframes notes-ping { from { opacity: .7; transform: scale(1); } to { opacity: 0; transform: scale(1.6); } }
@keyframes notes-fade { from { opacity: 0; } }
/* timing window fills along its own axis, then rests */
:root[data-motion="full"] [data-diagram="window"] li::after { animation: 16s linear infinite both; }
:root[data-motion="full"] [data-diagram="window"] [data-stage="warmup"]::after { animation-name: notes-fill-warmup; }
:root[data-motion="full"] [data-diagram="window"] [data-stage="preparation"]::after { animation-name: notes-fill-preparation; }
:root[data-motion="full"] [data-diagram="window"] [data-stage="capture"]::after { animation-name: notes-fill-capture; }
@keyframes notes-fill-warmup { 0% { transform: scaleX(0); opacity: 1; } 3.125%, 92% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
@keyframes notes-fill-preparation { 0%, 3.125% { transform: scaleX(0); opacity: 1; } 21.875%, 92% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
@keyframes notes-fill-capture { 0%, 21.875% { transform: scaleX(0); opacity: 1; } 84.375%, 92% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
/* holdout stations pulse in sequence */
:root[data-motion="full"] [data-diagram="holdout"] li::before { animation: notes-station 8s var(--ease-out) infinite both; }
:root[data-motion="full"] [data-diagram="holdout"] li:nth-child(2)::before { animation-delay: 1.2s; }
:root[data-motion="full"] [data-diagram="holdout"] li:nth-child(3)::before { animation-delay: 2.4s; }
:root[data-motion="full"] [data-diagram="holdout"] li:nth-child(4)::before { animation-delay: 3.6s; }
@keyframes notes-station { 0%, 12%, 100% { transform: scale(1); } 4% { transform: scale(1.35); } }
:root[data-motion="full"] #notesArticle .notes-state:not(:has(button)) h2::after { animation: notes-scan 1.6s var(--ease-in-out) infinite; }
@keyframes notes-scan { from { transform: translateX(-100%); } to { transform: translateX(286%); } }

/* hidden tab: nothing runs */
:root[data-visibility="hidden"] *, :root[data-visibility="hidden"] *::before, :root[data-visibility="hidden"] *::after { animation-play-state: paused !important; }
/* reduced: no movement; colour feedback stays unless the global setting is static */
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after { animation: none !important; transition: none !important; }
:root[data-motion="reduced"]:not([data-noise-motion="static"]) :is(.notes-tool, .noise-settings-entry, #notesLanguage, .notes-field, #notesClear, #notesBrowse, #notesCategories button, #notesCategories .notes-icon, .notes-strip-step, #notesResults .notes-icon, #notesResults a, .notes-contents a, .notes-contents-toggle, .notes-contents-toggle .notes-icon, .notes-term, .notes-related-title, .notes-related-glyph, .notes-source-link) { transition: color 120ms, background-color 120ms, border-color 120ms, text-decoration-color 120ms, opacity 120ms !important; }
@media (prefers-reduced-motion: reduce) {
  :root *, :root *::before, :root *::after { animation: none !important; transition: none !important; }
  :root:not([data-noise-motion="static"]) :is(.notes-tool, .noise-settings-entry, #notesLanguage, .notes-field, #notesClear, #notesBrowse, #notesCategories button, #notesCategories .notes-icon, .notes-strip-step, #notesResults .notes-icon, #notesResults a, .notes-contents a, .notes-contents-toggle, .notes-contents-toggle .notes-icon, .notes-term, .notes-related-title, .notes-related-glyph, .notes-source-link) { transition: color 120ms, background-color 120ms, border-color 120ms, text-decoration-color 120ms, opacity 120ms !important; }
}

/* ---------- global display settings: contrast and density ---------- */
:root[data-noise-contrast="high"] { --ink-read: var(--ink); --ink-3: var(--ink-2); --rule: var(--rule-3); --accent-line: var(--accent); --link-line: var(--accent); }
:root[data-noise-contrast="high"] .notes-scene { --field-strength: .5; }
:root[data-noise-contrast="high"] :is(.notes-tool, .noise-settings-entry, .notes-field, #notesBrowse, #notesLanguage) { border-color: currentColor; }
:root[data-noise-contrast="high"] #notesTools .notes-tool { border-color: transparent; }
:root[data-noise-contrast="high"] .notes-term { text-decoration-thickness: 2px; }
:root[data-noise-density="compact"] { --row: 2.125rem; }
:root[data-noise-density="compact"] :is(#notesResults a, .notes-contents a) { padding-block: .3125rem; }
:root[data-noise-density="compact"] .notes-procedure > li { padding-block: .625rem; }

/* ---------- forced colours and print ---------- */
@media (forced-colors: active) {
  .notes-scene { display: none; }
  #notesArticle > article::before { background: Canvas; border-top: 1px solid CanvasText; }
  #notesArticle > article::after { display: none; }
  .notes-field:focus-within { outline: 2px solid Highlight; }
  #notesResults a[aria-current="page"], #notesCategories button[aria-pressed="true"], #notesMotion[aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
  .notes-formula, .notes-figure[data-diagram], .notes-glyph, .notes-related-glyph { border: 1px solid CanvasText; }
  .notes-mark::before, .notes-category::before, [data-diagram="window"] li::after, #notesCategories button::after, #notesResults a[aria-current="page"]::before { background: CanvasText; }
  .notes-term { color: LinkText; text-decoration-color: LinkText; }
}
.notes-header.wc-head > .notes-project-link .wc-val > span {
  position: static; width: auto; height: auto; overflow: visible; clip-path: none;
}

@media print {
  :root, :root[data-theme] { color-scheme: light; --void: #fff; --panel: #fff; --sheet: #fff; --plate: #fff; --raised: #fff; --ink: #121412; --ink-read: #121412; --ink-2: #3d403a; --ink-3: #5f625b; --rule: #bbb; --rule-2: #888; --rule-3: #555; --tick: #888; --accent: #0e6b69; --signal: #0e6b69; --teal: #0e6b69; --violet: #5a3fae; --amber: #8a5300; --alert: #b53a0b; }
  html, body, .notes-page, #notesArticle { color: #121412; background: #fff !important; }
  *, *::before, *::after { animation: none !important; text-shadow: none !important; }
  .notes-scene, .notes-steps, .notes-settings, .notes-strip, .notes-directory, .notes-skip, #notesStatus, .notes-contents, .notes-header > .workspace-flow, .notes-external { display: none !important; }
  .notes-header { background: none; }
  .notes-page { display: block; height: auto; min-height: 0; }
  .notes-layout { display: block !important; }
  #notesArticle { display: block; padding: 0; overflow: visible !important; }
  #notesArticle > article { display: block !important; padding: 0; }
  #notesArticle > article::before, #notesArticle > article::after { display: none; }
  #notesArticle .notes-reading { display: block !important; padding: 1rem 0 0; }
  .notes-glyph { border-color: #888; background: none; }
  #notesArticle .notes-formula { border: 1px solid #888; border-inline-start: .25rem solid #121412; }
  .notes-formula .katex-display, .notes-formula > .katex { overflow: visible; background: none; }
  .notes-table-scroll { overflow: visible; background: none; }
  .notes-evidence-figure td { white-space: normal; }
  .notes-figure, .notes-source { break-inside: avoid; }
  .notes-related { margin-top: 2rem; }
  :is(.notes-source-link, .notes-evidence-figure > a)::after { content: " " attr(href); font: 400 .75rem/1.4 var(--f-num); color: #333; }
}
