/* ==== Vivi site design system (docs/website-art-direction.md, "Design system"). Living page: dev/ds.html.
   One file for the site's OWN components (not the One UI screens inside the phones, not the laptop's KDE chrome).
   Palette tokens (--paper, --raised, --card, --track, --ink*, --accent*, --line*) stay in css/site.css :root; this file
   adds the UI tier on top of them: spacing, radii, type roles, surfaces, elevation, motion, focus, and the primitives
   (.ds-note, .ds-label / .ds-hint / .ds-fine, .ds-seg, .ds-btn, .ds-chip, .ds-bubble, .ds-card, .ds-tooltip,
   .ds-dialog). Existing component classes (.ways-notice, .ui-perm, .vivi-say, .vm, ...) consume the same tokens.

   Cascade: the whole site is unlayered CSS, so this file is unlayered too and is linked right after site.css; the
   section files after it may only add placement (position, width, grid) to a primitive, never its look.

   One design, every surface: a primitive never gets a per-surface colour. On the dark #work stage it takes
   `.ds-dark` (color-scheme: dark), so the same light-dark() tokens resolve to basalt; the receipt slip takes
   color-scheme: light. Never pass colours to rubberSegment() / permissionToggle() on the site. */

:root {
  /* spacing: a 4 px base */
  --ds-1: 4px; --ds-2: 8px; --ds-3: 12px; --ds-4: 16px; --ds-5: 20px; --ds-6: 24px; --ds-8: 32px;
  /* radii. Nested: a shape inset in another (thumb in track, fill in button) = outer - inset */
  --ds-r-xs: 6px;      /* focus ring on text, small inset fills */
  --ds-r-sm: 10px;     /* static badges, catalog thumbnails */
  --ds-r-md: 14px;     /* segmented tracks, tooltips, small cards, speech bubbles from Vivi */
  --ds-r-lg: 20px;     /* notes, cards */
  --ds-r-xl: var(--r-outer);  /* dialogs (22 px) */
  --ds-r-pill: 999px;  /* every button and chip */
  /* type roles (no eyebrows, sentence case). Sizes in rem; display headings keep site.css --step-* */
  --ds-title: 400 1.05rem/1.25 var(--font-accent, var(--font));   /* card titles in Boxing (founder 2026-11-27) */
  --ds-title-track: -0.01em;
  --ds-body: 400 0.95rem/1.45 var(--font);
  --ds-label: 600 0.85rem/1.3 var(--font);
  --ds-hint: 400 0.85rem/1.4 var(--font);
  --ds-fine: 400 0.85rem/1.4 var(--font);
  --ds-control: 500 0.92rem/1 var(--font);
  /* type D (founder, 2026-11-26): the lead is Stack Sans Headline Light, the tag is Geist Mono. Display headings use
     --font-display (Stack Sans Notch, site.css) at --step-3 and up only */
  --ds-lead: var(--lead-wght) var(--step-1)/var(--lead-lh) var(--font-lead);
  --ds-tag: 400 0.78rem/1 var(--mono);
  /* surfaces: a note or card sits a step lighter than the page in both themes; floating UI is lighter still */
  --ds-surface: var(--raised);
  --ds-surface-float: var(--card);
  --ds-sunken: var(--track);
  --ds-soft: color-mix(in oklch, var(--ink) 7%, transparent);      /* soft fill: secondary buttons, chips */
  --ds-soft-hover: color-mix(in oklch, var(--ink) 11%, transparent);
  --ds-border: var(--line-2);
  --ds-divider: var(--line);
  /* elevation: flat things (notes, cards, bubbles) have an alpha border and no shadow; floating things (tooltips,
     menus, dialogs) add the layered warm shadow, which is transparent on basalt (depth there = lighter surface) */
  --ds-elev-0: none;
  --ds-elev-float: var(--shadow-raised);
  --ds-backdrop: oklch(0.15 0.01 60 / 0.45);
  /* segmented control (RubberSegment): a sunken track, an ink thumb, paper text on it */
  --ds-seg-track: var(--track);
  --ds-seg-thumb: var(--ink);
  --ds-seg-ink: var(--ink);
  --ds-seg-ink-on: var(--paper);
  /* focus ring: one for the whole site */
  --ds-focus-w: 2px;
  --ds-focus-c: var(--accent);
  --ds-focus-offset: 3px;
  /* motion (docs/research/micro-interactions.md, animation-principles.md) */
  --ds-t-press: 150ms;     /* press: scale(var(--press)) = 0.97, ease-out */
  --ds-t-hover: 150ms;
  --ds-t-enter: 280ms;     /* entrances: from opacity 0, scale 0.97, 6 px, var(--ease-enter) */
  --ds-t-exit: 160ms;      /* exits: shorter, var(--ease-exit) */
  --ds-t-swap: 180ms;      /* text swaps: crossfade + 4 px blur */
  --ds-stagger: 120ms;     /* a follower waits this long after its leader */
  --ds-enter-y: 6px;
  /* widths */
  --ds-note-w: 22rem;      /* a note beside a device: same width wherever it appears, so it wraps the same */
}

/* ---- surface context: a subtree that is always dark (the #work stage) or always light (the receipt slip).
   The element must paint its own background (modern-web-guidance: component-specific color-scheme). */
.ds-dark { color-scheme: dark; color: var(--ink); }
.ds-light { color-scheme: light; color: var(--ink); }

/* ---- type roles */
.ds-title { font: var(--ds-title); letter-spacing: var(--ds-title-track); color: var(--ink); text-wrap: balance; }
.ds-body { font: var(--ds-body); color: var(--ink-2); }
.ds-label { margin: 0; font: var(--ds-label); color: var(--ink); }
.ds-hint { margin: 0; font: var(--ds-hint); color: var(--ink-2); }
.ds-fine { margin: 0; font: var(--ds-fine); color: var(--ink-3); }

/* ---- note: the site speaking to the visitor (title, body, an optional control with its label and hint) */
.ds-note {
  display: grid; gap: var(--ds-2); padding: var(--ds-4) var(--ds-5) var(--ds-4);
  border: 1px solid var(--ds-border); border-radius: var(--ds-r-lg); background: var(--ds-surface); box-shadow: var(--ds-elev-0);
  color: var(--ink); font-family: var(--font); text-align: start;
  > :where(p) { margin: 0; }
  > .ds-title + .ds-body { margin-top: calc(var(--ds-1) * -1); }
  > :where(.ui-perm, .ds-note-control) { margin-top: var(--ds-1); }
}
/* compact: tighter type and padding; the control's visible label folds away (the title already says it), its hint
   stays as the feedback line. --compact always; --compact-auto where space is short: phones (< 900 px, the site's
   breakpoint) and short screens (< 720 px tall, e.g. a 1430 x 654 laptop at 133 %), so a note never squeezes a device */
.ds-note--compact {
  gap: var(--ds-1); padding: var(--ds-3) var(--ds-4);
  --ds-title: 600 1rem/1.25 var(--font); --ds-body: 400 0.88rem/1.4 var(--font); --ds-hint: 400 0.82rem/1.35 var(--font);
  > .ds-title + .ds-body { margin-top: 0; }
  > :where(.ui-perm, .ds-note-control) { margin-top: var(--ds-1); }
  :where(.ui-perm) { gap: var(--ds-1); }
  :where(.ui-perm-label) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  :where(.ui-perm-desc) { min-height: 0; }
  :where(.ds-note-more) { display: none; }
}
@media (width < 900px), (height < 720px) {
  .ds-note--compact-auto {
    gap: var(--ds-1); padding: var(--ds-3) var(--ds-4);
    --ds-title: 600 1rem/1.25 var(--font); --ds-body: 400 0.88rem/1.4 var(--font); --ds-hint: 400 0.82rem/1.35 var(--font);
    > .ds-title + .ds-body { margin-top: 0; }
    > :where(.ui-perm, .ds-note-control) { margin-top: var(--ds-1); }
    :where(.ui-perm) { gap: var(--ds-1); }
    :where(.ui-perm-label) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    :where(.ui-perm-desc) { min-height: 0; }
    :where(.ds-note-more) { display: none; }
  }
}

/* ---- segmented control: the look of every RubberSegment on the site (js/ui/rubber-segment.js reads these through
   --rs-*; css/ui.css falls back to React Bits' own colours only where no token exists) */
.ds-seg {
  --rs-track: var(--ds-seg-track); --rs-thumb: var(--ds-seg-thumb); --rs-ink: var(--ds-seg-ink); --rs-ink-active: var(--ds-seg-ink-on);
  font-family: var(--font);
  .ui-rubber-segment__item:focus-visible { outline: var(--ds-focus-w) solid var(--ds-focus-c); outline-offset: var(--ds-focus-offset); }
}

/* ---- buttons: pills. primary = filled glacier (the one action), secondary = soft fill, quiet = text until hovered.
   Sizes: sm 2.25rem, md 2.75rem, lg 3.25rem (touch: never under the 44 px target) */
:is(.ds-btn, .btn) {
  --h: 2.75rem; --bg: var(--ds-soft); --bg-hover: var(--ds-soft-hover); --fg: var(--ink); --fg-hover: var(--fg);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--ds-2);
  min-height: max(var(--h), var(--target)); padding: 0 1.25rem;
  border: 0; border-radius: var(--ds-r-pill); background: var(--bg); color: var(--fg);
  font: var(--ds-control); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color var(--ds-t-hover) ease-out, color var(--ds-t-hover) ease-out, scale var(--ds-t-press) ease-out;
  &:hover:not(:disabled) { background: var(--bg-hover); color: var(--fg-hover); }
  &:active:not(:disabled) { scale: var(--press); }
  &:disabled { opacity: 0.5; cursor: not-allowed; }
}
:is(.ds-btn--primary, .btn-primary) { --bg: var(--accent); --bg-hover: var(--accent-hover); --fg: var(--accent-ink); }
:is(.ds-btn--quiet, .btn-ghost) { --bg: transparent; --bg-hover: color-mix(in oklch, var(--ink) 6%, transparent); --fg: var(--ink-2); --fg-hover: var(--ink); }
.btn-dark { --bg: var(--ink); --bg-hover: color-mix(in oklch, var(--ink) 86%, var(--paper)); --fg: var(--paper); }
:is(.ds-btn--sm, .btn-sm) { --h: 2.25rem; padding-inline: 1rem; font-size: 0.88rem; }
:is(.ds-btn--lg) { --h: 3.25rem; padding-inline: 1.5rem; font-size: 1.0625rem; }

/* ---- chips: a count or status. Static badges are soft rounded rects; a chip that floats on the page (and opens
   something) is a pill on the floating surface */
.ds-chip {
  display: inline-flex; align-items: center; gap: var(--ds-1); padding: 0.3rem 0.6rem; border-radius: var(--ds-r-sm);
  background: var(--ds-soft); color: var(--ink-2); font: 500 0.8rem/1.2 var(--font); font-variant-numeric: tabular-nums; white-space: nowrap;
}
/* ---- bracket tag: a technical label in mono, in brackets ("[ S21 FE ]"): a device model, a version, a build. Quiet
   (ink-3), never a control, at most one per row of chips. The brackets are CSS (empty alt text), so the label is read
   without them */
.ds-tag { display: inline-flex; align-items: center; gap: 0.35em; font: var(--ds-tag); letter-spacing: -0.01em; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums;
  &::before { content: "[" / ""; } &::after { content: "]" / ""; } }
/* ---- sticker: one tilted glacier pill that marks the one new or live thing on screen ("v0.8", "New"). At most ONE per
   view (a design rule; CSS cannot count): two stickers are decoration, one is a signal. It sits on a heading's last line
   or a card's corner, never over body text, and does not move */
.ds-sticker { display: inline-block; padding: 0.35rem 0.7rem; border-radius: var(--ds-r-pill); background: var(--accent); color: var(--accent-ink);
  font: 600 0.8rem/1 var(--font); letter-spacing: 0; white-space: nowrap; rotate: -7deg; vertical-align: super; }
.ds-lead { margin: 0; font: var(--ds-lead); letter-spacing: var(--lead-track); color: var(--ink-2); text-wrap: pretty; }
.ds-chip--accent { background: var(--accent-soft); color: light-dark(oklch(0.38 0.08 var(--glacier-h)), oklch(0.88 0.05 var(--glacier-h))); }
.ds-chip--float {
  padding: 0.4rem 0.75rem; border-radius: var(--ds-r-pill); border: 1px solid var(--ds-border); background: var(--ds-surface-float); color: var(--ink);
  cursor: pointer; transition: background-color var(--ds-t-hover) ease-out, scale var(--ds-t-press) ease-out;
  &:hover { background: var(--paper-2); }
  &:active { scale: var(--press); }
}

/* labels optically centred in their pills (typography-details tip 2). Buttons (height set by min-height) trim the line
   box to cap height and baseline. Chips and the sticker don't need to: Stack Sans's line box (ascent 1.0, descent 0.3)
   puts the cap-height centre exactly on the line box's centre, so symmetric padding already centres it, and trimming
   would shrink chips that carry an icon */
@supports (text-box: trim-both cap alphabetic) {
  .ds-btn { text-box: trim-both cap alphabetic; }
}

/* ---- speech bubbles: who is talking. Vivi = floating surface with an alpha edge; you = the page's sunken tone.
   The tail is one tighter corner on the speaker's side */
.ds-bubble {
  margin: 0; padding: 0.55rem 0.9rem; border-radius: var(--ds-r-lg);
  font: 400 0.95rem/1.4 var(--font); text-wrap: pretty;
  > b { display: block; margin-bottom: 2px; font: var(--ds-label); font-weight: 500; color: var(--ink-2); }
}
.ds-bubble--vivi { background: var(--ds-surface-float); color: var(--ink); border: 1px solid var(--ds-border); border-start-start-radius: var(--ds-r-xs); }
.ds-bubble--you { background: var(--paper-2); color: var(--ink); border-end-end-radius: var(--ds-r-xs); }

/* ---- card: content that belongs together (common region). Flat: alpha border, no shadow */
.ds-card {
  display: grid; gap: var(--ds-2); padding: var(--ds-4);
  border: 1px solid var(--ds-divider); border-radius: var(--ds-r-lg); background: var(--ds-surface-float); color: var(--ink);
}
.ds-card--sm { padding: var(--ds-2); border-radius: var(--ds-r-md); background: var(--ds-surface); }
/* Magic Card (Magic UI, js/ui/magic-card.js): the one hover treatment for a product card. A soft glacier light follows
   the pointer around the 1 px border, and a faint ink spotlight fades in on the face (300 ms). No glow, no motion of the
   card itself; still under reduced motion / Pause motion (the script stops tracking, the border is the plain divider). */
.ds-card--magic {
  --mc-size: 200px; --mc-x: -200px; --mc-y: -200px;
  --mc-from: color-mix(in oklch, var(--accent) 70%, transparent); --mc-to: color-mix(in oklch, var(--accent) 22%, var(--ds-divider));
  --mc-color: color-mix(in oklch, var(--ink) 5%, transparent); --mc-opacity: 0.8;
  position: relative; isolation: isolate; border-color: transparent;
  background:
    linear-gradient(var(--ds-surface-float) 0 0) padding-box,
    radial-gradient(var(--mc-size) circle at var(--mc-x) var(--mc-y), var(--mc-from), var(--mc-to), var(--ds-divider) 100%) border-box;
  &::after {
    content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none; opacity: 0;
    background: radial-gradient(var(--mc-size) circle at var(--mc-x) var(--mc-y), var(--mc-color), transparent 100%);
    transition: opacity 300ms;
  }
  &:hover::after { opacity: var(--mc-opacity); }
}

/* ---- tooltip (popover="manual", role="tooltip"): floating, site type, enters from 0.97 */
.ds-tooltip {
  width: min(17rem, calc(100vw - 16px)); margin: 0; padding: var(--ds-3) var(--ds-4);
  border: 1px solid var(--ds-border); border-radius: var(--ds-r-md); background: var(--ds-surface-float); color: var(--ink); box-shadow: var(--ds-elev-float);
  font: 400 0.85rem/1.4 var(--font); text-align: start;
}

/* ---- dialog (native <dialog> + showModal) */
.ds-dialog {
  padding: 0; border: 1px solid var(--ds-border); border-radius: var(--ds-r-xl);
  background: var(--ds-surface-float); color: var(--ink); box-shadow: var(--ds-elev-float); font-family: var(--font);
  &:modal { overscroll-behavior: contain; }
  &::backdrop { background: var(--ds-backdrop); overscroll-behavior: contain; }
}

/* ---- entrance / exit for anything that appears (notes, bubbles, tooltips): 0.97 + 6 px + fade, staged */
@media (prefers-reduced-motion: no-preference) {
  html:not([data-motion="off"]) .ds-tooltip:not([data-still]):is(:popover-open, .\:popover-open) {
    transition: opacity var(--ds-t-enter) var(--ease-enter), translate var(--ds-t-enter) var(--ease-enter), scale var(--ds-t-enter) var(--ease-enter);
    @starting-style { opacity: 0; translate: 0 4px; scale: 0.97; }
  }
}

/* ==== Intelligent UI over text blocks (founder rule, docs/website-art-direction.md): explanations on the site are
   shown as the UI Vivi itself would answer with, not as paragraphs. Primitives mapped from the assistant-ui ports
   (js/ui/aui-elements.js; reference build: #status, css/status.css). Markup for each is on dev/ds.html. */

/* ---- answer: the visitor's question as a "you" bubble, then Vivi's orb and one spoken line (st-ask / st-turn) */
.ds-answer { display: grid; gap: var(--ds-3); }
.ds-answer > .ds-bubble--you { justify-self: end; max-inline-size: 80%; color: var(--ink-2); }
.ds-turn { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--ds-3); align-items: start; }
.ds-turn > .vivi-orb { --orb-size: 32px; margin-top: 0.1rem; }
.ds-turn > p { margin: 0; font: 400 var(--step-1)/1.45 var(--font); color: var(--ink); text-wrap: pretty; }

/* ---- fact card: key on the left, value right-aligned in tabular figures (AgentCard specs; visual tip 17) */
.ds-facts { margin: 0; display: grid; font: 400 0.92rem/1.35 var(--font); }
.ds-facts > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--ds-4); padding-block: 0.32rem; border-top: 1px solid var(--ds-divider); }
.ds-facts > div:first-child { border-top: 0; padding-top: 0; }
.ds-facts dt { flex: none; color: var(--ink-3); }
.ds-facts dd { margin: 0; min-width: 0; color: var(--ink); text-align: end; font-variant-numeric: tabular-nums; text-wrap: balance; }

/* ---- plan: steps on a line, done / active / next (assistant-ui AgentPlan + design "Steps"). Calm (founder, 2026-11-26):
   uniform 20 px marks (done: filled glacier with a check; active: glacier ring with a small turning arc; next: a quiet
   hollow ring), one thin line in segments BETWEEN the marks with a gap round each, no tiles behind steps, labels in one
   weight, the "when" in the hint role (glacier only while active). Markup: <li data-status="done|active|next">
   <span class="ds-plan-mark"></span><span>label <span class="ds-plan-sub">optional sub line</span></span>
   <span class="ds-plan-when">when</span></li>. Vertical by default; .ds-plan--across lays the steps in one row. */
.ds-plan { --mk: 20px; --mk-gap: 4px; list-style: none; margin: 0; padding: 0; display: grid; }
.ds-plan > li {
  position: relative; display: grid; grid-template-columns: var(--mk) minmax(0, 1fr) auto; column-gap: var(--ds-3); align-items: start;
  padding-block: var(--ds-3); font: 400 0.95rem/var(--mk) var(--font); color: var(--ink);
}
.ds-plan > li > :nth-child(2) { min-width: 0; text-wrap: pretty; }
.ds-plan-sub { display: block; margin-top: 2px; font: var(--ds-hint); color: var(--ink-3); }
.ds-plan-when { font: var(--ds-hint); line-height: var(--mk); color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ds-plan > [data-status="active"] .ds-plan-when { color: var(--accent); }
/* the line: from below one mark to above the next, a gap at both ends */
.ds-plan > li:not(:last-child)::before {
  content: ""; position: absolute; inline-size: 1px; background: var(--ds-border); pointer-events: none;
  inset-inline-start: calc(var(--mk) / 2 - 0.5px); top: calc(var(--ds-3) + var(--mk) + var(--mk-gap)); bottom: calc(var(--mk-gap) - var(--ds-3));
}
/* the marks */
.ds-plan-mark { position: relative; display: grid; place-items: center; inline-size: var(--mk); block-size: var(--mk); border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--ds-border); }
.ds-plan > [data-status="done"] .ds-plan-mark { background: var(--accent); box-shadow: none; }
.ds-plan > [data-status="done"] .ds-plan-mark::after { content: ""; inline-size: 12px; block-size: 12px; background: var(--accent-ink);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat; }
.ds-plan > [data-status="active"] .ds-plan-mark { box-shadow: inset 0 0 0 1.5px var(--accent); }
.ds-plan > [data-status="active"] .ds-plan-mark::after { content: ""; inline-size: 10px; block-size: 10px; box-sizing: border-box; border-radius: 50%;
  border: 1.5px solid transparent; border-block-start-color: var(--accent); border-inline-end-color: var(--accent); rotate: 45deg; }
@media (prefers-reduced-motion: no-preference) {
  html:not([data-motion="off"]) .ds-plan > [data-status="active"] .ds-plan-mark::after { animation: ds-turn 1.2s linear infinite; }
}
@keyframes ds-turn { from { rotate: 45deg; } to { rotate: 405deg; } }
/* pixel light (js/ui/component-fx.js): when a mark carries a pixel effect ([data-pfx]: the pixel loader, the pixel check,
   the quiet pixel ring), its canvas draws the whole mark, so the CSS ring, fill and arc step aside. Without JS, in
   forced colours or before the script runs, the CSS mark above is what shows. */
.ds-plan > li > .ds-plan-mark[data-pfx] { background: none; box-shadow: none; }
.ds-plan > li > .ds-plan-mark[data-pfx]::after { content: none; }
/* a segmented control while its pixel light plays: the track's canvas sits under the thumb (its own stacking context),
   the thumb's canvas under the thumb's words */
.ds-seg[data-pfx] { isolation: isolate; }
.ds-seg[data-pfx] .ui-rubber-segment__copy { z-index: 1; }
/* one row of equal steps: mark, then label and sub, then when; the line runs between the marks on their centre */
.ds-plan--across { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.ds-plan--across > li { grid-template-columns: minmax(0, 1fr); row-gap: var(--ds-2); align-content: start; padding: 0 var(--ds-4) 0 0; }
.ds-plan--across > li:not(:last-child)::before { inline-size: auto; block-size: 1px; top: calc(var(--mk) / 2 - 0.5px); bottom: auto;
  inset-inline-start: calc(var(--mk) + var(--mk-gap)); inset-inline-end: var(--mk-gap); }
.ds-plan--across .ds-plan-when { line-height: 1.4; margin-top: calc(-1 * var(--ds-1)); }

/* ---- receipt: what Vivi did, on thermal paper (always paper, mono, perforated edges) */
.ds-receipt {
  --edge: radial-gradient(circle at 7px 0, transparent 5px, #000 5.5px) top / 14px 10px repeat-x, radial-gradient(circle at 7px 10px, transparent 5px, #000 5.5px) bottom / 14px 10px repeat-x, linear-gradient(#000, #000) center / 100% calc(100% - 18px) no-repeat;
  color-scheme: light; display: grid; gap: var(--ds-2); padding: var(--ds-6) var(--ds-5); mask: var(--edge);
  background: var(--receipt); color: var(--receipt-ink); font: 400 0.85rem/1.5 var(--mono);
  > :where(p, h3) { margin: 0; }
  > h3 { font: 600 0.95rem/1.3 var(--mono); color: var(--receipt-ink); }
  .ds-receipt-row { display: flex; justify-content: space-between; gap: var(--ds-4); font-variant-numeric: tabular-nums; }
  .ds-receipt-rule { border-top: 1px dashed oklch(0.3 0.02 60 / 0.4); }
}

/* ---- action row: what you can do next, as a row of small pills (memory chips, suggestion chips). It scrolls
   sideways on narrow screens with an edge fade (craft rule 6) instead of wrapping into a block */
.ds-actions {
  display: flex; gap: var(--ds-2); margin: 0; padding: 2px; list-style: none; overflow-x: auto; scrollbar-width: none;
  mask: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  > :where(li) { flex: none; }
  :where(button, a) { min-height: max(2.25rem, var(--target)); }
}

/* ==== Library primitives (founder, 2026-11-26: "not all the components got replaced with proper components from Magic UI
   or React Bits"). Each is a faithful port, restyled to the palette; sources and licences in js/ui/CREDITS.md. Static
   under reduced motion and the site's Pause motion (html[data-motion="off"]): final states, no movement. */

/* ---- status chip: .ds-chip[data-state] = an icon that says the state + a label that says it in words.
   done = pixel check (component-fx draws lucide's check in); active = the pixel loader (component-fx swaps lucide's
   loader for it) + a shimmer through the label; live = a dot with a calm ripple + shimmer; next = a quiet pixel ring.
   Markup: <span class="ds-chip" data-state="active">${luc("loader")}<span class="ds-shiny">In testing</span></span> */
:root { --ds-chip: 550 0.8125rem/1.25 var(--font); --ds-chip-track: -0.004em; }
.ds-chip[data-state] {
  gap: 0.4rem; min-block-size: 1.75rem; padding: 0.25rem 0.7rem 0.25rem 0.55rem;
  font: var(--ds-chip); letter-spacing: var(--ds-chip-track); color: var(--ink);
  > svg.aui-i { inline-size: 0.95em; block-size: 0.95em; flex: none; stroke-width: 2.4; }
  > .pfx-slot { flex: none; }
}
.ds-chip[data-state].ds-chip--accent { color: light-dark(oklch(0.36 0.08 var(--glacier-h)), oklch(0.9 0.045 var(--glacier-h))); }
.ds-chip[data-state="done"] > svg.aui-i { color: var(--accent); }
/* next: a hollow ring (component-fx draws it as the quiet pixel ring, the same as a .ds-plan "next" mark) */
.ds-chip-ring { position: relative; flex: none; inline-size: 0.8em; block-size: 0.8em; border-radius: 50%; box-shadow: inset 0 0 0 1.5px color-mix(in oklch, currentColor 45%, transparent); }
.ds-chip-ring[data-pfx] { box-shadow: none; }
/* live: Magic UI Pulsating Button's "ripple" variant on a dot (keyframes pulse-ripple: a ring that grows to
   --distance and fades, --duration 1.5s, cubic-bezier(0.16, 1, 0.3, 1)) */
.ds-chip-dot { --distance: 5px; --duration: 1.5s; flex: none; inline-size: 0.45rem; block-size: 0.45rem; margin-inline: 0.15em; border-radius: 50%; background: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  html:not([data-motion="off"]) .ds-chip-dot { animation: ds-pulse-ripple var(--duration) cubic-bezier(0.16, 1, 0.3, 1) infinite; }
}
@keyframes ds-pulse-ripple {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 100%, transparent); }
  100% { box-shadow: 0 0 0 var(--distance) color-mix(in oklch, var(--accent) 0%, transparent); }
}

/* ---- shiny label: Magic UI Animated Shiny Text (https://magicui.design/r/animated-shiny-text.json). The label at 70 %
   of its colour, a --shiny-width band of the full ink clipped to the glyphs, panning across: keyframes shiny-text
   (0/90/100 % off the left, 30-60 % off the right), 8 s, infinite. Vivi changes: the band is the theme's ink (the
   source's black/80 and white/80), the resting colour 72 % of currentColor so small labels keep 4.5:1; still, the
   band rests off the label (the source parks it on the first 100 px). */
.ds-shiny {
  --shiny-width: 100px;
  color: color-mix(in oklch, currentColor 72%, transparent);
  background: linear-gradient(to right, transparent, color-mix(in oklch, var(--ink) 80%, transparent) 50%, transparent) no-repeat;
  background-size: var(--shiny-width) 100%; background-position: calc(-100% - var(--shiny-width)) 0;
  -webkit-background-clip: text; background-clip: text;
}
@media (prefers-reduced-motion: no-preference) {
  html:not([data-motion="off"]) .ds-shiny { animation: ds-shiny-text 8s infinite; }
}
@keyframes ds-shiny-text {
  0%, 90%, 100% { background-position: calc(-100% - var(--shiny-width)) 0; }
  30%, 60% { background-position: calc(100% + var(--shiny-width)) 0; }
}
@media (forced-colors: active) { .ds-shiny { color: CanvasText; background: none; } }

/* ---- spec tiles: key/value facts as Magic UI Bento Grid cells (https://magicui.design/r/bento-grid.json: BentoGrid's
   grid + gap, BentoCard's icon / name / description stack and its hover tint, group-hover:bg-black/3) in place of the
   hairline rows. A tile = a soft cell, a 16 px Lucide icon with the key beside it, the value under them. Same <dl>
   markup as .ds-facts (dt + dd per <div>), so the component-fx fact light ([data-on]) still finds its rows; a lit row
   takes the glacier soft fill. Entrances: Magic UI Blur Fade (js/ui/blur-fade.js, [data-blur-fade]). */
.ds-facts.ds-facts--bento {
  --fact-pad: 0px;   /* component-fx's fact light fills the tile itself, no outset */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--bento-min, 8rem)), 1fr)); gap: var(--ds-2);
  font: 400 0.92rem/1.3 var(--font); isolation: isolate;
  &::before { content: none; }
}
.ds-facts.ds-facts--bento > div {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; align-content: start;
  column-gap: 0.4rem; row-gap: 0.55rem; padding: 0.75rem 0.75rem 0.7rem; border: 0; border-radius: var(--ds-r-sm);
  background: var(--ds-soft); transition: background-color 300ms var(--ease-out);
  > .aui-i { grid-area: 1 / 1; inline-size: 0.95rem; block-size: 0.95rem; stroke-width: 2; color: var(--ink-3); transition: color 300ms var(--ease-out); }
  > dt { grid-area: 1 / 2; min-inline-size: 0; font: var(--ds-hint); font-size: 0.8rem; color: var(--ink-3); white-space: nowrap; }   /* no overflow clip: its box is cap-trimmed, a clip would cut descenders */
  > dd { grid-area: 2 / 1 / 3 / 3; text-align: start; font: 600 0.92rem/1.3 var(--font); letter-spacing: -0.006em; color: var(--ink); text-wrap: balance; }
  /* key and value trimmed to cap height, so the icon centres on the key's caps (and on the value's in a stack row)
     whatever the font (modern-web-guidance: text-box; without support the 1 px difference stays) */
  > :is(dt, dd) { text-box: trim-both cap alphabetic; }
  /* BentoCard's hover tint (3 % ink over the cell) */
  &::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: transparent; transition: background-color 300ms; }
  @media (hover: hover) { &:hover::after { background: color-mix(in oklch, var(--ink) 3%, transparent); } }
}
.ds-facts.ds-facts--bento > div[data-on] { background: var(--accent-soft); > .aui-i { color: var(--accent); } }
/* one tile per row (narrow cards, the #byo card) */
.ds-facts--bento.ds-facts--stack { grid-template-columns: minmax(0, 1fr); gap: var(--ds-1); }
.ds-facts--bento.ds-facts--stack > div { grid-template-columns: auto auto minmax(0, 1fr); padding-block: 0.8rem;
  > dd { grid-area: 1 / 3; text-align: end; } }

/* ---- interactive hover button: Magic UI Interactive Hover Button (https://magicui.design/r/interactive-hover-button.json).
   A pill with a dot before its label; on hover (and keyboard focus) the dot grows to fill the pill (scale 100.8), the
   label slides 3 rem right and fades, and a copy with an arrow slides in from the right (-1.25 rem) in the fill's ink.
   300 ms. Vivi changes: the fill is the design system's ink (the seg thumb's), the face is the floating surface with
   an alpha border; reduced motion / Pause motion: the same states without the slide. Markup: js/ui/hover-button.js. */
.ds-btn.ds-btn--hover {
  --bg: var(--ds-surface-float); --bg-hover: var(--ds-surface-float);
  --ihb-shift: 0rem;   /* the source's -translate-x-5 (-1.25 rem) clipped the copy's first letters on most of our pills (founder 2026-11-27): centred instead */
  position: relative; overflow: hidden; isolation: isolate; border: 1px solid var(--ds-border); padding-inline: 1.1rem 1.25rem; font-weight: 600;
  &.ds-btn--sm { --ihb-shift: 0rem; padding-inline: 0.9rem 1rem; }
  > .ds-ihb-front { display: flex; align-items: center; justify-content: center; gap: var(--ds-2); }
  .ds-ihb-dot { flex: none; inline-size: 0.5rem; block-size: 0.5rem; border-radius: 50%; background: var(--ds-seg-thumb); transition: all 300ms; }
  .ds-ihb-label { display: inline-flex; align-items: center; gap: 0.3rem; transition: all 300ms; }
  > .ds-ihb-back { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; gap: var(--ds-2);
    color: var(--ds-seg-ink-on); translate: 3rem 0; opacity: 0; transition: all 300ms;
    .aui-i { inline-size: 1.05em; block-size: 1.05em; stroke-width: 2.2; } }
  &:is(:hover, :focus-visible):not(:disabled) {
    .ds-ihb-dot { scale: 100.8; }
    .ds-ihb-label { translate: 3rem 0; opacity: 0; }
    > .ds-ihb-back { translate: var(--ihb-shift) 0; opacity: 1; }
  }
  &:focus-visible { outline: var(--ds-focus-w) solid var(--ds-focus-c); outline-offset: var(--ds-focus-offset); }
}
/* primary (the one action: the bar's invite, Join the list): a glacier face, and the dot that fills is the paper-light
   ink on glacier, so the label turns glacier on it */
.ds-btn.ds-btn--hover:is(.ds-btn--primary, .btn-primary) {
  --bg: var(--accent); --bg-hover: var(--accent); --fg: var(--accent-ink); border-color: transparent;
  .ds-ihb-dot { background: var(--accent-ink); }
  > .ds-ihb-back { color: var(--accent); }
}
@media (prefers-reduced-motion: reduce) {
  .ds-btn.ds-btn--hover { .ds-ihb-dot, .ds-ihb-label, > .ds-ihb-back { transition: none; } > .ds-ihb-back { translate: 0 0; } &:is(:hover, :focus-visible) > .ds-ihb-back { translate: 0 0; } }
}
html[data-motion="off"] .ds-btn.ds-btn--hover { .ds-ihb-dot, .ds-ihb-label, > .ds-ihb-back { transition: none; } > .ds-ihb-back { translate: 0 0; } &:is(:hover, :focus-visible) > .ds-ihb-back { translate: 0 0; } }
@media (forced-colors: active) { .ds-btn.ds-btn--hover .ds-ihb-dot { forced-color-adjust: none; background: ButtonText; } }

/* ---- progress gauge: Magic UI Animated Circular Progress Bar (https://magicui.design/r/animated-circular-progress-bar.json):
   two r=45 arcs in a 100 x 100 box with a 5 % gap between them, the done arc (primary) and the rest (secondary), round
   caps, stroke 10, 1 s ease on stroke-dasharray, the value in the middle. Vivi changes: primary = glacier, secondary =
   12 % ink (the sunken track vanished on basalt); a visually hidden native <progress> carries the value for assistive tech (modern-web-guidance
   "progress-ring"); the number in the middle is a Number Ticker (js/ui/number-ticker.js). Markup: js/ui/gauge.js. */
.ds-gauge {
  --circle-size: 100px; --gap-percent: 5; --offset-factor: 0; --transition-length: 1s; --delay: 0s; --percent-to-deg: 3.6deg;
  position: relative; display: inline-grid; place-items: center; inline-size: var(--gauge-size, 2.75rem); block-size: var(--gauge-size, 2.75rem); flex: none;
  font: 600 0.9rem/1 var(--font); font-variant-numeric: tabular-nums; color: var(--ink); translate: 0 0 0;
  > svg { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; overflow: visible; }
  circle { fill: none; stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; stroke-dashoffset: 0; transform-origin: calc(var(--circle-size) / 2) calc(var(--circle-size) / 2); }
  .ds-gauge-rest { stroke: color-mix(in oklch, var(--ink) 12%, transparent);   /* the sunken track tone vanished on basalt cards */
    stroke-dasharray: calc(var(--stroke-percent) * var(--percent-to-px)) var(--circumference);
    transform: rotate(calc(1turn - 90deg - (var(--gap-percent) * var(--percent-to-deg) * calc(1 - var(--offset-factor))))) scaleY(-1);
    transition: all var(--transition-length) ease var(--delay); }
  .ds-gauge-done { stroke: var(--accent);
    stroke-dasharray: calc(var(--stroke-percent) * var(--percent-to-px)) var(--circumference);
    transform: rotate(calc(-90deg + var(--gap-percent) * var(--offset-factor) * var(--percent-to-deg)));
    transition: stroke-dasharray var(--transition-length) ease var(--delay), transform var(--transition-length) ease var(--delay); }
  > .ds-gauge-v { position: relative; display: inline-flex; align-items: baseline; gap: 1px; }
  > .ds-gauge-v small { font-size: 0.68em; font-weight: 500; color: var(--ink-3); }
}
@media (prefers-reduced-motion: reduce) { .ds-gauge circle { transition: none; } }
html[data-motion="off"] .ds-gauge circle { transition: none; }

/* ---- animated list: Magic UI Animated List (https://magicui.design/r/animated-list.json, js/ui/animated-list.js). The
   newest item arrives on top, from scale 0 + opacity 0 (origin top), on a spring (stiffness 350, damping 40), and the
   ones below glide down to make room (motion's layout). Items are notification rows: an icon tile, a title with its
   time, a sub line. */
.ds-alist { display: flex; flex-direction: column; gap: var(--ds-2); margin: 0; padding: 0; list-style: none; }
.ds-alist > li { transform-origin: 50% 0; will-change: auto; }
.ds-notif {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: var(--ds-3);
  padding: var(--ds-2) var(--ds-3) var(--ds-2) var(--ds-2); border-radius: var(--ds-r-md); background: var(--ds-surface); border: 1px solid var(--ds-divider);
  > .ds-notif-i { display: grid; place-items: center; inline-size: 2rem; block-size: 2rem; border-radius: calc(var(--ds-r-md) - var(--ds-2)); background: var(--ds-soft); color: var(--ink-2);
    .aui-i, svg { inline-size: 1rem; block-size: 1rem; stroke-width: 2; } img { inline-size: 1.15rem; block-size: 1.15rem; object-fit: contain; } }
  > .ds-notif-t { min-inline-size: 0; display: grid; gap: 1px; }
  .ds-notif-title { font: 500 0.9rem/1.25 var(--font); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ds-notif-sub { font: var(--ds-hint); font-size: 0.8rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* the state on the right, on the row's centre line (the media is centred too): a 1 rem slot, its icon a block so
     no inline baseline gap shifts it */
  > .ds-notif-when { align-self: center; display: grid; place-items: center; min-inline-size: 1rem; block-size: 1rem; padding: 0;
    font: var(--ds-hint); font-size: 0.78rem; color: var(--accent); font-variant-numeric: tabular-nums;
    > svg.aui-i { display: block; inline-size: 1rem; block-size: 1rem; stroke-width: 2.4; } }
}
.ds-notif[data-status="active"] { background: var(--ds-surface-float); border-color: var(--ds-border);
  > .ds-notif-i { background: var(--accent-soft); color: var(--accent); } }
.ds-notif[data-status="done"] > .ds-notif-i { color: var(--accent); }

/* ---- device render slot (js/ui/device-shot.js): the site's own transparent stills of the phone, tablet, laptop and
   earbud in place of line icons in tiles (founder, 2026-11-26: "use the renders with no background"). A fixed
   --shot-w x --shot-h box, the render contained and centred in it, a soft contact shadow; one still per theme. */
.ds-shot {
  display: inline-grid; place-items: center; flex: none; inline-size: var(--shot-w, 40px); block-size: var(--shot-h, 32px); line-height: 0;
  > picture { display: block; line-height: 0; }
  img { display: block; max-inline-size: var(--shot-w, 40px); max-block-size: var(--shot-h, 32px); inline-size: auto; block-size: auto;
    filter: drop-shadow(0 1px 1px var(--contact)); }
  > .ds-shot-dark { display: none; }
}
html[data-scheme="dark"] .ds-shot { > .ds-shot-light { display: none; } > .ds-shot-dark { display: block; } }
/* a notification row whose lead is a render, not an icon tile */
.ds-notif > .ds-notif-media { display: grid; place-items: center; }
/* an interactive hover button whose dot is a render: the dot waits, invisible, under the render and grows from there */
.ds-btn.ds-btn--hover .ds-ihb-media { position: relative; display: grid; place-items: center; flex: none;
  > .ds-shot { position: relative; z-index: 1; transition: all 300ms; }
  > .ds-ihb-dot { position: absolute; inset: 0; margin: auto; opacity: 0; } }
.ds-btn.ds-btn--hover:is(:hover, :focus-visible):not(:disabled) .ds-ihb-media { > .ds-shot { translate: 3rem 0; opacity: 0; } > .ds-ihb-dot { opacity: 1; } }
/* Lucide strokes for the library primitives' icons (the base .aui-i rule lives in css/screens.css; dev/ds.html and any
   page without it still draws them as lines) */
:is(.ds-chip, .ds-facts--bento, .ds-ihb-back, .ds-notif) svg.aui-i { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }

/* ---- object glyph (js/ui/glyph.js): a tiny 1-bit dithered render of a real object (chip, RAM stick, discs, layered
   slabs, window, monitor, the earbud) instead of a line icon in a grey tile (founder, 2026-11-26: custom components
   for the icon tiles). One dot = one device pixel: the mask is drawn at its exact size per density (image-set 1x 2x
   3x of 24 / 48 / 72 px, dev/make-glyphs.mjs), never scaled, and painted with currentColor, so it takes the ink role,
   the theme and the lit glacier state. Same dither family as the #status device shots. */
.ds-glyph { display: inline-block; flex: none; inline-size: 24px; block-size: 24px; background: currentColor;
  -webkit-mask: no-repeat center / 24px 24px; mask: no-repeat center / 24px 24px; }
.ds-glyph[data-glyph="chip"] { -webkit-mask-image: url("../assets/glyphs/chip-48.png"); mask-image: url("../assets/glyphs/chip-48.png"); -webkit-mask-image: image-set(url("../assets/glyphs/chip-24.png") 1x, url("../assets/glyphs/chip-48.png") 2x, url("../assets/glyphs/chip-72.png") 3x); mask-image: image-set(url("../assets/glyphs/chip-24.png") 1x, url("../assets/glyphs/chip-48.png") 2x, url("../assets/glyphs/chip-72.png") 3x); }
.ds-glyph[data-glyph="ram"] { -webkit-mask-image: url("../assets/glyphs/ram-48.png"); mask-image: url("../assets/glyphs/ram-48.png"); -webkit-mask-image: image-set(url("../assets/glyphs/ram-24.png") 1x, url("../assets/glyphs/ram-48.png") 2x, url("../assets/glyphs/ram-72.png") 3x); mask-image: image-set(url("../assets/glyphs/ram-24.png") 1x, url("../assets/glyphs/ram-48.png") 2x, url("../assets/glyphs/ram-72.png") 3x); }
.ds-glyph[data-glyph="discs"] { -webkit-mask-image: url("../assets/glyphs/discs-48.png"); mask-image: url("../assets/glyphs/discs-48.png"); -webkit-mask-image: image-set(url("../assets/glyphs/discs-24.png") 1x, url("../assets/glyphs/discs-48.png") 2x, url("../assets/glyphs/discs-72.png") 3x); mask-image: image-set(url("../assets/glyphs/discs-24.png") 1x, url("../assets/glyphs/discs-48.png") 2x, url("../assets/glyphs/discs-72.png") 3x); }
.ds-glyph[data-glyph="slabs"] { -webkit-mask-image: url("../assets/glyphs/slabs-48.png"); mask-image: url("../assets/glyphs/slabs-48.png"); -webkit-mask-image: image-set(url("../assets/glyphs/slabs-24.png") 1x, url("../assets/glyphs/slabs-48.png") 2x, url("../assets/glyphs/slabs-72.png") 3x); mask-image: image-set(url("../assets/glyphs/slabs-24.png") 1x, url("../assets/glyphs/slabs-48.png") 2x, url("../assets/glyphs/slabs-72.png") 3x); }
.ds-glyph[data-glyph="window"] { -webkit-mask-image: url("../assets/glyphs/window-48.png"); mask-image: url("../assets/glyphs/window-48.png"); -webkit-mask-image: image-set(url("../assets/glyphs/window-24.png") 1x, url("../assets/glyphs/window-48.png") 2x, url("../assets/glyphs/window-72.png") 3x); mask-image: image-set(url("../assets/glyphs/window-24.png") 1x, url("../assets/glyphs/window-48.png") 2x, url("../assets/glyphs/window-72.png") 3x); }
.ds-glyph[data-glyph="monitor"] { -webkit-mask-image: url("../assets/glyphs/monitor-48.png"); mask-image: url("../assets/glyphs/monitor-48.png"); -webkit-mask-image: image-set(url("../assets/glyphs/monitor-24.png") 1x, url("../assets/glyphs/monitor-48.png") 2x, url("../assets/glyphs/monitor-72.png") 3x); mask-image: image-set(url("../assets/glyphs/monitor-24.png") 1x, url("../assets/glyphs/monitor-48.png") 2x, url("../assets/glyphs/monitor-72.png") 3x); }
.ds-glyph[data-glyph="bud"] { -webkit-mask-image: url("../assets/glyphs/bud-48.png"); mask-image: url("../assets/glyphs/bud-48.png"); -webkit-mask-image: image-set(url("../assets/glyphs/bud-24.png") 1x, url("../assets/glyphs/bud-48.png") 2x, url("../assets/glyphs/bud-72.png") 3x); mask-image: image-set(url("../assets/glyphs/bud-24.png") 1x, url("../assets/glyphs/bud-48.png") 2x, url("../assets/glyphs/bud-72.png") 3x); }
/* in a spec tile the glyph takes the icon's place: ink-2 dots (ink-3 is too faint for dithered shading), glacier when lit */
.ds-facts.ds-facts--bento > div > .ds-glyph { grid-area: 1 / 1; margin-block: -4px; color: var(--ink-2); transition: color 300ms var(--ease-out); }
.ds-facts.ds-facts--bento > div[data-on] > .ds-glyph { color: var(--accent); }

/* ==== Surfaces (founder, 2026-11-26: "I want grass texture background or grainy gradients"; references in
   reference/bg-refs/). A section can stand on one of three textured backdrops instead of the flat page colour.
   Living page with every section x surface option: dev/surfaces.html. Founder decision (2026-11-26, "let's go with
   grain", then "background isn't here": on every section): the grainy gradient is the site's surface, on every
   section and the footer (js/surfaces.js); the lawn and the painting are unused options that never load on the live page.

   Markup (js/surfaces.js surfaceLayer() writes it): the host section gets .ds-surface-host, its first child is
     <div class="ds-surface ds-surface--grain|grass|painting" aria-hidden="true"><div class="ds-surface-view">[<picture>]</div></div>
   .ds-surface covers the whole section, full bleed, behind the content, and dissolves into the page colour over
   --surface-fade at both ends (art direction: no hard edges between sections). .ds-surface-view is a 100dvh window that
   sticks to the viewport while the section scrolls by, so a pinned section (#devices, #work, #byo) keeps its backdrop
   framed instead of stretching one image over 500dvh. Images are <img loading="lazy"> with width/height and an
   AVIF/WebP srcset (they are never the LCP: no surface is in the first view), absolutely placed, so nothing shifts.

   Legibility (art direction "Text over scenes"): text never sits on raw texture. Every surface has a calm zone, a soft
   gradient from its own base colour on the copy's side (data-scrim="start" | "top" | "full"), and the copy keeps the
   site's ink for that zone. Contrast is measured on the real pixels under the text (report, 2026-11-26). */
.ds-surface-host { position: relative; }   /* no isolation: the glow layer (z -1) and the page grain share the root stacking context, under all content */
.ds-surface-host:has(> :is(.ds-surface--grass, .ds-surface--painting)) { isolation: isolate; }   /* dev-only options keep their own context */
/* in a grid host the layer must not take a grid cell (an abs-pos grid child with a placement is clipped to that cell) */
.ds-surface-host > .ds-surface { grid-area: auto; margin: 0; }
.ds-surface {
  --surface-fade: 20dvh;
  position: absolute; inset-block: 0; inset-inline-start: 50%; inline-size: 100vw; translate: -50% 0; z-index: -1;
  pointer-events: none; overflow: clip;
  /* the hand-over: alpha fades in oklab are the safe space for transparency (modern-web-guidance: visual-effects) */
  mask-image: linear-gradient(to bottom, transparent, #000 var(--surface-fade), #000 calc(100% - var(--surface-fade)), transparent);
}
.ds-surface-view {
  position: sticky; top: 0; block-size: min(100dvh, 100%); overflow: clip; background: var(--surface-base);
  > picture, > img { position: absolute; inset: 0; }
  img { display: block; inline-size: 100%; block-size: 100%; object-fit: cover; object-position: var(--surface-focus, 50% 50%); }
  /* the calm zone for the copy, then the surface's own light (vignette / glow) */
  &::before, &::after { content: ""; position: absolute; inset: 0; }
  &::before { z-index: 1; background: var(--surface-light, none); }
  &::after { z-index: 2; background: var(--surface-scrim, none); }
}
.ds-surface[data-scrim="start"] { --surface-scrim: linear-gradient(to right, var(--scrim) 0%, var(--scrim) 22%, transparent 62%); }
.ds-surface[data-scrim="top"] { --surface-scrim: linear-gradient(to bottom, var(--scrim) 0%, var(--scrim) 30%, transparent 75%); }
.ds-surface[data-scrim="full"] { --surface-scrim: linear-gradient(var(--scrim-soft), var(--scrim-soft)); }
@media (width < 760px) {   /* phones: copy stacks above the content, so the calm zone runs from the top */
  .ds-surface[data-scrim="start"] { --surface-scrim: linear-gradient(to bottom, var(--scrim) 0%, var(--scrim) 34%, transparent 80%); }
}

/* ---- grainy gradient: the site's one surface (founder decisions, 2026-11-26: "let's go with grain"; "background isn't
   here"; "sections don't have smooth fade transitions"; "too grainy, no lighting, no focus"; reference
   reference/bg-refs/ref-180-grain.png: a studio backdrop, deep basalt lit softly from one side, fine film grain that
   shows in the light and disappears in the dark). ONE sheet for the whole page:
   - base = the page colour (body, --paper); no section paints its own rectangle (#ways and the footer are transparent;
     #work's deeper stage is a long feathered gradient inside its light layer);
   - light = per section, one large soft key light (warm bone / warm grey, a touch of glacier as a rim) placed BEHIND the
     section's subject (js/surfaces.js GLOW: the close-up in #ways, the devices row, the work stage...), falling off in
     eased oklab stops into the base; the copy side stays dark and calm. The light lives in a 100dvh window that sticks
     while the section scrolls and fades out well inside it (mask 25 % top/bottom), so sections meet on plain base;
   - grain = ONE fixed layer (html::after): an SVG feTurbulence tile (baseFrequency 0.86, 4 octaves, 0.7 KB),
     soft-light blended at low opacity, so it is about 3-5 % luminance in the light falloff and nearly gone in the deep
     basalt; drawn at 1 device pixel (the tile shrinks with the device pixel ratio). Never animated, no `filter:` on any
     element, nothing per frame. It sits above the lights and under all content (root stacking context, z -1, last). */
.ds-surface--grain {
  --key: light-dark(oklch(0.995 0.008 85), oklch(0.42 0.011 75));       /* the key light at its centre */
  --rim: light-dark(oklch(0.93 0.025 230), oklch(0.3 0.028 230));       /* a faint glacier spill on the far side */
  --scrim: light-dark(oklch(0.952 0.013 85 / 0.8), oklch(0.18 0.006 55 / 0.8));
  --scrim-soft: light-dark(oklch(0.952 0.013 85 / 0.45), oklch(0.18 0.006 55 / 0.45));
  --light-w: 62%; --light-h: 78%;
  mask-image: none; background: var(--surface-bg, none);
  > .ds-surface-view { background: none;
    &::before, &::after { mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 75%, transparent); } }
  --surface-light:
    radial-gradient(var(--light-w) var(--light-h) at var(--glow-x, 70%) var(--glow-y, 50%) in oklab,
      var(--key), color-mix(in oklab, var(--key) 62%, transparent) 22%, color-mix(in oklab, var(--key) 30%, transparent) 45%,
      color-mix(in oklab, var(--key) 10%, transparent) 68%, transparent 92%),
    radial-gradient(30% 42% at var(--cool-x, 20%) var(--cool-y, 70%) in oklab,
      color-mix(in oklab, var(--rim) 55%, transparent), transparent 80%);
}
/* the #work stage: dark in both themes. Its deeper basalt is a long feathered gradient on the section's layer (from the
   page colour over 60dvh in and 95dvh out, so no 4 px step is more than ~1.5 % L), and its light is the basalt light whatever the theme */
.ds-surface--grain.ds-surface--stage {
  --stage-in: 60dvh; --stage-fade: 95dvh;   /* in: short enough that the stage captions sit on basalt by the time they show */
  /* its light only ever ADDS light (lighten): in the bone theme the hand-over gradient brightens toward the page at both
     ends, and a basalt-coloured light over it would darken it into a band (measured 2.3 % L per 4 px) */
  > .ds-surface-view { mix-blend-mode: lighten; }   /* on the window itself: it is a stacking context (sticky), so this
     blends its lights with the section-tall hand-over gradient behind it */
  /* the stage's floor under the devices (was .work-stage's own background, which stacked over the bone hand-over as a
     dark band) joins the light here, so it too only ever adds light */
  --surface-light:
    radial-gradient(var(--light-w) var(--light-h) at var(--glow-x, 56%) var(--glow-y, 52%) in oklab,
      var(--key), color-mix(in oklab, var(--key) 62%, transparent) 22%, color-mix(in oklab, var(--key) 30%, transparent) 45%,
      color-mix(in oklab, var(--key) 10%, transparent) 68%, transparent 92%),
    radial-gradient(60% 22% at 50% 80% in oklab, var(--stage-floor, oklch(0.21 0.007 55)), transparent 72%),
    radial-gradient(30% 42% at var(--cool-x, 20%) var(--cool-y, 70%) in oklab, color-mix(in oklab, var(--rim) 55%, transparent), transparent 80%);
  --surface-bg: linear-gradient(in oklab to bottom, var(--paper), var(--stage, oklch(0.14 0.006 55)) var(--stage-in), var(--stage, oklch(0.14 0.006 55)) calc(100% - var(--stage-fade)), var(--paper));
  --key: oklch(0.3 0.011 75); --rim: oklch(0.25 0.024 230);
  /* no calm zone here: the stage is already dark under the copy, and a dark scrim in the sticky window would darken the
     page-coloured hand-over at the top of the section into a band (measured: 95 -> 18 L* in 160 px on bone) */
  --scrim: transparent; --scrim-soft: transparent;
}
/* the page grain: one fixed layer, soft-light, 1 device pixel per grain at every density */
html[data-surfaces="on"]::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.86' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0.333 0.333 0.333 0 0 0.333 0.333 0.333 0 0 0.333 0.333 0.333 0 0 0 0 0 0 1'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='linear' slope='2.4' intercept='-0.7'/%3E%3CfeFuncG type='linear' slope='2.4' intercept='-0.7'/%3E%3CfeFuncB type='linear' slope='2.4' intercept='-0.7'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E") 0 0 / 256px 256px;
  mix-blend-mode: soft-light; opacity: 0.55;
}
html[data-surfaces="on"][data-scheme="dark"]::after { opacity: 0.42; }
@media (resolution >= 1.2dppx) { html[data-surfaces="on"]::after { background-size: 192px 192px; } }   /* 1.25-1.5x */
@media (resolution >= 1.75dppx) { html[data-surfaces="on"]::after { background-size: 128px 128px; } }  /* 2x */
@media (resolution >= 2.5dppx) { html[data-surfaces="on"]::after { background-size: 85.33px 85.33px; } } /* 3x */
/* a section's own hand-over overlay that sits ABOVE the page grain (the film's last 20dvh, .film::after at z 2) ends on
   plain paper, while the paper next to it carries the grain, which lifts its mean by ~2 % L on basalt (soft-light): a
   step. Under the surfaces the overlay ends on the grained paper's measured mean instead (bone: no measurable lift). */
html[data-surfaces="on"][data-scheme="dark"] .film { --film-next: oklch(0.2 0.006 55); }
/* with the surfaces on, no host paints its own rectangle (no-JS keeps each section's own colour) */
html[data-surfaces="on"] :is(.ds-surface-host, .ds-surface-host .work-stage) { background: none; }
html[data-surfaces="on"] body { background-image: none; }   /* the old faint dark-only body grain: replaced by the page grain */

/* ---- clover lawn (Clover & Rye reference: a cream card on deep green grass with tiny white clover flowers, soft top
   light). Our own Blender render (website/blender/grass/), lit from the upper right; the same lawn in both themes, so
   the host reads in dark tokens: copy on it uses the dark tokens (bone ink on deep green). The vignette pulls the
   edges into shade so the lawn reads as a place, not wallpaper. */
.ds-surface--grass {
  --surface-base: oklch(0.34 0.08 140);
  --scrim: oklch(0.22 0.045 145 / 0.78);
  --scrim-soft: oklch(0.22 0.045 145 / 0.4);
  --surface-light: radial-gradient(120% 95% at 62% 38%, transparent 45%, oklch(0.18 0.04 145 / 0.55) 100%);
}
/* ---- painting: Claude Monet, Water Lilies (1906), Art Institute of Chicago 1933.1157, CC0 / public domain. Cover-
   cropped to its calm open water; the same painting in both themes, washed with the theme's own paper on the copy
   side (bone on light, basalt on dark), so the copy keeps the page's ink. */
.ds-surface--painting {
  --surface-base: oklch(0.66 0.06 235);
  --surface-focus: 40% 45%;
  --scrim: light-dark(oklch(0.952 0.013 85 / 0.8), oklch(0.18 0.006 55 / 0.78));
  --scrim-soft: light-dark(oklch(0.952 0.013 85 / 0.55), oklch(0.18 0.006 55 / 0.55));
  /* on basalt the bright painting is dimmed toward the page so it reads as dusk on the pond, not a lit window */
  --surface-light: linear-gradient(light-dark(oklch(0.952 0.013 85 / 0.12), oklch(0.18 0.006 55 / 0.5)), light-dark(oklch(0.952 0.013 85 / 0.12), oklch(0.18 0.006 55 / 0.5)));
}
/* a host on the lawn reads in the dark tokens in both themes (the lawn is dark in both) */
.ds-surface-host:has(> .ds-surface--grass) { color-scheme: dark; color: var(--ink); }

/* contained: the surface fills its host's box instead of the viewport's width (a card-sized swatch, a table top under
   the bill); no sticky window, no section hand-over fade, the host's radius clips it */
.ds-surface--contained { inset: 0; inline-size: auto; translate: none; mask-image: none; border-radius: inherit;
  > .ds-surface-view { position: absolute; inset: 0; block-size: auto; } }

/* no motion to stop (nothing animates); print and forced colours drop the texture for the plain page */
@media print { .ds-surface { display: none; } }
@media (forced-colors: active) { .ds-surface { display: none; } }
