@charset "utf-8";
/* ============================================================================
   FrequencyMeasurer.com - design-system.css, the site's only stylesheet.
   Render-blocking. No preprocessor, no @import, no web font. BUILD-CONTRACT §4.
   Floor: Chrome/Edge 111+, Firefox 113+, Safari 16.4+.
   :has() and container queries are never load-bearing.

   01 reset - 02 tokens - 03 base+type - 04 layout - 05 a11y - 06 header/nav/
   dropdown - 07 footer - 08 hero+crumbs - 09 card - 10 buttons+seg - 11 readout+
   pills - 12 metrics - 13 tool shell+panels - 14 charts - 15 tables - 16 forms
   - 17 notes/disclose/faq - 18 toolgrid - 19 toast - 20 adslot - 21 utilities
   - 21A view presets + drop zone - 21B counter - 21C spectrum analyzer
   - 21D detector strip/confidence/band ruler - 21N note converters
   - 21P pitch detector tuner face
   - 22 responsive - 23 forced-colors - 24 reduced-motion - 25 print

   CONTRAST (AA: 4.5:1 body, 3:1 large/UI, both themes). Body pairs run
   5.1-17.4:1. TIGHTEST PAIR RELIED ON: light --text-3 #5d6b82 on --surface-3
   #e7ecf3 = 4.55:1 (13px hints). Dark's equivalent is 4.45:1 and FAILS, so
   dark --text-3 never leaves --bg/--bg-2/--surface/--surface-2 (>=5.1:1) and
   --text-2 is used on --surface-3. Large-text floor: light --accent on --bg-2
   = 3.60:1 (.readout__value, 65-104px, 3:1 bar). Known tension: light
   --accent-ink on --accent = 4.05:1, so .btn--primary fills with
   --accent-hover in light only (5.29:1) - see §10.
   ========================================================================== */

/* 01  RESET ============ */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; tab-size: 2; }

body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ol, ul, pre, fieldset, legend {
  margin: 0; padding: 0;
}

ul[class], ol[class] { list-style: none; }

img, svg, video, canvas, audio, iframe, embed, object { display: block; max-width: 100%; }

img, video { height: auto; }

input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }

button { background: none; }

/*
  Long unbreakable words must never push the page sideways.

  This was missing, and it shipped a real bug: at 320px the /about/ heading
  "About FrequencyMeasurer" could not break, so the brand word overflowed its 273px box
  and took the document to 340px against a 305px viewport. Nothing in the DOM appeared to
  overflow, because the box was the right size — it was the TEXT inside it that escaped,
  and `body { overflow-x: clip }` then hid the result.

  The site's own name is a 17-character compound, every tool page prints frequency values
  and note names, and the technical prose is full of terms like "autocorrelation" — so this
  is a permanent hazard at 320px, not a one-off.

  `break-word` for prose (only breaks when the word genuinely cannot fit) and `anywhere`
  for code and URLs, where a mid-token break is expected and harmless.
*/
h1, h2, h3, h4, h5, h6,
p, li, dt, dd, figcaption, th, td, summary, label, legend, blockquote {
  overflow-wrap: break-word;
}

code, kbd, samp, pre, .mono { overflow-wrap: anywhere; }

table { border-collapse: collapse; border-spacing: 0; }

fieldset { border: 0; }

/* Beats component display rules, so every [hidden] contract here works. */
[hidden] { display: none !important; }

/* 02  TOKENS ============ */
/* §4.2 verbatim. Retune the contract, not this block. */

:root {                        /* dark = default */
  --bg:            #080b11;
  --bg-2:          #0e131b;
  --surface:       #141a24;
  --surface-2:     #1b222e;
  --surface-3:     #232c3a;
  --border:        #253040;
  --border-strong: #35435a;

  --text:   #e9eef6;           /* body */
  --text-2: #a9b6c9;           /* secondary */
  --text-3: #8492a6;           /* axis ticks, placeholders — AA on --surface */

  --accent:      #38e0b0;      /* signal green: live data, primary action */
  --accent-hover:#5cebc3;
  --accent-ink:  #04120e;      /* text on accent fill */
  --accent-soft: rgba(56,224,176,.12);
  --accent-2:    #7cc4ff;      /* secondary series / reference */

  --ok:     #4ade80;
  --warn:   #f5b544;
  --danger: #ff7a7a;
  --info:   #7cc4ff;

  /* chart series — distinguishable in both themes and for common CVD types */
  --c1:#38e0b0; --c2:#7cc4ff; --c3:#f5b544;
  --c4:#c792ea; --c5:#ff8fa3; --c6:#9ae66e;

  --grid:      #1e2735;        /* chart gridlines */
  --grid-axis: #2f3c4e;

  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);

  --step-1: .8125rem;  --step0: .9375rem;  --step1: 1.0625rem;
  --step2: 1.375rem;   --step3: 1.75rem;   --step4: 2.25rem;  --step5: 3rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  --wrap: 1180px;
  --gap:  clamp(1rem, .6rem + 1.4vw, 1.75rem);
}

:root[data-theme="light"] {
  --bg:#f6f8fb; --bg-2:#eef2f7; --surface:#ffffff; --surface-2:#f2f5f9;
  --surface-3:#e7ecf3; --border:#d8e0ea; --border-strong:#b3c0d1;
  --text:#0f1620; --text-2:#46536a; --text-3:#5d6b82;
  /* Accent darkened from the spec's #0a8f72, which measured 4.05:1 against white and
     3.81:1 against --bg — failing AA in all three directions it is used: white text on an
     accent fill, accent text on a card, and accent text on the page background. #087a63
     clears 4.5:1 on every one of them (5.28 / 4.97 / 4.83) while staying the same hue, so
     the light theme reads as the same brand rather than a different green. The dark theme
     needs no equivalent change; it was already clear. */
  --accent:#087a63; --accent-hover:#066752; --accent-ink:#ffffff;
  --accent-soft: rgba(8,122,99,.10); --accent-2:#1d63d1;
  --ok:#16794a; --warn:#96610a; --danger:#c02626; --info:#1d63d1;
  --c1:#087a63; --c2:#1d63d1; --c3:#96610a;
  --c4:#7038a8; --c5:#b32d55; --c6:#3f7a17;
  --grid:#e4eaf2; --grid-axis:#c9d4e1;
  --shadow: 0 1px 2px rgba(15,22,32,.06), 0 8px 24px -14px rgba(15,22,32,.18);
}

/* Derived aliases: they reference §4.2 tokens, never redefine them. */
:root {
  /* Light --accent on white is 4.05:1 (under the body bar) so links take the darker
     --accent-hover, 5.29:1; dark uses --accent at 11.7:1. */
  --link:       var(--accent);
  --link-hover: var(--accent-hover);

  --header-h:  3.5rem;                          /* sticky header height */
  --wrap-pad:  clamp(1rem, .55rem + 1.6vw, 2rem);
  --measure:   70ch;                            /* reading line length, NOT a container */
  --tap:       44px;                            /* coarse-pointer minimum */
  --dur:       150ms;
  --t:         var(--dur) var(--ease);          /* transition timing */
  --ease:      cubic-bezier(.2, .6, .3, 1);
  --scroll-shade: rgba(0,0,0,.45);              /* .table--scroll edge hint */
  --focus:     2px solid var(--accent);
}

:root[data-theme="light"] {
  --link:       var(--accent-hover);
  --link-hover: var(--accent);
  --scroll-shade: rgba(15,22,32,.16);
}

/* 03  BASE + TYPOGRAPHY ============ */

html {
  color-scheme: dark; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 1rem);
}

:root[data-theme="light"] { color-scheme: light; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--step0);
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  /* clip, not hidden: clip makes no scroll container, so sticky still works. */
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scrollbar-color: var(--border-strong) var(--bg);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 650;
  line-height: 1.18;
  letter-spacing: -.015em;
  color: var(--text);
  text-wrap: balance;                 /* progressive: ignored below FF121 */
}

h1 { font-size: var(--step4); }
h2 { font-size: var(--step3); }
h3 { font-size: var(--step2); }
h4 { font-size: var(--step1); }
h5, h6 {
  font-size: var(--step0); letter-spacing: .04em; text-transform: uppercase; color: var(--text-2);
}

p { text-wrap: pretty; }

a {
  color: var(--link); text-decoration: underline; text-decoration-thickness: 1px;
  text-underline-offset: .18em; transition: color var(--t);
}

a:hover { color: var(--link-hover); text-decoration-thickness: 2px; }

strong, b { font-weight: 650; color: var(--text); }
small { font-size: var(--step-1); }

abbr[title] { text-decoration: underline dotted; text-underline-offset: .2em; cursor: help; }

code, kbd, samp, pre, var, output, time[datetime] {
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .92em;
}

code {
  padding: .1em .35em; border: 1px solid var(--border); border-radius: 4px;
  background-color: var(--surface-2); color: var(--text);
}

pre {
  overflow-x: auto; padding: .875rem 1rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background-color: var(--surface-2); line-height: 1.5;
}

pre code { padding: 0; border: 0; background: none; }

kbd {
  padding: .1em .4em; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 4px; background-color: var(--surface-3); font-size: .85em; color: var(--text);
}

hr { height: 0; margin: var(--gap) 0; border: 0; border-top: 1px solid var(--border); }

blockquote {
  padding-left: 1rem; border-left: 3px solid var(--border-strong); color: var(--text-2);
}

figcaption { margin-top: .5rem; font-size: var(--step-1); color: var(--text-2); }

::selection { background-color: var(--accent-soft); color: var(--text); }

/* Every measurement number, everywhere. Contract §4.2. */
.readout__value,
.readout__unit,
.readout__note,
.readout__cents,
.metric__value,
.metric__unit,
.chart__axis,
.chart__summary,
.table--peaks td,
.table--peaks th {
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
}

/* 04  LAYOUT ============ */

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--wrap-pad); }

/*
  READING MEASURE vs CONTENT COLUMN — these are two different jobs and must not be done by
  the same box.

  `.prose` caps line length. `.wrap` sets the page's content column and centres it. When a
  section carried both (`<div class="wrap prose">`, which is how nearly every section on the
  site is written) the narrower `max-width` won and `margin-inline: auto` then centred the
  whole section — headings included. The result: a prose section started 315px to the right
  of the section above it, on all 39 pages. One page, two left edges, and nothing lined up.

  So the container keeps the page width, and the measure is applied to the text ITSELF.
  Every section on a page now begins on the same left edge, headings align down the page,
  and paragraphs still break at a comfortable ~70 characters.
*/
.prose { max-width: var(--measure); line-height: 1.7; }

.wrap.prose { max-width: var(--wrap); }

.wrap.prose > * { max-width: var(--measure); }

/*
  Things that are not running text get the full column back. A table, a diagram or a card
  grid squeezed into a text measure is harder to read, not easier — and the alternation
  between a text column and a full-width figure is what gives a long article its rhythm.
*/
.wrap.prose > figure,
.wrap.prose > table,
.wrap.prose > .grid,
.wrap.prose > .toolgrid,
.wrap.prose > .metrics,
.wrap.prose > .chart,
.wrap.prose > .card,
.wrap.prose > .faq,
.wrap.prose > .table--scroll,
.wrap.prose > .tool,
.wrap.prose > .adslot,
.wrap.prose > .seg,
.wrap.prose > .cluster,
.wrap.prose > .toc { max-width: none; }

.prose > * + * { margin-top: 1rem; }
.prose > h2 { margin-top: 2.25rem; }
.prose > h3 { margin-top: 1.75rem; }
.prose > h4 { margin-top: 1.375rem; }
.prose > h2 + *,
.prose > h3 + *,
.prose > h4 + * { margin-top: .625rem; }

.prose ul,
.prose ol { padding-left: 1.375rem; }
.prose li + li { margin-top: .375rem; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose ul ul { list-style: circle; }

/*
  VERTICAL RHYTHM — the single most-used rule on the site. `.section` wraps every band of
  content on every page (83 of them on a tool page): the tool, each <h2> block, the ad
  slots, related tools, the FAQ. With no rule at all every band ran straight into the next
  one and the page read as one undifferentiated column, which is what made the whole site
  look unfinished.

  PADDING, not margin, and for two reasons: padding cannot collapse (so a section's space
  is its own and survives a background or a border being added later), and it cannot escape
  <main> the way a leading margin does.

  The trade padding makes is that two adjacent sections pay for the gap twice. The `+` rule
  takes the second payment back, so the distance between any two consecutive sections is
  exactly one step — and a section that follows something else (the bare `.wrap` an ad slot
  sits in, `.crumbs`, `.hero`) still gets its full leading space.
*/
.section { padding-block: clamp(2rem, 1.25rem + 3vw, 3.5rem); }

.section + .section { padding-block-start: 0; }

/*
  An ad slot between two sections must not cost the page a single pixel while it is empty.

  `.adslot` is a zero-box empty div, but it is still an element, so it breaks the `+`
  adjacency above: the following section stopped matching `.section + .section` and took
  its full leading padding back. That is 56px of blank space per slot at 1200px wide —
  measured at 168px on `/frequency-detector/` (3 such slots) and 112px on `/` (2) against
  the same page with the slot divs deleted. Exactly the gap §10.3 of the contract exists
  to prevent, and it appeared whenever the network no-filled, the script was blocked or
  ads were switched off — i.e. always, for anyone running an ad blocker.

  Reaching over the slot restores the collapse. Not `:has()` — §1.1 keeps this file clear
  of it — and deliberately NOT in Ads_terra/ads.css: that path is the first thing a filter
  list blocks, and this rule has to survive precisely when the ad code does not.

  A filled slot supplies its own vertical rhythm via `[data-ad-state="filled"]`, so zeroing
  the section's leading padding here is right in both states.
*/
.section + .adslot + .section { padding-block-start: 0; }

.grid { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }

/* .grid--2 / .grid--3 gain their columns at the breakpoints in §22. */

.stack { display: flex; flex-direction: column; }

.stack > * { margin-block: 0; }
.stack > * + * { margin-block-start: var(--stack-space, 1rem); }

.cluster {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-space, .625rem);
}

/* 05  A11Y ============ */

.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; top: -100px; left: .75rem; z-index: 100; padding: .625rem 1rem;
  border: 1px solid var(--accent); border-radius: var(--radius-sm); background-color: var(--accent);
  color: var(--accent-ink); font-weight: 650; text-decoration: none;
}

.skip-link:focus { top: .75rem; color: var(--accent-ink); }

/* Contract §8: one visible focus ring, everywhere, no exceptions. */
:focus-visible { outline: var(--focus); outline-offset: 2px; border-radius: 2px; }

/* :focus-visible is supported at the floor, so keyboard users keep a ring. */
:focus:not(:focus-visible) { outline: none; }

/* 06  HEADER, NAV, DROPDOWN ============ */
/*
  ONE MARKUP, TWO LAYOUTS. `<nav class="nav" id="site-nav">` is the desktop bar at >=900px
  and, below that, the mobile menu panel site.js opens from `.nav__burger`. There is no
  second copy of the twenty links to keep in sync, and no `.drawer` component: the previous
  stylesheet shipped a full `.drawer`/`.drawer__panel` for markup that exists on no page,
  while every class the pages actually use had no rule at all. If you are tempted to
  rewrite the header markup to match some CSS, check the markup in docs/PARTIALS.md first —
  that file is what ships.

  Everything opens from state that is already on the element: `aria-expanded` on the
  control, `[hidden]` on the panel. Never a state class, so JS and CSS cannot disagree.
*/

.site-header {
  position: sticky;
  top: 0;
  /* Above page content, the sticky readout (20) and the sticky mobile control bar (30);
     below the menu panels it owns (45) and the toast region (60). Being positioned also
     makes it the containing block for the mobile panel below. */
  z-index: 40;
  border-bottom: 1px solid var(--border);
  background-color: var(--bg-2);      /* solid: no blur, no glassmorphism */
}

/*
  Brand hard left (its own `margin-right: auto` does the pushing), then the burger, then
  the theme toggle hard right; the nav sits between them at >=900px and leaves the flow
  entirely below that. `min-height`, not `height`: the bar measures 57px (56 + the 1px
  rule) but a zoomed font grows it instead of clipping it.

  --header-h is the single number every sticky offset in this file is measured from
  (`scroll-padding-top`, the sticky readout at <=480, the panel's max-height). Change one,
  change the other.
*/
.site-header__inner {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: var(--header-h);
}

/* ---- Wordmark ----------------------------------------------------------- */

.brand {
  display: inline-flex; align-items: center; gap: .5rem; margin-right: auto;
  font-size: var(--step1); font-weight: 650; letter-spacing: -.02em; color: var(--text);
  text-decoration: none; white-space: nowrap;
}

.brand:hover { color: var(--text); }

/*
  --link, not --accent: it resolves to --accent in dark and to the darker --accent-hover in
  light, where plain --accent on --bg-2 measures 3.60:1 — fine for a 100px readout under
  the 3:1 large-text bar, not for a 17px wordmark that has to clear 4.5:1. --accent-hover
  on --bg-2 is 4.7:1 in light and the mark reads as the same green.
*/
.brand__mark { flex: none; color: var(--link); }

.brand__text b { color: var(--link); font-weight: inherit; }

/* ---- Burger (below 900px only) ------------------------------------------ */
/* Removed at >=900px (§22) and with JS off, where there is nothing for it to toggle. */

.nav__burger { flex: none; }

/* ---- Primary navigation ------------------------------------------------- */
/*
  Below 900px .nav is a panel, not a bar. site.js locks body scroll and traps focus while
  it is open, which is overlay behaviour, so it is positioned over the page rather than
  pushing it down — full-bleed under the header, scrollable when the six sections plus
  their submenus outrun a short viewport.

  THE CONTRACT WITH site.js, which writes attributes and never styles:

      button.nav__burger[aria-expanded="true"]   +   nav#site-nav[data-open="true"]

  Closed is the ABSENCE of data-open. Deliberately not `[hidden]`: §01 makes that
  `display: none !important`, which outranks the >=900px rule below, and stamping it on
  #site-nav at boot is exactly what hid the primary navigation at every width on all 40
  pages. Both halves of the pair are matched here so neither file can drift silently.
*/
.nav {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 45;
  max-height: calc(100vh - var(--header-h));
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: .5rem var(--wrap-pad) calc(.75rem + env(safe-area-inset-bottom));
  border-bottom: 1px solid var(--border-strong);
  background-color: var(--bg-2);
  box-shadow: var(--shadow);
}

.nav[data-open="true"],
.nav__burger[aria-expanded="true"] + .nav { display: block; }

/*
  site.js locks page scroll while the menu is open. Without a scrim the page behind simply
  refuses to move, with nothing on screen to say why. There is no element in the partial to
  make one from, so the header's own ::after is it — `.site-header` is positioned with a
  z-index, so it is a stacking context, and z-index:-1 puts the scrim behind the bar and
  behind the panel (45) while still covering every page element below the header.

  Only ever seen below 900px: site.js refuses to open the panel at desktop widths, so
  `is-nav-open` is never set there.
*/
html.is-nav-open .site-header::after {
  content: ""; position: fixed; inset: var(--header-h) 0 0; z-index: -1;
  background-color: rgba(0, 0, 0, .5);
}

/* A column below 900px, a wrapping row above it (§22). */
.nav__list {
  display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none;
}

.nav__list > li { min-width: 0; }

/*
  One rule for all three top-level controls, because site.js swaps the .nav__drop anchor
  for a <button> at runtime and the two must be pixel-identical or the bar reflows on load.
  Full-width rows in the panel; §22 shrinks them back to inline chips on the desktop bar.
*/
.nav__link,
.nav__drop > a,
.nav__drop > button {
  display: flex; align-items: center; gap: .375rem; width: 100%; padding: .5rem .625rem;
  border: 1px solid transparent; border-radius: var(--radius-sm); font-size: var(--step1);
  font-weight: 550; color: var(--text-2); text-align: left; text-decoration: none;
  cursor: pointer; transition: color var(--t), background-color var(--t);
}

.nav__link:hover,
.nav__drop > a:hover,
.nav__drop > button:hover { color: var(--text); background-color: var(--surface-2); }

/* Current page is marked by text weight AND a rule, never colour alone. */
.nav__link[aria-current="page"] {
  color: var(--text); font-weight: 650; box-shadow: inset 3px 0 0 var(--accent);
}

.nav__drop { position: relative; }

/* Caret. Pushed to the row end in the panel, tucked beside the label on the bar (§22). */
.nav__drop > button::after {
  content: ""; flex: none; width: .375rem; height: .375rem; margin-left: auto;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-1px) rotate(45deg); transition: transform var(--t);
}

.nav__drop > button[aria-expanded="true"] {
  color: var(--text); background-color: var(--surface-2);
}

.nav__drop > button[aria-expanded="true"]::after { transform: translateY(1px) rotate(-135deg); }

/*
  The submenu. Below 900px it is part of the panel: in normal flow, full width, indented
  under its parent by a rule rather than by a floating card — a card inside a card reads as
  a mistake on a phone, and an absolutely positioned menu inside a scrolling panel detaches
  from its trigger the moment you scroll. §22 turns it into the floating card at >=900px.
*/
.nav__menu {
  display: none; margin: 0 0 .25rem; padding: .125rem 0 .25rem .875rem;
  border-left: 1px solid var(--border); list-style: none;
}

/* The ONLY thing that opens a menu: aria-expanded on its control. Matching the attribute
   rather than the tag keeps this working before site.js upgrades the anchor to a button. */
.nav__drop > [aria-expanded="true"] + .nav__menu { display: block; }

.nav__menu a {
  display: block; padding: .5rem .625rem; border-radius: var(--radius-sm);
  font-size: var(--step0); color: var(--text-2); text-decoration: none;
}

.nav__menu a:hover,
.nav__menu a:focus-visible { color: var(--text); background-color: var(--surface-2); }

.nav__menu a[aria-current="page"] {
  color: var(--text); font-weight: 650; box-shadow: inset 3px 0 0 var(--accent);
}

/* ---- Theme toggle ------------------------------------------------------- */
/*
  Both icons are always in the DOM; which one paints is decided by :root[data-theme], so
  the right one is correct on the FIRST paint — the inline anti-flash script in <head> sets
  the attribute before this stylesheet is applied, and no JavaScript is needed to swap them
  afterwards. The icon names the CURRENT theme (moon while dark, sun while light); the
  button's aria-label, which site.js keeps in sync, names the ACTION. The two are different
  on purpose, and the label is what assistive technology reads.

  The :not() half covers a page served without the attribute at all: dark is the default.
*/
.theme-toggle { flex: none; color: var(--text-2); }

.theme-toggle:hover { color: var(--text); }

.theme-toggle__moon,
.theme-toggle__sun { display: none; }

:root[data-theme="dark"] .theme-toggle__moon,
:root:not([data-theme="light"]) .theme-toggle__moon { display: block; }

:root[data-theme="light"] .theme-toggle__sun { display: block; }

/* ---- No-JS fallback (contract §5.1: degrades to plain links) ------------- */
/*
  With no site.js there is nothing to open a panel with, so the nav is never a panel: the
  six primary links become a plain wrapped row at every width, the burger is removed
  because it would do nothing, and the submenus stay closed — every one of their parents is
  a real link to the section hub, which lists the same pages.
*/
html:not(.js) .nav {
  display: block; position: static; max-height: none; overflow: visible; padding: 0;
  border-bottom: 0; background: none; box-shadow: none;
}

html:not(.js) .nav__list {
  flex-direction: row; flex-wrap: wrap; align-items: center; gap: .125rem .25rem;
}

html:not(.js) .nav__link,
html:not(.js) .nav__drop > a {
  width: auto; padding: .375rem .5rem; font-size: var(--step0); white-space: nowrap;
}

html:not(.js) .nav__burger,
html:not(.js) .nav__menu { display: none; }

html:not(.js) .site-header__inner { flex-wrap: wrap; padding-block: .5rem; }

/* 07  FOOTER ============ */

.site-footer {
  margin-top: clamp(2.5rem, 6vw, 4.5rem); padding-block: 2rem 1.5rem;
  border-top: 1px solid var(--border); background-color: var(--bg-2); font-size: var(--step0);
  color: var(--text-2);
}

/*
  The link columns. One column on a phone, two at 600px, three at 900px and all five at
  1200px (§22) — five equal 236px tracks would put "How Frequency Measurement Works" on
  three lines, so the count steps rather than auto-fitting.

  This is `.site-footer__grid`, NOT `.site-footer > .wrap`: the bottom bar is also a
  `.wrap` child of the footer, and the old selector turned the copyright line into a
  one-cell grid whose only paragraph was being positioned as a grid item.
*/
.site-footer__grid {
  display: grid; gap: 1.75rem var(--gap); grid-template-columns: minmax(0, 1fr);
}

.site-footer__col { min-width: 0; }

/* The brand column is a paragraph, not a link list, so it earns a wider track once there
   are five of them (§22); below that it simply spans the row it is in. */
.site-footer__col--brand { display: block; }

.site-footer__title {
  margin: 0 0 .625rem; font-size: var(--step-1); font-weight: 650; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-2);
}

.site-footer ul { margin: 0; padding: 0; list-style: none; }

.site-footer li + li { margin-top: .4375rem; }

.site-footer a { color: var(--text-2); text-decoration: none; }

.site-footer a:hover {
  color: var(--text); text-decoration: underline; text-underline-offset: .18em;
}

/* `.site-footer a` outranks `.brand`, so without this the footer wordmark renders in the
   link-list grey and stops looking like the wordmark it is. */
.site-footer .brand { color: var(--text); }

/* Capped in ch, not px: it has to stay two or three comfortable lines in a 236px track
   and in a 330px one, and only a measure does that at both. */
.site-footer__blurb {
  max-width: 38ch; margin-top: .75rem; font-size: var(--step-1); line-height: 1.6;
  color: var(--text-2); text-wrap: pretty;
}

/* The bottom bar is a sibling of the grid, not a cell inside it. */
.site-footer__base {
  margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
  font-size: var(--step-1); color: var(--text-3);
}

/* ---- Back to top -------------------------------------------------------- */
/*
  site.js `initBackToTop()` owns the state: it sets [hidden] + aria-hidden + tabindex=-1
  until you are 600px down the page, then unhides and adds `.is-visible` on the NEXT frame
  so a transition has a start state to animate from. Style that mechanism — [hidden] is
  already `display: none !important` in §01, so this rule only has to handle the fade.

  `.btn.btn--top`, not `.btn--top`: §10 defines `.btn` and `.btn--icon` further down the
  file, and a single class here would lose the cascade to a single class there. Doubling
  the class is cheaper than moving the button out of the footer section it belongs to.
*/
.btn.btn--top {
  position: fixed;
  right: calc(1rem + env(safe-area-inset-right));
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  /* Clears page content and the sticky mobile control bar (30); stays under the toast
     region (60), which must never be covered by a decorative affordance. */
  z-index: 50;
  border-color: var(--border-strong);
  background-color: var(--surface-2);
  color: var(--text-2);
  box-shadow: var(--shadow);
  opacity: 0;
  translate: 0 .5rem;
  transition: opacity var(--t), translate var(--t), background-color var(--t),
              border-color var(--t), color var(--t);
}

.btn.btn--top:hover { background-color: var(--surface-3); color: var(--text); }

.btn.btn--top.is-visible { opacity: 1; translate: 0 0; }

/* 08  HERO + CRUMBS ============ */

.crumbs { padding-block: .875rem .25rem; font-size: var(--step-1); color: var(--text-2); }

.crumbs ol {
  display: flex; flex-wrap: wrap; align-items: center; gap: .3125rem; margin: 0; padding: 0;
  list-style: none;
}

.crumbs li { display: inline-flex; align-items: center; gap: .3125rem; }

.crumbs li + li::before { content: "/"; color: var(--text-3); }

.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs [aria-current="page"] { color: var(--text); font-weight: 600; }

.hero { padding-block: clamp(1.25rem, .9rem + 1.4vw, 2.25rem) clamp(1rem, .8rem + 1vw, 1.75rem); }

.hero h1 { font-size: clamp(var(--step4), 1.6rem + 2.4vw, var(--step5)); }

.hero__lede {
  max-width: 62ch; margin-top: .75rem; font-size: var(--step1); line-height: 1.55;
  color: var(--text-2); text-wrap: pretty;
}

/* 09  CARD ============ */

/* Flat instrument surface shared by the panelled components. */
.card, .panel, .toolcard, .disclose, .faq__item {
  border: 1px solid var(--border); border-radius: var(--radius); background-color: var(--surface);
}

.card__head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .75rem 1rem; border-bottom: 1px solid var(--border);
}

.card__title { margin: 0; font-size: var(--step1); font-weight: 650; letter-spacing: -.01em; }

.card__body { padding: 1rem; }
.card__body > * + * { margin-top: .875rem; }

.card__foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .75rem 1rem;
  border-top: 1px solid var(--border); background-color: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius); font-size: var(--step-1); color: var(--text-2);
}

/* 10  BUTTONS + SEGMENTED CONTROL ============ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.25rem; padding: .4375rem .875rem; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background-color: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: var(--step0); font-weight: 600; line-height: 1.2;
  text-align: center; text-decoration: none; white-space: nowrap; cursor: pointer;
  -webkit-user-select: none; user-select: none; transition: background-color var(--t),
  border-color var(--t), color var(--t);
}

.btn:hover { background-color: var(--surface-3); border-color: var(--text-3); color: var(--text); }

.btn:active { translate: 0 1px; }

.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; translate: none; }

.btn--primary {
  background-color: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}

.btn--primary:hover {
  background-color: var(--accent-hover); border-color: var(--accent-hover);
  color: var(--accent-ink);
}

/* A11Y EXCEPTION, light only: #fff on --accent is 4.05:1, short of 4.5:1 for a 15px label.
   --accent-hover is the same hue and gives 5.29:1. */
:root[data-theme="light"] .btn--primary {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
}

:root[data-theme="light"] .btn--primary:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  filter: brightness(.88);
}

.btn--ghost { background-color: transparent; border-color: var(--border); color: var(--text-2); }

.btn--ghost:hover {
  background-color: var(--surface-2); border-color: var(--border-strong); color: var(--text);
}

.btn--danger { background-color: transparent; border-color: var(--danger); color: var(--danger); }

.btn--danger:hover {
  background-color: var(--danger); border-color: var(--danger); color: var(--bg);
}

.btn--sm { min-height: 1.875rem; padding: .25rem .5625rem; font-size: var(--step-1); }

.btn--icon { width: 2.25rem; min-height: 2.25rem; padding: 0; flex: none; }

.btn--icon.btn--sm { width: 1.875rem; min-height: 1.875rem; }

/* Contract: 44px minimum touch target on coarse pointers. */
@media (pointer: coarse) {
  .btn, .btn--sm, .seg__btn { min-height: var(--tap); padding-inline: 1rem; }

  .btn--icon, .btn--icon.btn--sm { width: var(--tap); min-height: var(--tap); padding: 0; }
}

/* ---- Segmented control -------------------------------------------------- */
/* role=radiogroup + role=radio. Selection is styled from aria-checked. */

.seg {
  display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background-color: var(--surface-2); max-width: 100%;
  overflow-x: auto; scrollbar-width: none;
}

.seg::-webkit-scrollbar { display: none; }

.seg__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  min-height: 2rem; padding: .3125rem .75rem; border: 1px solid transparent; border-radius: 4px;
  background-color: transparent; color: var(--text-2); font-family: inherit;
  font-size: var(--step-1); font-weight: 600; line-height: 1.2; white-space: nowrap;
  cursor: pointer; transition: background-color var(--t), color var(--t);
}

.seg__btn:hover { color: var(--text); background-color: var(--surface-3); }

/* Selected state carries a shape (the inset accent rule) as well as colour. */
.seg__btn[aria-checked="true"], .seg__btn[aria-selected="true"] {
  background-color: var(--surface); border-color: var(--border-strong); color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.seg__btn:disabled,
.seg__btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }

/* 11  READOUT + STATUS PILLS ============ */
/* Colour comes from data-status (the engine’s seven states), not classes. */

.readout {
  display: grid;
  gap: .375rem;
  justify-items: start;
  padding: clamp(.875rem, .6rem + 1.2vw, 1.5rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--bg-2);       /* recessed instrument face */
}

.readout__value {
  display: inline-block;
  min-width: 3.5ch;                    /* holds width across digit counts */
  font-size: clamp(3rem, 2rem + 7vw, 6.5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--text);
  /* tabular-nums is what stops the value reflowing as the digits change. */
}

.readout__value:empty::before { content: "\2014"; color: var(--text-3); }

.readout[data-status="stable"] .readout__value { color: var(--accent); }
.readout[data-status="frozen"] .readout__value { color: var(--text); }

.readout[data-status="idle"] .readout__value,
.readout[data-status="listening"] .readout__value,
.readout[data-status="weak"] .readout__value,
.readout[data-status="noisy"] .readout__value,
.readout[data-status="searching"] .readout__value { color: var(--text-2); }

.readout__unit {
  display: inline-block; margin-left: .375rem;
  font-size: clamp(1.125rem, .9rem + 1.2vw, var(--step3)); font-weight: 550; color: var(--text-2);
}

.readout__note {
  display: inline-block; font-size: clamp(var(--step2), 1rem + 2vw, var(--step4)); font-weight: 650;
  line-height: 1; letter-spacing: -.01em; color: var(--text);
}

.readout__cents {
  display: inline-block; min-width: 6ch; font-size: var(--step1); color: var(--text-2);
}

.readout__sub {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .875rem; font-size: var(--step-1);
  color: var(--text-2);
}

.readout__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  min-height: 1.75rem;                 /* reserved: status swaps cause no CLS */
}

/* ---- Status pills: dot + text. Never colour alone. ---------------------- */

.pill {
  display: inline-flex; align-items: center; gap: .4375rem; padding: .1875rem .625rem;
  border: 1px solid var(--border-strong); border-radius: 999px; background-color: var(--surface-2);
  font-size: var(--step-1); font-weight: 600; line-height: 1.4; color: var(--text-2);
  white-space: nowrap;
}

.pill::before {
  content: ""; flex: none; width: .5rem; height: .5rem; border-radius: 50%;
  background-color: currentColor;
}

.pill--ok     { color: var(--ok);     border-color: var(--ok); }
.pill--warn   { color: var(--warn);   border-color: var(--warn); }
.pill--danger { color: var(--danger); border-color: var(--danger); }

.pill--idle {
  color: var(--text-3); border-color: var(--border-strong); background-color: transparent;
}

/* Hollow dot distinguishes idle from live for anyone who cannot see the hue. */
.pill--idle::before { background-color: transparent; box-shadow: inset 0 0 0 2px currentColor; }

.pill--live {
  color: var(--accent); border-color: var(--accent); background-color: var(--accent-soft);
}

/* 12  METRICS ============ */
/* Hairlines are the container background through a 1px gap: one border. */

.metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 1px;
  border: 1px solid var(--border); border-radius: var(--radius); background-color: var(--border);
  overflow: hidden;
}

.metric {
  display: flex; flex-direction: column; gap: .1875rem; padding: .6875rem .875rem;
  background-color: var(--surface); min-width: 0;
}

.metric__label {
  font-size: var(--step-1); font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-2);
}

.metric__value {
  font-size: var(--step2); font-weight: 600; line-height: 1.1; letter-spacing: -.01em;
  color: var(--text); overflow-wrap: anywhere;
}

/* 13  TOOL SHELL + PANELS ============ */
/* .tool__stage + .tool__controls + .tool__panels; split at 1024px (§22). */

.tool { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-items: start; }

/*
  `grid-template-columns` is declared explicitly as minmax(0, 1fr) — do not remove it.

  A grid with no declared columns gets one implicit `auto` track, and an `auto` track is
  sized to its content's MAX-content. A grid item's automatic minimum is likewise its
  min-content, not zero. Together those two defaults mean any single wide child drags the
  whole track past the viewport: the piano keyboard on /pitch/note-to-frequency/ expanded
  this 695px stage to 1994px and pushed the entire page into horizontal scroll, even though
  the keyboard already had its own `overflow-x: auto` wrapper — the wrapper never got the
  chance to scroll, because nothing ever forced it to be narrower than its contents.

  `min-width: 0` on the stage itself is not enough; the constraint has to be on the TRACK.
*/
.tool__stage {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: .875rem; min-width: 0;
  padding: clamp(.75rem, .5rem + 1vw, 1.125rem);
  border: 1px solid var(--border); border-radius: var(--radius); background-color: var(--surface);
}

.tool__controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .625rem; min-width: 0;
}

.tool__controls > .cluster { gap: .5rem; }

.tool__panels { display: grid; gap: .75rem; align-content: start; min-width: 0; }

/*
  ERROR / RECOVERY STATES. Every one of these notes ships in the served HTML and the shell
  only flips [hidden], so the recovery steps are crawlable and readable with JS off. That
  makes the container's usual state EMPTY, and an empty container must cost nothing: the
  spacing therefore lives on the visible children, not on the box.

  `:not([hidden])` twice, rather than `> * + *`, because the adjacent sibling of a visible
  note is usually a hidden one — a plain `+` would put the leading gap on whichever note
  happens to be second in the source and leave the one actually on screen flush against the
  tool. grid, so those margins cannot collapse into the tool block above.
*/
.tool__states { display: grid; align-content: start; }

.tool__states > :not([hidden]) { margin-block-start: var(--gap); }

.tool__states > :not([hidden]) ~ :not([hidden]) { margin-block-start: .75rem; }

.tool__states h3 { font-size: var(--step1); }

.tool__states ul { margin: 0; padding-left: 1.25rem; list-style: disc; }

.tool__states li + li { margin-top: .3125rem; }

/* ---- Panel -------------------------------------------------------------- */
/* The divider sits on .panel__body’s top edge, so hiding the body leaves no dangling border: the
   collapsed state needs no :has(). */

.panel { min-width: 0; }

.panel[hidden] { display: none; }

.panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .5625rem .75rem; min-height: 2.75rem;
}

.panel__title {
  margin: 0; font-size: var(--step0); font-weight: 650; letter-spacing: 0; color: var(--text);
}

.panel__tools { display: flex; align-items: center; gap: .375rem; flex: none; }

.panel__body { padding: .875rem; border-top: 1px solid var(--border); }

.panel__body > * + * { margin-top: .875rem; }

/* Disclosure caret on whichever control owns aria-expanded in the head. */
.panel__head [aria-expanded]::after {
  content: ""; display: inline-block; width: .4375rem; height: .4375rem; margin-left: .375rem;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg); transition: transform var(--t);
}

.panel__head [aria-expanded="false"]::after { transform: translateY(-1px) rotate(-45deg); }

/* 14  CHARTS ============ */
/* Height is reserved before the canvas paints, so CLS is zero. Modifier and data attribute both
   work; desktop values land at >=768px (§22). */

.chart {
  --chart-h: 180px; position: relative; min-width: 0; padding: .5rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background-color: var(--bg-2);
}

.chart--waveform,    .chart[data-chart="waveform"]    { --chart-h: 120px; }
.chart--spectrum,    .chart[data-chart="spectrum"]    { --chart-h: 200px; }
.chart--spectrogram, .chart[data-chart="spectrogram"] { --chart-h: 220px; }

/* CSS height beats the DPR-scaled attributes, so the box never resizes. */
.chart__canvas {
  display: block;
  width: 100%;
  height: var(--chart-h);
  border-radius: 4px;
  background-color: transparent;
  touch-action: none;                  /* pointer inspection, not page pan */
}

/* The figcaption from PARTIALS §9: chart title on the left, that chart's own display controls
   on the right, both wrapping as the box narrows. Unstyled these are block boxes, so a select
   stretches the full width of the chart and four of them cost about 180px of height directly
   above the canvas — on an instrument page that height belongs to the plot. */

.chart__head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .4375rem .875rem; padding: 0 .125rem .5rem;
}

.chart__title { margin: 0; font-size: var(--step1); font-weight: 650; }

.chart__tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .625rem; margin-left: auto;
}

/* Controls in the head size to their content, not to the chart. Their labels are usually
   .sr-only, so the option text has to name its own dimension. Heights are left alone: these
   are real controls and must keep their touch target. */
.chart__tools .field  { display: inline-flex; align-items: center; gap: .375rem; width: auto; }
.chart__tools .select,
.chart__tools .input  { width: auto; }

.chart__legend {
  display: flex; flex-wrap: wrap; gap: .375rem .875rem; margin: 0; padding: .4375rem .125rem 0;
  list-style: none; font-size: var(--step-1); color: var(--text-2);
}

.chart__legend > * { display: inline-flex; align-items: center; gap: .375rem; }

/* Swatch shape varies with hue so series stay separable under CVD. */
.chart__legend > *::before {
  content: ""; flex: none; width: .75rem; height: .75rem; border-radius: 1px;
  background-color: currentColor;
}

.chart__legend [data-series="1"] { color: var(--c1); }
.chart__legend [data-series="2"] { color: var(--c2); }
.chart__legend [data-series="3"] { color: var(--c3); }
.chart__legend [data-series="4"] { color: var(--c4); }
.chart__legend [data-series="5"] { color: var(--c5); }
.chart__legend [data-series="6"] { color: var(--c6); }

.chart__legend [data-series="1"]::before { height: .25rem; border-radius: 2px; }
.chart__legend [data-series="2"]::before { border-radius: 50%; }
.chart__legend [data-series="3"]::before { border-radius: 1px; }

.chart__axis {
  display: flex; justify-content: space-between; gap: .5rem; padding: .3125rem .125rem 0;
  font-size: var(--step-1); color: var(--text-3); white-space: nowrap; overflow: hidden;
}

/* Screen-reader path to the data (§8); kept visible, it helps everyone. */
.chart__summary {
  display: block; padding: .4375rem .125rem 0; font-size: var(--step-1); line-height: 1.5;
  color: var(--text-2);
}

.chart__empty {
  position: absolute; inset: .5rem; display: flex; align-items: center; justify-content: center;
  padding: 1rem; border-radius: 4px; background-color: var(--bg-2); font-size: var(--step0);
  text-align: center; text-wrap: balance; color: var(--text-2); pointer-events: none;
}

/* 15  TABLES ============ */

.table { width: 100%; border-collapse: collapse; font-size: var(--step0); }

.table th, .table td {
  padding: .4375rem .625rem; border-bottom: 1px solid var(--border); text-align: left;
  vertical-align: baseline;
}

.table thead th {
  position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--border-strong);
  background-color: var(--surface); font-size: var(--step-1); font-weight: 650;
  letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: 0; }

/* Explicit override wins over any inherited alignment. */
.table [data-align="start"]  { text-align: left; }
.table [data-align="center"] { text-align: center; }
.table [data-align="end"]    { text-align: right; }

/* Numeric columns right-aligned so the decimal points line up. */
.table--peaks th, .table--peaks td { text-align: right; white-space: nowrap; }

.table--peaks th:first-child, .table--peaks td:first-child {
  text-align: left; color: var(--text-2);
}

.table--peaks tbody tr:hover td { background-color: var(--surface-2); }

/* Cover panels scroll with the content (local) and uncover a fixed radial shade (scroll): an
   edge hint with no scroll listener. */
.table--scroll {
  overflow-x: auto; overscroll-behavior-x: contain; border: 1px solid var(--border);
  border-radius: var(--radius); background-color: var(--surface); background-image:
  linear-gradient(to right, var(--surface), rgba(0,0,0,0)),
  linear-gradient(to left,  var(--surface), rgba(0,0,0,0)),
  radial-gradient(farthest-side at 0    50%, var(--scroll-shade), rgba(0,0,0,0)),
  radial-gradient(farthest-side at 100% 50%, var(--scroll-shade), rgba(0,0,0,0));
  background-position: 0 0, 100% 0, 0 0, 100% 0; background-repeat: no-repeat;
  background-size: 2.5rem 100%, 2.5rem 100%, .875rem 100%, .875rem 100%;
  background-attachment: local, local, scroll, scroll;
}

.table--scroll > .table { min-width: 34rem; }

/*
  The placeholder row every peak table ships with ("No peaks detected yet."). It is a
  sentence, not a measurement, so it undoes the three things `.table--peaks` does to a data
  cell — right alignment, tabular mono, and nowrap — and it must not answer to hover, which
  on a data row means "this row is a reading you can point at".

  The leading `.table` is not decoration: the placeholder cell carries `colspan`, so it is
  also `:first-child`, and `.table--peaks td:first-child` (0,1,2) would otherwise pull it
  back to the left with the index column. `.table .table__empty td` is (0,2,1) and clears
  both that and `.table--peaks tbody tr:hover td`.
*/
.table .table__empty td {
  padding-block: 1rem; font-family: var(--font); font-variant-numeric: normal;
  text-align: center; white-space: normal; color: var(--text-2);
}

.table .table__empty:hover td { background-color: transparent; }

/* 16  FORMS ============ */

.field { display: grid; gap: .3125rem; min-width: 0; }

.field__label {
  font-size: var(--step-1); font-weight: 650; letter-spacing: .02em; color: var(--text-2);
}

.field__hint { font-size: var(--step-1); line-height: 1.45; color: var(--text-3); }

/* Errors carry a glyph as well as the colour (contract §8). */
.field__error {
  display: flex; align-items: flex-start; gap: .375rem; font-size: var(--step-1); font-weight: 600;
  color: var(--danger);
}

.field__error::before {
  content: "!"; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 1.0625rem; height: 1.0625rem; border: 1px solid currentColor; border-radius: 50%;
  font-size: .75rem; line-height: 1;
}

.input, .select {
  width: 100%; min-height: 2.375rem; padding: .4375rem .625rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background-color: var(--surface-2); color: var(--text); font-family: inherit;
  font-size: var(--step0); line-height: 1.4; transition: border-color var(--t);
}

.input:hover,
.select:hover { border-color: var(--text-3); }

.input::placeholder { color: var(--text-3); opacity: 1; }

.input:disabled, .select:disabled {
  opacity: .55; cursor: not-allowed; background-color: var(--surface-3);
}

.input[aria-invalid="true"] { border-color: var(--danger); }

/* Numeric entry matches the readouts it drives. */
.input[type="number"], .input[inputmode="decimal"], .input[inputmode="numeric"] {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}

.select {
  appearance: none;
  padding-right: 2rem;
  cursor: pointer;
  /* currentColor caret: themes for free, no data-URI, no icon font. */
  background-image:
    linear-gradient(45deg,  rgba(0,0,0,0) 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, rgba(0,0,0,0) 50%);
  background-size: 5px 5px, 5px 5px;
  background-position: right 1.0625rem top 55%, right .75rem top 55%;
  background-repeat: no-repeat;
}

/* ---- Range -------------------------------------------------------------- */
/* Separate rules: one unknown selector in a list drops the whole rule. */

.range {
  appearance: none; -webkit-appearance: none; width: 100%; height: 1.5rem; margin: 0;
  background: transparent; cursor: pointer;
}

.range::-webkit-slider-runnable-track {
  height: 4px; border: 1px solid var(--border); border-radius: 999px;
  background-color: var(--surface-3);
}

.range::-moz-range-track {
  height: 4px; border: 1px solid var(--border); border-radius: 999px;
  background-color: var(--surface-3);
}

/* The thumb still needs the prefix: it is a -webkit- pseudo-element. */
.range::-webkit-slider-thumb { -webkit-appearance: none;
  width: 1.125rem; height: 1.125rem; margin-top: -.5rem;
  border: 2px solid var(--bg-2); border-radius: 50%; background-color: var(--accent);
}

.range::-moz-range-thumb {
  width: 1.125rem; height: 1.125rem; border: 2px solid var(--bg-2); border-radius: 50%;
  background-color: var(--accent);
}

.range:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Switch ------------------------------------------------------------- */
/* The input is the track: no :has(), no sibling span, and a hard-stop radial knob because
   pseudo-elements on <input> are unreliable in Firefox. */

.switch {
  display: inline-flex; align-items: center; gap: .5rem; font-size: var(--step0);
  color: var(--text-2); cursor: pointer;
}

.switch input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none; width: 2.5rem; height: 1.375rem;
  margin: 0; border: 1px solid var(--border-strong); border-radius: 999px;
  background-color: var(--surface-3); background-image: radial-gradient(circle at center,
  var(--text-2) 0 .4062rem, rgba(0,0,0,0) .4062rem); background-repeat: no-repeat;
  background-size: 1.25rem 1.25rem; background-position: left center; cursor: pointer;
  transition: background-color var(--t), background-position var(--t), border-color var(--t);
}

.switch input[type="checkbox"]:checked {
  border-color: var(--accent); background-color: var(--accent);
  background-image: radial-gradient(circle at center,
  var(--accent-ink) 0 .4062rem, rgba(0,0,0,0) .4062rem); background-position: right center;
}

.switch input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; }

/* Plain checkboxes and radios inherit the accent without custom painting. */
input[type="checkbox"]:not(.switch input),
input[type="radio"] { accent-color: var(--accent); }

/* 17  NOTES, DISCLOSE, FAQ ============ */

/* The kind must be named in the text; colour is never the only signal. */
.note {
  padding: .75rem .875rem; border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong); border-radius: var(--radius-sm);
  background-color: var(--surface-2); font-size: var(--step0); line-height: 1.6;
  color: var(--text-2);
}

.note > * + * { margin-top: .5rem; }
.note strong { color: var(--text); }

.note--info { border-left-color: var(--info); }
.note--warn { border-left-color: var(--warn); }
.note--tip  { border-left-color: var(--accent); }

.disclose > summary, .faq__item > summary {
  display: flex; align-items: center; gap: .625rem; padding: .6875rem .875rem; font-weight: 650;
  color: var(--text); cursor: pointer; list-style: none;
}

.disclose > summary::-webkit-details-marker,
.faq__item > summary::-webkit-details-marker { display: none; }

.disclose > summary::after, .faq__item > summary::after {
  content: ""; flex: none; width: .5rem; height: .5rem; margin-left: auto;
  border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3);
  transform: rotate(-45deg); transition: transform var(--t);
}

.disclose[open] > summary::after,
.faq__item[open] > summary::after { transform: rotate(45deg); }

.disclose > summary:hover,
.faq__item > summary:hover { background-color: var(--surface-2); }

.disclose > summary + *, .faq__item > summary + * {
  padding: .875rem; border-top: 1px solid var(--border); color: var(--text-2);
}

.disclose > summary + * > * + *,
.faq__item > summary + * > * + * { margin-top: .75rem; }

.faq { display: grid; gap: .5rem; }

.faq__item > summary { font-size: var(--step1); }

/*
  The answer body. `.faq__item > summary + *` above already gave it its padding and its
  divider; what it was missing was a reading treatment. These answers are four to six
  sentences of technical prose and they inherit the full width of the content column, so
  they need the same measure the rest of the site's running text gets — applied to the
  children, never to the box (§4.3.1).
*/
.faq__answer { line-height: 1.65; }

.faq__answer > * { max-width: var(--measure); }

.faq__answer ul,
.faq__answer ol { padding-left: 1.25rem; }

.faq__answer ul { list-style: disc; }
.faq__answer ol { list-style: decimal; }

.faq__answer li + li { margin-top: .3125rem; }

/*
  The §11 disclaimer, verbatim on every page with a measuring tool. It is already a
  `.note--info`, so it arrives with its surface and its blue edge; what it needs is to sit
  clear of the tool it qualifies and to stay readable. It is the one piece of copy on a
  tool page that carries legal weight, so it keeps a measure rather than running the full
  column width, and it is never allowed to look like a dismissible hint.
*/
.measure-disclaimer { max-width: var(--measure); margin-block: var(--gap); }

/* 18  TOOL GRID ============ */

.toolgrid {
  display: grid;
  gap: .875rem;
  grid-template-columns: minmax(0, 1fr);   /* widened in §22 */
  padding: 0;
  margin: 0;
  list-style: none;
}

.toolcard {
  display: flex; flex-direction: column; gap: .3125rem; height: 100%; padding: .9375rem 1rem;
  color: inherit; text-decoration: none; transition: border-color var(--t),
  background-color var(--t);
}

.toolcard:hover {
  border-color: var(--border-strong); background-color: var(--surface-2); color: inherit;
}

.toolcard__title {
  margin: 0; font-size: var(--step1); font-weight: 650; letter-spacing: -.01em; color: var(--text);
}

a.toolcard:hover .toolcard__title { color: var(--link-hover); }

.toolcard__desc {
  margin: 0; font-size: var(--step-1); line-height: 1.55; color: var(--text-2); text-wrap: pretty;
}

/* 19  TOAST ============ */
/* Must never sit on top of the sticky mobile control bar. */

.toast-region {
  position: fixed; left: 0; right: 0; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: .5rem; padding-inline: 1rem;
  pointer-events: none;
}

.toast {
  display: flex; align-items: center; gap: .5rem; max-width: min(30rem, 100%);
  padding: .5625rem .875rem; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background-color: var(--surface-2); box-shadow: var(--shadow);
  font-size: var(--step0); color: var(--text); pointer-events: auto;
  animation: fm-toast-in 140ms var(--ease) both;
}

@keyframes fm-toast-in {
  from { opacity: 0; translate: 0 .5rem; }
  to   { opacity: 1; translate: 0 0; }
}

/* 20  AD SLOT ============ */
/*
  Deliberately empty of rules that give `.adslot` a box. Every rule that styles the slot
  itself lives in Ads_terra/ads.css, which loads after this file, and it must stay that way.

  One exception, and it is not a rule on `.adslot` at all: `.section + .adslot + .section`
  in §7 zeroes the FOLLOWING SECTION's leading padding, because an empty slot between two
  sections otherwise breaks the `.section + .section` adjacency and re-adds 56px of blank
  space. It has to live in this file, not in ads.css, because it must still apply when a
  filter list has blocked everything under /Ads_terra/. See the comment there.

  This section used to reserve a dashed, captioned box of fixed height, because v1 shipped
  containers with no ad script and a labelled placeholder was the honest way to show one.
  That is no longer what a slot is. A slot is now an empty div that must have NO BOX AT ALL
  until a real creative is confirmed inside it: no height, no margin, no border, no
  background. That is the entire mechanism by which a no-fill, a blocked script or ads
  switched off leave the page looking exactly as it does with no advertising.

  Anything declared here would defeat it silently. The rules in ads.css set only `display`,
  `max-inline-size` and `overflow-x`; a `margin-block` or a `border` left in this file is
  NOT overridden by them, and would put a visible empty frame on all 37 monetised pages
  while every automated check still passed.

  Equally: never hide a slot from here. The network walks the container's ancestors and
  refuses to fill anything hidden or below ~0.9 opacity, so `display: none` on a slot — even
  as "belt and braces" for a slot that should not be there — serves zero ads rather than
  fixing the placement. Misplacement is caught in build/qa-static.js, where a wrong position
  fails the build instead of quietly costing money.
*/

/* 21  UTILITIES ============ */
/*
  Namespaced with u- so they can never collide with the §4.3 vocabulary. */

.u-mono          { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.u-muted         { color: var(--text-2); }
.u-quiet         { color: var(--text-3); }
.u-small         { font-size: var(--step-1); }
.u-center        { text-align: center; }
.u-nowrap        { white-space: nowrap; }

/* JS-only controls are removed when JS is off; the fallback is revealed. */
html:not(.js) [data-requires-js] { display: none !important; }
html.js        [data-nojs]       { display: none !important; }

/* 21A  TOOL VIEW PRESETS + IDLE DISCLOSURE + FILE DROP ZONE ============ */
/*
  The preset control writes exactly one attribute — .tool[data-view] — and every layout
  consequence is here. JavaScript never adds a class, never hides a node itself and never
  moves one: which blocks a preset drops, and which numbers it makes loud, are style
  decisions and belong in the stylesheet.

  A preset is LAYOUT ONLY. It does not touch fftSize, the window, the detection mode or the
  frequency range — see VIEWS in assets/js/pages/home.js for why that separation had to be
  made explicit. Choosing the readable view must never quietly coarsen the measurement.

  Nothing is hidden that carries a number you cannot get back: every preset keeps the
  readout, and one tap on Spectrum restores the full workbench. `/` opens on `quick` for the
  reason BUILD-CONTRACT §0.2 gives — the working tool above the fold, understood in about
  three seconds — and every block `quick` drops is still in the served HTML, still crawlable,
  still one control away. */

.tool[data-view="quick"] [data-view-part="waveform"],
.tool[data-view="quick"] [data-view-part="history"],
.tool[data-view="quick"] [data-view-part="peaks"],
.tool[data-view="quick"] [data-view-part="stats"],
.tool[data-view="pitch"] [data-view-part="waveform"],
.tool[data-view="pitch"] [data-view-part="history"] { display: none; }

/* Quick is the across-the-room reading: one number, as large as the box allows. */
.tool[data-view="quick"] .readout__value { font-size: clamp(var(--step5), 2.5rem + 6vw, 5rem); }

/* Pitch leads with the note and the cents; the hertz value stays, one step quieter. */
.tool[data-view="pitch"] .readout__note  { font-size: var(--step3); color: var(--text); }
.tool[data-view="pitch"] .readout__cents { font-size: var(--step1); }

/* Precision leads with the dispersion, because that is what a precision run is for. */
.tool[data-view="precision"] [data-view-part="stats"] .metric__value { font-size: var(--step3); }

/* ---- Idle disclosure: what has not happened yet does not shout ---------- */
/*
  Progressive disclosure driven entirely by the state channel TOOL-DOM §3 already defines:
  `data-status` on .readout, written only by the shell. No class is toggled from JavaScript
  and nothing is taken out of the DOM. Every element below is in the served HTML, is found by
  a crawler, keeps its accessible name and keeps its place in the tab order. What moves is
  visual weight, and only while the tool is doing nothing.

  `idle` is the one status that means exactly that: the shell publishes it before the first
  Start and again after every Stop.

  1. The telemetry rows. Detection type, confidence, input level, dominant peak, fundamental,
     sample rate, FFT size, bin spacing and window are nine slots — seven of them an em dash
     before anything has been measured — and they sat directly under the headline, making
     them the third thing a first-time visitor read on a page whose job is to answer "how
     many hertz is this sound". They are the reading's provenance, so they arrive with the
     reading rather than standing in for it. The headline, the unit, the note, the cents and
     the status sentence all stay: those are the answer and the reason there isn't one yet.

  2. The controls that cannot act yet. Freeze, Reset, Copy result and the two exports are
     `disabled` until there is something to freeze, clear, copy or export, and the shell owns
     that flag. `:disabled` is therefore the honest condition to style on — not "before you
     start" but "this cannot do anything" — so a control that is useful again after a Stop
     comes straight back to full weight without any extra state being invented for it. They
     keep their size, their hit area and their label; they lose the border and the type
     weight that had them competing with Start Measuring. Colour is untouched, so the
     contrast pairs measured in the audit are unchanged.

  Scoped to `[data-tool="frequency-measurer"]`, which is `/` and only `/`. Twenty pages share
  `.readout__sub`, and for several of them those rows are the point rather than the noise —
  `/audio/fft-analyzer/` exists to show bin spacing and window, `/frequency-analyzer/` opens
  every setting on purpose. Whether each of them wants this is that page's own decision, taken
  against its own Differentiation line, not a side effect of fixing the homepage. */

[data-tool="frequency-measurer"] .readout[data-status="idle"] .readout__sub { display: none; }

/* General sibling: .readout and these clusters are all children of .tool__stage. Scoped to
   `.btn[data-action]` so it reaches Freeze/Reset/Copy and the two exports, and never the
   Detection or Preset radiogroups (which are `.seg__btn`, carry no data-action, and work
   before a measurement exists) and never Start/Stop (a different box, and ahead of the
   readout in the source). */
[data-tool="frequency-measurer"] .readout[data-status="idle"] ~ .cluster
  .btn[data-action]:disabled {
  border-color: transparent; background-color: transparent; font-weight: 500;
}

/*
  Analyzer inverts the emphasis for /frequency-analyzer/: the charts are the stage and the
  numbers ride in the rail. It is a static attribute in that page's markup, not a preset a
  control writes, but it belongs here for the same reason the presets do — the page describes
  what it is, the stylesheet decides what that looks like.

  Only three things change, and all three are consequences of the rail being narrow:
  the headline has to fit a 21rem column instead of a 60rem one, the four charts have to
  agree on a height or the 2x2 grid comes out ragged, and the always-open settings bench
  needs columns rather than a wrapping flex row. Nothing is hidden, and no other view is
  touched. */

.tool[data-view="analyzer"] .readout { padding: .875rem; }

.tool[data-view="analyzer"] .readout__value { font-size: clamp(2.25rem, 1.4rem + 3vw, 3.25rem); }
.tool[data-view="analyzer"] .readout__unit  { font-size: var(--step1); }
.tool[data-view="analyzer"] .readout__note  { font-size: var(--step2); }

/* One height for every panel in the grid; the >=768 value is in §22 with the other widths. */
.tool[data-view="analyzer"] .chart { --chart-h: 190px; }

/* The settings bench only. `:not(--sticky)` because the analyzer's primary Start/Stop bar is
   also a .tool__controls, and a two-button row laid out as a 15rem card grid is two very wide
   buttons with a gutter down the middle. */
.tool[data-view="analyzer"] .tool__controls:not(.tool__controls--sticky) {
  display: grid; gap: var(--gap); align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

/* ---- File drop zone and offline progress ------------------------------- */
/* State is the attribute, not a class, and it is paired with a border change as well as a
   fill so it survives forced-colors and colour-blind vision (§8). */

[data-dropzone][data-active="true"] {
  border-color: var(--accent); border-left-color: var(--accent);
  background-color: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: 3px;
}

.tool__file-progress {
  display: flex; align-items: center; gap: .625rem; flex-wrap: wrap;
}

.tool__file-progress progress {
  flex: 1 1 10rem; height: .5rem; border: 1px solid var(--border); border-radius: 999px;
  background-color: var(--surface-2); accent-color: var(--accent);
}

/* 21B  FREQUENCY COUNTER ============ */
/*
  /frequency-counter/ runs its own controller (pages/counter.js) rather than the shared tool
  shell, because it is a counter in the electronics sense and not another transform display:
  no FFT, so no spectrum, no peak table and no note. What it needs instead is an input level
  bar with the trigger point drawn on it, a gate progress bar, and a tap target large enough
  to hit without looking.

  All three take their values as custom properties written by the controller (--level,
  --threshold, --fill), so JavaScript sets numbers and this stylesheet decides what they look
  like. Nothing here is toggled by a class.

  Mode is one attribute — [data-mode="acoustic"|"tap"] on the tool root — and it changes order
  and emphasis only. Nothing is hidden: the microphone counter and the tap counter are both
  always present, because a mode switch that removes the Stop button of a run in progress is a
  trap, not a preset. */

.counter__block {
  display: grid; gap: .5rem; min-width: 0; padding: .75rem .875rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background-color: var(--bg-2);
}

.counter__block > h3 { margin: 0; font-size: var(--step0); font-weight: 650; color: var(--text); }

/* ---- Input level bar, with the trigger point marked on it --------------- */
/* The bar exists to answer one question: is the signal clearing the trigger on each event and
   falling back under it in between? A number alone cannot answer that. */

.counter__bar {
  --level: 0%; --threshold: 62.5%;
  position: relative; height: .875rem; overflow: hidden;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background-color: var(--surface-2);
}

.counter__bar::before {
  content: ""; position: absolute; inset-block: 0; left: 0; width: var(--level);
  background-color: var(--accent-2);
}

.counter__bar::after {
  content: ""; position: absolute; inset-block: 0; left: var(--threshold); width: 2px;
  margin-left: -1px; background-color: var(--warn);
}

.counter__bar[data-over="true"]::before { background-color: var(--accent); }

/* The same state in words, because state is never colour-only (§8). Exactly one of the two
   phrases is ever displayed, and "below" is the served default. */
.counter__armed--over { display: none; }

.counter__bar[data-over="true"] ~ .counter__armed .counter__armed--under { display: none; }
.counter__bar[data-over="true"] ~ .counter__armed .counter__armed--over  { display: inline; }
.counter__bar[data-over="true"] ~ .counter__armed { color: var(--accent); }

/* ---- Gate progress ------------------------------------------------------ */

.counter__gatewrap { width: 100%; }

.counter__gatebar {
  --fill: 0%; flex: 1 1 8rem; height: .375rem; overflow: hidden;
  border: 1px solid var(--border); border-radius: 999px; background-color: var(--surface-2);
}

.counter__gatebar::before {
  content: ""; display: block; height: 100%; width: var(--fill); background-color: var(--accent);
}

/* ---- Tap pad ------------------------------------------------------------ */
/* A real <button>. It is deliberately the largest hit area on the page: a tempo tapped with a
   fingertip on a 44px target reads slower than the one performed, because the misses are all
   late. */

.counter__tappad {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .25rem; width: 100%; min-height: 7.5rem; padding: 1rem;
  border: 2px solid var(--accent); border-radius: var(--radius);
  background-color: var(--accent-soft); color: var(--text);
  font: inherit; font-size: var(--step2); font-weight: 650; text-align: center;
  cursor: pointer; touch-action: manipulation; user-select: none;
  -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}

.counter__tappad:active { background-color: var(--accent); color: var(--accent-ink); }

.counter__tappad__hint { font-size: var(--step-1); font-weight: 500; color: var(--text-2); }
.counter__tappad:active .counter__tappad__hint { color: var(--accent-ink); }

/* ---- Stage order: the one thing [data-mode] changes --------------------- */
/* Explicit orders, in tens, so the tap block can be lifted between two of them without
   renumbering anything. The primary action keeps order 10 in both modes: nothing is ever
   placed between the h1 and the button that starts the tool. */

[data-counter] .tool__stage > *   { order: 50; }
[data-counter] .counter__primary  { order: 10; }
[data-counter] .tool__privacy     { order: 20; }
[data-counter] .tool__stage > [data-nojs] { order: 22; }
[data-counter] .readout           { order: 30; }
[data-counter] .counter__modes    { order: 40; }
[data-counter] .counter__mic      { order: 50; }
[data-counter] .counter__gateout  { order: 60; }
[data-counter] .counter__tap      { order: 70; }
[data-counter] .counter__totals   { order: 80; }

[data-counter][data-mode="tap"] .counter__tap     { order: 45; }
[data-counter][data-mode="tap"] .counter__tappad  { min-height: 11rem; font-size: var(--step3); }

/* The headline rate is only green once a gate has actually closed on a real count. */
[data-counter][data-status="counting"] .readout__value { color: var(--accent); }

[data-counter][data-status="idle"] .readout__value,
[data-counter][data-status="starting"] .readout__value,
[data-counter][data-status="stopped"] .readout__value,
[data-counter][data-status="error"] .readout__value { color: var(--text-2); }

@media (forced-colors: active) {
  .counter__bar::before,
  .counter__gatebar::before { background-color: CanvasText; }
  .counter__bar::after      { background-color: Highlight; }
  .counter__tappad          { border: 2px solid CanvasText; }
}

/* 21C  SPECTRUM ANALYZER ============ */
/* The one page where the chart IS the instrument rather than an illustration of it, so the
   only thing this section does is height. Both rules are scoped to that tool: a spectrum on
   any other page keeps the shared 200/300px box, and nothing here can leak into it.

   Fluid rather than stepped, so section 22 keeps its monopoly on width breakpoints. The
   display grows with the viewport and then stops, because a chart taller than about 34rem
   pushes the status line and the strongest-peak reading off the bottom of a laptop screen —
   and the numbers under the trace are what tell you the trace is trustworthy. */

[data-tool="audio-spectrum-analyzer"] .chart--tall  { --chart-h: clamp(15rem, 50vh, 34rem); }

/* The level bar is a strip, not a plot: two rows of pixels for the bar and its dBFS scale. */
[data-tool="audio-spectrum-analyzer"] .chart--meter { --chart-h: 4.5rem; }

/* 21N  NOTE CONVERTERS: HERO FIELD + PIANO KEYBOARD ============ */
/*
  Used by /pitch/frequency-to-note/ (hero field) and /pitch/note-to-frequency/ (keyboard).

  The keyboard is 88 real <button>s in the served HTML — nothing here draws a key, and the
  page still lists every note with scripting off. Black keys need no magic offset table:
  each one is a flex item whose negative inline margins cancel its own width, so it adds
  nothing to the row and lands centred on the boundary between the two white keys it sits
  between, which is exactly where a black key is on a piano. Where a semitone has no black
  key (E-F, B-C) the markup simply omits one.

  Key colour is the one place on the site that uses literal light/dark values rather than
  surface tokens: "white key" and "black key" are the object being drawn, so inverting them
  with the theme would draw the wrong instrument. Both pairs clear 4.5:1 in both themes. */

.input--hero {
  min-height: 3.25rem; font-size: var(--step3); font-weight: 600; letter-spacing: -.01em;
}

.keys {
  --key-white:     #ced7e4;
  --key-white-ink: #1b222e;
  --key-black:     #0a0e15;
  --key-black-ink: #cfd8e4;
  position: relative; padding: .5rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background-color: var(--bg-2);
  /* Belt and braces with the track fix on .tool__stage: as a grid/flex item this box's
     automatic minimum would otherwise be the full min-content width of 88 keys. */
  min-inline-size: 0; max-inline-size: 100%;
}

:root[data-theme="light"] .keys {
  --key-white:     #ffffff;
  --key-white-ink: #0f1620;
  --key-black:     #2b3545;
  --key-black-ink: #eef2f7;
}

/* 88 keys is 88 tab stops. Hidden until focused, exactly like .skip-link. */
.keys__skip {
  position: absolute; top: .5rem; left: .5rem; z-index: 5; padding: .375rem .625rem;
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background-color: var(--accent); color: var(--accent-ink); font-size: var(--step-1);
  font-weight: 650; text-decoration: none;
}

.keys__skip:not(:focus) {
  width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); border: 0;
  white-space: nowrap;
}

/*
  `position: relative` is load-bearing — do not remove it.

  An overflow container only clips descendants whose containing block lives inside it.
  `.keys` is `position: relative` (it anchors the skip link), so positioned descendants of
  the key row resolved their containing block against `.keys`, one level ABOVE this scroll
  box — and were therefore never clipped by it. The 88-key row reported its full 1976px to
  the page, and `body { overflow-x: clip }` then hid the damage: no scrollbar, no visible
  fault, just a keyboard silently cut off at the right edge on /pitch/note-to-frequency/
  and /generators/tone-generator/.

  Making the scroll box itself positioned puts the containing block inside the scroller,
  so the clip applies and the row scrolls here instead of stretching the document.
  Verified: page scrollWidth 1959px -> 1185px at 1200px wide, with the keyboard still
  scrolling internally.
*/
.keys__scroll {
  position: relative; overflow-x: auto; overscroll-behavior-x: contain;
  min-inline-size: 0; max-inline-size: 100%;
}

.keys__row {
  --key-w: 2.125rem; --key-bw: 1.3125rem; --key-h: 8.5rem;
  display: flex; align-items: flex-start; width: max-content; min-width: 100%;
  height: var(--key-h);
}

.keys__key {
  flex: none; display: flex; align-items: flex-end; justify-content: center;
  padding: 0 .0625rem .375rem; border: 1px solid var(--border-strong);
  border-radius: 0 0 4px 4px; font-family: var(--mono); font-size: var(--step-1);
  font-variant-numeric: tabular-nums; font-weight: 600; line-height: 1; cursor: pointer;
  -webkit-user-select: none; user-select: none; transition: box-shadow var(--t);
}

.keys__key--white {
  width: var(--key-w); height: 100%; z-index: 1;
  background-color: var(--key-white); color: var(--key-white-ink);
}

.keys__key--black {
  width: var(--key-bw); height: 62%; z-index: 2;
  margin-inline: calc(var(--key-bw) / -2);
  border-color: var(--key-black); background-color: var(--key-black); color: var(--key-black-ink);
}

/* Pressed and hovered keys gain a shape (an accent bar along the key foot), not just a hue,
   and the bar survives on both key colours. */
.keys__key:hover  { box-shadow: inset 0 -4px 0 var(--accent); }
.keys__key:focus  { box-shadow: inset 0 -6px 0 var(--accent); }
.keys__key:active { translate: 0 1px; }

/*
  The selected key. Drawn from `aria-pressed`, which is the state a screen reader already
  reads out, so there is one source of truth instead of a class and an attribute that can
  disagree — and no JS-toggled class, per BUILD-CONTRACT §4.3/TOOL-DOM ("never bind
  behaviour or state to a CSS class").

  Placed after :hover/:focus deliberately: those selectors have the same specificity, so the
  selected key would otherwise lose its mark the moment the pointer crossed it. The focus
  RING is an outline set globally and is untouched by this.

  The mark is a shape as well as a hue (§8): a deep bar along the key foot, twice the hover
  bar, plus an accent edge — legible on the white keys and the black ones alike.
*/
.keys__key[aria-pressed="true"],
.keys__key[aria-pressed="true"]:hover,
.keys__key[aria-pressed="true"]:focus {
  border-color: var(--accent);
  box-shadow: inset 0 -8px 0 var(--accent), inset 0 0 0 1px var(--accent);
}

@media (min-width: 768px) {
  .keys__row { --key-w: 2.375rem; --key-bw: 1.4375rem; --key-h: 9.5rem; }
}

/* Coarse pointers get a 44px-wide white key; the black keys scale with it. */
@media (pointer: coarse) {
  .keys__row { --key-w: 2.75rem; --key-bw: 1.75rem; }
}

@media (forced-colors: active) {
  .keys__key--white {
    forced-color-adjust: none; background-color: Canvas; color: CanvasText;
    border-color: CanvasText;
  }
  .keys__key--black {
    forced-color-adjust: none; background-color: CanvasText; color: Canvas;
    border-color: Canvas;
  }

  /* forced-color-adjust:none above means the accent bar would keep painting a colour the
     user asked the system to replace. Highlight is that user's own selection colour. */
  .keys__key[aria-pressed="true"],
  .keys__key[aria-pressed="true"]:hover,
  .keys__key[aria-pressed="true"]:focus {
    border-color: Highlight;
    box-shadow: inset 0 -8px 0 Highlight, inset 0 0 0 1px Highlight;
  }
}

/* 21D  DETECTOR PAGES: SPECTRUM STRIP, CONFIDENCE BAR, BAND RULER ============ */
/*
  Three components used only by the two minimal detector pages, /frequency-detector/ and
  /hz-detector/. They are new names rather than parallel spellings of anything in §4.3:
  the vocabulary has no bar-of-confidence and no frequency-band scale, because until these
  two pages nothing needed one.

  The band ruler is deliberately NOT a canvas. It is an ordered list whose flex-basis per
  band is that band's share of the log axis, so the scale is real markup: selectable,
  translatable, printable, readable with CSS alone and legible to a screen reader without
  a generated text alternative. Only two things arrive from JavaScript — the custom
  property --fm-band-pos and the data-active / data-band-state attributes — which keeps
  the §21A rule intact: state is an attribute, layout is a stylesheet decision.

  Every live state is paired with text as well as colour (§8): the marker carries its own
  hertz flag, each band cell carries a "Current reading" chip that is unhidden rather than
  coloured in, and the sentence under the ruler names the band in words.
*/

/* ---- Compact spectrum strip -------------------------------------------- */
/* .chart.chart--strip, two classes, so it also beats the §22 .chart height at >=768. */

.chart.chart--strip { --chart-h: 76px; padding: .375rem; }

@media (min-width: 768px) { .chart.chart--strip { --chart-h: 104px; } }

/* ---- Confidence bar ----------------------------------------------------- */
/* A native <progress>: labelable, announced as a progress bar, and correct with JS off
   (it reads zero, which is the truth before anything has been measured). */

.confidence {
  display: flex; align-items: center; gap: .625rem; flex-wrap: wrap;
  font-size: var(--step-1); color: var(--text-2);
}

.confidence__label { font-weight: 650; letter-spacing: .02em; }

.confidence__bar {
  flex: 1 1 8rem; height: .5rem; appearance: none; -webkit-appearance: none;
  border: 1px solid var(--border); border-radius: 999px; background-color: var(--surface-2);
  color: var(--accent); accent-color: var(--accent);
}

/* Split rules: one unknown pseudo-element would drop the whole declaration list. */
.confidence__bar::-webkit-progress-bar { border-radius: 999px; background-color: var(--surface-2); }
.confidence__bar::-webkit-progress-value { border-radius: 999px; background-color: var(--accent); }
.confidence__bar::-moz-progress-bar { border-radius: 999px; background-color: var(--accent); }

.confidence__value {
  font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text);
}

/* ---- Frequency band ruler ----------------------------------------------- */
/* Vertical on purpose. Presence is 5.87% of a three-decade log axis, which is 40 px on a
   desktop-width horizontal bar — too narrow for its own name. Given height instead, every
   band has room to label itself at every viewport width. */

.ruler { position: relative; }

.ruler__bands {
  display: flex; flex-direction: column; height: 24rem; margin: 0; padding: 0; overflow: hidden;
  list-style: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background-color: var(--surface-2);
}

.ruler__band {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 0;
  overflow: hidden; padding: .1875rem .625rem; border-top: 1px solid var(--border);
  font-size: var(--step-1); line-height: 1.2; white-space: nowrap; color: var(--text-2);
}

.ruler__band:first-child { border-top: 0; }

/* Active carries an inset bar (a shape) as well as the tint, and an unhidden text chip. */
.ruler__band[data-active="true"] {
  background-color: var(--accent-soft); box-shadow: inset 3px 0 0 0 var(--accent);
  color: var(--text);
}

/* Top to bottom: 20 kHz down to 20 Hz. Shares are log10 spans over three decades. */
.ruler__band[data-band="brilliance"] { flex: 0 0 17.429%; }
.ruler__band[data-band="presence"]   { flex: 0 0  5.870%; }
.ruler__band[data-band="high-mid"]   { flex: 0 0 10.034%; }
.ruler__band[data-band="mid"]        { flex: 0 0 20.069%; }
.ruler__band[data-band="low-mid"]    { flex: 0 0 10.034%; }
.ruler__band[data-band="bass"]       { flex: 0 0 20.660%; }
.ruler__band[data-band="sub-bass"]   { flex: 0 0 15.904%; }

.ruler__name { overflow: hidden; font-weight: 650; text-overflow: ellipsis; }

.ruler__range {
  font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text-3);
}

/* The page module writes --fm-band-pos as a percentage of the log axis. clamp() keeps the
   2 px line inside the box at both ends instead of letting it be clipped away. */
.ruler__marker {
  position: absolute; left: 0; right: 0; bottom: clamp(0px, var(--fm-band-pos, 0%),
  calc(100% - 2px)); height: 2px; background-color: var(--accent); pointer-events: none;
  transition: bottom var(--t);
}

.ruler__flag {
  position: absolute; right: .375rem; bottom: 0; translate: 0 50%; padding: .0625rem .4375rem;
  border-radius: 999px; background-color: var(--accent); color: var(--accent-ink);
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--step-1);
  font-weight: 650; white-space: nowrap;
}

/* No valid reading means no marker. A marker parked at the last number would be a lie. */
.ruler[data-band-state="none"] .ruler__marker { display: none; }

.ruler__summary {
  padding-top: .5rem; font-size: var(--step-1); line-height: 1.5; color: var(--text-2);
}

/* ---- Plain-English band key --------------------------------------------- */

.bands { display: grid; gap: .25rem; margin: 0; padding: 0; list-style: none; }

.bands__item {
  padding: .5rem .625rem; border: 1px solid rgba(0,0,0,0); border-radius: var(--radius-sm);
  font-size: var(--step-1); line-height: 1.55; color: var(--text-2);
}

.bands__item[data-active="true"] {
  border-color: var(--accent); background-color: var(--accent-soft); color: var(--text);
}

.bands__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3125rem .625rem; }

.bands__name { font-weight: 650; color: var(--text); }

.bands__range {
  font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text-3);
}

.bands__flag {
  padding: .0625rem .4375rem; border-radius: 999px; background-color: var(--accent);
  color: var(--accent-ink); font-weight: 650;
}

.bands__what { margin-top: .1875rem; }

/* Forced colors: tints vanish, so the state falls back to an outline plus the text chip. */
@media (forced-colors: active) {
  .ruler__bands,
  .confidence__bar { border: 1px solid CanvasText; background-color: Canvas; }

  .ruler__band[data-active="true"],
  .bands__item[data-active="true"] {
    background-color: Canvas; box-shadow: none; outline: 2px solid CanvasText;
    outline-offset: -3px;
  }

  .ruler__marker { background-color: CanvasText; }

  .ruler__flag,
  .bands__flag { border: 1px solid CanvasText; background-color: Canvas; color: CanvasText; }
}

/* 21P  PITCH DETECTOR: TUNER FACE ============ */
/*
  Used by /pitch/pitch-detector/ only, and scoped to that tool so nothing leaks.

  A tuner inverts the site's usual hierarchy. Everywhere else the hertz value is the
  measurement and the note is a gloss on it; here the note is what the reader came for, so the
  markup puts `data-readout="note"` in `.readout__value` and the hertz value drops into
  `.readout__sub`. That is a markup decision, and it needs no CSS at all — the shared readout
  already makes `.readout__value` the loudest thing on the page and already turns it green on a
  stable reading.

  So this section is four heights and one type step. The needle is the instrument face rather
  than an illustration of one and gets real vertical travel; the trail is a strip, because its
  job is to show whether a line is flat and 150px is plenty for that; the level bar is two rows
  of pixels. The cents figure moves up one step because on a tuner "+7" is a reading, not a
  footnote to one. */

[data-tool="pitch-detector"] .chart--tuner { --chart-h: clamp(9rem, 26vh, 15rem); }
[data-tool="pitch-detector"] .chart--trail { --chart-h: 150px; }
[data-tool="pitch-detector"] .chart--meter { --chart-h: 4.5rem; }

[data-tool="pitch-detector"] .readout__cents { font-size: var(--step2); color: var(--text); }

/* 21G  GENERATOR PAGES ============ */
/*
  /generators/frequency-generator/, /generators/tone-generator/ and
  /generators/frequency-sweep-generator/. Three workbenches, one oscillator
  (assets/js/core/generator.js), wired by assets/js/pages/generator.js.

  A generator measures nothing, so §11's seven data-status selectors never match here and the
  readout would sit at plain --text forever. What a generator has instead is one boolean — is
  it making a sound — and that boolean lives on the tool root as [data-playing], written by the
  page module. Colour follows the attribute, exactly as it follows data-status elsewhere, and
  the status line beside it always says the same thing in words, so nothing is colour-only (§8).

  Two live bars. Both take a percentage as a custom property, the same contract as §21B: the
  controller writes a number, this stylesheet decides what a number looks like. */

[data-generator] .readout__value { color: var(--text-2); }
[data-generator][data-playing="true"] .readout__value { color: var(--accent); }

/* ---- Step and preset rows ----------------------------------------------- */
/* Monospaced on purpose: these buttons are a row of numbers, and +0.01 has to line up under
   +0.10 or the row reads as decoration rather than as a scale. */

.gen__steps,
.gen__presets { display: flex; flex-wrap: wrap; gap: .375rem; }

.gen__steps .btn,
.gen__presets .btn { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---- Output level meter -------------------------------------------------- */
/* Not a <progress>: the page module writes --level, and a meter of "how far the level sits
   between silence and the cap" is a meter, not a task in progress. */

.gen__meter {
  --level: 0%; position: relative; width: 100%; height: .75rem; overflow: hidden;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background-color: var(--surface-2);
}

.gen__meter::before {
  content: ""; position: absolute; inset-block: 0; left: 0; width: var(--level);
  background-color: var(--accent-2);
}

[data-playing="true"] .gen__meter::before { background-color: var(--accent); }

/* ---- Sweep progress ------------------------------------------------------ */
/* A real <progress>, so it is announced as one and reads zero with scripting off — which is
   the truth before anything has been swept. */

.gen__progress {
  width: 100%; height: .5rem; appearance: none; -webkit-appearance: none;
  border: 1px solid var(--border); border-radius: 999px; background-color: var(--surface-2);
  color: var(--accent); accent-color: var(--accent);
}

/* Split rules: one unknown pseudo-element would drop the whole declaration list. */
.gen__progress::-webkit-progress-bar { border-radius: 999px; background-color: var(--surface-2); }
.gen__progress::-webkit-progress-value { border-radius: 999px; background-color: var(--accent); }
.gen__progress::-moz-progress-bar { border-radius: 999px; background-color: var(--accent); }

@media (forced-colors: active) {
  .gen__meter,
  .gen__progress { border: 1px solid CanvasText; background-color: Canvas; }
  .gen__meter::before { background-color: CanvasText; }
}

/* 22  RESPONSIVE ============ */
/* All width breakpoints live here, ascending. Pointer and feature queries stay with their
   components. */

/* ---- <= 480 : single column, sticky controls, readout stays on screen ---- */
@media (max-width: 480px) {
  .tool__stage { padding: .75rem; border-radius: var(--radius-sm); }

  /* The Hz value stays on screen while measuring (§4.4). Either column may own the readout:
     a page that rails its numbers beside the charts still has to keep the number on screen. */
  .tool__stage > .readout,
  .tool__panels > .readout {
    position: sticky; top: var(--header-h); z-index: 20; width: 100%; padding: .75rem .875rem;
  }

  /* A railed readout sticks only as far as the rail: its containing block ends where the rail
     does, so on one column the value would unpin the moment the charts began. Dissolving the
     rail into the tool grid makes .tool the containing block instead, and the number stays on
     screen over the charts — which is the actual §4.4 requirement. */
  .tool[data-view="analyzer"] .tool__panels { display: contents; }

  /* Spectrum analyzer, same requirement from the other direction: its display is half the
     viewport tall and sits above the numbers, so on a phone the reading would start a screen
     and a half below the start button and only pin itself once you had scrolled to it.
     Reordering the grid puts the numbers back under the button. The plot keeps its full
     height and is one flick away — it is still the product, it is just no longer in the way
     of the value it produced. Orders in tens so a block can be slid between two of them. */
  [data-tool="audio-spectrum-analyzer"] .tool__stage > *      { order: 50; }
  [data-tool="audio-spectrum-analyzer"] .tool__stage > :first-child { order: 10; }
  [data-tool="audio-spectrum-analyzer"] .tool__privacy        { order: 20; }
  [data-tool="audio-spectrum-analyzer"] .tool__stage > [data-nojs] { order: 25; }
  [data-tool="audio-spectrum-analyzer"] .readout              { order: 30; }
  [data-tool="audio-spectrum-analyzer"] #chart-level          { order: 35; }

  .readout__value  { font-size: clamp(var(--step4), 2rem + 7vw, 4.5rem); }
  .readout__status { min-height: 1.5rem; }

  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric  { padding: .5625rem .625rem; }
  .metric__value { font-size: var(--step1); }

  .tool__panels { gap: .5rem; }

  /* sticky, not fixed: it keeps its own space and never covers a panel. */
  .tool__controls--sticky {
    position: sticky; bottom: 0; z-index: 30; margin-inline: calc(-1 * var(--wrap-pad));
    padding: .5rem var(--wrap-pad) calc(.5rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-strong); border-radius: 0; background-color: var(--bg-2);
    justify-content: center;
  }

  .tool__controls--sticky > .btn { flex: 1 1 auto; }

  /* Lift toasts clear of the control bar. */
  .toast-region { bottom: calc(4.5rem + env(safe-area-inset-bottom)); }

  .card__head,
  .card__body,
  .card__foot { padding-inline: .875rem; }

  .table--scroll > .table { min-width: 30rem; }
}

/* ---- 481–767 : single column, persistent primary controls --------------- */
@media (min-width: 481px) and (max-width: 767px) {
  .tool__controls--sticky {
    position: sticky; bottom: 0; z-index: 30; padding-block: .5rem;
    padding-bottom: calc(.5rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--border);
    background-color: var(--bg-2);
  }
}

/* ---- <= 767 : lift back-to-top clear of the sticky control bar ---------- */
/* The bar is sticky-bottom for the whole of this range, and a floating button parked on
   top of Start/Stop is worse than no button. Above 767px the bar is in normal flow. */
@media (max-width: 767px) {
  /*
    WHERE THE BAR SITS IN THE FLOW — the half of `position: sticky` that is easy to miss.

    A sticky box reserves its space at its NORMAL position and is then offset from there,
    within its containing block. The primary action is authored FIRST inside the tool, and
    §0.2 keeps it there: the served document and the tab order must put it immediately after
    the <h1>. Left at that flow position, `bottom: 0` pins it to the foot of the viewport
    while leaving its reserved 3rem gap at the TOP of the stage, and everything below it —
    the readout included — then scrolls underneath it. Laying it out last moves the reserved
    space to the foot of the tool, where the comment on the rule above ("keeps its own space
    and never covers a panel") is actually true.

    So the DOM order is the reading order and the visual order is the instrument layout:
    readout pinned under the header, charts scrolling between, controls pinned at the foot.

    The last two selectors exist only to outrank the two pages that already order their own
    stage children (the spectrum analyzer's `:first-child` rule above, and `[data-counter]`
    in §21C); they say the same thing at the same specificity, later in the file.
  */
  .tool__stage > .tool__controls--sticky,
  .tool__panels > .tool__controls--sticky,
  [data-tool="audio-spectrum-analyzer"] .tool__stage > .tool__controls--sticky,
  [data-counter] .tool__stage > .tool__controls--sticky { order: 90; }

  .btn.btn--top { bottom: calc(4.75rem + env(safe-area-inset-bottom)); }
}

/* ---- >= 600 : the footer gets a second column -------------------------- */
/* Not in the §4.4 table because it is not a layout mode — it is the point at which four
   five-item link lists stop being a single 800px-tall ribbon. */
@media (min-width: 600px) {
  .site-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Two tracks is still narrow enough that the blurb wants the whole row. */
  .site-footer__col--brand { grid-column: 1 / -1; }
}

/* ---- >= 768 : two columns where it helps, full-size charts -------------- */
@media (min-width: 768px) {
  .chart                                                { --chart-h: 240px; }
  .chart--waveform,    .chart[data-chart="waveform"]    { --chart-h: 180px; }
  .chart--spectrum,    .chart[data-chart="spectrum"]    { --chart-h: 300px; }
  .chart--spectrogram, .chart[data-chart="spectrogram"] { --chart-h: 340px; }

  /* The analyzer's 2x2 grid overrides all of the above: four equal cells, or it reads ragged. */
  .tool[data-view="analyzer"] .chart { --chart-h: 250px; }

  .grid--2,
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .toolgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .readout { grid-template-columns: auto 1fr; align-items: end; column-gap: 1.25rem; }

  .readout__status,
  .readout__sub { grid-column: 1 / -1; }
}

/* ---- >= 900 : the mobile panel becomes the desktop bar ------------------ */
@media (min-width: 900px) {
  /*
    Same element, opposite layout: back into the flex row, no scroll container and no
    surface of its own. `overflow: visible` is load-bearing — the dropdowns are absolutely
    positioned children of `.nav__drop`, and a scrolling ancestor would clip every one of
    them to the height of the 57px bar.
  */
  .nav {
    display: block; position: static; max-height: none; overflow: visible; padding: 0;
    border-bottom: 0; background: none; box-shadow: none;
  }

  /* The burger is gone, so nothing sets aria-expanded on it; the bar shows unconditionally. */
  .nav__burger { display: none; }

  .nav__list {
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: .125rem .25rem;
  }

  .nav__link,
  .nav__drop > a,
  .nav__drop > button {
    width: auto; padding: .4375rem .625rem; font-size: var(--step0); white-space: nowrap;
  }

  /* Underline the current page instead of edge-marking it: on a horizontal bar a left rule
     reads as a divider between two items rather than as a marker on one. */
  .nav__link[aria-current="page"] {
    box-shadow: inset 0 -2px 0 var(--accent);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  }

  .nav__drop > button::after { margin-left: .125rem; }

  /* Now a floating card under its trigger. z-index sits above the header itself (40) so it
     is never trapped behind the bar that spawned it. */
  /* .625rem, measured not guessed: a 40px chip centred in the 56px bar ends 9px above the
     bar's 1px rule, so anything smaller opens the card *inside* the header. */
  .nav__menu {
    position: absolute; top: calc(100% + .625rem); left: 0; z-index: 45; min-width: 15rem;
    margin: 0; padding: .3125rem; border: 1px solid var(--border-strong);
    border-radius: var(--radius); background-color: var(--surface); box-shadow: var(--shadow);
  }

  /* The last item sits against the theme toggle; a left-anchored 15rem card would hang off
     the right edge of the window. */
  .nav__list > li:last-child > .nav__menu { left: auto; right: 0; }

  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .toolgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .site-footer__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .site-footer__col--brand { grid-column: auto; }
}

/* ---- 900–1099 : the bar at its tightest, still one row ------------------ */
/*
  MEASURED, not decorative. The bar carries a 186px wordmark, seven nav chips and the 36px
  theme toggle. At the default chip padding those total 659px against the 601px the nav
  gets at 900, so the list wrapped to a second row and the header grew from 57px to 83px —
  which silently invalidates --header-h, and every sticky offset in this file is measured
  from it. Tightening the chips over this range brings the row to ~591px and keeps the
  header exactly one line tall. §4.4 fixes the desktop line at 900px, so the breakpoint is
  not the thing to move.
*/
@media (min-width: 900px) and (max-width: 1099px) {
  .nav__list { gap: 0 2px; }

  .nav__link,
  .nav__drop > a,
  .nav__drop > button { padding-inline: .375rem; }
}

/* ---- >= 1024 : two-column workstation, stage left, panels right --------- */
@media (min-width: 1024px) {
  .tool {
    grid-template-columns: minmax(0, 1fr) minmax(19rem, 22rem); grid-template-areas:
    "stage    panels" "controls panels"; align-content: start;
  }

  .tool__stage    { grid-area: stage; }
  .tool__panels   { grid-area: panels; }

  /*
    Direct children only — the `>` is load-bearing, not tidiness.

    `.tool__stage` and `.tool__panels` are grids too, and a .tool__controls INSIDE one of them
    (the primary Start/Stop bar is) would take this `grid-area` there as well. `controls` is
    not a named line in those grids, and an unmatched <custom-ident> is not ignored: every
    implicit line is treated as carrying the name, so the bar was placed out in the implicit
    grid past the last row and stretched to fill it — 1071px tall at the bottom of the stage,
    with Start nowhere near the top of the tool. Only a direct child of .tool has areas to
    address.
  */
  .tool > .tool__controls { grid-area: controls; }

  /* A sticky bar makes no sense once the controls sit beside the panels. */
  .tool__controls--sticky {
    position: static; margin-inline: 0; padding: 0; border-top: 0; background: none;
  }

  .toast-region {
    left: auto; right: 1.25rem; bottom: 1.25rem; align-items: flex-end; padding-inline: 0;
  }
}

/* ---- >= 1200 : full layout with a wider side panel ---------------------- */
@media (min-width: 1200px) {
  .tool { grid-template-columns: minmax(0, 1fr) minmax(21rem, 25rem); }
  .toolgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  /* All five footer columns on one row. The brand track is 1.4fr because it carries a
     sentence and the other four carry two-word links; five equal tracks would set the
     blurb three words to the line. */
  .site-footer__grid {
    grid-template-columns: minmax(0, 1.4fr) repeat(4, minmax(0, 1fr));
  }
}

/* ---- >= 1440 : content caps at --wrap; whitespace absorbs the rest ------ */
@media (min-width: 1440px) {
  :root { --wrap-pad: 2rem; }
}

/* ---- 22Z  TOUCH TARGETS — must be the LAST word on control sizing -------- */
/*
  §10's `@media (pointer: coarse)` block sets these too, but it sits above the component
  definitions it is trying to override, and a media query adds no specificity. `.seg__btn`
  at §10.1 therefore re-declared `min-height: 2rem` further down the file and won the
  cascade, so segmented controls shipped at 32px on touch devices against a 44px contract.
  Selects, native checkboxes and radios were never covered at all — a checkbox measured
  22px, half the minimum.

  This block lives at the end of the component cascade on purpose. Anything that sets a
  control's height must come BEFORE it, so leave it here.

  Checkboxes and radios are grown with a transparent outline-style hit area rather than by
  scaling the box, because a 44px checkbox glyph looks broken; the padding on the wrapping
  label is what the finger actually lands on.
*/
@media (pointer: coarse) {
  .btn,
  .btn--sm,
  .seg__btn,
  .select,
  .input,
  .nav__link,
  .nav__drop > a,
  .nav__drop > button,
  .nav__menu a,
  .brand,
  .faq__item > summary,
  .disclose > summary,
  .panel__head button {
    min-height: var(--tap);
  }

  .seg__btn { padding-inline: .875rem; }

  .btn--icon,
  .btn--icon.btn--sm { inline-size: var(--tap); min-height: var(--tap); padding: 0; }

  /*
   * The control keeps its drawn size; the touchable area is the label around it, which is
   * why `.switch` and the check fields below carry the 44px, not the box. A checkbox
   * scaled to 44px reads as a rendering fault, and the finger was never aiming at the
   * glyph anyway.
   */
  input[type="checkbox"],
  input[type="radio"] { inline-size: 1.375rem; block-size: 1.375rem; }

  .field--check > label,
  label.switch,
  .field__label--inline {
    display: flex; align-items: center; gap: .625rem; min-height: var(--tap);
  }

  /* A range thumb under a finger needs room above and below the track. */
  .range { min-height: var(--tap); }
}

/* 23  FORCED COLORS  (Windows High Contrast) ============ */
/* Never background alone; keep a real border so it can be forced. */

@media (forced-colors: active) {
  *,
  *::before,
  *::after { box-shadow: none !important; }

  body { background-color: Canvas; color: CanvasText; }

  .site-header,
  .site-footer,
  .card, .card__foot,
  .panel, .panel__body,
  .metrics, .metric,
  .readout, .chart, .chart__empty,
  /* .adslot is deliberately absent: forcing a border onto it would draw an empty
     framed box on every page the network does not fill. The creative inside a
     filled slot brings its own frame. */
  .note, .toast,
  .toolcard, .disclose, .faq__item,
  .table--scroll,
  .btn, .seg, .seg__btn, .pill,
  .input, .select,
  .nav__menu { border: 1px solid CanvasText; background-color: Canvas; color: CanvasText; }

  /* The mobile panel floats over the page, so it must be opaque — but only a fill, never a
     border: at >=900px this same element is the bar itself and a box around the whole bar
     would read as a stray frame under the wordmark. */
  .nav { background-color: Canvas; }

  /* The hairline grid is a background colour, erased here: border each cell. */
  .metrics { gap: 0; }

  .btn--primary { border-width: 2px; background-color: Canvas; color: LinkText; }

  /* Selection is an outline plus the aria state, not a fill. */
  .seg__btn[aria-checked="true"], .seg__btn[aria-selected="true"] {
    outline: 2px solid CanvasText; outline-offset: -3px;
  }

  /* box-shadow is erased above, so the current-page marker has to be redrawn as an outline
     in both the bar and the submenus. */
  .nav__link[aria-current="page"], .nav__menu a[aria-current="page"] {
    outline: 1px solid CanvasText; outline-offset: 2px;
  }

  /* Only one theme icon is ever displayed, and forced-colors paints it CanvasText; the
     button around it is already bordered by the .btn rule above. */
  .theme-toggle, .nav__burger, .btn--top { color: CanvasText; }

  .pill::before, .chart__legend > *::before {
    background-color: CanvasText; outline: 1px solid CanvasText;
  }

  .pill--idle::before { background-color: Canvas; }

  .readout__value,
  .metric__value,
  .table--peaks td { color: CanvasText; }

  .readout[data-status="stable"] .readout__value { color: CanvasText; }

  /* No gradient survives forced colors — drop the scroll hint cleanly. */
  .table--scroll { background-image: none; }

  .toast::before { background-color: CanvasText; }

  a { color: LinkText; }

  :focus-visible { outline: 2px solid CanvasText; outline-offset: 2px; }

  .skip-link { background-color: Canvas; color: CanvasText; }
}

/* 24  REDUCED MOTION ============ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-delay: .01ms !important;
    animation-iteration-count: 1 !important; transition-duration: .01ms !important;
    transition-delay: 0ms !important; scroll-behavior: auto !important;
  }

  html { scroll-behavior: auto; }
  .btn:active { translate: none; }
}

/* 25  PRINT ============ */
/* Black on white; the measurement survives, the chrome does not. */

@media print {
  :root, :root[data-theme="light"], :root[data-theme="dark"] {
    --bg: #fff; --bg-2: #fff;
    --surface: #fff; --surface-2: #fff; --surface-3: #fff;
    --border: #999; --border-strong: #555;
    --text: #000; --text-2: #1a1a1a; --text-3: #444;
    --accent: #000; --accent-hover: #000; --accent-ink: #fff;
    --accent-soft: transparent; --accent-2: #000;
    --ok: #000; --warn: #000; --danger: #000; --info: #000;
    --grid: #ccc; --grid-axis: #999;
    --shadow: none;
    --link: #000; --link-hover: #000;
  }

  html { color-scheme: light; }

  body { background: #fff !important; color: #000 !important; font-size: 11pt; }

  .site-header,
  .site-footer,
  .nav, .nav__menu, .nav__burger, .theme-toggle,
  .tool__controls, .seg, .btn,
  .toast-region, .toast,
  .adslot, .skip-link,
  .chart__empty { display: none !important; }

  /* The readout, metrics and chart digests are the point of a printed page. */
  .readout, .metrics, .metric, .chart__summary, .table, .table--scroll {
    display: revert; break-inside: avoid; background: #fff !important; box-shadow: none !important;
  }

  .readout        { display: grid; border: 1px solid #000; }
  .readout__value { color: #000 !important; font-size: 32pt; }
  .metrics        { display: grid; gap: 0; border: 1px solid #000; }
  .metric         { border: 1px solid #999; }

  .table--scroll {
    overflow: visible !important; background-image: none !important; border: 1px solid #000;
  }

  .chart__canvas { max-height: 2.5in; }

  .card, .panel, .note, .toolcard, .chart {
    border: 1px solid #999 !important; break-inside: avoid;
  }

  h1, h2, h3, h4 { break-after: avoid; }

  .disclose > summary + *,
  .faq__item > summary + * { display: block !important; }
}
