/* =========================================================================
   Aperiodic · styles
   Every size, gap, duration and colour comes from a token. The values below
   are first-paint defaults (Paper palette); js/tokens.js is the source of truth
   and rewrites them per palette (with contrast-solved --muted / --accent-text).
   ========================================================================= */
/* Tokens (:root custom properties) live in tokens.css, loaded before this file. */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-body)/1.5 var(--mono);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#c { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; cursor: crosshair; touch-action: none; }
#c.dragging { cursor: grabbing; }
#c.circling { cursor: cell; }
#rulers { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; }

/* No backdrop blur: it re-blurs the moving canvas under every panel on every frame. */
.chip { background: var(--panel); border: 1px solid var(--line); }
.ui { transition: opacity var(--dur-slow) ease; }
body.bare .ui { opacity: 0; pointer-events: none; }

/* keyboard focus, everywhere (mouse clicks don't show it) */
:focus { outline: none; }
:focus-visible { outline: var(--focus); outline-offset: 2px; }
.sw:focus-visible, .vcell:focus-visible { outline-offset: 3px; }

/* ---------- controls ---------- */
.btn, .seg button, .sizes button {
  font: inherit; color: var(--ink); background: transparent; cursor: pointer;
  border: 1px solid var(--line); text-align: center; white-space: nowrap;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.btn, .seg button {
  min-height: var(--control-h); padding: 0 var(--sp-3);
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { border-color: var(--ink); }
.btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 82%, var(--accent)); }
.btn.wide { width: 100%; margin-top: var(--sp-2); min-height: var(--control-h-md); }
.btn.big { min-height: var(--control-h-lg); font-size: var(--fs-text); letter-spacing: .02em; }
a.btn { text-decoration: none; }
.btn .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  border: 1px solid currentColor; margin-right: var(--sp-2);
}
.btn.on .dot { background: var(--accent); border-color: var(--accent); }
.btn .ring {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  border: 1px dashed currentColor; margin-right: var(--sp-2);
}
.btn.on .ring { border: 1px solid var(--accent); }

.link {
  font: inherit; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: var(--sp-2);
  transition: color var(--dur-fast);
}
.link:hover { color: var(--ink); }
.link i {
  font-style: normal; font-size: var(--fs-micro); width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid currentColor; display: inline-flex; align-items: center; justify-content: center;
}
.link.mini { font-size: var(--fs-label); margin-left: var(--sp-3); pointer-events: auto; }
.link.mini.on { color: var(--accent-text); }
.link.today { margin-top: var(--sp-2); font-size: var(--fs-label); }
/* your places: the ones you found before, as small tags */
.places { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--sp-2) 0 0; padding: 0; list-style: none; }
.places[hidden] { display: none; }
.places li { display: flex; align-items: stretch; max-width: 100%; border: 1px solid var(--line); font-size: var(--fs-label); }
.places button { background: none; border: 0; color: var(--ink); font: inherit; cursor: pointer; }
.places .go { padding: 3px 4px 3px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.places .x { padding: 0 7px; color: var(--muted); }
.places li:hover { border-color: var(--ink); }
.places .x:hover { color: var(--ink); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); }
.seg button { border: 0; border-left: 1px solid var(--line); padding: 0 var(--sp-1); font-size: var(--fs-label); overflow: hidden; text-overflow: ellipsis; }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--line); }
.seg button.on { background: var(--ink); color: var(--bg); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-2); }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.row3 .btn { padding: 0 var(--sp-1); }
.field .row:first-child { margin-top: 0; }

.text, .place input {
  font: inherit; color: var(--ink); background: transparent; width: 100%; min-width: 0;
  height: var(--control-h); border: 1px solid var(--line); padding: 0 var(--sp-2);
}
.text:focus, .place input:focus { border-color: var(--ink); }
.text::placeholder, .place input::placeholder { color: var(--muted); }
.place { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-2); }

.checks { display: flex; gap: var(--sp-4); color: var(--ink); flex-wrap: wrap; }
.checks label { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; }
.checks input { accent-color: var(--ink); margin: 0; }
.hint { color: var(--muted); line-height: 1.55; }
.hint.mini { font-size: var(--fs-label); margin-top: var(--sp-2); }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: var(--sp-4); background: transparent; cursor: pointer; display: block; }
input[type=range]::-webkit-slider-runnable-track { height: 1px; background: var(--line-2); }
input[type=range]::-moz-range-track { height: 1px; background: var(--line-2); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; margin-top: -4.5px; background: var(--ink); border: 0; }
input[type=range]::-moz-range-thumb { width: 10px; height: 10px; background: var(--ink); border: 0; border-radius: 0; }

/* ---------- header ---------- */
/* phones with notches and home bars: keep the chrome clear of them (zero elsewhere) */
:root { --safe-t: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-right, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); }
.brand { position: fixed; top: calc(var(--gutter) + var(--safe-t)); left: calc(var(--gutter) + var(--safe-l)); padding: var(--sp-3) var(--sp-4); pointer-events: none; }
.brand-l { display: flex; flex-direction: column; gap: var(--sp-1); }
.brand h1 { font: italic 400 var(--fs-brand)/0.95 var(--serif); letter-spacing: -0.02em; }
.brand p { color: var(--muted); }
.brand-r { display: flex; gap: var(--sp-4); margin-top: var(--sp-3); pointer-events: auto; }
.brand-r [hidden] { display: none; }
.placetag { color: var(--accent-text) !important; }

/* plate mode: a header row above the plate, aligned to its edges (left/width set in JS) */
body.plate .brand {
  background: none; border: 0; padding: 0; top: var(--sp-8);
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-6);
}
body.plate .brand-l { flex-direction: row; align-items: baseline; gap: var(--sp-4); flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; }
body.plate .brand-l p { overflow: hidden; text-overflow: ellipsis; }
body.plate .brand-r { margin-top: 0; flex: none; }

/* rotating tip, centred in the plate-mode header */
.tipline {
  display: none; font: inherit; color: var(--muted); background: none; border: 0; padding: 0;
  cursor: pointer; pointer-events: auto; min-width: 0; flex: 1 1 0; /* only leftover space */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
  transition: opacity var(--dur-slow) ease, color var(--dur-fast);
}
.tipline:hover { color: var(--ink); }
.tipline.fade { opacity: 0; }
.tipline b { font-weight: 400; color: var(--accent-text); margin-right: 6px; letter-spacing: .08em; }
body.plate .tipline { display: block; }
body.plate .tipline[hidden] { display: none; }

/* ---------- panel ---------- */
.panel {
  position: fixed; top: calc(var(--gutter) + var(--safe-t)); right: calc(var(--gutter) + var(--safe-r)); width: var(--pw);
  max-height: calc(100vh - 2 * var(--gutter) - var(--safe-t) - var(--safe-b)); overflow-y: auto; scrollbar-width: none;
}
.panel::-webkit-scrollbar { display: none; }
.panel section { padding: var(--sp-4) var(--sp-5) var(--sp-5); border-top: 1px solid var(--line); }
.view > section:first-child { border-top: 0; }

.sec-h {
  display: flex; align-items: baseline; gap: var(--sp-2); margin-bottom: var(--sp-3);
  font: italic 400 var(--fs-heading)/1 var(--serif); letter-spacing: -0.005em;
}
.sec-h span { font: 400 var(--fs-label) var(--mono); color: var(--accent-text); letter-spacing: .08em; min-width: var(--sp-4); }

.field + .field { margin-top: var(--sp-4); }
.label { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); color: var(--muted); margin-bottom: var(--sp-2); }
.label b { font-weight: 400; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.label sub { font-size: .75em; }

.nticks { display: flex; justify-content: space-between; color: var(--muted); font-size: var(--fs-micro); margin-top: var(--sp-1); padding: 0 1px; }
#pad { display: block; width: 100%; height: var(--size-pad); border: 1px solid var(--line); cursor: crosshair; touch-action: none; }

.swatches { display: grid; grid-template-columns: repeat(10, 1fr); gap: var(--sp-1); }
.sw { aspect-ratio: 1; cursor: pointer; border: 1px solid var(--line); padding: 0; appearance: none; transition: transform var(--dur-fast); }
.sw:hover { transform: translateY(-1px); }
.sw.on { outline: 1px solid var(--ink); outline-offset: 2px; }

.keys { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2) var(--sp-3); color: var(--muted); }
.keys div { display: flex; align-items: center; gap: var(--sp-2); }
.keys kbd {
  font: inherit; font-size: var(--fs-label); color: var(--ink); border: 1px solid var(--line);
  padding: 0 var(--sp-1); min-width: var(--sp-6); text-align: center;
}

/* views: explore ↔ poster */
body.print .view-explore, body:not(.print) .view-print { display: none; }
.print-head { background: color-mix(in srgb, var(--accent) 5%, var(--bg)); }
.print-head .back { margin-bottom: var(--sp-3); }
.print-head .kinds { margin-top: 0; }
.print-head #makeHint { margin-top: var(--sp-3); }
.print-head h2 { font: italic 400 var(--fs-title)/1.05 var(--serif); letter-spacing: -0.015em; margin-bottom: var(--sp-2); }
/* size and screen cards: two across, a glyph on the left (paper drawn to scale, or the
   device), the name above its dimensions on the right, all on one inner margin */
.sizes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
/* screens: the same cards, a little tighter (there are seven) */
.sizes.devices { gap: 6px; }
.sizes.devices button { min-height: 40px; padding: 5px 10px; }
.sizes.devices .glyph { height: 22px; }
.sizes button {
  display: flex; align-items: center; gap: var(--sp-2); min-width: 0; min-height: 48px;
  padding: var(--sp-2) 10px; text-align: left;
}
.sizes .glyph { flex: none; width: 20px; height: 28px; display: flex; align-items: center; justify-content: center; }
.sizes .glyph .ico { width: 20px; height: 20px; }
.sizes .t { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 11px; line-height: 1.2; white-space: nowrap; }
.sizes .t small { font-size: var(--fs-micro); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sizes button:hover { border-color: var(--ink); }
.sizes button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.sizes button.on small { color: var(--bg); color: color-mix(in srgb, var(--bg) 75%, var(--ink)); }
/* the download stays in reach however far the poster view scrolls */
.print-go { position: sticky; bottom: 0; background: var(--bg); box-shadow: 0 -10px 18px -12px rgba(0, 0, 0, .25); }
.print-go .hint { margin-top: var(--sp-2); text-align: center; }
.print-go .btn.wide { margin-top: 0; }

/* ---------- plate mode: cartouche + field notes ---------- */
body.plate .coords, body.plate .stats { display: none; }
body:not(.plate) .cart, body:not(.plate) .notes, body:not(.plate):not(.print) #rulers { display: none; }

.cart {
  position: fixed; display: flex; gap: var(--sp-3); align-items: center;
  padding: var(--sp-2) var(--sp-4) var(--sp-2) var(--sp-2); background: var(--bg); color: var(--ink);
  border: 1px solid var(--ink); outline: 1px solid var(--line); outline-offset: 3px;
  pointer-events: none;
}
.cart canvas { width: var(--size-compass); height: var(--size-compass); display: block; pointer-events: auto; cursor: pointer; }
.cart .k { font-size: var(--fs-micro); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.cart .t { font: italic 400 var(--fs-subtitle)/1.15 var(--serif); margin: var(--sp-1) 0 var(--sp-2); }
.cart .m { font-size: var(--fs-label); line-height: 1.6; font-variant-numeric: tabular-nums; white-space: pre; }
.cart .m em, .notes em { font-style: normal; color: var(--muted); }

.notes {
  position: fixed; display: grid; grid-template-columns: minmax(0, 1fr) var(--size-window) minmax(150px, 210px); gap: var(--sp-6);
  align-items: start;
}
.notes .head { display: flex; justify-content: space-between; gap: var(--sp-3); color: var(--muted); margin-bottom: var(--sp-2); white-space: nowrap; overflow: hidden; cursor: help; }
.notes .head span { color: var(--ink); }
.notes .head b { font-weight: 400; color: var(--ink); font-variant-numeric: tabular-nums; }
.notes .head sub { font-size: .75em; }
#win { width: var(--size-window); height: var(--size-window); display: block; cursor: crosshair; border: 1px solid var(--line); touch-action: none; }
.vt { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: var(--sp-1); }
.vcell {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: var(--sp-1) 0 3px;
  border: 1px solid transparent; cursor: pointer; min-width: 0;
}
.vcell:hover { border-color: var(--line); }
.vcell.on { border-color: var(--ink); }
.vcell canvas { width: var(--size-icon); height: var(--size-icon); display: block; }
.vcell .code { font-size: var(--fs-label); letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
.vcell .n { font-variant-numeric: tabular-nums; }
.vcell.more { justify-content: center; color: var(--muted); cursor: default; }
#spark { width: 100%; height: 72px; display: block; }

/* ---------- full-bleed readouts ---------- */
.coords, .stats { position: fixed; bottom: calc(var(--gutter) + var(--safe-b)); padding: var(--sp-1) var(--sp-3); font-size: var(--fs-label); font-variant-numeric: tabular-nums; white-space: pre; pointer-events: none; }
.coords { left: calc(var(--gutter) + var(--safe-l)); }
.stats { right: calc(var(--pw) + 2 * var(--gutter) + var(--safe-r)); }
.coords em, .stats em { font-style: normal; color: var(--muted); }

.tip {
  position: fixed; left: 0; top: 0; padding: var(--sp-2) var(--sp-3); white-space: pre; pointer-events: none;
  opacity: 0; transition: opacity var(--dur-fast); font-variant-numeric: tabular-nums; line-height: 1.65;
}
.tip.show { opacity: 1; }
.tip em { font-style: normal; color: var(--muted); }

.toast {
  position: fixed; left: 50%; top: calc(var(--gutter) + var(--safe-t)); transform: translate(-50%, -8px); padding: var(--sp-2) var(--sp-3);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-base), transform var(--dur-base); z-index: 6;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.plate .toast { top: calc(var(--plate-top) + var(--sp-4)); left: calc((100vw - var(--pw) - var(--plate-right) + var(--plate-x)) / 2); }
body.print .toast { top: auto; bottom: calc(var(--sp-5) + var(--safe-b)); left: calc((100vw - var(--pw) - var(--gutter)) / 2); }

.veil { position: fixed; inset: 0; background: var(--bg); opacity: 0; pointer-events: none; transition: opacity var(--dur-slow) ease; }
.veil.on { opacity: 1; transition: none; }

/* ---------- print mode ---------- */
body.print .brand, body.print .cart, body.print .notes, body.print .coords, body.print .stats,
body.print .intro { display: none !important; }
body.print #rulers { display: block; }
body.print { background: var(--desk); }

/* ---------- first-visit intro ---------- */
/* A typographic card: eyebrow, headline, one short paragraph, three steps as rows,
   then the main action. Text sits at a reading measure; no imagery. */
.intro {
  position: fixed; z-index: 5; width: min(540px, calc(100vw - 2 * var(--sp-4)));
  padding: var(--sp-6) var(--sp-8) var(--sp-6);
  background: var(--bg); color: var(--ink); border: 1px solid var(--ink);
  outline: 1px solid var(--line); outline-offset: 5px;
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, .4);
  user-select: text;
  max-height: calc(100vh - 2 * var(--sp-4)); overflow-y: auto; scrollbar-width: none;
}
.intro-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-5); }
.intro-x {
  width: var(--control-h); height: var(--control-h); border-radius: 50%; margin-right: calc(-1 * var(--sp-3));
  font: 400 16px/1 var(--mono); color: var(--muted); background: none; border: 1px solid transparent; cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.intro-x:hover { color: var(--ink); border-color: var(--line); }
.eyebrow { font-size: var(--fs-micro); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.intro h2 { font: italic 400 var(--fs-display)/1.08 var(--serif); letter-spacing: -0.02em; }
.intro h2 em { color: var(--muted); }
.lede { font: 400 var(--fs-lede)/1.6 var(--serif); color: var(--soft); margin-top: var(--sp-4); }
.lede i { color: var(--ink); }
.place.big input { height: var(--control-h-lg); padding: 0 var(--sp-3); font-size: var(--fs-text); }
.place.big .btn { padding: 0 var(--sp-5); font-size: var(--fs-text); min-height: var(--control-h-lg); }
.intro-foot { display: flex; justify-content: space-between; margin-top: var(--sp-4); }
/* the first step: the tour, then a quieter second way in */
.intro-tour { margin-top: var(--sp-6); gap: var(--sp-2); display: flex; align-items: center; justify-content: center; }
.intro-tour i { font-style: normal; }
.intro-sub { margin-top: var(--sp-2); font: 400 var(--fs-prose)/1.45 var(--serif); color: var(--soft); text-align: center; }
.intro-or { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-6) 0 var(--sp-3); font-size: var(--fs-label); color: var(--muted); }
.intro-or::before, .intro-or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.intro-keys { margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.intro-keys[hidden] { display: none; }
.intro-foot .foot-r { display: flex; gap: var(--sp-4); }

/* ---------- footnotes ---------- */
/* Small numbered markers on the instruments; each opens a two-line note that links to the
   field-guide section explaining it. The panel stays as quiet as it was. */
.fn {
  font: 400 9px/1 var(--mono); color: var(--accent-text); background: none; border: 0;
  padding: 0 2px; margin-left: 1px; vertical-align: super; cursor: pointer; pointer-events: auto;
  transition: color var(--dur-fast);
}
.fn:hover, .fn.on { color: var(--ink); }
.fnote {
  position: fixed; z-index: 9; width: min(280px, calc(100vw - 24px)); padding: var(--sp-3) var(--sp-4) var(--sp-3);
  background: var(--bg); border: 1px solid var(--ink); box-shadow: 0 18px 50px -20px rgba(0, 0, 0, .35);
  animation: rise var(--dur-base) ease both;
}
.fnote p { font: 400 var(--fs-prose)/1.45 var(--serif); color: var(--soft); }
.fnote .fn-h { font: italic 400 var(--fs-heading)/1.2 var(--serif); color: var(--ink); margin-bottom: var(--sp-1); }
.fnote .fn-h .num { font: 400 var(--fs-label) var(--mono); font-style: normal; color: var(--accent-text); margin-right: var(--sp-2); vertical-align: 2px; }
.fnote a { display: inline-block; margin-top: var(--sp-2); color: var(--accent-text); text-decoration: none; font-size: var(--fs-label); }
.fnote a:hover { color: var(--ink); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- field guide contents ---------- */
/* The intro card's sibling: an atlas table of contents. Each chapter shows a tiny live
   window onto the plane; unpublished chapters are listed honestly, a little quieter. */
.contents { width: min(600px, calc(100vw - 2 * var(--sp-4))); }
.contents h2 { font-size: var(--fs-display); }
.toc { list-style: none; margin: var(--sp-6) 0 var(--sp-2); counter-reset: none; }
.toc li { border-top: 1px solid var(--line); }
.toc li:last-child { border-bottom: 1px solid var(--line); }
.toc a, .toc li > div {
  display: grid; grid-template-columns: 52px var(--sp-8) 1fr auto; align-items: center; gap: 0 var(--sp-3);
  padding: var(--sp-3) 0; color: inherit; text-decoration: none;
}
.toc canvas { width: 52px; height: 52px; display: block; border: 1px solid var(--line); transition: border-color var(--dur-fast); }
.toc .num { font: 400 var(--fs-label) var(--mono); color: var(--accent-text); letter-spacing: .08em; text-align: right; }
.toc .ch-t b { display: block; font: italic 400 var(--fs-heading)/1.25 var(--serif); }
.toc .ch-t span { display: block; font: 400 var(--fs-prose)/1.4 var(--serif); color: var(--soft); margin-top: 2px; }
.toc .ch-go { font-size: var(--fs-label); color: var(--muted); white-space: nowrap; }
.toc .live a:hover canvas { border-color: var(--ink); }
.toc .live a:hover .ch-go, .toc .live a:focus-visible .ch-go { color: var(--accent-text); }
.toc .live a:hover b { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.toc .soon canvas { opacity: .45; filter: grayscale(.6); }
.toc .soon .ch-t, .toc .soon .num { opacity: .6; }
.toc .soon .ch-go { font-style: italic; font-family: var(--serif); font-size: var(--fs-text); }

/* ---------- guided tour ---------- */
/* A card that walks the explorer, and a spotlight that glides between the parts it
   talks about. The spotlight never blocks the page: you can drag and click through it. */
.tour-spot {
  position: fixed; left: 0; top: 0; z-index: 4; pointer-events: none; opacity: 0;
  outline: 1px solid var(--accent); outline-offset: 0;
  box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--bg) 58%, transparent);
  transition: transform var(--dur-slow) cubic-bezier(.2, .7, .2, 1), width var(--dur-slow) cubic-bezier(.2, .7, .2, 1),
    height var(--dur-slow) cubic-bezier(.2, .7, .2, 1), opacity var(--dur-base);
}
.tour-spot.on { opacity: 1; }
.tour {
  position: fixed; z-index: 8; width: min(340px, calc(100vw - 2 * var(--sp-4)));
  padding: var(--sp-4) var(--sp-5) var(--sp-4); background: var(--bg); color: var(--ink);
  border: 1px solid var(--ink); outline: 1px solid var(--line); outline-offset: 4px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .4);
  transition: left var(--dur-slow) cubic-bezier(.2, .7, .2, 1), top var(--dur-slow) cubic-bezier(.2, .7, .2, 1);
}
.tour[hidden] { display: none; }
.tour-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-2); }
.tour-top .eyebrow span { color: var(--accent-text); }
.tour h3 { font: italic 400 var(--fs-title)/1.12 var(--serif); letter-spacing: -0.01em; font-weight: 400; }
.tour-body { font: 400 var(--fs-prose)/1.5 var(--serif); color: var(--soft); margin-top: var(--sp-2); }
.tour.in h3, .tour.in .tour-body { animation: rise var(--dur-slow) ease both; }
.tour.in .tour-body { animation-delay: 60ms; }
.tour-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); margin-top: var(--sp-4); }
.tour-dots { display: flex; gap: 7px; }
/* each step is a small rhombus: hollow ahead, inked behind, accent where you are */
.tour-dots button {
  width: 7px; height: 7px; padding: 0; border: 1px solid var(--line-2); background: none; cursor: pointer;
  transform: rotate(45deg); transition: background var(--dur-fast), border-color var(--dur-fast);
}
.tour-dots button.done { background: var(--ink); border-color: var(--ink); }
.tour-dots button.on { background: var(--accent); border-color: var(--accent); }
.tour-nav { display: flex; align-items: center; gap: var(--sp-4); }
.tour-nav .btn { padding: 0 var(--sp-4); min-height: var(--control-h-md); display: inline-flex; align-items: center; text-decoration: none; }
.tour.last .tour-foot { flex-wrap: wrap; }
.tour.last .tour-dots { display: none; }
.tour.last .tour-nav { width: 100%; justify-content: space-between; }
body.touring .tipline { visibility: hidden; }

/* ---------- reduced motion: keep the state changes, drop the movement ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* the bottom-sheet bar exists only on phones */
.sheet-bar { display: none; }

@media (max-width: 680px) {
  :root { --pw: auto; --fs-brand: 26px; --fs-display: 29px; --fs-lede: 15.5px; }
  .brand { top: calc(var(--sp-3) + var(--safe-t)); left: calc(var(--sp-3) + var(--safe-l)); padding: var(--sp-3) var(--sp-3) var(--sp-2); }
  /* the panel becomes a bottom sheet: collapsed to its bar, open to most of the screen */
  .panel {
    top: auto; bottom: calc(var(--sp-3) + var(--safe-b)); right: calc(var(--sp-3) + var(--safe-r)); left: calc(var(--sp-3) + var(--safe-l)); width: auto;
    max-height: 52px; overflow: hidden; transition: max-height var(--dur-base) ease;
    box-shadow: 0 -10px 30px -18px rgba(0, 0, 0, .35);
  }
  .panel.open { max-height: 72vh; max-height: 72dvh; overflow-y: auto; }
  /* making something: the preview takes the top half, so the open sheet stops below it */
  body.print .panel.open { max-height: 46vh; max-height: 46dvh; }
  .sheet-bar {
    display: flex; align-items: center; gap: var(--sp-2); height: 52px; padding: 0 var(--sp-3) 0 0;
    position: sticky; top: 0; z-index: 1; background: var(--panel); border-bottom: 1px solid var(--line);
  }
  .sheet-grab {
    flex: 1; align-self: stretch; display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-4);
    font: inherit; color: var(--ink); background: none; border: 0; cursor: pointer; touch-action: none;
  }
  .sheet-grab i { width: 28px; height: 3px; border-radius: 2px; background: var(--line-2); flex: none; }
  .sheet-grab span::after { content: ' ▴'; color: var(--muted); }
  .panel.open .sheet-grab span::after { content: ' ▾'; }
  .sheet-bar .btn { min-height: var(--control-h); padding: 0 var(--sp-3); }
  .panel .view-explore > section:first-child { border-top: 0; }
  .coords, .stats { display: none; }
  #pad { height: 84px; }
  .panel section { padding: var(--sp-3) var(--sp-4); }
  .intro { padding: var(--sp-5); }
  .intro-x { margin-right: calc(-1 * var(--sp-2)); }
  .contents h2 { font-size: var(--fs-display); }
  .toc a, .toc li > div { grid-template-columns: 44px 1fr; }
  .toc canvas { width: 44px; height: 44px; grid-row: span 2; }
  .toc .num { display: none; }
  .toc .ch-go { grid-column: 2; }
}

/* ---------- looks: named combinations, the controls folded under "adjust" ---------- */
.looks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.looks button {
  display: flex; flex-direction: column; padding: 0; overflow: hidden; cursor: pointer;
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
}
.looks canvas { display: block; width: 100%; height: 38px; }
.looks span { padding: 3px 2px; font-size: var(--fs-micro); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 1px solid var(--line); }
.looks button:hover { border-color: var(--line-2); }
.looks button.on { border-color: var(--ink); }
.looks button.on span { background: var(--ink); color: var(--bg); border-top-color: var(--ink); }
.link.shuffle { margin-top: var(--sp-2); font-size: var(--fs-label); }
/* the Make view's eighth tile: shuffle */
.looks .shuffle-tile { align-items: stretch; }
.looks .shuffle-tile i { display: flex; align-items: center; justify-content: center; height: 38px; font-style: normal; font-size: 20px; color: var(--muted); }
.looks .shuffle-tile:hover i { color: var(--ink); }
.link.shuffle i { font-style: normal; margin-right: var(--sp-1); }
.adjust { margin-top: var(--sp-4); border-top: 1px solid var(--line); }
.adjust summary {
  display: flex; align-items: baseline; gap: var(--sp-2); padding-top: var(--sp-3); cursor: pointer; list-style: none;
  font-size: var(--fs-label); color: var(--ink);
}
.adjust summary::-webkit-details-marker { display: none; }
.adjust summary::before { content: '▸'; display: inline-block; color: var(--muted); transition: transform var(--dur-fast); }
.adjust[open] summary::before { transform: rotate(90deg); }
.adjust summary span { color: var(--muted); font-size: var(--fs-micro); }
.adjust summary:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }
.adjust > .field:first-of-type { margin-top: var(--sp-3); }

/* read out, not shown */
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- share & save menu ---------- */
.menu {
  position: fixed; z-index: 7; width: 248px; padding: var(--sp-1); background: var(--bg); color: var(--ink);
  border: 1px solid var(--ink); box-shadow: 0 18px 50px -20px rgba(0, 0, 0, .35);
  animation: rise var(--dur-base) ease both;
}
.menu[hidden] { display: none; }
.menu button {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: var(--sp-2) var(--sp-3);
  font: inherit; font-size: var(--fs-text); color: var(--ink); text-align: left; background: none; border: 0; cursor: pointer;
}
.menu button[hidden] { display: none; }
/* (older browsers without color-mix get the plain line colour) */
.menu button:hover, .menu button:focus-visible { background: var(--line); background: color-mix(in srgb, var(--ink) 7%, var(--bg)); outline: none; }
.menu button span { display: flex; flex-direction: column; gap: 2px; }
.menu small { font-size: var(--fs-micro); color: var(--muted); }

/* ---------- the Make view ---------- */
/* what you're making: four tabs under the heading */
.kinds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: var(--sp-4); border: 1px solid var(--line); background: var(--line); }
.kinds button {
  font: inherit; font-size: var(--fs-label); color: var(--ink); background: transparent; cursor: pointer;
  min-height: var(--control-h-lg); border: 0; padding: 0 var(--sp-3); background: var(--panel);
  display: flex; align-items: center; gap: var(--sp-2); text-align: left; white-space: nowrap; overflow: hidden;
}
.kinds button span { overflow: hidden; text-overflow: ellipsis; }
.ico { flex: none; display: block; }
.kinds button:hover { background: var(--line); background: color-mix(in srgb, var(--ink) 6%, var(--panel)); }
.kinds button.on { background: var(--ink); color: var(--bg); }
/* only the current kind's sections and fields */
.view-print [hidden] { display: none !important; }
/* the explore panel's way in: one button, and the four kinds as icon shortcuts */
.makes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-1); margin-top: var(--sp-2); }
.makes button {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: var(--sp-2) 2px var(--sp-1);
  font: inherit; font-size: var(--fs-micro); color: var(--muted); background: none; border: 1px solid transparent; cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.makes button .ico { color: var(--ink); }
.makes button:hover { color: var(--ink); border-color: var(--line); }

