/* Heatmap lab · an acoustic bench on the lab's tokens.
   Composition: a recipe rack (a numbered signal chain ending in the command dock) beside the plate
   (the saved output with its map controls and recorded key), the version ledger under or beside it, advanced drawers last.
   The engine owns every value, state and word; this sheet only places and dresses them.
   Type is fixed rem throughout; nothing scales with the viewport. Motion is transform/opacity. */

:root {
  color-scheme: light;
  --paper: #ecebe6; --plate: #f7f6f2; --plate-2: #dddcd5; --field: #fff;
  --ink: #121412; --ink-2: #3d403a; --ink-3: #5f625b;
  --rule: rgb(18 20 18 / .11); --rule-2: rgb(18 20 18 / .26);
  --slab: #121412; --on-slab: #edece5; --signal: #c4ee2c; --on-signal: #121412;
  --alert: #b93a0b; --ok: #12704f; --warn: #855300;
  --table: #e3e2dc; --grid: rgb(18 20 18 / .055);
  --veil: rgb(236 235 230 / .82); --lift: 0 .75rem 2rem rgb(18 20 18 / .16);
  --f-display: Bahnschrift, "DIN Alternate", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --f-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Microsoft YaHei UI", sans-serif;
  --f-num: "Cascadia Mono", "JetBrains Mono", ui-monospace, Consolas, monospace;
  --ease: cubic-bezier(.2, .9, .25, 1);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-io: cubic-bezier(.77, 0, .175, 1);
  --hit: 2.5rem; --ctl: 2.25rem; --r: .375rem;
  --pad-l: max(.75rem, env(safe-area-inset-left)); --pad-r: max(.75rem, env(safe-area-inset-right));
  --rack-w: 21rem; --key-w: 14rem; --ledger-w: 22rem;
  /* measured by the presenter; the fallbacks cover the first frame (the dock's is its usual height, used only for scroll padding) */
  --an-top: var(--an-top-h, 3.5rem); --an-foot: var(--an-foot-h, 2.75rem); --an-commit: var(--an-commit-h, 8rem);
  /* tallest the map may draw: the viewport less the header, the bench padding, the plate identity and the status line */
  --an-cap: max(18rem, calc(100dvh - var(--an-top) - 8rem - var(--an-foot)));
  /* "transparent" in the saved prediction layer = no valid observation; fixed light so colours sit as on paper */
  --chk: repeating-conic-gradient(#deded8 0 25%, #fff 0 50%) 0 0 / .75rem .75rem;
  /* one cycle of a sine, used as a mask for wave rules */
  --wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='8' viewBox='0 0 24 8'%3E%3Cpath d='M0 4q3-4 6 0t6 0t6 0t6 0' fill='none' stroke='%23000' stroke-width='1.1'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0d0e0d; --plate: #151715; --plate-2: #1f221f; --field: #0f110f;
  --ink: #edece5; --ink-2: #c6c5bd; --ink-3: #93948c;
  --rule: rgb(237 236 229 / .1); --rule-2: rgb(237 236 229 / .24);
  --slab: #2a2e2a; --on-slab: #edece5; --signal: #d4f347; --on-signal: #121412;
  --alert: #ff7a2e; --ok: #4ade9a; --warn: #ffc23d;
  --table: #1a1c1a; --grid: rgb(237 236 229 / .045);
  --veil: rgb(13 14 13 / .82); --lift: 0 .75rem 2rem rgb(0 0 0 / .5);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
/* focus never lands under the docked command or the status line */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--paper); scroll-padding-block: 4rem calc(var(--an-commit) + var(--an-foot) + 1rem); }
:is(button, input, select, textarea, a) { scroll-margin-block: 4rem; }
body.an {
  margin: 0; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--paper); color: var(--ink); font: 400 .9375rem/1.5 var(--f-ui);
}
:lang(ja) body.an, :lang(zh-CN) body.an { line-height: 1.65; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.an-i { width: 1.125rem; height: 1.125rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.an-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.an-skip { position: absolute; left: var(--pad-l); top: .5rem; z-index: 40; padding: .5rem .875rem; border-radius: var(--r); background: var(--slab); color: var(--on-slab); text-decoration: none; transform: translateY(-200%); }
.an-skip:focus { transform: none; }
.an-eyebrow { font: 600 .75rem/1.3 var(--f-num); letter-spacing: 0; text-transform: uppercase; color: var(--ink-3); }
:lang(ja) .an-eyebrow, :lang(zh-CN) .an-eyebrow { font-family: var(--f-ui); letter-spacing: 0; text-transform: none; }

/* ---- control dress: fields carry their own unit in the label and their own error edge */
.an-field { display: grid; gap: .3125rem; min-width: 0; align-content: start; }
.an-field > span { font: 600 .8125rem/1.3 var(--f-ui); color: var(--ink-2); }
.an-field :is(select, input, textarea), .an-lang select {
  width: 100%; min-width: 0; min-height: var(--hit); padding: .4375rem .625rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--field); color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.an-field input[type="number"] { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.an-field textarea { font: .875rem/1.5 var(--f-num); resize: vertical; }
@media (hover: hover) and (pointer: fine) {
  .an-field :is(select, input, textarea):hover { border-color: var(--ink-3); }
}
.an-field :is(select, input, textarea):focus-visible, .an-lang select:focus-visible {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in oklab, var(--signal) 60%, transparent);
}
.an-field :is(select, input, textarea):disabled { opacity: .6; background: var(--plate-2); }
.an-field :is(input, textarea):user-invalid { border-color: var(--alert); box-shadow: inset 3px 0 0 var(--alert); }
.an-help, .an-note { font-size: .8125rem; line-height: 1.5; color: var(--ink-3); text-wrap: pretty; }
.an-field .an-help { margin-top: .125rem; }
/* Japanese breaks at phrase boundaries where the browser can find them */
:lang(ja) :is(.an-help, .an-note, .an-method small, .method-eligibility small, .an-scale-note, .an-caveat) { word-break: auto-phrase; }

/* quiet = navigation and display settings; act = secondary commands; go = the one primary command */
.an-quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: .4375rem; min-height: var(--hit); min-width: var(--hit);
  padding: 0 .625rem; border: 1px solid transparent; border-radius: var(--r); background: transparent; color: var(--ink-2);
  font-size: .875rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.an-act {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--hit); padding: 0 .875rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--field); color: var(--ink);
  font-size: .875rem; font-weight: 600; position: relative; overflow: hidden;
  transition: border-color .15s ease, background-color .15s ease, transform .12s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .an-quiet:hover { background: var(--plate-2); color: var(--ink); }
  .an-act:not(:disabled):hover { border-color: var(--ink); }
}
.an-act:not(:disabled):active { transform: translateY(1px); }
.an-act:disabled { opacity: .55; }
.an-act[aria-busy="true"], .an-act.working { cursor: progress; }
.an-act.working::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: linear-gradient(90deg, transparent, var(--ok), transparent); animation: an-scan 1.4s linear infinite; }

/* ---- header: one band - home · identity · the shared workspace nav (appended last by the shell) · display settings.
   Every part keeps its own room; when they do not fit side by side the band wraps instead of overlapping. */
.an-head {
  position: relative; z-index: 20; display: flex; flex-wrap: wrap; align-items: center;
  column-gap: .5rem; row-gap: .375rem; padding: .5rem var(--pad-r) .5rem var(--pad-l);
  background: var(--paper); border-bottom: 1px solid var(--rule);
}
body.an > .an-head > .workspace-flow { order: 1; flex: 1 1 0; width: auto; min-width: 0; margin: 0; padding: 0; border-top: 0; grid-column: auto; }
.an-head .workspace-rail > a { padding-inline: .5rem; }
.an-util { order: 2; position: relative; display: flex; align-items: center; flex: none; margin-inline-start: auto; }
/* anything else the shell places in the band stays with the settings at its end */
.an-head > :not(.an-home, .an-mark, .an-task, .an-util, .workspace-flow) { order: 3; }
.an-home {
  display: inline-flex; align-items: center; gap: .5rem; min-height: var(--hit); padding: 0 .875rem 0 .6875rem;
  border: 1px solid var(--rule-2); border-radius: 999px; color: var(--ink-2); font-size: .875rem; font-weight: 600; text-decoration: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
@media (hover: hover) and (pointer: fine) { .an-home:hover { border-color: var(--ink); color: var(--ink); } }
:root[data-lab-host] .an-home { display: none; }
.an-mark { display: flex; align-items: center; gap: .875rem; min-width: 0; padding-inline-start: .375rem; }
.an-mark-text { display: grid; gap: .0625rem; min-width: 0; }
.an-mark h1 { font: 600 1.25rem/1.15 var(--f-display); letter-spacing: 0; text-wrap: balance; }
/* hosted, the lab's own bar names the page and the rail marks it; the heading stays for assistive tech */
:root[data-lab-host] .an-mark { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* the lab badge: a numeral inside two wavefronts; a third wave leaves it while a run is in progress */
.an-no {
  position: relative; display: grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: var(--slab); color: var(--signal); font: 600 .875rem/1 var(--f-num); font-variant-numeric: tabular-nums;
}
.an-no::before, .an-no::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.an-no::before { inset: -.3125rem; border: 1px solid var(--rule-2); }
.an-no::after { inset: 0; border: 1px solid var(--ok); opacity: 0; }
body:has(.an-bench[data-run="running"]) .an-no::after { animation: an-ring 1.8s var(--ease-out) infinite; }
.an-prefs-toggle { gap: .375rem; border-color: var(--rule-2); }
.an-head[data-prefs="open"] .an-prefs-toggle { background: var(--slab); border-color: var(--slab); color: var(--on-slab); }
#anPrefsCode { font: 600 .8125rem/1 var(--f-num); }
.an-lang { display: flex; align-items: center; gap: .375rem; min-width: 0; color: var(--ink-2); }
.an-prefs #anThemeLabel { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }

/* until the band has room for the full rail and every setting, the settings open from their toggle as an anchored panel */
.an-prefs { display: none; }
.an-head[data-prefs="open"] .an-prefs {
  display: grid; gap: .25rem; position: absolute; inset-inline-end: 0; top: calc(100% + .375rem); z-index: 30; min-width: 15.5rem;
  padding: .5rem; background: var(--plate); border: 1px solid var(--rule-2); border-radius: calc(var(--r) * 1.75); box-shadow: var(--lift);
  transform-origin: top right; opacity: 1; transform: none; transition: opacity .16s var(--ease-out), transform .2s var(--ease-out);
}
@starting-style { .an-head[data-prefs="open"] .an-prefs { opacity: 0; transform: translateY(-.25rem) scale(.97); } }
@media (max-width: 109.99rem) {
  .an-prefs .an-lang { padding: .25rem .25rem .5rem .5rem; border-bottom: 1px solid var(--rule); }
  .an-prefs .an-lang .an-sr { position: static; width: auto; height: auto; overflow: visible; clip-path: none; flex: 1 1 auto; font-size: .875rem; font-weight: 600; }
  .an-prefs .an-lang select { width: auto; flex: 0 1 8.5rem; }
  .an-prefs :is(#anTheme, #anClassic) { justify-content: flex-start; width: 100%; }
}
@media (min-width: 110rem) {
  .an-prefs-toggle { display: none; }
  .an-prefs, .an-head[data-prefs="open"] .an-prefs {
    position: static; display: flex; align-items: center; gap: .25rem; min-width: 0; padding: 0;
    background: none; border: 0; box-shadow: none; transition: none;
  }
  .an-lang { padding-inline-start: .5625rem; border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--field); }
  .an-lang select { width: auto; min-height: calc(var(--hit) - 2px); border: 0; background: transparent; padding-inline: .25rem .5rem; }
  .an-lang:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in oklab, var(--signal) 60%, transparent); }
  .an-lang select:focus-visible { box-shadow: none; }
}

/* ---- bench */
.an-bench {
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "rack" "plate" "versions" "advanced";
  align-items: start; gap: 1.5rem; min-width: 0; padding: 1.25rem var(--pad-r) 1.5rem var(--pad-l);
}
.an-task { grid-area: task; display: none; }
.an-rack { grid-area: rack; }
.an-plate { grid-area: plate; }
.an-versions { grid-area: versions; }
.an-advanced { grid-area: advanced; }

/* ---- rack: the recipe as a signal chain */
.an-rack { display: grid; align-content: start; gap: 1rem; min-width: 0; container: an-rack / inline-size; }
.an-rack-title, .an-advanced-title { display: flex; align-items: center; gap: .625rem; font: 600 .8125rem/1.3 var(--f-num); letter-spacing: 0; text-transform: uppercase; color: var(--ink-3); }
:lang(ja) :is(.an-rack-title, .an-advanced-title), :lang(zh-CN) :is(.an-rack-title, .an-advanced-title) { font-family: var(--f-ui); letter-spacing: 0; text-transform: none; }
.an-rack-title::after, .an-advanced-title::after {
  content: ""; flex: 1 1 auto; min-width: 2rem; height: .5rem; background: var(--rule-2);
  -webkit-mask: var(--wave) repeat-x left center / 1.5rem .5rem; mask: var(--wave) repeat-x left center / 1.5rem .5rem;
}
.an-steps { list-style: none; margin: 0; padding: 0; display: grid; }
.an-step { position: relative; display: grid; gap: .875rem; min-width: 0; padding: 0 0 1.5rem 2.625rem; }
/* the chain: dotted particles between step numerals, continuing into the dock */
.an-step::before {
  content: ""; position: absolute; inset-block: 2.125rem .375rem; inset-inline-start: .875rem; width: 2px;
  background: radial-gradient(circle, var(--rule-2) 0 1px, transparent 1.25px) center top / 2px 6px repeat-y;
}
.an-step-title { display: flex; align-items: center; gap: .875rem; margin-inline-start: -2.625rem; font: 600 1rem/1.3 var(--f-ui); }
.an-step-no {
  display: grid; place-items: center; flex: none; width: 1.75rem; height: 1.75rem; border-radius: 50%;
  border: 1px solid var(--rule-2); background: var(--paper); color: var(--ink-2);
  font: 600 .8125rem/1 var(--f-num); font-variant-numeric: tabular-nums;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.an-bench[data-eligibility="ready"] :is([data-step="input"], [data-step="method"]) .an-step-no { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* method: three radio plates, each with a glyph of how it fills space between measured points.
   The lamp sits in the corner so the description keeps the full text column. */
.an-methods { display: grid; gap: .375rem; min-width: 0; margin: 0; padding: 0; border: 0; }
@container an-rack (min-width: 40rem) { .an-methods { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.an-method {
  --glyph: var(--ink-3); --glyph-soft: color-mix(in oklab, var(--ink-3) 30%, transparent);
  position: relative; display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); grid-template-rows: auto auto;
  column-gap: .625rem; row-gap: .0625rem; align-items: center; min-height: 3.75rem; padding: .5rem .625rem .5rem .5rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--field); cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.an-method input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.an-method::before { content: ""; grid-row: 1 / 3; width: 2.5rem; height: 2.5rem; border-radius: calc(var(--r) * .75); background-color: var(--table); }
.an-method::after {
  content: ""; position: absolute; inset-block-start: .6875rem; inset-inline-end: .625rem; width: 1rem; height: 1rem; border-radius: 50%;
  border: 1.5px solid var(--rule-2); transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.an-method b { grid-column: 2; padding-inline-end: 1.375rem; font-weight: 600; font-size: .9375rem; line-height: 1.3; }
.an-method small { grid-column: 2; font-size: .8125rem; line-height: 1.4; color: var(--ink-3); text-wrap: pretty; }
.an-method.is-on { --glyph: var(--ok); --glyph-soft: color-mix(in oklab, var(--ok) 34%, transparent); border-color: var(--ink); box-shadow: inset 3px 0 0 var(--ok); }
.an-method.is-on::after { border-color: var(--ink); background: var(--signal); box-shadow: inset 0 0 0 3px var(--field); }
.an-method:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .an-method:not(.is-on):hover { border-color: var(--ink-3); } }
.an-method[data-glyph="nearest"]::before {
  background-image:
    radial-gradient(circle at 28% 34%, var(--glyph) 0 2px, transparent 2.5px),
    radial-gradient(circle at 70% 30%, var(--glyph) 0 2px, transparent 2.5px),
    radial-gradient(circle at 52% 74%, var(--glyph) 0 2px, transparent 2.5px),
    conic-gradient(from 20deg at 50% 46%, var(--glyph-soft) 0 120deg, transparent 0 240deg, color-mix(in oklab, var(--glyph) 14%, transparent) 0);
}
.an-method[data-glyph="idw"]::before {
  background-image:
    radial-gradient(circle at 30% 36%, var(--glyph) 0 2px, transparent 2.5px),
    radial-gradient(circle at 70% 64%, var(--glyph) 0 2px, transparent 2.5px),
    radial-gradient(circle at 30% 36%, var(--glyph-soft), transparent 55%),
    radial-gradient(circle at 70% 64%, var(--glyph-soft), transparent 50%);
}
.an-method[data-glyph="kriging"]::before {
  background-image:
    radial-gradient(circle at 34% 40%, var(--glyph) 0 2px, transparent 2.5px),
    radial-gradient(circle at 68% 62%, var(--glyph) 0 2px, transparent 2.5px),
    repeating-radial-gradient(ellipse at 50% 52%, transparent 0 4px, var(--glyph-soft) 4px 5px),
    radial-gradient(ellipse at 50% 52%, color-mix(in oklab, var(--glyph) 12%, transparent), transparent 70%);
}

.an-fold { border-top: 1px solid var(--rule); }
.an-fold > summary, .an-ledger > summary, .an-drawer > summary { list-style: none; cursor: pointer; }
:is(.an-fold, .an-ledger, .an-drawer) > summary::-webkit-details-marker { display: none; }
.an-fold > summary { display: flex; align-items: center; gap: .5rem; min-height: var(--hit); font-size: .875rem; font-weight: 600; color: var(--ink-2); }
:is(.an-fold, .an-ledger, .an-drawer) > summary::after {
  content: ""; flex: none; margin-inline-start: auto; width: .5rem; height: .5rem; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-.125rem) rotate(45deg); transition: transform .2s var(--ease-out); color: var(--ink-3);
}
:is(.an-fold, .an-ledger, .an-drawer)[open] > summary::after { transform: translateY(.125rem) rotate(225deg); }
.an-params { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .75rem; padding: .25rem 0 .5rem; }
.an-applies { display: none; font-style: normal; font-size: .75rem; line-height: 1.3; color: var(--ink-3); }
/* a parameter the chosen method ignores stays editable but recedes and says which method reads it */
.an-bench:not([data-method="idw"]) [data-applies="idw"], .an-bench:not([data-method="kriging"]) [data-applies="kriging"] { opacity: .62; }
.an-bench:not([data-method="idw"]) [data-applies="idw"] .an-applies, .an-bench:not([data-method="kriging"]) [data-applies="kriging"] .an-applies { display: block; }

/* the dock: readiness sits on the command it gates */
.an-commit {
  position: sticky; bottom: var(--an-foot); z-index: 6; display: grid; gap: .75rem;
  margin-inline: calc(var(--pad-l) * -1) calc(var(--pad-r) * -1); padding: .875rem var(--pad-r) .875rem var(--pad-l);
  background: var(--paper); border-top: 1px solid var(--rule-2);
}
.an-commit::before { content: ""; position: absolute; inset-inline: 0; bottom: 100%; height: 1rem; background: linear-gradient(to top, var(--paper), transparent); pointer-events: none; }
.an-commit-state { display: none; }
.method-eligibility { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: .625rem; font-size: .875rem; line-height: 1.45; }
.method-eligibility > i { flex: none; width: .625rem; height: .625rem; margin-top: .35em; border-radius: 50%; border: 1.5px solid var(--ink-3); transition: background-color .2s ease, border-color .2s ease, transform .2s var(--ease-out); }
.method-eligibility b { display: block; font-weight: 600; }
.method-eligibility small { display: block; margin-top: .125rem; font-size: .8125rem; color: var(--ink-3); font-variant-numeric: tabular-nums; text-wrap: pretty; }
.method-eligibility small:empty { display: none; }
.method-eligibility.checking > i { animation: an-blink 1.2s ease-in-out infinite; }
.method-eligibility.ready > i { background: var(--ok); border-color: var(--ok); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 22%, transparent); }
.method-eligibility.error > i { background: var(--alert); border-color: var(--alert); border-radius: 1px; transform: rotate(45deg); }
.method-eligibility.error b { color: var(--alert); }

body.an #generate {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: .625rem; width: 100%;
  min-height: 3rem; padding: 0 1rem; border: 1px solid var(--ink); border-radius: var(--r); box-shadow: none;
  background: var(--signal); color: var(--on-signal); font-size: 1rem; font-weight: 700;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .12s var(--ease-out);
}
body.an #generate .an-i { width: 1.25rem; height: 1.25rem; stroke-width: 2; }
@media (hover: hover) and (pointer: fine) { body.an #generate:not(:disabled):hover { background: color-mix(in oklab, var(--signal) 84%, var(--ink)); } }
body.an #generate:not(:disabled):active { transform: scale(.985); }
body.an #generate:disabled { background: var(--plate-2); color: var(--ink-3); border: 1px dashed var(--rule-2); }
body.an #generate.working { background: var(--slab); color: var(--on-slab); border: 1px solid var(--slab); cursor: progress; }
body.an #generate.working::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: linear-gradient(90deg, transparent, var(--signal), transparent); animation: an-scan 1.4s linear infinite; }

/* ---- plate: identity on top, then the map with its controls and key beside or below it */
.an-plate { display: grid; align-content: start; gap: .875rem; min-width: 0; container: an-plate / inline-size; }
.an-plate:focus { outline: none; }
.an-plate:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.an-plate-head { display: grid; gap: .75rem; min-width: 0; }
.an-plate-id { display: grid; gap: .25rem; min-width: 0; }
.an-plate-id h2 { font: 600 1.5rem/1.15 var(--f-display); overflow-wrap: anywhere; }
.an-plate-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; font-size: .8125rem; color: var(--ink-3); }
.an-plate-meta:empty { display: none; }
.an-m-method { font-weight: 600; color: var(--ink-2); }
.an-m-date { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.an-m-lineage { display: inline-flex; align-items: center; gap: .375rem; }
.an-m-lineage::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; border: 1.5px solid currentColor; }

.an-stage { position: relative; display: grid; gap: 1rem; min-width: 0; }
.an-stage[aria-busy="true"] { cursor: progress; }
@container an-plate (min-width: 46rem) { .an-stage[data-compare="on"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.an-frame { display: grid; align-content: start; gap: .5rem; min-width: 0; margin: 0; container: an-frame / inline-size; }
.an-frame figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .625rem; min-height: var(--hit); font-size: .875rem; }
.an-frame-tag { flex: none; padding: .3125rem .5625rem; border: 1px solid var(--rule-2); border-radius: 999px; font: 600 .75rem/1 var(--f-num); letter-spacing: 0; text-transform: uppercase; }
:lang(ja) .an-frame-tag, :lang(zh-CN) .an-frame-tag { font-family: var(--f-ui); letter-spacing: 0; }
.an-frame-main .an-frame-tag { background: var(--slab); border-color: var(--slab); color: var(--on-slab); }
.an-frame-ref .an-frame-tag { border-style: dashed; color: var(--ink-2); }
.an-frame-name { flex: 1 1 8rem; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.an-unpin { margin-inline-start: auto; border-color: var(--rule-2); }
/* the key takes a column beside the map only while it has something to show */
.an-plot { display: grid; gap: .875rem; min-width: 0; }
@container an-frame (min-width: 44rem) {
  .an-plot:has(> .an-key > :is(.an-plate-tools, .an-scale):not([hidden]), > .an-key > .an-out > :not([hidden]), > .an-scale:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) var(--key-w); align-items: start; gap: 1.25rem;
  }
}

/* the view is the lab table: graph paper under the saved image */
.an-view {
  position: relative; display: grid; place-items: center; min-width: 0; min-height: 16rem; overflow: hidden;
  border: 1px solid var(--rule); border-radius: var(--r);
  background-color: var(--table);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 1.5rem 1.5rem;
}
.an-view img { display: block; width: auto; height: auto; max-width: 100%; max-height: var(--an-cap); object-fit: contain; }
.an-plate[data-plate="ready"] #anView, .an-frame-ref .an-view { min-height: 0; }
#anLayerImage, .an-frame-ref[data-layer="prediction"] #anRefImage { background: var(--chk); }
.an-stage[data-layer="prediction"] #heatmapImage { display: none; }
.an-stage[data-layer="pending"] #heatmapImage { opacity: .6; transition: opacity .2s ease; }
.an-plate[data-busy]:not([data-busy=""]):not([data-busy="false"]) #anView img { opacity: .55; transition: opacity .2s ease; }
.an-frame-ref[data-image="error"] .an-view { min-height: 10rem; background-image: repeating-linear-gradient(135deg, var(--rule) 0 1px, transparent 1px 8px); }
.an-frame-ref[data-image="error"] #anRefImage { visibility: hidden; }
.an-stage[data-zoom="actual"] #anView { display: block; overflow: auto; max-height: var(--an-cap); overscroll-behavior: contain; }
.an-stage[data-zoom="actual"] #anView img { max-width: none; max-height: none; }
#anView:focus-visible { outline-offset: -2px; }
/* a saved version arriving: one signal ring on the table, then gone */
.an-plate[data-flash="saved"] #anView::after {
  content: ""; position: absolute; inset: 0; z-index: 3; border: 2px solid var(--signal); border-radius: inherit; pointer-events: none;
  animation: an-fade-out 1.1s var(--ease-out) forwards;
}

/* until a version is on the table: measurement points with their wavefronts */
.an-empty { position: relative; z-index: 1; display: grid; place-items: center; width: 100%; min-height: inherit; padding: 2rem 1.5rem; text-align: center; }
.an-plate[data-plate="ready"] .an-empty { display: none; }
.an-empty-msg { display: none; max-width: 28rem; padding: .625rem .875rem; border-radius: var(--r); background: color-mix(in oklab, var(--table) 82%, transparent); font-size: .9375rem; line-height: 1.55; color: var(--ink-2); text-wrap: pretty; }
.an-plate[data-plate="loading"] [data-show="loading"],
.an-plate[data-plate="empty"] [data-show="empty"],
.an-plate[data-plate="error"] [data-show="error"],
.an-plate[data-plate="image"] [data-show="image"],
.an-plate[data-plate="image-error"] [data-show="image-error"] { display: block; }
.an-plate:is([data-plate="error"], [data-plate="image-error"]) .an-empty-msg { color: var(--ink); box-shadow: inset 3px 0 0 var(--alert); text-align: start; }
.an-plate:not([data-plate="ready"]) #anView::before {
  content: ""; position: absolute; inset: -15%; pointer-events: none; opacity: .75;
  background-image:
    radial-gradient(circle at 34% 42%, var(--ink-3) 0 3px, transparent 3.5px),
    radial-gradient(circle at 62% 36%, var(--ink-3) 0 3px, transparent 3.5px),
    radial-gradient(circle at 54% 66%, var(--ink-3) 0 3px, transparent 3.5px),
    repeating-radial-gradient(circle at 34% 42%, transparent 0 1.75rem, var(--rule-2) 1.75rem calc(1.75rem + 1px)),
    repeating-radial-gradient(circle at 62% 36%, transparent 0 2.25rem, var(--rule) 2.25rem calc(2.25rem + 1px)),
    repeating-radial-gradient(circle at 54% 66%, transparent 0 2rem, var(--rule) 2rem calc(2rem + 1px));
  -webkit-mask: radial-gradient(closest-side, #000 35%, transparent); mask: radial-gradient(closest-side, #000 35%, transparent);
}
.an-plate:is([data-plate="loading"], [data-plate="image"]) #anView::before { animation: an-breathe 2.8s var(--ease-io) infinite alternate; }
.an-plate:is([data-plate="error"], [data-plate="image-error"]) #anView::before { opacity: .3; }

/* the key: how to look at this map, its recorded scale for exactly this version, then the version's exits.
   Narrow (beside the map) it reads top to bottom; wide (under the map) the controls run in a row. */
.an-key { display: grid; align-content: start; gap: 1rem; min-width: 0; container: an-key / inline-size; }
.an-key:not(:has(> :is(.an-plate-tools, .an-scale):not([hidden]), > .an-out > :not([hidden]))) { display: none; }
.an-plate-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; }
.an-seg { display: inline-flex; gap: .125rem; padding: .1875rem; border-radius: calc(var(--r) + .1875rem); background: var(--plate-2); }
.an-tool {
  display: inline-flex; align-items: center; gap: .4375rem; min-height: var(--ctl); padding: 0 .75rem; border: 0; border-radius: var(--r);
  background: transparent; color: var(--ink-2); font-size: .875rem; font-weight: 600; white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.an-seg .an-tool[aria-pressed="true"] { background: var(--plate); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .14), 0 0 0 1px var(--rule); }
.an-tool-solo { min-height: calc(var(--ctl) + .375rem); border: 1px solid var(--rule-2); }
.an-tool-solo[aria-pressed="true"] { background: var(--slab); border-color: var(--slab); color: var(--on-slab); }
@media (hover: hover) and (pointer: fine) { .an-tool:not(:disabled):not([aria-pressed="true"]):hover { color: var(--ink); background: color-mix(in oklab, var(--plate) 60%, transparent); } }
.an-tool:disabled { opacity: .5; }
.an-stage[data-layer="pending"] #anLayers [data-layer="prediction"] { animation: an-blink 1.2s ease-in-out infinite; }
.an-tool-note { flex-basis: 100%; font-size: .8125rem; line-height: 1.4; color: var(--warn); text-wrap: pretty; }
.an-out { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .875rem; }
.an-out:not(:has(> :not([hidden]))) { display: none; }
@container an-key (max-width: 20rem) {
  .an-plate-tools { display: grid; }
  .an-plate-tools .an-seg { display: grid; }
  .an-plate-tools .an-tool { justify-content: flex-start; white-space: normal; text-align: start; }
  .an-out { display: grid; justify-items: start; }
}
.an-out-csv {
  display: inline-flex; align-items: center; gap: .5rem; min-height: var(--hit); font-size: .875rem; font-weight: 600;
  text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: .22em;
}
.an-out-csv::before { content: "↓" / ""; display: grid; place-items: center; width: 1.375rem; height: 1.375rem; border: 1px solid var(--rule-2); border-radius: 50%; font: 600 .8125rem/1 var(--f-num); text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .an-out-csv:hover { text-decoration-color: currentColor; } }
body.an #openSimulation {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--hit); padding: 0 1rem;
  border: 1px solid var(--ink); border-radius: var(--r); box-shadow: none; background: transparent; color: var(--ink);
  font-size: .9375rem; font-weight: 600; transition: background-color .15s ease, color .15s ease, transform .12s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { body.an #openSimulation:hover { background: var(--slab); color: var(--on-slab); } }
body.an #openSimulation:active { transform: translateY(1px); }

.an-scale { display: grid; gap: .625rem; min-width: 0; padding-top: .75rem; border-top: 1px solid var(--rule-2); font-size: .8125rem; line-height: 1.45; }
.an-scale-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem .75rem; }
.an-scale-metric { font: 600 .875rem/1.2 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink); }
.an-scale-bar { display: grid; grid-template-columns: auto minmax(3rem, 1fr) auto; align-items: center; gap: .5rem; }
.an-scale-ramp { display: block; height: .75rem; border-radius: 2px; background-color: var(--plate-2); box-shadow: inset 0 0 0 1px var(--rule); }
.an-scale-end { font: 600 .875rem/1 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink); }
.an-scale-keys { display: flex; flex-wrap: wrap; gap: .25rem .875rem; margin: 0; padding: 0; list-style: none; font-family: var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.an-scale-note, .an-scale-base, .an-scale-unknown { color: var(--ink-3); overflow-wrap: anywhere; text-wrap: pretty; }
.an-scale-unknown { display: flex; align-items: center; gap: .5rem; }
.an-checker { flex: none; width: 1rem; height: 1rem; border-radius: 2px; background: var(--chk); box-shadow: inset 0 0 0 1px var(--rule-2); }
.an-scale-csv { font-weight: 600; text-underline-offset: .2em; }
.an-scale[data-state="loading"] .an-scale-ramp { animation: an-blink 1.2s ease-in-out infinite; }
.an-scale:is([data-state="none"], [data-state="missing"], [data-state="unread"]) { border-top: 1px dashed var(--rule-2); }
.an-scale[data-state="failed"] { border-top: 1px dashed var(--alert); }

/* running: the veil covers the stage only; the rest of the bench stays usable */
.an-veil {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 1rem;
  border-radius: var(--r); background: var(--veil); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  animation: an-in .2s var(--ease-out);
}
.an-veil-card {
  display: grid; justify-items: start; gap: .5rem; width: min(100%, 24rem); padding: 1.125rem 1.25rem 1rem;
  border: 1px solid var(--rule-2); border-radius: calc(var(--r) * 2); background: var(--plate); box-shadow: var(--lift);
  animation: an-rise .24s var(--ease-out);
}
.an-sweep { display: block; width: 100%; height: 1.75rem; margin-bottom: .25rem; overflow: hidden; }
.an-sweep svg { display: block; width: 200%; height: 100%; overflow: visible; transform-origin: 50% 50%; transition: transform .3s var(--ease-out); }
.an-sweep path { fill: none; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.an-wave-a { stroke: var(--ink); stroke-width: 1.75; animation: an-wave-a 1.5s linear infinite; }
.an-wave-b { stroke: var(--ok); stroke-width: 1.25; opacity: .7; animation: an-wave-b 2.6s linear infinite; }
.an-veil-title { font: 600 1.125rem/1.3 var(--f-display); overflow-wrap: anywhere; }
.an-veil-title:empty { display: none; }
.an-veil-time { display: flex; align-items: baseline; gap: .5rem; font-size: .8125rem; color: var(--ink-3); }
#anVeilTime { font: 600 1.5rem/1 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink); }
.an-veil-note { font-size: .875rem; color: var(--ink-2); text-wrap: pretty; }
#anVeilHide { justify-self: end; border-color: var(--rule-2); }
/* failure: the signal flattens and stops */
.an-bench[data-run="failed"] .an-sweep svg { transform: scaleY(.1); }
.an-bench[data-run="failed"] :is(.an-wave-a, .an-wave-b) { animation: none; }
.an-bench[data-run="failed"] .an-wave-a { stroke: var(--alert); }
.an-bench[data-run="failed"] .an-wave-b { opacity: 0; }
.an-bench[data-run="failed"] .an-veil-card { border-color: var(--alert); }
.an-bench[data-run="failed"] #anVeilKind { color: var(--alert); }

.an-chip {
  position: absolute; inset-block-start: .75rem; inset-inline-end: .75rem; z-index: 7; display: inline-flex; align-items: center; gap: .5rem;
  min-height: var(--hit); padding: 0 .875rem 0 .75rem; border: 1px solid var(--rule-2); border-radius: 999px;
  background: var(--plate); color: var(--ink); font-size: .875rem; font-weight: 600; box-shadow: var(--lift);
  animation: an-rise .2s var(--ease-out);
}
.an-chip[data-float="on"] { position: fixed; inset-block-start: auto; bottom: calc(var(--an-foot) + .75rem + env(safe-area-inset-bottom)); inset-inline-end: var(--pad-r); z-index: 25; }
.an-pulse { position: relative; flex: none; width: .625rem; height: .625rem; border-radius: 50%; background: var(--ok); }
.an-pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--ok); animation: an-ring 1.4s var(--ease-out) infinite; }
.an-chip[data-state="saved"] .an-pulse { background: var(--signal); box-shadow: 0 0 0 1px var(--ink); }
.an-chip[data-state="saved"] .an-pulse::after { animation: none; opacity: 0; }

.an-verdict { display: flex; align-items: flex-start; gap: .625rem; font-size: .875rem; line-height: 1.5; color: var(--ink-2); text-wrap: pretty; }
.an-verdict::before { content: ""; flex: none; width: .625rem; height: .625rem; margin-top: .42em; border-radius: 50%; border: 1.5px solid var(--ink-3); }
.an-verdict[data-tone="ok"]::before { background: var(--ok); border-color: var(--ok); }
.an-verdict[data-tone="warn"] { color: var(--ink); }
.an-verdict[data-tone="warn"]::before { background: var(--warn); border-color: var(--warn); border-radius: 1px; transform: rotate(45deg); }
.an-summary { max-width: 62rem; font-size: .875rem; line-height: 1.55; color: var(--ink-2); overflow-wrap: anywhere; text-wrap: pretty; }
.an-caveat { display: flex; align-items: flex-start; gap: .625rem; max-width: 62rem; font-size: .8125rem; line-height: 1.5; color: var(--ink-3); text-wrap: pretty; }

/* ---- ledger: saved versions */
.an-versions { min-width: 0; container: an-ledger / inline-size; }
.an-ledger > summary { display: flex; align-items: center; gap: .5rem; min-height: var(--hit); padding-bottom: .25rem; border-bottom: 1px solid var(--rule-2); font: 600 1rem/1.3 var(--f-ui); }
.an-count { margin-inline-start: auto; padding: .25rem .5rem; border-radius: 999px; background: var(--plate-2); color: var(--ink-2); font: 600 .8125rem/1 var(--f-num); font-variant-numeric: tabular-nums; }
.an-count:empty { display: none; }
.an-ledger:has(.an-count:not(:empty)) > summary::after { margin-inline-start: .25rem; }
/* comparing only means something once there are two versions */
.an-hint { display: none; margin-top: .625rem; font-size: .8125rem; line-height: 1.5; color: var(--ink-3); text-wrap: pretty; }
.an-ledger:has(#savedHeatmaps .record ~ .record) .an-hint { display: block; }
#savedHeatmaps { display: grid; gap: .5rem; margin-top: .75rem; font-size: .875rem; color: var(--ink-3); }
@container an-ledger (min-width: 36rem) { #savedHeatmaps { grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); } }

.an-records .record { position: relative; min-width: 0; padding: .75rem .875rem; border: 1px solid var(--rule); border-radius: var(--r); background: var(--plate); color: var(--ink-2); font-size: .875rem; line-height: 1.5; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.an-records .record > b { color: var(--ink); font-weight: 600; }
.an-records .record button {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem; min-height: var(--ctl); padding: 0 .75rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--field); color: var(--ink); font-size: .875rem; font-weight: 600;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
@media (hover: hover) and (pointer: fine) { .an-records .record button:not(:disabled):hover { border-color: var(--ink); } }
.an-records .record button:disabled { opacity: .5; }
.an-records .record button[aria-busy="true"] { cursor: progress; animation: an-blink 1.2s ease-in-out infinite; }
#routeResult .record, #obstacles .record { margin-top: .5rem; }
#obstacles .record button { margin: .5rem .375rem 0 0; }

/* a saved version: tag · name · delete / recorded tags / date · lineage / use · compare */
#savedHeatmaps .record { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .5rem; padding-inline-start: 1rem; transition: border-color .15s ease, box-shadow .15s ease; }
#savedHeatmaps .record > br { display: none; }
#savedHeatmaps .record > b { order: 1; flex: 1 1 8rem; min-width: 0; font-size: .9375rem; line-height: 1.35; }
#savedHeatmaps .record[data-an-tag]:not([data-an-tag=""])::before {
  content: attr(data-an-tag); order: 0; flex: none; padding: .25rem .5rem; border: 1px solid var(--rule-2); border-radius: 999px;
  font: 600 .75rem/1 var(--f-num); letter-spacing: 0; text-transform: uppercase; color: var(--ink-2);
}
:lang(ja) #savedHeatmaps .record::before, :lang(zh-CN) #savedHeatmaps .record::before { font-family: var(--f-ui); letter-spacing: 0; }
#savedHeatmaps .record .an-del { order: 2; flex: none; min-width: var(--ctl); padding: 0; border-color: transparent; background: transparent; color: var(--ink-3); }
@media (hover: hover) and (pointer: fine) { #savedHeatmaps .record .an-del:not(:disabled):hover { border-color: color-mix(in oklab, var(--alert) 50%, transparent); color: var(--alert); } }
#savedHeatmaps .an-rec-tags { order: 3; flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: .25rem .375rem; }
#savedHeatmaps .record:has(.an-rec-tags) > small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#savedHeatmaps .record > small { order: 4; flex: 1 1 100%; font-size: .8125rem; color: var(--ink-3); }
#savedHeatmaps .record > span:not(.asset-lineage):not(.an-rec-tags) { order: 5; font: .8125rem/1.4 var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink-3); }
#savedHeatmaps .asset-lineage { order: 6; display: inline-flex; align-items: center; gap: .375rem; font-size: .8125rem; color: var(--ink-3); }
#savedHeatmaps .asset-lineage::before { content: ""; width: .4375rem; height: .4375rem; border-radius: 50%; border: 1.5px solid currentColor; }
#savedHeatmaps .record::after { content: ""; order: 6; flex: 1 1 100%; height: 0; }
#savedHeatmaps .record [data-use-heatmap] { order: 7; }
#savedHeatmaps .record .an-compare { order: 8; }
.an-rec-tags > span {
  display: inline-flex; align-items: center; gap: .375rem; max-width: 100%; min-height: 1.5rem; padding: 0 .5rem;
  border-radius: 999px; background: var(--plate-2); color: var(--ink-2); font-size: .75rem; font-weight: 600; line-height: 1.3;
}
.an-rec-scale { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.an-rec-scale > i { flex: none; width: 1.5rem; height: .375rem; border-radius: 1px; background-color: var(--rule-2); }
.an-rec-scale:not(:has(> i)) { background: transparent; border: 1px dashed var(--rule-2); color: var(--ink-3); }
#savedHeatmaps .record:is(.an-on, .active-record, [aria-current]:not([aria-current="false"])) { border-color: var(--ink-2); box-shadow: inset 3px 0 0 var(--ok); }
#savedHeatmaps .record.an-on::before, #savedHeatmaps .record.active-record::before { background: var(--slab); border-color: var(--slab); color: var(--on-slab); }
#savedHeatmaps .record.an-pinned { border-style: dashed; border-color: var(--ink-3); }
#savedHeatmaps .record.an-pinned::before { border-style: dashed; }
#savedHeatmaps .record.an-pinned .an-compare { background: var(--slab); border-color: var(--slab); color: var(--on-slab); }

/* ---- advanced: drawers behind the main path */
.an-advanced { display: grid; align-content: start; min-width: 0; padding-top: .5rem; }
.an-advanced-title { padding-bottom: .5rem; border-bottom: 1px solid var(--rule-2); }
.an-advanced-title .an-i { color: var(--ink-3); }
.an-drawer { border-bottom: 1px solid var(--rule); container: an-drawer / inline-size; }
.an-drawer > summary { display: flex; align-items: center; gap: .75rem; min-height: 3.25rem; padding: .5rem 0; }
.an-drawer > summary > .an-i { color: var(--ink-2); }
.an-drawer > summary > span { display: grid; gap: .0625rem; min-width: 0; }
.an-drawer > summary b { font-weight: 600; font-size: .9375rem; }
.an-drawer > summary small { font-size: .75rem; color: var(--ink-3); letter-spacing: 0; }
.an-drawer-body { display: grid; gap: .875rem; padding: .25rem 0 1.25rem; min-width: 0; }
.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .75rem; }
.an-grid-4 { grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); }
.an-grid-3 { grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); margin-top: .75rem; }
.an-drawer .an-fold { margin-top: .25rem; }
.an-drawer .an-fold > div:last-child { padding-bottom: .5rem; }
#route, #addObstacle { justify-self: start; }
@container an-drawer (min-width: 52rem) { .an-obstacle { grid-template-columns: minmax(0, 1.4fr) minmax(16rem, 1fr); align-items: start; column-gap: 1.25rem; } .an-obstacle > .an-help:first-child { grid-column: 1 / -1; } }
.an-canvas { min-width: 0; overflow: hidden; border: 1px solid var(--rule); border-radius: var(--r); background: var(--table); }
.an-canvas canvas { display: block; width: 100%; height: auto; touch-action: none; }
.an-obstacle-form { display: grid; gap: .75rem; min-width: 0; }
.an-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---- status line: visible while there is something to read; a plain "ready" stays with screen readers only */
.an-foot {
  position: sticky; bottom: 0; z-index: 12; padding: .5rem var(--pad-r) calc(.5rem + env(safe-area-inset-bottom)) var(--pad-l);
  border-top: 1px solid var(--rule-2); background: color-mix(in oklab, var(--paper) 94%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#status { display: flex; align-items: flex-start; gap: .625rem; margin: 0; font-size: .875rem; line-height: 1.45; color: var(--ink-2); overflow-wrap: anywhere; text-wrap: pretty; }
#status::before { content: ""; flex: none; width: .5rem; height: .5rem; margin-top: .45em; border-radius: 50%; border: 1.5px solid var(--ink-3); }
#status[data-kind="error"] { color: var(--ink); }
#status[data-kind="error"]::before { background: var(--alert); border-color: var(--alert); border-radius: 1px; transform: rotate(45deg); }
.an-foot:has(#status[data-kind="ready"]) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.an-noscript { margin: 1rem var(--pad-r) 1rem var(--pad-l); padding: .75rem 1rem; border-inline-start: 3px solid var(--alert); background: var(--plate); }

.calibration-quality-warning{margin:.75rem 0;padding:.75rem 1rem;border-inline-start:3px solid var(--warn);color:var(--ink);background:color-mix(in oklab,var(--warn) 9%,transparent);font-size:.875rem;line-height:1.6;overflow-wrap:anywhere}
.calibration-quality-warning[hidden]{display:none}

/* ---- two working columns: the rack stays in reach, the plate takes the rest */
@media (min-width: 64rem) {
  .an-bench {
    grid-template-columns: minmax(18rem, var(--rack-w)) minmax(0, 1fr);
    grid-template-areas: "rack plate" "rack versions" "rack advanced"; grid-template-rows: auto auto 1fr;
    column-gap: 1.5rem; row-gap: 2rem;
  }
  .an-rack { padding-inline-end: 1.5rem; border-inline-end: 1px solid var(--rule); }
  .an-commit { margin-inline: 0; padding-inline: 0; }
}
/* the rack fits the viewport from where it starts (under the header and the bench padding),
   so its dock - readiness and Generate - is in view on arrival; inputs scroll inside it, clear of the dock */
@media (min-width: 64rem) and (min-height: 40rem) {
  .an-rack {
    position: sticky; top: .75rem; max-height: calc(100dvh - var(--an-top) - 2rem - var(--an-foot)); overflow: auto; overscroll-behavior: contain;
    scroll-padding-block-end: calc(var(--an-commit) + .75rem); margin-inline-start: -.25rem; padding-inline-start: .25rem; scrollbar-width: thin;
  }
  .an-commit { bottom: 0; }
}
/* Versions follow the result; a short list does not reserve a full-height column. */
@media (min-width: 110rem) {
  :root { --rack-w: 23rem; }
}

/* ---- short landscape: one header row, two columns, the map and its key side by side on the short side */
@media (orientation: landscape) and (max-height: 32rem) and (min-width: 40rem) {
  :root { --key-w: 12rem; --an-cap: max(10rem, calc(100dvh - var(--an-top) - 5.5rem - var(--an-foot))); }
  .an-head { column-gap: .75rem; padding-block: .25rem; }
  .an-home { min-width: var(--hit); padding: 0; justify-content: center; }
  .an-home > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .an-mark { gap: .75rem; }
  .an-mark .an-eyebrow { display: none; }
  .an-mark h1 { font-size: 1.125rem; }
  .an-bench {
    grid-template-columns: minmax(16rem, 19rem) minmax(0, 1fr); grid-template-areas: "rack plate" "rack versions" "rack advanced";
    grid-template-rows: auto auto 1fr; column-gap: 1rem; row-gap: 1.5rem; padding-top: .75rem;
  }
  .an-rack {
    position: sticky; top: 0; max-height: calc(100dvh - var(--an-top) - .75rem - var(--an-foot)); overflow: auto; overscroll-behavior: contain;
    scroll-padding-block-end: calc(var(--an-commit) + .5rem); padding-inline-end: 1rem; border-inline-end: 1px solid var(--rule); scrollbar-width: thin;
  }
  .an-commit { bottom: 0; gap: .5rem; margin-inline: 0; padding: .5rem 0; }
  body.an #generate { min-height: 2.75rem; }
  .an-plate { gap: .5rem; }
  .an-plate-id .an-eyebrow { display: none; }
  .an-plate-id h2 { font-size: 1.125rem; }
  .an-view { min-height: 10rem; }
  @container an-frame (min-width: 28rem) {
    .an-plot:has(> .an-key > :is(.an-plate-tools, .an-scale):not([hidden]), > .an-key > .an-out > :not([hidden]), > .an-scale:not([hidden])) {
      grid-template-columns: minmax(0, 1fr) var(--key-w); align-items: start; gap: 1rem;
    }
  }
}

/* ---- narrow and short phone layouts: one task at a time (the presenter's exact query).
   The header becomes the working bar in two layers: the shared workspace navigation, then the task switch beside the
   display settings. Hosted, the lab's own bar already names the page, so the heading stays for assistive tech only.
   Scrolling, the bar stays pinned with only its last row in view - the settings/result return and display settings. */
@media (max-width: 47.99rem) and (orientation: portrait), (max-width: 47.99rem) and (min-height: 32.01rem), (max-width: 39.99rem), (max-width: 63.99rem) and (max-height: 32rem) {
  /* the header's last row with its gap, bottom padding and rule: what stays in view once pinned */
  :root { --an-pin: calc(.75rem + max(var(--hit), 2.75rem) + 1px); }
  .an-head {
    position: sticky; top: calc(var(--an-pin) - var(--an-top));
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "flow flow flow" "task task util";
    align-items: center; column-gap: .5rem; row-gap: .375rem; padding-block: .375rem;
    background: color-mix(in oklab, var(--paper) 94%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  }
  :root:not([data-lab-host]) .an-head { grid-template-areas: "home mark mark" "flow flow flow" "task task util"; }
  :root:not([data-lab-host]) .an-home { grid-area: home; }
  :root:not([data-lab-host]) .an-mark { grid-area: mark; }
  body.an > .an-head > .workspace-flow { grid-area: flow; }
  .an-util { grid-area: util; justify-self: end; margin-inline-start: 0; }
  .an-mark { gap: .75rem; padding-inline-start: .25rem; }
  .an-mark .an-eyebrow { display: none; }
  .an-mark h1 { font-size: 1.125rem; }
  .an-home { min-width: var(--hit); padding: 0; justify-content: center; }
  .an-home > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  /* the row is exactly one hit tall, which is what --an-pin assumes */
  .an-task { grid-area: task; display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; min-width: 0; min-height: max(var(--hit), 2.75rem); }
  .an-task > .an-task-btn { gap: .375rem; padding-inline: .5rem; }
  /* the bench starts under the pinned row, so returning to the top of a task (the presenter scrolls to the bench) shows
     its first line; each task lays out only its own areas, so a hidden one leaves no empty row and double gap */
  .an-bench {
    grid-template-columns: minmax(0, 1fr); grid-template-areas: "rack" "plate" "versions" "advanced"; gap: 1.25rem;
    margin-top: calc(var(--an-pin) * -1); padding-top: calc(var(--an-pin) + 1rem);
  }
  .an-bench[data-task="recipe"] { grid-template-areas: "rack"; }
  .an-bench[data-task="result"] { grid-template-areas: "plate" "versions" "advanced"; }
  .an-rack { position: static; max-height: none; overflow: visible; padding-inline-end: 0; border-inline-end: 0; }
  .an-bench[data-task="recipe"] :is(.an-plate, .an-versions, .an-advanced) { display: none; }
  .an-bench[data-task="result"] .an-rack { display: none; }
  .an-plate-id h2 { font-size: 1.375rem; }

  /* wide enough for one bar: workspace · task · settings */
  @media (min-width: 52rem) {
    .an-head { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "flow task util"; }
    :root:not([data-lab-host]) .an-head { grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "home mark mark mark" "flow flow task util"; }
  }
  /* the smallest phones: the settings take their own row so both task labels keep their full width */
  @media (max-width: 22.49rem) {
    .an-head { grid-template-areas: "flow flow flow" "util util util" "task task task"; }
    :root:not([data-lab-host]) .an-head { grid-template-areas: "home mark util" "flow flow flow" "task task task"; }
  }
  /* short screens: the version's name sits beside its exits, so the map starts sooner */
  @media (max-height: 32rem) and (min-width: 40rem) {
    .an-plate-head { grid-template-columns: minmax(0, 1fr) auto; align-items: end; column-gap: 1rem; }
  }
  /* tall screens: the map follows the version's name directly. Its exits - this exact version into route comparison,
     its grid as CSV - ride a dock at the foot of the screen, as Generate does in the recipe, and settle after the caveat. */
  @media (min-height: 32.01rem) and (min-width: 18rem) {
    .an-plate-head { display: contents; }
    .an-out {
      order: 1; position: sticky; bottom: var(--an-foot); z-index: 6; flex-wrap: nowrap; gap: .75rem;
      margin-inline: calc(var(--pad-l) * -1) calc(var(--pad-r) * -1); padding: .5rem var(--pad-r) .5rem var(--pad-l);
      border-top: 1px solid var(--rule-2); background: color-mix(in oklab, var(--paper) 94%, transparent);
      -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
      animation: an-dock .26s var(--ease-out);
    }
    .an-out > #openSimulation { flex: 1 0 auto; }
    .an-out > .an-out-csv { flex: 0 1 auto; min-width: 0; line-height: 1.3; }
    /* the floating run chip waits above the dock rather than over it */
    .an-plate:has(.an-out > :not([hidden])) .an-chip[data-float="on"] { bottom: calc(var(--an-foot) + var(--hit) + 1.75rem); }
    html:not([data-an-reading-flow]):has(.an-bench[data-task="result"] .an-out > :not([hidden])) { scroll-padding-block-end: calc(var(--an-foot) + var(--hit) + 2rem); }
  }
  /* enlarged text: an ordinary scrolling page - nothing pinned or docked, every part on its own row */
  @media (max-width: 17.99rem), (max-height: 19.99rem) {
    :root { --an-pin: 0px; }
    .an-head { position: relative; top: auto; grid-template-columns: minmax(0, 1fr); grid-template-areas: "flow" "task" "util"; }
    :root:not([data-lab-host]) .an-head { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "home mark" "flow flow" "task task" "util util"; }
    .an-task { grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr)); }
  }
}
/* Media-query rem units use the initial font. The presenter applies the same
   small-reading-space fallback using the current font and actual iframe size. */
:root[data-an-reading-flow] { --an-pin: 0px; scroll-padding-block: .5rem; }
:root[data-an-reading-flow] :is(button, input, select, textarea, a) { scroll-margin-block: .5rem; }
:root[data-an-reading-flow] .an-head {
  position: relative; top: auto; grid-template-columns: minmax(0, 1fr); grid-template-areas: "flow" "task" "util";
}
:root[data-an-reading-flow]:not([data-lab-host]) .an-head {
  grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "home mark" "flow flow" "task task" "util util";
}
:root[data-an-reading-flow] .an-task { grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr)); }
:root[data-an-reading-flow] .an-util { justify-self: start; max-width: 100%; flex-wrap: wrap; }
:root[data-an-reading-flow] .an-bench { margin-top: 0; padding-top: 1rem; }
:root[data-an-reading-flow] .an-plate-head { display: grid; grid-template-columns: minmax(0, 1fr); }
:root[data-an-reading-flow] .an-out { position: static; flex-wrap: wrap; margin-inline: 0; padding-inline: 0; }
:root[data-an-reading-flow] .an-out > #openSimulation { flex: 1 1 auto; min-width: 0; max-width: 100%; }
:root[data-an-reading-flow] :is(.an-foot, .an-commit) { position: static; }
.an-task-btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--hit); padding: 0 .75rem;
  border: 1px solid var(--rule-2); border-radius: var(--r); background: transparent; color: var(--ink-2); font-size: .9375rem; font-weight: 600; overflow: hidden;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.an-task-btn[aria-pressed="true"] { background: var(--slab); border-color: var(--slab); color: var(--on-slab); }
.an-task-no { font: 600 .8125rem/1 var(--f-num); opacity: .7; }
.an-task-lamp { width: .5rem; height: .5rem; border-radius: 50%; border: 1.5px solid currentColor; opacity: .6; transition: background-color .2s ease, transform .2s var(--ease-out); }
/* the switch sits in the header; the bench still owns the state it reports */
body:has(.an-bench[data-eligibility="ready"]) .an-task-lamp { background: var(--ok); border-color: var(--ok); opacity: 1; }
body:has(.an-bench[data-eligibility="error"]) .an-task-lamp { background: var(--alert); border-color: var(--alert); border-radius: 1px; transform: rotate(45deg); opacity: 1; }
body:has(.an-bench[data-eligibility="checking"]) .an-task-lamp { animation: an-blink 1.2s ease-in-out infinite; }
.an-task-count { padding: .1875rem .4375rem; border-radius: 999px; background: var(--plate-2); color: var(--ink-2); font: 600 .8125rem/1 var(--f-num); font-variant-numeric: tabular-nums; }
.an-task-btn[aria-pressed="true"] .an-task-count { background: color-mix(in oklab, var(--on-slab) 18%, transparent); color: var(--on-slab); }
.an-task-count:empty { display: none; }
body:has(.an-bench[data-run="running"]) .an-task-btn[data-task="result"]::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: linear-gradient(90deg, transparent, var(--ok), transparent); animation: an-scan 1.4s linear infinite; }

@media (pointer: coarse) { :root { --hit: 2.75rem; --ctl: 2.5rem; } }

/* ---- motion */
@keyframes an-blink { 50% { opacity: .35; } }
@keyframes an-scan { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes an-ring { from { transform: scale(1); opacity: .85; } to { transform: scale(2.4); opacity: 0; } }
@keyframes an-in { from { opacity: 0; } }
@keyframes an-rise { from { opacity: 0; transform: translateY(.375rem) scale(.97); } }
@keyframes an-dock { from { opacity: 0; transform: translateY(.75rem); } }
@keyframes an-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes an-breathe { from { transform: scale(.97); opacity: .4; } to { transform: scale(1.03); opacity: .85; } }
@keyframes an-wave-a { to { transform: translateX(-60px); } }
@keyframes an-wave-b { to { transform: translateX(-80px); } }

/* reduced: no travelling motion; colour and opacity changes still mark state */
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after {
  animation: none !important; scroll-behavior: auto !important;
  transition-property: opacity, color, background-color, border-color, box-shadow !important; transition-duration: .12s !important;
}
:root[data-motion="reduced"] .an-skip { transition: none !important; }
/* a hidden tab keeps its place in every loop */
:root[data-an-hidden] *, :root[data-an-hidden] *::before, :root[data-an-hidden] *::after { animation-play-state: paused !important; }
