/* ==========================================================================
   Trellis · core · v0.11 · 2026-11-28

   Two values set everything else:
     the CELL      u = 0.75rem, rounded to a whole even pixel or fitted to the
                   screen. Space is counted in cells, and any whole count is
                   on the grid.
     the RATIO     type sizes step by a ratio, and the ratio itself grows on
                   wider screens.
     RESPONSE      on touch screens the cell is fitted to the screen's width,
                   the ratio grows with the space, and --u-scale (the reader's
                   dial) scales the cell and every space counted in it.
     CONTEXT       type sizes come from the container's width, and a context
                   changes variables rather than markup, so a component can
                   sit inside any other.

   h1 to h3 get line heights in whole cells, so every baseline sits on a cell
   line. Other text is trimmed to the top of its capitals, starts on a cell
   line, and its block rounds up to whole cells, so the next block starts on
   one too.

   This file is product-agnostic. Product layers customize it by setting
   variables. They don't add or override rules.
   ========================================================================== */

/* One namespace, so nothing merges with a framework's layers of the same name
   (Tailwind v4 also declares theme, base and utilities). A project that loads
   Tailwind states the order first, before either stylesheet:
     @layer theme, base, trellis, components, utilities;
   See README, Adoption: without that line, neither import order is safe. */
@layer trellis.reset, trellis.tokens, trellis.theme, trellis.base, trellis.layout, trellis.primitives, trellis.product, trellis.utilities;

/* --u and --cells are deliberately NOT registered properties.
   - Chrome passes a registered length on as its serialization, rounded to six
     significant digits, so a fitted 10.03125px arrives as 10.0312px and the
     error adds up down a page.
   - WebKit (every iPhone browser) can't compute a registered number from a
     length ratio: --cells came out 0, the unit infinite, the page blank.
   Unregistered, they stay expressions; everything in them (rem, vw) resolves
   the same on every element. --u-px is a registered copy, kept for
   convenience. Don't build layout from it: when a page or app sets the root's
   font size, WebKit computes a registered length on the root against the
   default text size, so --u-px can be wrong while --u is right. Scripts read
   the cell from the probe below (Trellis.cell()) instead. */
@property --u-px {
  syntax: "<length>";
  inherits: true;
  initial-value: 12px;
}
/* settle.js writes these per element, so they're registered with inherits:
   false. Unregistered, they would inherit, and a blockquote's cell count would
   hold open every paragraph inside it too. The count has no initial value, so
   where it isn't written a list row's height is left to its content (D121). */
@property --settle-n {
  syntax: "*";
  inherits: false;
}
@property --settle {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
@property --settle-start {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
/* What a card's corner floor compares (D113): its corner and its two paddings,
   registered so a bare 0 is a length. Only compared, never laid out. */
@property --card-corner { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --card-own-inline { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --card-own-block { syntax: '<length>'; inherits: false; initial-value: 0px; }
/* A control's state, as the share of its ink mixed into its fill. Registered
   so a state belongs to one box: a hovered row doesn't hover the button in it. */
/* The presets' moving values: registered, so they animate (presets below). */
@property --fade-start { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --fade-end { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --glow-a { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@property --state-act {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}
@property --state-on {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}
/* The label's ink and the fill a control's state is mixed from (D120): each
   control's own, so a control inside another doesn't take its parent's. */
@property --state-ink { syntax: "*"; inherits: false; }
@property --state-fill { syntax: "*"; inherits: false; }

/* --------------------------------------------------------------------------
   RESET
   -------------------------------------------------------------------------- */
@layer trellis.reset {
  *, *::before, *::after { box-sizing: border-box; }
  /* The hidden attribute hides, whatever display a class gives the element: a
     .stack, a .prose or a .card with hidden on it is gone. Important, and in
     the first layer, so it wins over every layer after it. */
  [hidden]:not([hidden="until-found"]) { display: none !important; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
  ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
  img, svg, video, canvas { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; }
}

/* --------------------------------------------------------------------------
   TOKENS
   -------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------
   TOKENS, generated. The values every platform shares live in tokens.json, in
   cells and points. This block is written from it; change a value there and
   run node tools/build-tokens.js. The hand-written tokens below are formulas
   and web-only plumbing: the cell's rounding, lines, the frame, the fit.
   -------------------------------------------------------------------------- */
/* tokens:start · generated from tokens.json by tools/build-tokens.js · do not edit by hand */
@layer trellis.tokens {
  :root {
    /* The cell's target: 10pt up to a 500pt screen, rising to 12pt at 1000pt.
       It follows the reader's text size up to 1.5× and no further: above that only type grows.
       --u-type is the rem formula alone, with no cap and no dial: the cell the reader's text size asks for. */
    --u-type: clamp(0.625rem, calc(0.5rem + 0.4vw), 0.75rem);
    --u-base: min(var(--u-type), clamp(15px, calc(12px + 0.4vw), 18px));
    --frame-max-n: 100;

    /* Counts: space in cells. Any whole count is on the grid; these have names */
    --sp-q: max(var(--line), round(nearest, calc(var(--u) / 4), 1px));   /* ¼u 3 */
    --sp-q2: calc(var(--sp-h) - var(--sp-q));   /* the other quarter: ¼u + this is exactly ½u at any cell */
    --sp-h: calc(var(--u) / 2);   /* ½u 6 */
    --sp-1: var(--u);   /* u 12 */
    --sp-1h: calc(var(--u) * 1.5);   /* 1.5u 18 */
    --sp-2: calc(var(--u) * 2);   /* 2u 24 */
    --sp-3: calc(var(--u) * 3);   /* 3u 36 */
    --sp-4: calc(var(--u) * 4);   /* 4u 48 */
    --sp-5: calc(var(--u) * 5);   /* 5u 60 */
    --sp-6: calc(var(--u) * 6);   /* 6u 72 */
    --sp-8: calc(var(--u) * 8);   /* 8u 96 */
    --sp-12: calc(var(--u) * 12);   /* 12u 144 */
    --sp-13: calc(var(--u) * 13);   /* 13u 156 */
    --sp-16: calc(var(--u) * 16);   /* 16u 192 */

    /* Sizes: named roles, each in cells, or in cells plus a line */
    --size-icon-sm: var(--sp-1);   /* 12 */
    --size-icon: calc(var(--sp-1) + var(--line) * 2);   /* 12 + 2 lines */
    --size-icon-md: var(--sp-1h);   /* 18 */
    --size-icon-lg: var(--sp-2);   /* 24 */
    --size-control-xs: var(--sp-1h);   /* 18 */
    --size-control-sm: var(--sp-2);   /* 24 */
    --size-control-md: calc(var(--u) * 2.5);   /* 30 */
    --size-control-lg: var(--sp-3);   /* 36 */
    --size-control-xl: var(--sp-4);   /* 48 */
    --hit-min: 44px;   /* the least hit area on a coarse pointer */

    /* Control type: fixed sizes, deliberately not fluid */
    --fs-control-xs: 0.6875rem;
    --fs-control-sm: 0.75rem;
    --fs-control-md: 0.8125rem;
    --fs-control: 0.875rem;
    --fs-control-lg: 1rem;

    /* Radii: measured in cells too. Nested radius = outer radius − padding */
    --r-q: var(--sp-q);
    --r-h: var(--sp-h);
    --r-1: var(--sp-1);
    --r-1h: var(--sp-1h);
    --r-2: var(--sp-2);
    --r-round: 999px;

    /* Layers: one scale for everything that stacks */
    --z-raised: 10;
    --z-sticky: 100;
    --z-overlay: 1000;
    --z-float: 1100;
    --z-toast: 1200;

    /* Motion: enter slower than exit */
    --dur-out: 150ms;
    --dur-in: 200ms;
    --dur-in-slow: 250ms;
    --dur-tray-in: 350ms;
    --dur-tray-out: 300ms;
    --dur-skeleton: 1.4s;
    --ease-in: cubic-bezier(.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, .2, 1);
    --ease-spring: cubic-bezier(.32, .72, 0, 1);

    /* The ratio: seven values, in rem, unitless. Products set these */
    --c-min: 20;   /* 320pt, the narrow space */
    --c-max: 90;   /* 1440pt, the wide space */
    --h1-max: 4.5;   /* H1 in a wide space */
    --body-max: 1.125;   /* body in a wide space */
    --label-max: .75;   /* the label */
    --rh-min: 1.26;   /* the ratio in a narrow space */
    --rh-max: 1.414;   /* the ratio in a wide space */
  }

  /* And five that follow from the seven, with no default: --rp-min, --rp-max, --body-min, --h1-min,
     --label-min. A product may set any; core reads --type-*, worked out here and on every scope. */
  :root, [data-product] {
    --type-rp-min: var(--rp-min, sqrt(var(--rh-min)));   /* the text step, narrow: half a heading step */
    --type-rp-max: var(--rp-max, sqrt(var(--rh-max)));   /* the text step, wide */
    --type-body-min: var(--body-min, calc(var(--body-max) / sqrt(var(--rh-min))));   /* body in a narrow space: body less a narrow text step */
    --type-h1-min: var(--h1-min, calc(var(--type-body-min) * pow(var(--rh-min), log(var(--h1-max) / var(--body-max), var(--rh-max)))));   /* H1 in a narrow space: as many steps above body as in a wide one */
    --type-label-min: var(--label-min, var(--label-max));   /* the label is one size */
  }
}
@layer trellis.theme {
  :root {
    /* Seeds: one color each, in its light-theme form. A product sets the accent. The others follow
       from it, and a product may set any of them in its place (--seed-neutral, --seed-person, …,
       --seed-ground and --seed-ink, the neutral for grounds and for text, and --seed-night, the ground at
       night; --seed-stage-1 to -7, the steps of a process). None has a default. If a
       product layer sets one, it carries into its scopes; if not, each scope works it out from its own
       accent. Products set seeds here, never roles. */
    --seed-accent: oklch(.553 .166 258.4);
    --color-lift: .17;   /* how much lighter a hue is in the dark theme */
    --ink-flip: .58;   /* ink on a fill: white below this lightness, dark above it */
    --day-depth: 0;   /* how much darker every ground and edge is by day: 0 is white paper, higher is a beige paper; never under 0 */
    --night-lift: 0;   /* how much lighter every ground and edge is at night: 0 is core's night, higher is lighter, like dusk, and down to -.025 is a deeper night */
    --gradient-space: oklch;   /* the space gradients interpolate in */
    --gradient-turn: 40;   /* degrees the accent gradient turns its hue */
  }

  /* Everything that follows from the seeds, on the root and again on every scope (D96), so a
     scope that sets a seed recolors everything inside it. */
  :root, [data-product] {

    /* The seeds that follow from the accent. Each takes its lightness, kept clear of the ink flip so
       its ink reads; a kind is the accent turned around the hue wheel, with no more chroma than sRGB
       holds at its hue; a status keeps its own hue; the neutral is a trace of the accent's hue; a
       stage is the accent turned an eighth of the wheel further than the stage before it. */
    --derived-base: oklch(from var(--seed-accent) calc((1 - clamp(0, (l - var(--ink-flip)) * 1000, 1)) * clamp(.61 - var(--color-lift), l, .54) + clamp(0, (l - var(--ink-flip)) * 1000, 1) * max(l, .61)) c h);   /* the accent, its lightness kept clear of the flip */
    --derived-accent-night: oklch(from var(--seed-accent) calc(l + var(--color-lift)) c h);   /* the accent at night, unless a product gives it a night of its own (D98) */
    --derived-neutral: oklch(from var(--seed-accent) .55 .004 h);
    --derived-person: oklch(from var(--derived-base) l min(c * .85, l * (.2764 - .0014 * clamp(0, h, 6) - .0047333 * clamp(0, h - 6, 15) - .0012667 * clamp(0, h - 21, 30) - .0001667 * clamp(0, h - 51, 30) + .0048333 * clamp(0, h - 81, 30) + .0066667 * clamp(0, h - 111, 15) - .0004 * clamp(0, h - 216, 30) - .0075333 * clamp(0, h - 246, 15) - .0032667 * clamp(0, h - 261, 15) - .0011667 * clamp(0, h - 276, 30) + .0013 * clamp(0, h - 306, 30) + .004 * clamp(0, h - 336, 15) - .0014 * clamp(0, h - 351, 9))) calc(h + 144));
    --derived-group: oklch(from var(--derived-base) l min(c * .85, l * (.399 - .0004 * clamp(0, h - 72, 30) - .0075333 * clamp(0, h - 102, 15) - .0032667 * clamp(0, h - 117, 15) - .0011667 * clamp(0, h - 132, 30) + .0013 * clamp(0, h - 162, 30) + .004 * clamp(0, h - 192, 15) - .0014 * clamp(0, h - 207, 15) - .0047333 * clamp(0, h - 222, 15) - .0012667 * clamp(0, h - 237, 30) - .0001667 * clamp(0, h - 267, 30) + .0048333 * clamp(0, h - 297, 30) + .0066667 * clamp(0, h - 327, 15))) calc(h + 288));
    --derived-event: oklch(from var(--derived-base) l min(c * .85, l * (.211 - .0011667 * clamp(0, h, 18) + .0013 * clamp(0, h - 18, 30) + .004 * clamp(0, h - 48, 15) - .0014 * clamp(0, h - 63, 15) - .0047333 * clamp(0, h - 78, 15) - .0012667 * clamp(0, h - 93, 30) - .0001667 * clamp(0, h - 123, 30) + .0048333 * clamp(0, h - 153, 30) + .0066667 * clamp(0, h - 183, 15) - .0004 * clamp(0, h - 288, 30) - .0075333 * clamp(0, h - 318, 15) - .0032667 * clamp(0, h - 333, 15) - .0011667 * clamp(0, h - 348, 12))) calc(h + 72));
    --derived-course: oklch(from var(--derived-base) l min(c * .85, l * (.1555 - .0001667 * clamp(0, h, 9) + .0048333 * clamp(0, h - 9, 30) + .0066667 * clamp(0, h - 39, 15) - .0004 * clamp(0, h - 144, 30) - .0075333 * clamp(0, h - 174, 15) - .0032667 * clamp(0, h - 189, 15) - .0011667 * clamp(0, h - 204, 30) + .0013 * clamp(0, h - 234, 30) + .004 * clamp(0, h - 264, 15) - .0014 * clamp(0, h - 279, 15) - .0047333 * clamp(0, h - 294, 15) - .0012667 * clamp(0, h - 309, 30) - .0001667 * clamp(0, h - 339, 21))) calc(h + 216));
    --derived-topic: oklch(from var(--seed-accent) calc((1 - clamp(0, ((l - .045) - var(--ink-flip)) * 1000, 1)) * clamp(.61 - var(--color-lift), (l - .045), .54) + clamp(0, ((l - .045) - var(--ink-flip)) * 1000, 1) * max((l - .045), .61)) calc(c * min(1, calc((1 - clamp(0, ((l - .045) - var(--ink-flip)) * 1000, 1)) * clamp(.61 - var(--color-lift), (l - .045), .54) + clamp(0, ((l - .045) - var(--ink-flip)) * 1000, 1) * max((l - .045), .61)) / l)) h);   /* the accent a step darker */
    --derived-ok: oklch(from var(--derived-base) l min(clamp(.1, c * .9, .17), l * .2585333) 152);
    --derived-warn: oklch(from var(--derived-base) l min(clamp(.1, c * .9, .17), l * .2133333) 70);
    --derived-alert: oklch(from var(--derived-base) l min(clamp(.1, c * .9, .17), l * .387) 30);
    --derived-stage-1: oklch(from var(--derived-base) l min(c * .85, l * (.274 - .0032667 * clamp(0, h, 15) - .0011667 * clamp(0, h - 15, 30) + .0013 * clamp(0, h - 45, 30) + .004 * clamp(0, h - 75, 15) - .0014 * clamp(0, h - 90, 15) - .0047333 * clamp(0, h - 105, 15) - .0012667 * clamp(0, h - 120, 30) - .0001667 * clamp(0, h - 150, 30) + .0048333 * clamp(0, h - 180, 30) + .0066667 * clamp(0, h - 210, 15) - .0004 * clamp(0, h - 315, 30) - .0075333 * clamp(0, h - 345, 15))) calc(h + 45));
    --derived-stage-2: oklch(from var(--derived-base) l min(c * .85, l * (.19 + .0013 * clamp(0, h, 30) + .004 * clamp(0, h - 30, 15) - .0014 * clamp(0, h - 45, 15) - .0047333 * clamp(0, h - 60, 15) - .0012667 * clamp(0, h - 75, 30) - .0001667 * clamp(0, h - 105, 30) + .0048333 * clamp(0, h - 135, 30) + .0066667 * clamp(0, h - 165, 15) - .0004 * clamp(0, h - 270, 30) - .0075333 * clamp(0, h - 300, 15) - .0032667 * clamp(0, h - 315, 15) - .0011667 * clamp(0, h - 330, 30))) calc(h + 90));
    --derived-stage-3: oklch(from var(--derived-base) l min(c * .85, l * (.289 - .0014 * clamp(0, h, 15) - .0047333 * clamp(0, h - 15, 15) - .0012667 * clamp(0, h - 30, 30) - .0001667 * clamp(0, h - 60, 30) + .0048333 * clamp(0, h - 90, 30) + .0066667 * clamp(0, h - 120, 15) - .0004 * clamp(0, h - 225, 30) - .0075333 * clamp(0, h - 255, 15) - .0032667 * clamp(0, h - 270, 15) - .0011667 * clamp(0, h - 285, 30) + .0013 * clamp(0, h - 315, 30) + .004 * clamp(0, h - 345, 15))) calc(h + 135));
    --derived-stage-4: oklch(from var(--derived-base) l min(c * .85, l * (.178 - .0012667 * clamp(0, h, 15) - .0001667 * clamp(0, h - 15, 30) + .0048333 * clamp(0, h - 45, 30) + .0066667 * clamp(0, h - 75, 15) - .0004 * clamp(0, h - 180, 30) - .0075333 * clamp(0, h - 210, 15) - .0032667 * clamp(0, h - 225, 15) - .0011667 * clamp(0, h - 240, 30) + .0013 * clamp(0, h - 270, 30) + .004 * clamp(0, h - 300, 15) - .0014 * clamp(0, h - 315, 15) - .0047333 * clamp(0, h - 330, 15) - .0012667 * clamp(0, h - 345, 15))) calc(h + 180));
    --derived-stage-5: oklch(from var(--derived-base) l min(c * .85, l * (.154 + .0048333 * clamp(0, h, 30) + .0066667 * clamp(0, h - 30, 15) - .0004 * clamp(0, h - 135, 30) - .0075333 * clamp(0, h - 165, 15) - .0032667 * clamp(0, h - 180, 15) - .0011667 * clamp(0, h - 195, 30) + .0013 * clamp(0, h - 225, 30) + .004 * clamp(0, h - 255, 15) - .0014 * clamp(0, h - 270, 15) - .0047333 * clamp(0, h - 285, 15) - .0012667 * clamp(0, h - 300, 30) - .0001667 * clamp(0, h - 330, 30))) calc(h + 225));
    --derived-stage-6: oklch(from var(--derived-base) l min(c * .85, l * (.399 - .0004 * clamp(0, h - 90, 30) - .0075333 * clamp(0, h - 120, 15) - .0032667 * clamp(0, h - 135, 15) - .0011667 * clamp(0, h - 150, 30) + .0013 * clamp(0, h - 180, 30) + .004 * clamp(0, h - 210, 15) - .0014 * clamp(0, h - 225, 15) - .0047333 * clamp(0, h - 240, 15) - .0012667 * clamp(0, h - 255, 30) - .0001667 * clamp(0, h - 285, 30) + .0048333 * clamp(0, h - 315, 30) + .0066667 * clamp(0, h - 345, 15))) calc(h + 270));
    --derived-stage-7: oklch(from var(--derived-base) l min(c * .85, l * (.399 - .0004 * clamp(0, h - 45, 30) - .0075333 * clamp(0, h - 75, 15) - .0032667 * clamp(0, h - 90, 15) - .0011667 * clamp(0, h - 105, 30) + .0013 * clamp(0, h - 135, 30) + .004 * clamp(0, h - 165, 15) - .0014 * clamp(0, h - 180, 15) - .0047333 * clamp(0, h - 195, 15) - .0012667 * clamp(0, h - 210, 30) - .0001667 * clamp(0, h - 240, 30) + .0048333 * clamp(0, h - 270, 30) + .0066667 * clamp(0, h - 300, 15))) calc(h + 315));

    /* Neutral roles: a seed's hue and chroma at a lightness for each theme. Grounds and edges take the ground seed (the night seed at night, lifted by --night-lift), text the ink seed; all follow the neutral unless set */
    --bg: light-dark(oklch(from var(--seed-ground, var(--seed-neutral, var(--derived-neutral))) calc(.973 - var(--day-depth)) c h), oklch(from var(--seed-night, var(--seed-ground, var(--seed-neutral, var(--derived-neutral)))) calc(.176 + var(--night-lift)) c h));
    --bg-raised: light-dark(oklch(from var(--seed-ground, var(--seed-neutral, var(--derived-neutral))) calc(1 - var(--day-depth)) c h), oklch(from var(--seed-night, var(--seed-ground, var(--seed-neutral, var(--derived-neutral)))) calc(.213 + var(--night-lift)) c h));
    --bg-raised-2: light-dark(oklch(from var(--seed-ground, var(--seed-neutral, var(--derived-neutral))) calc(.975 - var(--day-depth)) c h), oklch(from var(--seed-night, var(--seed-ground, var(--seed-neutral, var(--derived-neutral)))) calc(.245 + var(--night-lift)) c h));
    --bg-raised-3: light-dark(oklch(from var(--seed-ground, var(--seed-neutral, var(--derived-neutral))) calc(.95 - var(--day-depth)) c h), oklch(from var(--seed-night, var(--seed-ground, var(--seed-neutral, var(--derived-neutral)))) calc(.277 + var(--night-lift)) c h));
    --bg-sunken: light-dark(oklch(from var(--seed-ground, var(--seed-neutral, var(--derived-neutral))) calc(.943 - var(--day-depth)) c h), oklch(from var(--seed-night, var(--seed-ground, var(--seed-neutral, var(--derived-neutral)))) calc(.148 + var(--night-lift)) c h));
    --bg-hover: light-dark(oklch(from var(--seed-ground, var(--seed-neutral, var(--derived-neutral))) calc(.936 - var(--day-depth)) c h), oklch(from var(--seed-night, var(--seed-ground, var(--seed-neutral, var(--derived-neutral)))) calc(.264 + var(--night-lift)) c h));
    --text: light-dark(oklch(from var(--seed-ink, var(--seed-neutral, var(--derived-neutral))) calc(.213 * (1 - min(1, var(--day-depth) * 3))) c h), oklch(from var(--seed-ink-night, var(--seed-ink, var(--seed-neutral, var(--derived-neutral)))) calc(.967 + .033 * min(1, var(--night-lift) * 3)) c h));
    --text-secondary: light-dark(oklch(from var(--seed-ink, var(--seed-neutral, var(--derived-neutral))) calc(.397 * (1 - min(1, var(--day-depth) * 3))) c h), oklch(from var(--seed-ink-night, var(--seed-ink, var(--seed-neutral, var(--derived-neutral)))) calc(.823 + .177 * min(1, var(--night-lift) * 3)) c h));
    --text-tertiary: light-dark(oklch(from var(--seed-ink, var(--seed-neutral, var(--derived-neutral))) calc(.52 * (1 - min(1, var(--day-depth) * 3))) c h), oklch(from var(--seed-ink-night, var(--seed-ink, var(--seed-neutral, var(--derived-neutral)))) calc(.655 + .345 * min(1, var(--night-lift) * 3)) c h));
    --text-faint: light-dark(oklch(from var(--seed-ink, var(--seed-neutral, var(--derived-neutral))) calc(.695 * (1 - min(1, var(--day-depth) * 3))) c h), oklch(from var(--seed-ink-night, var(--seed-ink, var(--seed-neutral, var(--derived-neutral)))) calc(.495 + .505 * min(1, var(--night-lift) * 3)) c h));
    --border: light-dark(oklch(from var(--seed-ground, var(--seed-neutral, var(--derived-neutral))) calc(.879 - var(--day-depth)) c h), oklch(from var(--seed-night, var(--seed-ground, var(--seed-neutral, var(--derived-neutral)))) calc(.308 + var(--night-lift)) c h));
    --border-subtle: light-dark(oklch(from var(--seed-ground, var(--seed-neutral, var(--derived-neutral))) calc(.921 - var(--day-depth)) c h), oklch(from var(--seed-night, var(--seed-ground, var(--seed-neutral, var(--derived-neutral)))) calc(.259 + var(--night-lift)) c h));
    --border-strong: light-dark(oklch(from var(--seed-ground, var(--seed-neutral, var(--derived-neutral))) calc(.741 - var(--day-depth)) c h), oklch(from var(--seed-night, var(--seed-ground, var(--seed-neutral, var(--derived-neutral)))) calc(.419 + var(--night-lift)) c h));

    /* Hues: the seed in the light theme, lifted in the dark. Kinds: what sort of thing this is; shape and color both follow kind */
    --accent: light-dark(var(--seed-accent), var(--seed-accent-night, var(--derived-accent-night)));
    --accent-ink: oklch(from var(--accent) clamp(.16, (var(--ink-flip) - l) * 1000, 1) calc(clamp(0, (l - var(--ink-flip)) * 1000, 1) * c * .3) h);   /* white on a dark accent, a dark ink of its hue on a light one */
    --focus: var(--accent);
    --kind-person: light-dark(var(--seed-person, var(--derived-person)), oklch(from var(--seed-person, var(--derived-person)) calc(l + var(--color-lift)) c h));
    --kind-group: light-dark(var(--seed-group, var(--derived-group)), oklch(from var(--seed-group, var(--derived-group)) calc(l + var(--color-lift)) c h));
    --kind-event: light-dark(var(--seed-event, var(--derived-event)), oklch(from var(--seed-event, var(--derived-event)) calc(l + var(--color-lift)) c h));
    --kind-course: light-dark(var(--seed-course, var(--derived-course)), oklch(from var(--seed-course, var(--derived-course)) calc(l + var(--color-lift)) c h));
    --kind-topic: light-dark(var(--seed-topic, var(--derived-topic)), oklch(from var(--seed-topic, var(--derived-topic)) calc(l + var(--color-lift)) c h));
    --ok: light-dark(var(--seed-ok, var(--derived-ok)), oklch(from var(--seed-ok, var(--derived-ok)) calc(l + var(--color-lift)) c h));
    --warn: light-dark(var(--seed-warn, var(--derived-warn)), oklch(from var(--seed-warn, var(--derived-warn)) calc(l + var(--color-lift)) c h));
    --alert: light-dark(var(--seed-alert, var(--derived-alert)), oklch(from var(--seed-alert, var(--derived-alert)) calc(l + var(--color-lift)) c h));

    /* Stages: the steps of a process, in order. A fill (the seed, lifted in the dark no further than a derived seed is, so a pale one stays), an ink that reads as text in both themes, and a tint: the fill at a share */
    --stage-1: light-dark(var(--seed-stage-1, var(--derived-stage-1)), oklch(from var(--seed-stage-1, var(--derived-stage-1)) max(l, min(l + var(--color-lift), .61 + var(--color-lift))) calc(c * min(1, (1 - max(l, min(l + var(--color-lift), .61 + var(--color-lift)))) / max(1 - l, .001))) h));
    --stage-1-ink: light-dark(oklch(from var(--seed-stage-1, var(--derived-stage-1)) min(l, .48) calc(c * min(1, .48 / max(l, .001))) h), oklch(from var(--seed-stage-1, var(--derived-stage-1)) max(l, .76) calc(c * min(1, (1 - max(l, .76)) / max(1 - l, .001))) h));
    --stage-1-tint: color-mix(in oklab, var(--stage-1) 14%, transparent);
    --stage-2: light-dark(var(--seed-stage-2, var(--derived-stage-2)), oklch(from var(--seed-stage-2, var(--derived-stage-2)) max(l, min(l + var(--color-lift), .61 + var(--color-lift))) calc(c * min(1, (1 - max(l, min(l + var(--color-lift), .61 + var(--color-lift)))) / max(1 - l, .001))) h));
    --stage-2-ink: light-dark(oklch(from var(--seed-stage-2, var(--derived-stage-2)) min(l, .48) calc(c * min(1, .48 / max(l, .001))) h), oklch(from var(--seed-stage-2, var(--derived-stage-2)) max(l, .76) calc(c * min(1, (1 - max(l, .76)) / max(1 - l, .001))) h));
    --stage-2-tint: color-mix(in oklab, var(--stage-2) 14%, transparent);
    --stage-3: light-dark(var(--seed-stage-3, var(--derived-stage-3)), oklch(from var(--seed-stage-3, var(--derived-stage-3)) max(l, min(l + var(--color-lift), .61 + var(--color-lift))) calc(c * min(1, (1 - max(l, min(l + var(--color-lift), .61 + var(--color-lift)))) / max(1 - l, .001))) h));
    --stage-3-ink: light-dark(oklch(from var(--seed-stage-3, var(--derived-stage-3)) min(l, .48) calc(c * min(1, .48 / max(l, .001))) h), oklch(from var(--seed-stage-3, var(--derived-stage-3)) max(l, .76) calc(c * min(1, (1 - max(l, .76)) / max(1 - l, .001))) h));
    --stage-3-tint: color-mix(in oklab, var(--stage-3) 14%, transparent);
    --stage-4: light-dark(var(--seed-stage-4, var(--derived-stage-4)), oklch(from var(--seed-stage-4, var(--derived-stage-4)) max(l, min(l + var(--color-lift), .61 + var(--color-lift))) calc(c * min(1, (1 - max(l, min(l + var(--color-lift), .61 + var(--color-lift)))) / max(1 - l, .001))) h));
    --stage-4-ink: light-dark(oklch(from var(--seed-stage-4, var(--derived-stage-4)) min(l, .48) calc(c * min(1, .48 / max(l, .001))) h), oklch(from var(--seed-stage-4, var(--derived-stage-4)) max(l, .76) calc(c * min(1, (1 - max(l, .76)) / max(1 - l, .001))) h));
    --stage-4-tint: color-mix(in oklab, var(--stage-4) 14%, transparent);
    --stage-5: light-dark(var(--seed-stage-5, var(--derived-stage-5)), oklch(from var(--seed-stage-5, var(--derived-stage-5)) max(l, min(l + var(--color-lift), .61 + var(--color-lift))) calc(c * min(1, (1 - max(l, min(l + var(--color-lift), .61 + var(--color-lift)))) / max(1 - l, .001))) h));
    --stage-5-ink: light-dark(oklch(from var(--seed-stage-5, var(--derived-stage-5)) min(l, .48) calc(c * min(1, .48 / max(l, .001))) h), oklch(from var(--seed-stage-5, var(--derived-stage-5)) max(l, .76) calc(c * min(1, (1 - max(l, .76)) / max(1 - l, .001))) h));
    --stage-5-tint: color-mix(in oklab, var(--stage-5) 14%, transparent);
    --stage-6: light-dark(var(--seed-stage-6, var(--derived-stage-6)), oklch(from var(--seed-stage-6, var(--derived-stage-6)) max(l, min(l + var(--color-lift), .61 + var(--color-lift))) calc(c * min(1, (1 - max(l, min(l + var(--color-lift), .61 + var(--color-lift)))) / max(1 - l, .001))) h));
    --stage-6-ink: light-dark(oklch(from var(--seed-stage-6, var(--derived-stage-6)) min(l, .48) calc(c * min(1, .48 / max(l, .001))) h), oklch(from var(--seed-stage-6, var(--derived-stage-6)) max(l, .76) calc(c * min(1, (1 - max(l, .76)) / max(1 - l, .001))) h));
    --stage-6-tint: color-mix(in oklab, var(--stage-6) 14%, transparent);
    --stage-7: light-dark(var(--seed-stage-7, var(--derived-stage-7)), oklch(from var(--seed-stage-7, var(--derived-stage-7)) max(l, min(l + var(--color-lift), .61 + var(--color-lift))) calc(c * min(1, (1 - max(l, min(l + var(--color-lift), .61 + var(--color-lift)))) / max(1 - l, .001))) h));
    --stage-7-ink: light-dark(oklch(from var(--seed-stage-7, var(--derived-stage-7)) min(l, .48) calc(c * min(1, .48 / max(l, .001))) h), oklch(from var(--seed-stage-7, var(--derived-stage-7)) max(l, .76) calc(c * min(1, (1 - max(l, .76)) / max(1 - l, .001))) h));
    --stage-7-tint: color-mix(in oklab, var(--stage-7) 14%, transparent);

    /* Gradients: an interpolation space and stops. Add a direction or a shape: linear-gradient(to right var(--gradient-accent)) */
    --gradient-accent: in var(--gradient-space), var(--accent), oklch(from var(--accent) l c calc(h + var(--gradient-turn)));
    --gradient-surface: in var(--gradient-space), var(--bg-raised), var(--bg-sunken);
  }

  /* A product's own colors (D117): --seed-own-gold and any other a layer names. An element that takes one as its
     --seed has its roles, worked out as a stage's are: a fill, an ink that reads as text in both themes, a tint,
     and a solid fill (the fill, clear of the ink flip) with the ink that reads on it. No element, no cost. */
  .u-seed, .tag.cc-seed, .dot.cc-seed {
    --seeded: light-dark(var(--seed, var(--seed-accent)), oklch(from var(--seed, var(--seed-accent)) max(l, min(l + var(--color-lift), .61 + var(--color-lift))) calc(c * min(1, (1 - max(l, min(l + var(--color-lift), .61 + var(--color-lift)))) / max(1 - l, .001))) h));
    --seeded-ink: light-dark(oklch(from var(--seed, var(--seed-accent)) min(l, .48) calc(c * min(1, .48 / max(l, .001))) h), oklch(from var(--seed, var(--seed-accent)) max(l, .76) calc(c * min(1, (1 - max(l, .76)) / max(1 - l, .001))) h));
    --seeded-tint: color-mix(in oklab, var(--seeded) 14%, transparent);
    --seeded-solid: oklch(from var(--seeded) calc((1 - clamp(0, (l - var(--ink-flip)) * 100000, 1)) * min(l, .54) + clamp(0, (l - var(--ink-flip)) * 100000, 1) * max(l, .62)) calc(c * min(1, ((1 - clamp(0, (l - var(--ink-flip)) * 100000, 1)) * min(l, .54) + clamp(0, (l - var(--ink-flip)) * 100000, 1) * max(l, .62)) / max(l, .001), (1 - ((1 - clamp(0, (l - var(--ink-flip)) * 100000, 1)) * min(l, .54) + clamp(0, (l - var(--ink-flip)) * 100000, 1) * max(l, .62))) / max(1 - l, .001))) h);
    --seeded-solid-ink: oklch(from var(--seeded-solid) clamp(.16, (var(--ink-flip) - l) * 1000, 1) calc(clamp(0, (l - var(--ink-flip)) * 1000, 1) * c * .3) h);
  }
  /* Without relative colors: core's palette, resolved by math.js. */
  @supports not (color: oklch(from red l c h)) {
    :root {
      --bg: light-dark(#f4f6f9, #101112);
      --bg-raised: light-dark(#fdffff, #18191b);
      --bg-raised-2: light-dark(#f5f7f9, #1f2022);
      --bg-raised-3: light-dark(#edeef1, #27282a);
      --bg-sunken: light-dark(#eaecef, #0a0b0c);
      --bg-hover: light-dark(#e8eaec, #242527);
      --text: light-dark(#18191b, #f2f4f7);
      --text-secondary: light-dark(#464749, #c3c5c8);
      --text-tertiary: light-dark(#67696b, #8f9193);
      --text-faint: light-dark(#9b9d9f, #606264);
      --border: light-dark(#d5d7da, #2f3032);
      --border-subtle: light-dark(#e3e5e8, #232426);
      --border-strong: light-dark(#a9abae, #4b4d4f);
      --accent: light-dark(#2c6fd1, #60a5ff);
      --accent-ink: light-dark(#ffffff, #020c22);
      --focus: light-dark(#2c6fd1, #60a5ff);
      --kind-person: light-dark(#af4d20, #e98156);
      --kind-group: light-dark(#0e8077, #54b4aa);
      --kind-event: light-dark(#9b4c95, #d27fcb);
      --kind-course: light-dark(#6e7606, #a0aa4b);
      --kind-topic: light-dark(#2662bb, #5997f4);
      --ok: light-dark(#088543, #53ba75);
      --warn: light-dark(#986106, #cf944a);
      --alert: light-dark(#b54436, #f07968);
      --stage-1: light-dark(#8056b1, #ad94cf);
      --stage-1-ink: light-dark(#6d4997, #bba6d8);
      --stage-2: light-dark(#a7477c, #cc8bab);
      --stage-2-ink: light-dark(#8f3b69, #d59eb9);
      --stage-3: light-dark(#b14933, #d38d7d);
      --stage-3-ink: light-dark(#973d2a, #dca193);
      --stage-4: light-dark(#916508, #b99d70);
      --stage-4-ink: light-dark(#7b5606, #c5ad88);
      --stage-5: light-dark(#607a06, #97aa70);
      --stage-5-ink: light-dark(#516804, #a8b989);
      --stage-6: light-dark(#138263, #78af9a);
      --stage-6-ink: light-dark(#0f6e54, #90bdab);
      --stage-7: light-dark(#227b8c, #7babb6);
      --stage-7-ink: light-dark(#1c6877, #92b9c2);
      --gradient-accent: in oklab, var(--accent), var(--accent);
      --gradient-surface: in oklab, var(--bg-raised), var(--bg-sunken);
    }
    .u-seed, .tag.cc-seed, .dot.cc-seed { --seeded: var(--seed, var(--accent)); --seeded-ink: var(--text); --seeded-solid: var(--text); --seeded-solid-ink: var(--bg); }
  }
}
/* tokens:end */

@layer trellis.tokens {
  :root {
    /* ---- The cell -------------------------------------------------------
       The target follows the reader's font-size setting and the screen:
       10px (0.625rem) up to a 500px screen, rising to 12px at 1000px.
       --u-scale is the accessibility and density dial. On a wide screen the
       target rounds to an even pixel, which keeps every half-unit whole; on
       a touch screen it is fitted instead (below). */
    --u-scale: 1;
    --u-target: calc(var(--u-base) * var(--u-scale));
    --u: round(nearest, var(--u-target), 2px);
    --u-px: var(--u);

    /* Lines don't scale with the cell. --line is one CSS pixel; --hair is one
       device pixel (⅓px on a 3x screen, ½px on 2x), the thinnest mark a
       screen can make. A line is drawn in the pixels just after its
       coordinate (to the right of it, below it), so N cells drawn with their
       edges need N cells plus one line. */
    --line: 1px;
    --dpr: 1;
    --hair: calc(1px / var(--dpr));

    /* ---- The only raw neutrals: ink on a solid color or a photo. */
    --white: #fff;
    --black: #000;

    /* ---- The frame: the page's outer box. It holds a FIELD of whole modules
       (4 cells each) with a gutter of whole cells either side, and it is
       centered, so the strongest lines are symmetric about the screen.
       On a wide screen the frame steps by a module and the gutter by two
       cells; fitted (below), the frame steps by two cells and the gutter
       takes 2 or 3 cells so the field stays whole modules. Gutters clear the
       phone's safe areas (the notch, in landscape). */
    --frame-max: calc(var(--u) * var(--frame-max-n));
    --frame-step: calc(var(--u) * 4);
    --gutter: max(
      round(down, clamp(var(--sp-2), 4vw, var(--sp-4)), var(--sp-2)),
      round(up, env(safe-area-inset-left, 0px), var(--sp-2)),
      round(up, env(safe-area-inset-right, 0px), var(--sp-2)));

    /* ---- The ratio: fluid, fractal type ---------------------------------
       Every size is clamp(min, slope × container + intercept, max). The two
       anchors are H1 and body; everything else steps from them by a ratio.
       The ratio has a min and a max too, so hierarchy is compressed in a
       narrow space and opens up in a wide one. Numbers are rem, unitless.
       Products set these; the values here are neutral defaults. */

    --lh-h1: 1.05;   --lh-h-step: .05;     /* each smaller heading opens by a step */
    --mb-h1: .33;    --mb-h-step: .11;     /* space after a heading, in its own ems */
    --lh-body: 1.45; --lh-p-step: .03;     /* each larger paragraph closes by a step */
    --lh-label: 1.2;

    --font-sans: ui-sans-serif, system-ui, sans-serif;
    --font-serif: Georgia, serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
    --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;   /* color emoji first, so a reaction draws in color at its size */
    --fw-body: 400; --fw-heading: 500; --fw-label: 500; --fw-label-text: 400; --fw-strong: 600;   /* --fw-label: a control's; --fw-label-text: the label and eyebrow roles' */
    --label-tracking: .08em;
    --label-case: uppercase;

    /* ---- Product knobs: products change these on :root and nothing else.
       Primitives read them; variants and contexts set the primitive's own
       variables, so a product never overrides a variant by accident. */
    --shape-card: var(--r-1h);
    /* States: the share of a control's own ink mixed into its own fill. */
    --state-hover: 6%;
    --state-press: 12%;
    --state-selected: 10%;
    --outset: 1;                 /* cells a card's edge steps out into the space around it */
    --prose-measure: calc(var(--u) * 56);   /* the widest a column of running text gets */
    --shape-control: var(--r-round);
    --shape-input: var(--r-h);   /* a small corner: a pill suits a button's short label, but an input holds a sentence */
    --shape-float: var(--r-1);
    /* Speech (D122): a bubble's own corner, its padding, and the faint grounds
       of others' messages and your own, as shares of the text and the accent
       over the surface. --chat-bubble-bg, --chat-own-bg, --chat-own-ink and
       --chat-bubble-edge are unset: the chat item reads them with its defaults. */
    --chat-shape: var(--r-1h);
    --chat-bubble-pad: var(--sp-1);
    --chat-bubble-wash: 7%;
    --chat-own-wash: 20%;
    --density-card-pad: var(--sp-2);
    /* --density-card-pad-inline and --density-card-pad-block: its sides and its
       top and bottom, unset so they follow it (on every scope too, D96).
       Trimmed text makes equal padding optically equal, so equal is the
       default; a product may tighten the sides and keep the vertical rhythm. */
    --density-control-h: var(--size-control-lg);
    --density-control-fs: var(--fs-control);
    /* A compact product sets these once, and every menu and segmented control
       follows; a context still sets the primitive's own variable for a one-off.
       Two cells for a control: --density-seg-h at 1½ cells and --density-seg-pad
       at a quarter; menu rows two cells in small type. */
    --density-option-h: var(--size-control-md);
    --density-option-fs: var(--fs-control);
    --density-options-pad: var(--sp-q);
    --density-seg-h: var(--size-control-sm);
    --density-seg-pad: calc((var(--size-control-lg) - var(--density-seg-h)) / 2);
    --tag-default-h: var(--size-control-sm);
    --tag-default-fs: var(--tag-fs-md);
    --tag-fs-sm: .6875rem;
    --tag-fs-md: .75rem;
    --tag-fs-lg: .8125rem;
    --tag-r-fixed: 0px;          /* a fixed corner, or …            */
    --tag-r-ratio: .5;           /* … a share of the height (.5 = pill) */
    --tag-case: none;
    --tag-tracking: 0;
    /* A button's face (D100): its case and letter spacing. Its family and
       weight, --font-button and --fw-button, are unset so they follow the sans
       and the control weight (on every scope too, D96). */
    --button-case: none;
    --button-tracking: 0;

    /* The sheet's durations, renamed for the tray: aliases for one minor. */
    --dur-sheet-in: var(--dur-tray-in);
    --dur-sheet-out: var(--dur-tray-out);

    /* Isometric lattice: a 2:1 slope, so every lattice point is a cell corner. */
    --iso-dx: var(--sp-2);
    --iso-dy: var(--sp-1);
  }
}

/* Device pixels. 2x and 3x cover phones and most laptops; a script may set
   --dpr exactly (2.625 on some Android phones). */
@layer trellis.tokens {
  @media (min-resolution: 2dppx) { :root { --dpr: 2; } }
  @media (min-resolution: 3dppx) { :root { --dpr: 3; } }
}

/* Fit. Where the screen's edge frames the page (touch screens: phones in
   either orientation, foldables, tablets), the cell is fitted to the screen.
   - The count is even, so the screen's center is a line, and it follows the
     reader's target: N = the even number nearest (width - hair) / target.
     The cell strays at most ~2.5% from the target.
   - The cell is (width - hair) / N: N cells plus the one hair that the last
     line needs, since a line occupies the pixel after its coordinate.
   - The gutter takes 2 or 3 cells (more beside a notch) so the field between
     the gutters is whole modules of 4: the strongest lines are then the
     field's edges and every 4th cell in from them, symmetric on the screen.
     How --gutter-n gets there: field = cells - 2 × gutter must divide by 4,
     so the gutter must have the same parity as cells / 2.
       40 cells: 40/2 = 20 is even, gutter 2, field 36 = 9 modules.
       42 cells: 42/2 = 21 is odd,  gutter 3, field 36 = 9 modules.
     Beside a notch the gutter must clear the safe area: the smallest count
     of cells that does, nudged up by one if its parity is wrong. The count
     is the frame's, so a frame capped at 100 cells uses 100.
   - The cell becomes fractional; lines never do (--line, --hair).
   - Rounding to 1/32px keeps every half-unit exact in the browser's 1/64px
     layout grid, so baselines never drift; what's left over (under a pixel
     or so) is split between the two edges.
   - 1x screens never fit: a fractional cell would draw equal gaps as 5px and
     6px. Desktop windows don't fit by default, or every space would breathe
     while the window is dragged. data-unit-fit="on" forces it, "off" refuses.
   - The clamp is a guard: a fitted cell is always near its target, so a
     browser that gets the math wrong still lays out a sane page.
   - The 1/4096px nudge keeps an exact fit exact (820 / 82 is 10, not the
     9.99999 floating point can make of it, which would round down a step).
   - --fit-width lets a script pass the exact width where 100vw would include
     a classic scrollbar.
   - The count needs typed division (a length divided by a length). Where a
     browser lacks it, @supports keeps the whole unit. Don't swap in the older
     tan(atan2()) trick: WebKit computes it wrongly with viewport units (0 or
     4.14 where 81.66 is right), which blanked every iPhone in v0.3.0. */
@layer trellis.tokens {
  @supports (width: calc(100vw / 1px * 1px)) {
    @media (pointer: coarse) and (min-resolution: 1.5dppx) {
      :root:not([data-unit-fit="off"]) {
        --fit-w: calc(var(--fit-width, 100vw) - var(--hair));
        --cells: calc(2 * round(nearest, var(--fit-w) / (var(--u-target) * 2), 1));
        --u: clamp(calc(var(--u-target) * 0.8),
                   round(down, calc(var(--fit-w) / max(var(--cells), 2) + 1px / 4096), 1px / 32),
                   calc(var(--u-target) * 1.25));
        --frame-step: calc(var(--u) * 2);
        --gutter-safe: round(up, max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)) / var(--u), 1);
        --gutter-n: max(calc(2 + mod(min(var(--cells), var(--frame-max-n)) / 2, 2)),
                        calc(var(--gutter-safe) + mod(min(var(--cells), var(--frame-max-n)) / 2 - var(--gutter-safe), 2)));
        --gutter: calc(var(--u) * var(--gutter-n));
      }
    }
    :root[data-unit-fit="on"] {
      --fit-w: calc(var(--fit-width, 100vw) - var(--hair));
      --cells: calc(2 * round(nearest, var(--fit-w) / (var(--u-target) * 2), 1));
      --u: clamp(calc(var(--u-target) * 0.8),
                 round(down, calc(var(--fit-w) / max(var(--cells), 2) + 1px / 4096), 1px / 32),
                 calc(var(--u-target) * 1.25));
      --frame-step: calc(var(--u) * 2);
      --gutter-safe: round(up, max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)) / var(--u), 1);
      --gutter-n: max(calc(2 + mod(min(var(--cells), var(--frame-max-n)) / 2, 2)),
                      calc(var(--gutter-safe) + mod(min(var(--cells), var(--frame-max-n)) / 2 - var(--gutter-safe), 2)));
      --gutter: calc(var(--u) * var(--gutter-n));
    }
  }
}

/* --------------------------------------------------------------------------
   THEME: semantic roles. light-dark() reads color-scheme, so one declaration
   per role carries both themes and nothing can drift between them.
   -------------------------------------------------------------------------- */
@layer trellis.theme {
  :root { color-scheme: light dark; }
  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"]  { color-scheme: dark; }
  /* A scope (D96): data-product on any element below the root. Its roles are worked out again
     from its seeds (the theme layer), so it sets its own ink, type and the ground everything in
     it reads. A scope with data-theme is a mood: night on a day page, or the reverse; it brings
     its ground with it, since its ink would not read on the page's. */
  [data-product]:not(:root) {
    --surface: var(--bg);
    --scrollbar-thumb: color-mix(in oklab, var(--text) 22%, transparent);
    --scrollbar-thumb-hover: color-mix(in oklab, var(--text) 40%, transparent);
    color: var(--text);
    font-family: var(--font-sans);
  }
  [data-product][data-theme="light"]:not(:root) { color-scheme: light; background: var(--surface); }
  [data-product][data-theme="dark"]:not(:root)  { color-scheme: dark; background: var(--surface); }

  :root {

    --lift: 0 var(--sp-h) var(--sp-2) light-dark(rgb(16 20 22 / .12), rgb(0 0 0 / .55)),
            0 0 0 var(--line) light-dark(rgb(16 20 22 / .04), rgb(0 0 0 / .3));

    /* Scrollbars: one rule for all of them. Variants change its variables. */
    --scrollbar-width: thin;
    --scrollbar-size: var(--sp-h);
    --scrollbar-thumb: color-mix(in oklab, var(--text) 22%, transparent);
    --scrollbar-thumb-hover: color-mix(in oklab, var(--text) 40%, transparent);
    --scrollbar-track: transparent;
  }
}

/* --------------------------------------------------------------------------
   BASE
   -------------------------------------------------------------------------- */
@layer trellis.base {
  :root { --surface: var(--bg); }

  /* The cell, measured: settle.js keeps one hidden box a cell wide on the
     root, outside body, and reads the cell from it. It takes no space. */
  [data-trellis-cell] {
    position: absolute; top: 0; left: 0;
    width: var(--u); height: 0;
    visibility: hidden; pointer-events: none;
  }

  body {
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-sans);
    font-weight: var(--fw-body);
    font-size: 1rem;
    line-height: var(--sp-2);
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
    /* A word wider than its line breaks rather than scrolling the page: at the
       largest text sizes one heading word can outgrow a phone. */
    overflow-wrap: break-word;
  }

  :focus-visible { outline: calc(var(--line) * 2) solid var(--focus); outline-offset: var(--line); }

  /* Scrollbars ------------------------------------------------------------ */
  * {
    scrollbar-width: var(--scrollbar-width);
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  }
  @supports not (scrollbar-color: auto) {
    ::-webkit-scrollbar { width: var(--scrollbar-size); height: var(--scrollbar-size); }
    ::-webkit-scrollbar-track { background: var(--scrollbar-track); }
    ::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--r-round); }
    ::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
  }

  /* Type roles ------------------------------------------------------------
     Each role sets its min, max and line-height ratio; one rule turns them
     into a fluid size. How a role meets the grid depends on its kind:
     - HEADLINES (h1, h2, h3) stand on the cells: the line height rounds to
       whole cells and every baseline lands on a cell line.
     - TEXT (h4 to h6, the paragraph roles, the label) runs on its own
       proportional line. It hangs from a cell line (the top of its
       capitals) and its block rounds up to whole cells, so whatever follows
       starts on a line.
     The cell stays the only line on the page. Type answers to it where it
     is large enough to be seen doing so.
     A heading is never smaller than body text (D89): each of its two ends is
     floored at body's. A wide ratio runs out of room under H1 before it runs
     out of headings; the ones it would put under body take body's size, and
     keep the heading's family, weight, line and space. */
  .t-h1, :where(.prose h1) { --t-min: max(var(--type-body-min), var(--type-h1-min)); --t-max: max(var(--body-max), var(--h1-max)); --t-lh: var(--lh-h1); --t-mb: var(--mb-h1); }
  .t-h2, :where(.prose h2) { --t-min: max(var(--type-body-min), var(--type-h1-min) / var(--rh-min)); --t-max: max(var(--body-max), var(--h1-max) / var(--rh-max)); --t-lh: calc(var(--lh-h1) + var(--lh-h-step)); --t-mb: calc(var(--mb-h1) + var(--mb-h-step)); }
  .t-h3, :where(.prose h3) { --t-min: max(var(--type-body-min), var(--type-h1-min) / pow(var(--rh-min), 2)); --t-max: max(var(--body-max), var(--h1-max) / pow(var(--rh-max), 2)); --t-lh: calc(var(--lh-h1) + var(--lh-h-step) * 2); --t-mb: calc(var(--mb-h1) + var(--mb-h-step) * 2); }
  .t-h4, :where(.prose h4) { --t-min: max(var(--type-body-min), var(--type-h1-min) / pow(var(--rh-min), 3)); --t-max: max(var(--body-max), var(--h1-max) / pow(var(--rh-max), 3)); --t-lh: calc(var(--lh-h1) + var(--lh-h-step) * 3); --t-mb: calc(var(--mb-h1) + var(--mb-h-step) * 3); }
  .t-h5, :where(.prose h5) { --t-min: max(var(--type-body-min), var(--type-h1-min) / pow(var(--rh-min), 4)); --t-max: max(var(--body-max), var(--h1-max) / pow(var(--rh-max), 4)); --t-lh: calc(var(--lh-h1) + var(--lh-h-step) * 4); --t-mb: calc(var(--mb-h1) + var(--mb-h-step) * 4); }
  .t-h6, :where(.prose h6) { --t-min: max(var(--type-body-min), var(--type-h1-min) / pow(var(--rh-min), 5)); --t-max: max(var(--body-max), var(--h1-max) / pow(var(--rh-max), 5)); --t-lh: calc(var(--lh-h1) + var(--lh-h-step) * 5); --t-mb: calc(var(--mb-h1) + var(--mb-h-step) * 5); }
  .t-xl { --t-min: calc(var(--type-body-min) * pow(var(--type-rp-min), 2)); --t-max: calc(var(--body-max) * pow(var(--type-rp-max), 2)); --t-lh: calc(var(--lh-body) - var(--lh-p-step) * 2); }
  .t-lg, :where(.prose blockquote), :where(.prose) blockquote :is(p, li) { --t-min: calc(var(--type-body-min) * var(--type-rp-min)); --t-max: calc(var(--body-max) * var(--type-rp-max)); --t-lh: calc(var(--lh-body) - var(--lh-p-step)); }
  .t-body, :where(.prose :is(p, li, dt, dd, summary), .prose div:not([class], :has(> :is(p, div, ul, ol, dl, h1, h2, h3, h4, h5, h6, blockquote, pre, table, figure, hr, details, img, video, iframe)))) { --t-min: var(--type-body-min); --t-max: var(--body-max); --t-lh: var(--lh-body); }
  .t-sm, :where(.prose :is(figcaption, caption, td)), :where(.prose) blockquote > :is(footer, cite) { --t-min: calc(var(--type-body-min) / var(--type-rp-min)); --t-max: calc(var(--body-max) / var(--type-rp-max)); --t-lh: calc(var(--lh-body) + var(--lh-p-step)); }
  .t-xs { --t-min: calc(var(--type-body-min) / pow(var(--type-rp-min), 2)); --t-max: calc(var(--body-max) / pow(var(--type-rp-max), 2)); --t-lh: calc(var(--lh-body) + var(--lh-p-step) * 2); }
  .t-label, :where(.prose th) { --t-min: var(--type-label-min); --t-max: var(--label-max); --t-lh: var(--lh-label); }
  /* The eyebrow: the label one paragraph step up, for what opens a section. */
  .t-eyebrow { --t-min: calc(var(--type-label-min) * var(--type-rp-min)); --t-max: calc(var(--label-max) * var(--type-rp-max)); --t-lh: var(--lh-label); }

  :where(.t-h1, .t-h2, .t-h3, .t-h4, .t-h5, .t-h6, .t-xl, .t-lg, .t-body, .t-sm, .t-xs, .t-label, .t-eyebrow,
         .prose :is(h1, h2, h3, h4, h5, h6, th, td), .prose :is(p, li, dt, dd, summary, blockquote, figcaption, caption), .prose blockquote > :is(footer, cite), .prose div:not([class], :has(> :is(p, div, ul, ol, dl, h1, h2, h3, h4, h5, h6, blockquote, pre, table, figure, hr, details, img, video, iframe)))) {
    --t-slope: calc((var(--t-max) - var(--t-min)) / (var(--c-max) - var(--c-min)));
    --t-fs: clamp(
      calc(var(--t-min) * 1rem),
      calc((var(--t-min) - var(--t-slope) * var(--c-min)) * 1rem + var(--t-slope) * 100cqi),
      calc(var(--t-max) * 1rem));
    --t-line: calc(1em * var(--t-lh));
    font-size: var(--t-fs);
    line-height: var(--t-line);
  }
  :where(.t-h1, .t-h2, .t-h3, .prose :is(h1, h2, h3)) { --t-line: round(nearest, calc(1em * var(--t-lh)), var(--u)); }
  :where(.t-h1, .t-h2, .t-h3, .t-h4, .t-h5, .t-h6, .prose :is(h1, h2, h3, h4, h5, h6)) { font-family: var(--font-heading, var(--font-sans)); font-weight: var(--fw-heading); text-wrap: balance; letter-spacing: var(--heading-tracking, -.01em); }
  /* A heading carries its own space after it, proportional to its size and
     rounded up to whole cells. In a stack, the space below it is whichever is
     larger, that space or the stack's gap; the two aren't added. */
  :where(.t-h1, .t-h2, .t-h3, .t-h4, .t-h5, .t-h6, .prose :is(h1, h2, h3, h4, h5, h6)):not(:last-child) {
    --t-own: round(up, calc(1em * var(--t-mb) - 1px / 64), var(--u));   /* up, or a common size drops a cell; 1/64px absorbs layout's rounding */
    margin-block-end: var(--t-own);
  }
  :is(.stack, .member-tile-body, .modal-body, .cover-body, .list-body) > :where(.t-h1, .t-h2, .t-h3, .t-h4, .t-h5, .t-h6):not(:last-child) {
    margin-block-end: max(0px, calc(var(--t-own) - var(--stack-gap, var(--sp-1))));
  }
  /* In a row the space after a heading has nothing to part: a title between two
     buttons centers on them. */
  :is(.cluster, .row) > :where(.t-h1, .t-h2, .t-h3, .t-h4, .t-h5, .t-h6) { margin-block-end: 0; }
  :where(.prose, .prose div:not([class])) > :where(.t-h1, .t-h2, .t-h3, .t-h4, .t-h5, .t-h6, h1, h2, h3, h4, h5, h6):not(:last-child) {
    --prose-after: max(0px, calc(var(--t-own) - var(--stack-gap, var(--sp-1))));
    margin-block-end: var(--prose-after);
  }
  a { color: inherit; text-decoration-thickness: var(--line); text-underline-offset: .22em; text-decoration-color: color-mix(in oklab, currentColor 40%, transparent); }
  @media (hover: hover) { a:hover { text-decoration-color: currentColor; } }
  a:active { text-decoration-color: currentColor; text-decoration-thickness: calc(var(--line) * 2); }
  /* A scroller's ring is drawn inside it, or its own clipping would cut it. */
  :is(.rail, .board, .tabs):focus-visible { outline-offset: calc(var(--line) * -2); }
  :where(.t-xl, .t-lg, .t-body, .t-sm, .t-xs, .prose :is(p, li, dt, dd, summary, blockquote, figcaption, caption), .prose blockquote > :is(footer, cite), .prose div:not([class], :has(> :is(p, div, ul, ol, dl, h1, h2, h3, h4, h5, h6, blockquote, pre, table, figure, hr, details, img, video, iframe)))) { text-wrap: pretty; }
  .t-label, .t-eyebrow, :where(.prose th) { font-weight: var(--fw-label-text); letter-spacing: var(--label-tracking); text-transform: var(--label-case); }
  /* The eyebrow takes the label's case and spacing unless a product gives it its own (D102):
     field labels in sentence case, a section's eyebrow in spaced capitals. */
  .t-eyebrow { letter-spacing: var(--eyebrow-tracking, var(--label-tracking)); text-transform: var(--eyebrow-case, var(--label-case)); }
  /* Marks inside running text never stretch its line. */
  :where(.t-h1, .t-h2, .t-h3, .t-h4, .t-h5, .t-h6, .t-xl, .t-lg, .t-body, .t-sm, .t-xs, .t-label, .t-eyebrow, p, .prose :is(li, dt, dd, summary, blockquote, figcaption, caption, th, td, h1, h2, h3, h4, h5, h6, div)) :where(code, .t-mono, b, strong, em, i, a, sub, sup, kbd, mark, small, cite, abbr, q, s, del, ins, u, var, samp, dfn, time) { line-height: 0; }
  .t-serif { font-family: var(--font-serif); font-weight: var(--fw-serif, 400); }
  .t-mono  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

  /* Settling. CSS trims a text box to its real edges: the top of the
     capitals and the alphabetic baseline. */
  @supports (text-box: trim-both cap alphabetic) {
    :where(.t-h1, .t-h2, .t-h3, .t-h4, .t-h5, .t-h6, .t-xl, .t-lg, .t-body, .t-sm, .t-xs, .t-label, .t-eyebrow, .snap,
           .prose :is(h1, h2, h3, h4, h5, h6), .prose :is(p, li, dt, dd, summary, blockquote, figcaption, caption), .prose blockquote > :is(footer, cite), .prose div:not([class], :has(> :is(p, div, ul, ol, dl, h1, h2, h3, h4, h5, h6, blockquote, pre, table, figure, hr, details, img, video, iframe)))) { text-box: trim-both cap alphabetic; }
    /* A headline pads its top so the block is whole cells. Its bottom edge
       is its last baseline, and each line above is one line-height (a whole
       number of cells) higher, so every baseline falls on a cell line. Layout
       stores the trimmed box in 1/64px units, so the cap height is quantized
       the same way; otherwise the error adds up down the page. */
    :where(.t-h1, .t-h2, .t-h3, .prose :is(h1, h2, h3)) {
      --t-stand: calc(round(up, 1cap, var(--u)) - round(down, 1cap, 0.015625px));
      padding-block-start: var(--t-stand);
    }
    /* Beside a control, text centers its capitals on the control. On one line
       only: settle.js marks one that wraps, and it hangs from its top line and
       rounds up like other text (rule 8). */
    .cap-center { padding-block: 0; align-self: center; height: auto; }
    .cap-center[data-trellis-wrap] { align-self: start; }
    /* x-height edge: lowercase text that aligns with a mark beside it. */
    .snap-x { text-box: trim-both ex alphabetic; }
  }
  /* Text hangs from its top line and rounds its block up to whole cells;
     a headline rounds to the nearest (it is whole cells already, this only
     absorbs sub-pixel error). */
  @supports (height: calc-size(fit-content, size)) and (text-box: trim-both cap alphabetic) {
    :where(.t-h4, .t-h5, .t-h6, .t-xl, .t-lg, .t-body, .t-sm, .t-xs, .t-label, .t-eyebrow, .snap, .snap-x,
           .prose :is(h4, h5, h6), .prose :is(p, li, dt, dd, summary, blockquote, figcaption, caption), .prose blockquote > :is(footer, cite), .prose div:not([class], :has(> :is(p, div, ul, ol, dl, h1, h2, h3, h4, h5, h6, blockquote, pre, table, figure, hr, details, img, video, iframe)))) { height: calc-size(fit-content, round(up, size, var(--u))); }
    /* A cluster (a wrapping row of tags, chips, avatars) settles like text.
       Its items are spaced in half cells, and its block rounds up to whole
       cells. */
    .settle, .field, .pair, .chat-item-meta, .chat-quote, .chat-link, .chat-reactions, :where(.prose :is(pre, table, figure, details, dl, video, audio), .prose > :not(h1, h2, h3, h4, h5, h6, p, ul, ol, hr, blockquote, iframe, div:not([class]))) { height: calc-size(fit-content, round(up, size, var(--u))); }
    /* A cluster rounds to the nearest whole cell, with halves going down and a
       minimum of one cell. So a row of 1½-cell tags takes one cell, and the
       extra half cell overlaps the gap after it. That's safe only because the
       gap between blocks is always a whole number of cells, at least one
       (rule 6), which is why .u-gap-q and .u-gap-h don't apply to a stack.
       Don't follow a cluster with less than a cell. */
    .cluster { height: calc-size(fit-content, max(var(--u), round(down, calc(size + var(--sp-h) - 0.5px), var(--u)))); }
    /* At the end of a surface nothing follows a cluster but the surface's own
       padding, which half a cell of overflow would eat: there it rounds up.
       What it gains sits above its row, in the gap, so the space under it is
       the surface's padding and no more (D92). */
    :is(.card, .modal-body, .member-tile) > .cluster:last-child { height: calc-size(fit-content, round(up, size, var(--u))); align-content: end; }
    :where(.t-h1, .t-h2, .t-h3, .prose :is(h1, h2, h3)) { height: calc-size(fit-content, round(nearest, size, var(--u))); }
    .cap-center[data-trellis-wrap] { height: calc-size(fit-content, round(up, size, var(--u))); }
    /* A list row rounds once, as a whole, and what is in it doesn't (D121).
       Layout rounds each of its outer tracks up to 1/64px, so the two may
       come to 1/32px over the line they share out; that isn't a cell more. */
    .list-item { height: calc-size(fit-content, round(up, size - 0.03125px, var(--u))); }
    .list-item :where(.t-h4, .t-h5, .t-h6, .t-xl, .t-lg, .t-body, .t-sm, .t-xs, .t-label, .t-eyebrow, .snap, .snap-x, .settle, .field, .pair, .cluster),
    .list-item .cap-center[data-trellis-wrap] { height: auto; }
  }
  /* Without calc-size (Safari today) settle.js counts the cells each text block
     needs and writes the count, and the block's min-height is exactly that many
     cells. It writes a count rather than a measured height because WebKit's
     trimmed heights vary by 1/64px depending on where a box sits, and a height
     held at whole cells can't build up that error. */
  @supports not (height: calc-size(fit-content, size)) {
    :where(.t-h4, .t-h5, .t-h6, .t-xl, .t-lg, .t-body, .t-sm, .t-xs, .t-label, .t-eyebrow, .snap, .snap-x,
           .prose :is(h4, h5, h6), .prose :is(p, li, dt, dd, summary, blockquote, figcaption, caption), .prose blockquote > :is(footer, cite), .prose div:not([class], :has(> :is(p, div, ul, ol, dl, h1, h2, h3, h4, h5, h6, blockquote, pre, table, figure, hr, details, img, video, iframe)))) { min-height: calc(var(--u) * var(--settle-n, 0)); }
    .cap-center[data-trellis-wrap] { min-height: calc(var(--u) * var(--settle-n, 0)); }
    /* A row is held at its count, not grown to it: its outer tracks take what
       the count adds, and the 1/32px layout may round them over (D121). */
    .list-item { height: calc(var(--u) * var(--settle-n)); }
    .list-item :where(.t-h4, .t-h5, .t-h6, .t-xl, .t-lg, .t-body, .t-sm, .t-xs, .t-label, .t-eyebrow, .snap, .snap-x),
    .list-item .cap-center[data-trellis-wrap] { min-height: 0; }
  }
}

/* --------------------------------------------------------------------------
   LAYOUT: the anatomy of a page, and the compositions inside it.

   PAGE         .frame      the field of modules and its gutters, centered
                .shell      navigation, main, aside; a tab bar when narrow
   SECTION      .section    a band of the page: a head and a body
                  .cc-split   the head beside the body, when there is room
                  .cc-band    the band's surface reaches the screen's edges
                .cover      a full-screen opening: media to the edges, words in the field
   COMPOSITION  how a region arranges what it holds
                .stack      one above another
                .cluster    a wrapping row: tags, chips, avatars, actions
                .cols       n equal columns
                .split      two columns at a ratio (2 : 1 by default)
                .grid       as many fixed tracks as fit
                .cells      the lattice itself: place things by cell
                .rail       a sideways strip that scrolls and snaps
                .list       rows divided by hairlines
                .board      lanes of cards in a sideways scroller
                .prose      bare tags from an editor, mapped to the roles
   SURFACE      .card       a plane with padding, an edge and its own type
   ELEMENT      the primitives: type roles, tag, button, avatar, float …

   Every composition starts its children on cells and keeps whole cells
   between blocks. It sizes itself from its container rather than the
   window, so it works the same in a sidebar, a card or a page. Contexts
   change its variables; the markup stays the same.
   -------------------------------------------------------------------------- */
@layer trellis.layout {
  /* PAGE. The frame: whole cells wide (plus the hair its last line needs)
     and centered, so the grid fits whatever frames the page: the screen's
     edges when fitted, the frame's own edges on a wide screen, where the
     margins take the rest. The 1/16px tolerance stops an exact fit losing a
     step.
     A reserve (D87): something that lives in a margin, a column of navigation
     beside the page, asks the frame to keep that much clear with
     --frame-reserve-start or --frame-reserve-end, set on the frame or above
     it. The frame stays centered while both margins cover their reserves.
     When one no longer does, the frame gives up the other margin first, then
     its own width, a module at a time. With no reserve nothing changes. */
  .frame {
    --frame-w: min(round(down, calc(100% - var(--frame-reserve-start, 0px) - var(--frame-reserve-end, 0px) - var(--hair) + 1px / 16), var(--frame-step)), var(--frame-max));
    --frame-spare: calc(100% - var(--frame-w) - var(--hair));
    --frame-margin-start: clamp(var(--frame-reserve-start, 0px), var(--frame-spare) / 2, var(--frame-spare) - var(--frame-reserve-end, 0px));
    width: var(--frame-w);
    margin-inline: var(--frame-margin-start) calc(var(--frame-spare) - var(--frame-margin-start));
    padding-inline: var(--gutter);
    /* How far a reserve has moved the frame off the screen's center, in screen
       terms (no percentages), so what's inside can still reach the screen's
       edges: a cover's media reads it. Zero with no reserve. */
    --frame-spare-screen: calc(var(--fit-width, 100vw) - var(--hair) - min(round(down, calc(var(--fit-width, 100vw) - var(--frame-reserve-start, 0px) - var(--frame-reserve-end, 0px) - var(--hair) + 1px / 16), var(--frame-step)), var(--frame-max)));
    --frame-shift: calc(clamp(var(--frame-reserve-start, 0px), var(--frame-spare-screen) / 2, var(--frame-spare-screen) - var(--frame-reserve-end, 0px)) - var(--frame-spare-screen) / 2);
  }

  /* SECTION. A band: a head (label, title, a line of intro) and a body. */
  .section { display: grid; gap: var(--sp-2) var(--sp-4); grid-template-columns: minmax(0, 1fr); align-items: start; }
  .section-head { --stack-gap: var(--sp-1); }
  .section-body { --stack-gap: var(--sp-3); min-width: 0; }
  /* Split: on a wide enough page the head sits beside the body, 22 cells wide. */
  @container (width > 54rem) {
    .section.cc-split { grid-template-columns: var(--section-head-w, calc(var(--u) * 22)) minmax(0, 1fr); }
  }
  /* Band: the section's surface reaches the screen's edges while its content
     stays in the field. Painted with an outset border image, so it never
     widens the page or adds sideways scroll. */
  .section.cc-band {
    padding-block: var(--sp-6);
    border-image: conic-gradient(var(--band-bg, var(--bg-sunken)) 0 0) fill 0 // 0 100vw;
  }

  /* COMPOSITIONS */
  .stack   { display: flex; flex-direction: column; gap: var(--stack-gap, var(--sp-1)); }
  .cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--sp-h)); }
  /* Pair: two lines that belong together, a name over its context, a title over
     its source. Text is trimmed to its letters, so two lines a stack holds a
     cell apart read as two things and a zero gap makes them collide. Inside, a
     pair's lines are spaced in half cells; its block rounds up to whole cells,
     like .settle, so what follows it is on a line. In a cluster
     it takes the row's spare room, so a header's trailing buttons sit at its end. */
  .pair { display: flex; flex-direction: column; gap: var(--sp-h); min-width: 0; }
  .cluster > .pair { flex: 1 1 0; }
  /* Columns: a count, each track rounded down to whole cells, so every
     column's left edge lands on a line. The last right edge is free. */
  .cols {
    --cols: 2;
    --cols-gap: var(--sp-2);
    display: grid;
    gap: var(--cols-gap);
    grid-template-columns: repeat(var(--cols), round(down, calc((100% - (var(--cols) - 1) * var(--cols-gap)) / var(--cols)), var(--u)));
  }
  /* Split: two columns at a ratio, the first rounded down to whole cells.
     Below 36rem of container it becomes one column. */
  .split {
    --split-a: 2;
    --split-b: 1;
    --split-gap: var(--sp-2);
    display: grid;
    gap: var(--split-gap);
    align-items: start;
    grid-template-columns: round(down, calc((100% - var(--split-gap)) * var(--split-a) / (var(--split-a) + var(--split-b))), var(--u)) minmax(0, 1fr);
  }
  @container (width < 36rem) { .split { grid-template-columns: minmax(0, 1fr); } }
  /* As many fixed tracks as fit. Tracks don't stretch; the remainder is space. */
  .grid {
    display: grid;
    gap: var(--grid-gap, var(--sp-2));
    grid-template-columns: repeat(auto-fill, min(var(--grid-min, var(--sp-16)), 100%));
  }
  /* Fill: the tracks share the remainder, so a row of cards reaches both of
     the frame's edges. --grid-min is each track's floor; a short last row
     stretches too (auto-fit). Its tracks are not whole cells. */
  .grid.cc-fill { grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-min, var(--sp-16)), 100%), 1fr)); }
  /* Cells: the lattice as a layout. Every track is one cell; a child is
     placed by --cell-x / --cell-y (1-based, or auto) and sized by --cell-w /
     --cell-h, in cells. For compositions that are drawn rather than flowed:
     Mondrian panels, collages, a hero's free arrangement. Re-place children
     in container queries; never in pixels. */
  .cells { display: grid; grid-template-columns: repeat(auto-fill, var(--u)); grid-auto-rows: var(--u); }
  .cells > * {
    grid-column: var(--cell-x, auto) / span var(--cell-w, 4);
    grid-row: var(--cell-y, auto) / span var(--cell-h, 4);
    min-width: 0;
  }
  /* Rail: a sideways strip that scrolls and snaps: galleries, case studies,
     a row of boards. Items are --rail-item wide (24 cells by default). */
  .rail {
    display: grid; grid-auto-flow: column;
    grid-auto-columns: var(--rail-item, calc(var(--u) * 24));
    gap: var(--rail-gap, var(--sp-2));
    overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    padding-block-end: var(--sp-1);
  }
  .rail > * { scroll-snap-align: start; }
  .row { display: flex; flex-wrap: wrap; gap: var(--row-gap, var(--sp-2)); }
  .col { flex: 1 1 0; min-width: 0; }
  .context { container-type: inline-size; }

  /* PROSE: the CMS layer. Content arrives from editors and markdown as bare
     tags with no classes; .prose maps each tag to its role and settles every
     block to whole cells. All of it has zero specificity against a class, so
     a class on a tag wins. Headings and text follow the same rules as
     everywhere else (see the type roles in BASE). README, Prose, has the whole map and what it does with things
     an editor emits that have no role. */
  .prose {
    --stack-gap: var(--sp-2);
    --prose-inner-gap: var(--sp-1);
    container-type: inline-size;
    display: flex; flex-direction: column;
    gap: var(--stack-gap);
    max-inline-size: var(--prose-measure);
    min-width: 0;
    overflow-wrap: break-word;
  }
  /* A heading keeps more space before it than after, so it belongs to what it
     introduces. Whole cells added to the gap; none right after another heading. */
  :where(.prose, .prose div:not([class])) > :where(h1, h2):not(:first-child) { --prose-before: var(--sp-4); margin-block-start: var(--prose-before); }
  :where(.prose, .prose div:not([class])) > :where(h3):not(:first-child) { --prose-before: var(--sp-2); margin-block-start: var(--prose-before); }
  :where(.prose, .prose div:not([class])) > :where(h4, h5, h6):not(:first-child) { --prose-before: var(--sp-1); margin-block-start: var(--prose-before); }
  :where(.prose, .prose div:not([class])) > :where(h1, h2, h3, h4, h5) + :where(h2, h3, h4, h5, h6) { --prose-before: 0px; margin-block-start: 0px; }

  /* Lists: whole cells between items, the marker in a whole-cell margin. */
  .prose :where(ul, ol) {
    display: flex; flex-direction: column;
    gap: var(--prose-inner-gap);
    padding-inline-start: var(--sp-2);
    margin: 0;
  }
  .prose :where(ol) { padding-inline-start: var(--sp-3); }
  .prose :where(li)::marker { color: var(--text-tertiary); }
  /* A task list's box is the choice's checkbox (D109, under Primitives). */

  /* Blocks that nest. What follows text or an image inside them can't be
     rounded in CSS: the text is an anonymous box, the image any height. So
     settle.js measures and writes --settle-start, in every browser. Without
     it the outer block still rounds to whole cells. */
  .prose :where(li, blockquote, figure, details) > * { margin-block-start: var(--settle-start, 0px); }
  .prose :where(li, blockquote, details) > :where(p, ul, ol, dl, pre, blockquote, figure, table, details, h1, h2, h3, h4, h5, h6, footer):not(:first-child),
  .prose :where(li) > :where(ul, ol),
  .prose :where(blockquote) > :where(footer, cite),
  .prose :where(figure) > figcaption,
  .prose :where(details) > :not(summary) {
    margin-block-start: calc(var(--prose-inner-gap) + var(--settle-start, 0px));
  }

  /* Quotation: a line after its coordinate, text on the second cell. */
  .prose :where(blockquote) {
    margin: 0;
    padding-inline-start: calc(var(--sp-2) - var(--line));
    border-inline-start: var(--line) solid var(--border-strong);
  }
  .prose :where(blockquote > cite) { display: block; font-style: normal; }
  .prose :where(blockquote > footer, blockquote > cite, figcaption, caption) { color: var(--text-secondary); }

  /* Code: a surface with one cell of padding, so it steps out like a card (Outset). */
  .prose :where(pre) {
    container-type: inline-size;   /* a surface, as wide as its column */
    margin-block: 0;
    padding: var(--sp-1);
    overflow-x: auto;
    border-radius: var(--r-h);
    background: var(--bg-sunken);
    font-family: var(--font-mono);
    font-size: var(--fs-control-md);
    line-height: var(--sp-2);
    tab-size: 2;
  }
  .prose > :where(pre) { margin-inline: calc(var(--outset) * var(--u) * -1); }
  .prose :where(pre code) { font: inherit; background: none; padding: 0; }
  .prose :where(code, kbd, samp) { font-family: var(--font-mono); font-size: .9em; }
  .prose :where(:not(pre) > code, kbd) {
    padding-inline: var(--sp-q);
    border-radius: var(--r-q);
    background: color-mix(in oklab, var(--text) 9%, transparent);
    box-decoration-break: clone; -webkit-box-decoration-break: clone;
  }
  .prose :where(kbd) { outline: var(--line) solid var(--border); outline-offset: calc(var(--line) * -1); }
  .prose :where(mark) { color: inherit; background: color-mix(in oklab, var(--accent) 24%, transparent); }
  .prose :where(small) { font-size: .8em; }
  .prose :where(strong, b) { font-weight: var(--fw-strong); }
  /* Moved, not baseline-shifted, so a superscript can't push its line apart. */
  .prose :where(sub, sup) { font-size: .72em; vertical-align: baseline; position: relative; }
  .prose :where(sup) { inset-block-start: -.4em; }
  .prose :where(sub) { inset-block-start: .25em; }

  /* The rule is one line tall, and its bottom margin is one line shorter to
     make up for it, so what follows stays on the cell grid. */
  .prose :where(hr) {
    height: var(--line);
    margin-block: var(--sp-2) calc(var(--sp-2) - var(--line));
    margin-inline: 0;   /* the browser's auto margins would collapse it to nothing in a flex column */
    border: 0;
    background: var(--border);
  }

  /* Tables are a lattice: every line of a cell is whole cells, so rows stand on
     the grid with no measuring, and a row's rule is given back in its padding.
     Displayed as a block so a wide one scrolls inside itself. */
  .prose :where(table) {
    display: block;
    width: max-content; max-width: 100%;
    overflow-x: auto;
    border-collapse: separate; border-spacing: 0;
  }
  .prose :where(caption) { caption-side: top; text-align: start; margin-block-end: var(--sp-1); }
  .prose :where(th, td) {
    --t-line: round(up, calc(1em * var(--t-lh)), var(--u));
    padding-block: var(--sp-h) calc(var(--sp-h) - var(--line));
    padding-inline: 0 var(--sp-2);
    border-block-end: var(--line) solid var(--border-subtle);
    text-align: start;
    vertical-align: top;
  }
  .prose :where(th) { border-block-end-color: var(--border-strong); color: var(--text-secondary); }
  .prose :where(th:last-child, td:last-child) { padding-inline-end: 0; }

  /* Media. Corners from the card knob; a caption hangs from the next line. */
  .prose :where(figure) { margin: 0; }
  .prose :where(img, video) { width: 100%; height: auto; border-radius: var(--shape-card); }
  .prose :where(iframe) {
    display: block;
    width: 100%;
    height: round(up, calc(100cqi * var(--embed-h, 9) / var(--embed-w, 16)), var(--u));
    border: 0;
    border-radius: var(--shape-card);
  }
  /* Gallery: two or more images side by side, in a figure or a paragraph (what
     markdown emits for images on one line). Tracks are whole cells and squares,
     so nothing in it needs measuring.
     Two images, each alone or inside a link: a link counts only for the image
     in it, so a sentence with two links in it stays a sentence. A paragraph
     is a gallery only when images are all it holds: images, links with no
     class, a break. A tag, a chip, a face (.avatar), a link with a class or
     any mark in it makes it text, and what is inline in it stays inline (D106).
     CSS can't see bare words, so a paragraph of nothing but words and two
     images is still read as a gallery. */
  .prose :where(figure):where(:has(> img ~ img), :has(> img):has(> a > img), :has(> a > img):has(> a ~ a > img)),
  .prose :where(p):where(:not(:has(> :not(img:not(.avatar), a:not([class]), br)))):where(:has(> img ~ img), :has(> img):has(> a > img), :has(> a > img):has(> a ~ a > img)) {
    --cols: 3;
    --cols-gap: var(--sp-1);
    display: grid;
    gap: var(--cols-gap);
    grid-template-columns: repeat(var(--cols), round(down, calc((100% - (var(--cols) - 1) * var(--cols-gap)) / var(--cols)), var(--u)));
  }
  @container (width < 36rem) {
    .prose :where(figure):where(:has(> img ~ img), :has(> img):has(> a > img), :has(> a > img):has(> a ~ a > img)),
    .prose :where(p):where(:not(:has(> :not(img:not(.avatar), a:not([class]), br)))):where(:has(> img ~ img), :has(> img):has(> a > img), :has(> a > img):has(> a ~ a > img)) { --cols: 2; }
  }
  .prose :where(figure):where(:has(> img ~ img), :has(> img):has(> a > img), :has(> a > img):has(> a ~ a > img)) > :where(img, a > img),
  .prose :where(p):where(:not(:has(> :not(img:not(.avatar), a:not([class]), br)))):where(:has(> img ~ img), :has(> img):has(> a > img), :has(> a > img):has(> a ~ a > img)) > :where(img, a > img) { aspect-ratio: 1; object-fit: cover; }
  .prose :where(figure):where(:has(> img ~ img), :has(> img):has(> a > img), :has(> a > img):has(> a ~ a > img)) > figcaption { grid-column: 1 / -1; margin-block-start: 0; }

  /* Disclosure. The summary is a full-row target with the shared states, its
     ground half a cell around it. Its chevron sits in a two-cell margin, like a
     list's marker, centered on the capitals (rule 9), and turns when open. The
     answer takes the same inset, in --details-ink: a role, not opacity, so an
     image or code inside isn't faded. Consecutive details are rows: a hairline
     in the middle of the gap between them, a plane on a line, adding no height. */
  .prose :where(details) {
    --details-ink: var(--text-secondary);
    --details-chevron: var(--sp-h);
    position: relative;
    margin: 0;
  }
  .prose :where(summary) {
    position: relative;
    display: block; list-style: none;
    padding-inline-start: var(--sp-2);
    border-radius: var(--r-q);
    cursor: pointer; font-weight: var(--fw-label);
    background: color-mix(in oklab, var(--text) var(--state-act), transparent);
    box-shadow: 0 0 0 var(--sp-h) color-mix(in oklab, var(--text) var(--state-act), transparent);
    transition: background-color var(--dur-out) var(--ease-in), box-shadow var(--dur-out) var(--ease-in);
  }
  .prose :where(summary)::-webkit-details-marker { display: none; }
  .prose :where(summary):focus-visible { outline-offset: var(--sp-h); }
  /* Two sides of a square, turned: the drawn half sits off the square's center
     by a third of its side, which the translate gives back. */
  .prose :where(summary)::before {
    content: ""; position: absolute;
    inset-inline-start: calc(var(--sp-h) - var(--details-chevron) / 2);
    inset-block-start: calc(.5cap - var(--details-chevron) / 2);
    width: var(--details-chevron); height: var(--details-chevron);
    border-inline-end: calc(var(--line) * 1.5) solid var(--text-tertiary);
    border-block-end: calc(var(--line) * 1.5) solid var(--text-tertiary);
    transform: translateX(calc(var(--details-chevron) * -.354)) rotate(-45deg);
    transition: transform var(--dur-in) var(--ease-out);
  }
  .prose :where(summary:dir(rtl))::before { transform: translateX(calc(var(--details-chevron) * .354)) rotate(45deg) scaleX(-1); }
  .prose :where(details[open] > summary)::before { transform: translateY(calc(var(--details-chevron) * -.354)) rotate(45deg); }
  .prose :where(details) > :where(:not(summary)) { margin-inline-start: var(--sp-2); color: var(--details-ink); }
  .prose :where(details + details)::before {
    content: ""; position: absolute;
    inset-inline: 0;
    inset-block-start: calc(round(down, var(--stack-gap, var(--sp-2)) / 2, var(--u)) * -1);
    height: var(--hair);
    background: var(--border-subtle);
    pointer-events: none;
  }
  .prose :where(dl) { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--prose-inner-gap); }   /* the track may shrink below its longest word, so a long word breaks instead of widening the column */
  .prose :where(dt) { font-weight: var(--fw-strong); }
  .prose :where(dd + dt) { margin-block-start: var(--sp-1); }   /* a term belongs to its definition */
  .prose :where(dd) { margin: 0; }

  /* What an editor emits that has no role. README, Prose, has the reasoning. */
  /* A nested div from a paste is transparent: its children join the column. A
     div holding only text and marks is a paragraph (see the role map above). */
  :where(.prose div:not([class]):has(> :is(p, div, ul, ol, dl, h1, h2, h3, h4, h5, h6, blockquote, pre, table, figure, hr, details, img, video, iframe))) { display: contents; }
  /* An empty block is not space. :empty catches what CSS can see; settle.js
     marks a lone <br> or &nbsp;, which CSS can't tell from real content. */
  .prose :where(h1, h2, h3, h4, h5, h6, p, li, blockquote, div:not([class])):empty,
  .prose [data-prose-empty] { display: none; }
  /* A style attribute may keep emphasis and alignment; it does not get type,
     color or space. !important is what beats an inline style. The selector
     skips styles that only set variables (rule: inline styles set variables),
     which is all settle.js ever writes. */
  .prose :where(span, font, a, em, strong, b, i, u)[style]:not([style^="--"]), .prose :where(font) {
    font-size: inherit !important; font-family: inherit !important; line-height: inherit !important;
    letter-spacing: inherit !important;
    color: inherit !important; background: none !important;
    margin: 0 !important; padding: 0 !important;
  }
  .prose :where(h1, h2, h3, h4, h5, h6, p, li, blockquote, div:not([class]))[style]:not([style^="--"]) {
    font-size: var(--t-fs) !important;
    line-height: var(--t-line) !important;
    letter-spacing: normal !important; text-indent: 0 !important;
    color: inherit !important; background: none !important;
    margin-block-start: var(--prose-before, 0px) !important;
    margin-block-end: var(--prose-after, 0px) !important;
    margin-inline: 0 !important;
    padding-inline: 0 !important;
    padding-block-start: var(--t-stand, 0px) !important;
    padding-block-end: 0 !important;
    float: none !important;
  }
  .prose :where(h1, h2, h3, h4, h5, h6)[style]:not([style^="--"]) { font-family: var(--font-heading, var(--font-sans)) !important; }
  .prose :where(p, li, div:not([class]))[style]:not([style^="--"]) { font-family: var(--font-sans) !important; }
  .prose :where(th, td)[style]:not([style^="--"]) {
    font-size: var(--t-fs) !important; color: inherit !important; background: none !important;
    width: auto !important; height: auto !important;
  }
  .prose :where(img)[style]:not([style^="--"]) { float: none !important; width: 100% !important; height: auto !important; margin: 0 !important; }

  /* LIST: rows divided by hairlines: chats, actions, members, post indexes.
     A row's height is whole cells (its padding is, and everything in it
     settles), and its rule is a plane after its bottom coordinate, so rules
     never add height. Rows step out like cards (Outset): the hover surface steps out while
     the text stays on the column's edge. Markup: ul.list > li.list-item >
     leading mark, .list-body, .list-end.
     Where a row's parts meet (D104). Text in a role is trimmed to its capitals,
     so a row's parts hang from one line by default (--list-align: flex-start):
     right for a face beside two lines. A mark the size of a line, a dot, an
     icon, a small face, sits in a .list-mark, which centers it on the first
     line's capitals however many lines the row runs to. A row that is one line
     and its controls centers them all with --list-align: center, its words
     cap-centered (rule 8).
     A row centers its words in the space it takes (D121): its words, its marks
     and its end make one line of the row, the middle of three tracks, and the
     row rounds up to whole cells once, so what rounding adds is shared evenly
     above and below. Text in a row is not rounded on its own. A face or an
     image beside the words spans the three tracks at the row's top, so words
     shorter than it center on it. The body is the one column that gives way;
     what comes before it takes columns before, what comes after, columns after. */
  .list {
    --list-pad-y: var(--sp-1);
    --list-gap: var(--sp-1);
    --list-rule: var(--border-subtle);
    --list-align: flex-start;
    --list-mark-w: var(--sp-1);
    --list-outset: calc(var(--outset) * var(--u));
    display: flex; flex-direction: column;
    margin: 0; padding: 0;
    margin-inline: calc(var(--list-outset) * -1);
    list-style: none;
    min-width: 0;
  }
  .list-item {
    position: relative;
    display: grid; align-items: var(--list-align, flex-start); column-gap: var(--list-gap);
    grid-template-columns: minmax(0, 1fr); grid-auto-columns: max-content;
    grid-template-rows: 1fr auto 1fr;
    padding-block: var(--list-pad-y);
    padding-inline: var(--list-outset);
    min-width: 0;
    color: inherit; text-decoration: none;
  }
  .list-item:not(:last-child)::after {
    content: ""; position: absolute;
    inset-inline: var(--list-outset);
    inset-block-end: calc(var(--hair) * -1);
    height: var(--hair);
    background: var(--list-rule);
    pointer-events: none;
  }
  :where(a, button).list-item { width: 100%; text-align: start; cursor: pointer; }
  :where(a, button).list-item, .list-item:has(.list-link) { background: color-mix(in oklab, var(--text) calc(var(--state-on) + var(--state-act)), transparent); }
  @media (hover: hover) { .list-item:has(.list-link:hover) { --state-act: var(--state-hover); } }
  .list-item:has(.list-link:active) { --state-act: var(--state-press); }
  .list-item:has(.list-link:is([aria-current]:not([aria-current="false"]), [aria-selected="true"])) { --state-on: var(--state-selected); }
  /* A selected row also gets an accent bar at its start (see States). */
  .list-item:is([aria-current]:not([aria-current="false"]), [aria-selected="true"]) { --state-on: var(--state-selected); background: color-mix(in oklab, var(--text) calc(var(--state-on) + var(--state-act)), transparent); }
  .list-item:is([aria-current]:not([aria-current="false"]), [aria-selected="true"]), .list-item:has(.list-link:is([aria-current]:not([aria-current="false"]), [aria-selected="true"])) { box-shadow: inset calc(var(--line) * 2) 0 0 var(--accent); }
  /* A row that links rings the whole row, not the words in it. */
  .list-link:focus-visible { outline: none; }
  .list-item:has(.list-link:focus-visible) { outline: calc(var(--line) * 2) solid var(--focus); outline-offset: calc(var(--line) * -2); }
  .list-item > :not(.list-actions) { grid-row: 1 / -1; }
  .list-item > :is(.list-body, .list-end, .list-mark) { grid-row: 2; }
  .list-body { --stack-gap: var(--sp-1); grid-column: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--stack-gap); }
  .list-item > :has(+ .list-body) { grid-column: -3; }
  .list-item > :has(+ * + .list-body) { grid-column: -4; }
  .list-item > :has(+ * + * + .list-body) { grid-column: -5; }
  .list-end { flex: none; display: flex; align-items: var(--list-align, flex-start); gap: var(--sp-h); }
  /* A mark on the first line (.list-mark, at the row's start or in its end): a
     box as tall as a capital, at the row's top, where the first line's capitals
     are; what it holds is centered on them and may reach past it, into the row's
     padding. It is a capital of its own type: give it the role of the line
     beside it (span.list-mark.t-sm) and it is exactly that line's; with none it
     takes the type around the row, within a pixel or two from .t-xs to .t-body.
     A role would round it up to whole cells, as it does text; the mark keeps its
     capital. At the row's start it is a column --list-mark-w wide, a cell, with
     the mark at its start (rule 7), so the row's words start on a line whatever
     the mark's size; in the row's end it is as wide as its mark. */
  .list-mark { flex: none; display: flex; align-items: center; justify-content: flex-start; width: var(--list-mark-w, var(--sp-1)); height: 1cap; min-height: 0; }
  .list-end > .list-mark { width: auto; justify-content: flex-end; }
  /* One line of words in a centered row: its capitals center on the row's
     controls (.cap-center), across the body's width, not in its middle. */
  .list-body > .cap-center { align-self: stretch; }
  /* A row's two lines, when it has them: its title and the line under it (a
     name and a preview). Unread (.cc-unread) weighs the title and inks the
     line under it; a .dot.cc-accent in .list-end says so without color alone
     when it carries a label. */
  .list-title { color: var(--text); }
  .list-sub { color: var(--text-secondary); }
  .list-item.cc-unread .list-title { font-weight: var(--fw-strong); }
  .list-item.cc-unread .list-sub { color: var(--text); }
  .list-end:has(> .pair) { text-align: end; }
  /* A whole row that links somewhere, from a link inside it. */
  .list-link { color: inherit; text-decoration: none; }
  .list-link::before { content: ""; position: absolute; inset: 0; }
  /* Grouped rows (.list.cc-group): the rows share one surface, with a card's
     ground, edge and corner, stepping out as a card does. Each rule starts at
     the row's text, past its leading mark, and runs to the surface's edge: an
     outset border image on the row's body, clipped sideways by the row, so it
     adds no size and needs no measure of the mark. */
  .list.cc-group {
    --surface: var(--bg-raised);
    position: relative;
    background: var(--surface);
    border-radius: var(--shape-card);
  }
  .list.cc-group::after {
    content: ""; position: absolute;
    inset: 0 calc(var(--line) * -1) calc(var(--line) * -1) 0;
    border: var(--line) solid var(--border-subtle);
    border-radius: inherit;
    pointer-events: none;
  }
  .list.cc-group > .list-item { overflow-x: clip; }
  .list.cc-group > .list-item:first-child { border-start-start-radius: inherit; border-start-end-radius: inherit; }
  .list.cc-group > .list-item:last-child { border-end-start-radius: inherit; border-end-end-radius: inherit; }
  .list.cc-group > .list-item:not(:last-child)::after { grid-column: 1 / auto; inset-inline: 0; }
  /* A dense row is treated as one control: its edges stay on cell lines and
     its contents are spaced in half cells, as in a button or a cluster. */
  .cc-dense .list, .list.cc-dense { --list-pad-y: var(--sp-h); --list-gap: var(--sp-h); }
  /* ...and the gap between its lines is halved with its padding (D121). */
  :is(.cc-dense .list, .list.cc-dense) .list-body { --stack-gap: var(--sp-h); }

  /* SHELL: navigation, main, an aside, and a foot. It lays out by its own
     width rather than the window's: three columns, then the aside under main, then a
     tab bar. A query can't restyle the container it asks, so .shell is the
     container and .shell-grid does the layout. Markup: .shell > .shell-grid >
     .shell-nav, .shell-main, .shell-aside, .shell-foot. .shell.cc-top puts the
     navigation in a bar across the top instead (below). */
  .shell { container: shell / inline-size; }
  .shell-grid {
    --shell-nav-w: calc(var(--u) * 20);
    --shell-aside-w: calc(var(--u) * 24);
    --shell-aside-col: 0px;   /* the aside's column, there only when there is an aside (below) */
    --shell-pad: var(--sp-2);
    display: grid;
    min-height: var(--shell-h, 100svh);
    grid-template-columns: var(--shell-nav-w) minmax(0, 1fr) var(--shell-aside-col);
    grid-template-areas: "nav main aside" "nav foot foot";
    grid-template-rows: 1fr auto;
  }
  .shell-grid:has(> .shell-aside:not([hidden])) { --shell-aside-col: var(--shell-aside-w); }
  .shell-nav {
    grid-area: nav;
    position: sticky; inset-block-start: 0;
    align-self: start;
    height: var(--shell-h, 100svh);
    display: flex; flex-direction: column; gap: var(--sp-q2);
    padding: var(--sp-1);
    background: var(--shell-nav-bg);
    backdrop-filter: blur(var(--shell-nav-blur));
    box-shadow: var(--line) 0 0 var(--border-subtle);
    z-index: var(--z-raised);
  }
  /* Its ground and its blur (D115). Opaque and not blurred unless a context
     says so: with no blur set, the filter is none. What scrolls under a
     translucent bar is anything, so a ground keeps at least 85% of --surface
     or --bg-raised: there --text and --text-secondary hold 4.5:1 over black
     and over white. --text-tertiary does not, and the focus ring may not (set
     --focus: var(--text) beside it). Opaque for a reader who asks for less
     transparency, and in forced colors. */
  .shell-nav { --shell-nav-bg: var(--surface); --shell-nav-blur: initial; }
  @media (prefers-reduced-transparency: reduce) { .shell-nav { background: var(--surface); backdrop-filter: none; } }
  .shell-main { grid-area: main; min-width: 0; padding: var(--shell-pad); }
  .shell-aside { grid-area: aside; min-width: 0; padding: var(--shell-pad); }
  /* The foot: groups of links, then the small print. Its rule is a plane
     after its top coordinate, inside it, so it adds no height. */
  .shell-foot {
    grid-area: foot; min-width: 0;
    display: flex; flex-direction: column; gap: var(--sp-4);
    padding: var(--shell-pad);
    box-shadow: inset 0 var(--line) 0 var(--border-subtle);
  }
  .shell-link {
    display: flex; align-items: center; gap: var(--sp-h);
    min-height: var(--size-control-md);
    padding-inline: var(--sp-h);
    border-radius: var(--r-h);
    color: var(--text-secondary); text-decoration: none;
    font-size: var(--fs-control); font-weight: var(--fw-label);
  }
  .shell-link { background: color-mix(in oklab, var(--text) calc(var(--state-on) + var(--state-act)), transparent); }
  @media (hover: hover) { .shell-link:hover { color: var(--text); } }
  /* A mark is a straight line: the corners it touches are square (D85). */
  .shell-link[aria-current]:not([aria-current="false"]) { color: var(--text); box-shadow: inset calc(var(--line) * 2) 0 0 var(--accent); border-start-start-radius: 0; border-end-start-radius: 0; }
  @container shell (width < 72rem) {
    .shell-grid {
      grid-template-columns: var(--shell-nav-w) minmax(0, 1fr);
      grid-template-areas: "nav main" "nav aside" "nav foot";
      grid-template-rows: 1fr auto auto;
    }
  }
  @container shell (width < 48rem) {
    .shell-grid {
      grid-template-columns: minmax(0, 1fr);
      grid-template-areas: "main" "aside" "foot" "nav";
      grid-template-rows: 1fr auto auto auto;
    }
    .shell-nav {
      position: sticky; inset-block: auto 0;
      height: auto;
      flex-direction: row; justify-content: space-around; gap: 0;
      /* Whole cells, so a tab bar never pushes what follows off the lines. */
      padding-block: 0 round(up, env(safe-area-inset-bottom, 0px), var(--u));
      padding-inline: var(--shell-pad);   /* as main pads, so the outer links' fills share its content edge */
      box-shadow: inset 0 var(--line) 0 var(--border-subtle);
    }
    .shell-link {
      flex: 1 1 0; flex-direction: column; justify-content: center; gap: var(--sp-q);
      min-height: round(up, max(var(--sp-4), var(--hit-min)), var(--u));
      padding-inline: 0;
      font-size: var(--fs-control-xs);
    }
    /* The tab bar's own current state: the fill, and its mark on the bar's
       edge, the top, where the wide column's mark is on the start. The
       corners the mark touches are square (D85). Not in .cc-top, whose
       narrow links are a tray and keep the column's mark. */
    .shell:not(.cc-top) .shell-link[aria-current]:not([aria-current="false"]) {
      box-shadow: inset 0 calc(var(--line) * 2) 0 var(--accent);
      border-radius: 0 0 var(--r-h) var(--r-h);
    }
  }

  /* SHELL ACROSS THE TOP (.shell.cc-top): the navigation is a bar across the
     top, --shell-bar-h tall (four cells) and sticky, its rule a plane after
     its bottom coordinate. Main and the aside sit under it, the foot under
     them; the aside drops under main below 72rem. Under 48rem the links fold
     behind the menu button and open as a left tray (see .shell-links). */
  .shell.cc-top > .shell-grid {
    --shell-bar-h: var(--sp-4);
    grid-template-columns: minmax(0, 1fr) var(--shell-aside-col);
    grid-template-areas: "nav nav" "main aside" "foot foot";
    grid-template-rows: auto 1fr auto;
  }
  .shell.cc-top .shell-nav {
    position: sticky; inset-block: 0 auto;
    height: var(--shell-bar-h);
    flex-direction: row; align-items: center; justify-content: flex-start; gap: var(--sp-2);
    padding-block: 0; padding-inline: var(--shell-pad);
    box-shadow: 0 var(--line) 0 var(--border-subtle);
    z-index: var(--z-sticky);
  }
  @container shell (width < 72rem) {
    .shell.cc-top > .shell-grid {
      grid-template-columns: minmax(0, 1fr);
      grid-template-areas: "nav" "main" "aside" "foot";
      grid-template-rows: auto 1fr auto auto;
    }
  }
  @container shell (width < 48rem) {
    .shell.cc-top .shell-nav {
      position: sticky; inset-block: 0 auto;
      height: var(--shell-bar-h);
      justify-content: flex-start; gap: var(--sp-1);
      padding-block: 0;
      box-shadow: 0 var(--line) 0 var(--border-subtle);
    }
  }

  /* COVER: a full-screen opening. Media to the edges, words in the field. The
     media reaches the screen through --fit-width, the real width settle.js
     publishes, so a classic scrollbar can't add sideways scroll. Its height is
     whole cells, so what follows is on a line. Markup: .cover > .cover-media +
     .cover-body. */
  .cover {
    --cover-h: round(up, 100svh, var(--u));
    --cover-pad: var(--sp-6);
    --cover-scrim: color-mix(in oklab, var(--black) 72%, transparent);
    position: relative;
    isolation: isolate;
    display: grid; align-content: end;
    min-height: var(--cover-h);
    padding-block: var(--cover-pad);
    color: var(--white);
  }
  .cover-media {
    position: absolute; z-index: -1;
    inset-block: 0;
    inset-inline: calc((100% - var(--fit-width, 100vw)) / 2 - var(--frame-shift, 0px)) calc((100% - var(--fit-width, 100vw)) / 2 + var(--frame-shift, 0px));
    overflow: hidden;
    background: var(--bg-sunken);
  }
  .cover-media > :where(img, video) { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
  .cover-media::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(to top, var(--cover-scrim), transparent 70%);
    pointer-events: none;
  }
  .cover-body { --stack-gap: var(--sp-2); display: flex; flex-direction: column; gap: var(--stack-gap); max-inline-size: var(--prose-measure); min-width: 0; }

  /* BOARD: lanes of cards in a sideways scroller. Markup: .board > .board-lane
     > .board-lane-head + cards. A lane clips nothing; the board keeps a line
     spare at its end and a cell below, or it would cut off the last card's edge
     plane and scrollbar. Lane cards pad --board-card-pad (a cell) and the lane
     head pads its sides the same, so the lane's label and its cards' text share
     a line. Cards in a lane don't step out: the scroller would clip them. */
  .board {
    --board-lane-w: calc(var(--u) * 24);
    --board-card-pad: var(--sp-1);
    --board-gap: var(--sp-2);
    display: grid; grid-auto-flow: column;
    grid-auto-columns: var(--board-lane-w);
    gap: var(--board-gap);
    align-items: start;
    overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding-inline-end: var(--line);
    padding-block-end: var(--sp-1);
  }
  .board-lane { display: flex; flex-direction: column; gap: var(--board-lane-gap, var(--sp-1)); min-width: 0; scroll-snap-align: start; }
  .board-lane-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-h); min-height: var(--sp-2); padding-inline: var(--board-card-pad); }
  .cc-dense .board, .board.cc-dense { --board-lane-w: calc(var(--u) * 20); --board-gap: var(--sp-1); --board-lane-gap: var(--sp-h); }

  /* SURFACES step out (Outset). A card's edge steps --outset cells (a
     product knob, 1 by default) into the space around it, so the text inside
     a card with a one-cell padding lines up with the text outside; a card
     with more padding still steps out one cell. A row steps out as a whole,
     but only when it holds nothing but cards: a text column beside a card
     never moves, and a card inside one column of a row stays in its column.
     Gutters are at least two cells, so a card that steps out never reaches
     the screen's edge. Nested, a card steps out into its parent's padding.
     Outset is clipped by any ancestor with hidden overflow (a scroll pane, a
     clipped section): a card there silently loses its step-out. Give that
     ancestor --outset: 0, or a cell of inline padding. */
  :where(.stack, .section-body):not(:where(.cols, .split, .grid, .rail) > *) > .card { margin-inline: calc(var(--outset) * var(--u) * -1); }
  /* Not applied to .frame: a frame is centered by its margins, so a grid of
     cards that is also the frame would lose its centering and run off the
     page. */
  :where(.cols, .grid, .split, .rail):has(> .card):not(:has(> :not(.card))):not(.frame) { margin-inline: calc(var(--outset) * var(--u) * -1); }
}

/* --------------------------------------------------------------------------
   PRIMITIVES. Each exposes variables; context and products retune them.
   A surface's edge is a plane one line thick that sits after its
   coordinate, like every line: inside the box on the left and top, just
   outside it on the right and bottom (an ::after frame one line larger).
   So each edge lies on the same device pixels as the grid line it stands
   on, and it never changes the box's size or moves its content. Surfaces
   that scroll clip their own children, so they keep an inset outline.
   Controls with a fixed height keep a real border and give its width back
   in their padding.
   -------------------------------------------------------------------------- */
@layer trellis.primitives {

  /* Card --------------------------------------------------------------- */
  .card {
    /* Padding is two variables, sides and top-and-bottom. --card-pad is the
       shorthand a variant or context sets for both; it starts empty on every
       card, so a nested card doesn't inherit its parent's. */
    --card-pad: initial;
    --card-pad-inline: var(--card-pad, var(--density-card-pad-inline, var(--density-card-pad)));
    --card-pad-block: var(--card-pad, var(--density-card-pad-block, var(--density-card-pad)));
    --card-radius: var(--shape-card);
    /* Padding clears the corner (D113): what a card lays out is its inset, its
       padding and whole cells more where content would meet the corner's curve.
       Content p in on both sides is inside a corner of radius r from .293r
       (1 - 1/√2); with its other side further in, at q, from the chord between
       there and no padding at all where the curve ends: .415 (r - q). The
       corner counts up to eight cells: a pill's real corner is its height's. */
    --card-corner: min(var(--card-radius), calc(var(--u) * 8));
    --card-own-inline: var(--card-pad-inline);
    --card-own-block: var(--card-pad-block);
    --card-inset-inline: calc(var(--card-pad-inline) + round(up, max(0px, min(.293 * var(--card-corner), .415 * (var(--card-corner) - var(--card-own-block))) - var(--card-own-inline) - 1px / 16), var(--u)));
    --card-inset-block: calc(var(--card-pad-block) + round(up, max(0px, min(.293 * var(--card-corner), .415 * (var(--card-corner) - var(--card-own-inline))) - var(--card-own-block) - 1px / 16), var(--u)));
    --card-border: var(--border-subtle);
    --surface: var(--bg-raised);
    position: relative;
    container-type: inline-size;
    background: var(--surface);
    border-radius: var(--card-radius);
    padding-block: var(--card-inset-block);
    padding-inline: var(--card-inset-inline);
  }
  .card::after {
    content: "";
    position: absolute;
    inset: 0 calc(var(--line) * -1) calc(var(--line) * -1) 0;
    border: var(--line) solid var(--card-border);
    border-radius: inherit;
    pointer-events: none;
  }
  .card-media {
    /* Concentric with the card's corner, from the nearer of its two paddings. */
    border-radius: max(var(--r-q), calc(var(--card-radius) - min(var(--card-inset-inline), var(--card-inset-block))));
    overflow: hidden;
  }
  /* A dense card's corner is the product's knob too (D115): a cell unless set. */
  .cc-dense .card, .card.cc-dense { --card-pad: var(--sp-1); --card-radius: var(--shape-card-dense, var(--r-1)); }
  /* Surfaces on surfaces (D81). Nesting shows as a change of ground rather
     than a shadow. A surface inside a surface (a card, a grouped list, a
     modal, a float) is one step along the neutral ladder, --bg-raised-2, and
     one inside that is --bg-raised-3, where it stops at three levels. --surface-level says which, for
     anything that reads it. Nesting needs no class. */
  .card, .list.cc-group { --surface-level: 1; }
  :is(.card, .list.cc-group, .modal-inner, .float) :is(.card, .list.cc-group) { --surface-level: 2; --surface: var(--bg-raised-2); }
  :is(.card, .list.cc-group, .modal-inner, .float) :is(.card, .list.cc-group, .modal-inner, .float) :is(.card, .list.cc-group) { --surface-level: 3; --surface: var(--bg-raised-3); }
  /* A surface on a surface is drawn by its ground alone (D88). It has no
     border, because outlines nested two or three deep start to look like a
     wireframe. It has one cell of padding, so after its one-cell step out its
     text lines up with the text of the surface around it. */
  :is(.card, .list.cc-group, .modal-inner, .float) .card {
    --card-border: transparent;
    --card-pad-inline: var(--card-pad, min(var(--density-card-pad-inline, var(--density-card-pad)), var(--sp-1)));
    --card-pad-block: var(--card-pad, min(var(--density-card-pad-block, var(--density-card-pad)), var(--sp-1)));
  }
  /* A nested card steps out only into padding its parent can spare, so at
     least a cell stays between the two edges: a card in a two-cell card steps
     out a cell, a card in a one-cell card stays where it is. And nested
     corners are concentric with the real gap between the edges: the parent's
     corner less that gap, never under a quarter cell. Each level reads the
     one above from variables that level alone writes, so none refers to
     itself. */
  .card:not(.card .card) {
    --card-nest-out: min(calc(var(--outset) * var(--u)), max(0px, calc(var(--card-inset-inline) - var(--u))));
    --card-nest-r: max(var(--r-q), calc(var(--card-radius) - min(calc(var(--card-inset-inline) - var(--card-nest-out)), var(--card-inset-block))));
  }
  .card .card:not(.card .card .card) {
    --card-radius: var(--card-nest-r);
    --card-nest-out2: min(calc(var(--outset) * var(--u)), max(0px, calc(var(--card-inset-inline) - var(--u))));
    --card-nest-r2: max(var(--r-q), calc(var(--card-radius) - min(calc(var(--card-inset-inline) - var(--card-nest-out2)), var(--card-inset-block))));
  }
  .card .card .card { --card-radius: var(--card-nest-r2); }
  :is(.card, .card *):where(.stack, .section-body):not(:where(.cols, .split, .grid, .rail) > *) > .card,
  :is(.card, .card *):where(.cols, .grid, .split, .rail):has(> .card):not(:has(> :not(.card))) { margin-inline: calc(var(--card-nest-out) * -1); }
  :is(.card .card, .card .card *):where(.stack, .section-body):not(:where(.cols, .split, .grid, .rail) > *) > .card,
  :is(.card .card, .card .card *):where(.cols, .grid, .split, .rail):has(> .card):not(:has(> :not(.card))) { margin-inline: calc(var(--card-nest-out2) * -1); }
  /* A nested card that opens or closes its parent steps out at that end too,
     so the same cell parts the two edges all the way round. */
  .card > .card:first-child { margin-block-start: calc(var(--card-nest-out) * -1); }
  .card > .card:last-child { margin-block-end: calc(var(--card-nest-out) * -1); }
  .card .card > .card:first-child { margin-block-start: calc(var(--card-nest-out2) * -1); }
  .card .card > .card:last-child { margin-block-end: calc(var(--card-nest-out2) * -1); }
  /* A scroller in a card. It spans the card's sides, so its scrollbar runs on
     the card's edge. At the card's start or end it reaches the card's edge
     there too, and takes the card's corners, so what scrolls is cut at the
     card's line and nowhere inside it (D95); its content keeps the card's
     padding, so at rest nothing moves. Between other parts of the card it
     stays inside them. Its own sides pad --card-scroll-pad, the card's by
     default, so what scrolls lines up with the rest of the card. */
  .card-scroll {
    --card-scroll-pad: var(--card-inset-inline);
    margin-inline: calc(var(--card-inset-inline) * -1);
    padding-inline: var(--card-scroll-pad);
    overflow-y: auto; overscroll-behavior: contain;
  }
  .card-scroll:first-child {
    margin-block-start: calc(var(--card-inset-block) * -1); padding-block-start: var(--card-inset-block);
    border-start-start-radius: var(--card-radius); border-start-end-radius: var(--card-radius);
  }
  .card-scroll:last-child {
    margin-block-end: calc(var(--card-inset-block) * -1); padding-block-end: var(--card-inset-block);
    border-end-start-radius: var(--card-radius); border-end-end-radius: var(--card-radius);
  }
  .board-lane > .card { --card-pad: var(--board-card-pad); }

  /* Cover link and cover image (D108) ------------------------------------
     A whole card as one link, with no link wrapped round anything: the card's
     title is an a.card-link, and its ::before covers the card (the link's
     nearest positioned ancestor, so the card's own parts never hold one).
     The card's other controls (links, buttons, fields, summaries, anything
     focusable) are raised above it and keep their own clicks; a list row's
     .list-link does the same. The covered card takes the shared state layer
     on the cover (D55): hover and press mix the ink in, selected keeps an
     accent mark at its start, and the focus ring is drawn round the card.
     The card is isolated, so the cover and what is raised stay inside it. */
  .card-link { color: inherit; text-decoration: none; }
  .card-link::before {
    content: ""; position: absolute; inset: 0; z-index: 1;
    border-radius: var(--card-radius, 0px);
    background: color-mix(in oklab, var(--text) calc(var(--state-on) + var(--state-act)), transparent);
  }
  @media (hover: hover) { .card-link:hover::before { --state-act: var(--state-hover); } }
  .card-link:active::before { --state-act: var(--state-press); }
  .card-link:is([aria-current]:not([aria-current="false"]), [aria-selected="true"])::before { --state-on: var(--state-selected); box-shadow: inset calc(var(--line) * 2) 0 0 var(--accent); }
  .card-link:focus-visible { outline: none; }
  .card-link:focus-visible::before { outline: calc(var(--line) * 2) solid var(--focus); outline-offset: var(--line); }
  .list-link::before { z-index: 1; }
  :where(.card:has(.card-link, .card-choice), .list-item:has(.list-link)) { isolation: isolate; }
  :where(.card:has(.card-link, .card-choice), .list-item:has(.list-link)) :where(a[href], button, input, select, textarea, summary, label, .cc-slots, [tabindex]:not([tabindex="-1"])):where(:not(.card-link, .list-link, .card-choice, .input-control)) { position: relative; z-index: 2; }

  /* A frame an image fills by cover: .media > img (or video, picture). The
     frame is sized in cells, --media-w by --media-h (no width fills its
     column), so nothing moves when the image loads; the image is a real
     <img> with its alt, object-fit: cover, and --media-focus as its focal
     point (object-position: 50% 25% keeps a face). An empty frame shows
     --media-fill; --media-scrim draws over the image (a gradient for words
     on it). In a card its corners are concentric with the card's (rule 21).
     It bleeds to a card's edges as the card's own child, giving back the
     card's padding and taking the card's corners where it meets them:
     .cc-bleed reaches both sides, and the top as the card's first part, the
     bottom as its last (a banner; in a .card.stack the stack's gap parts it
     from the words); .cc-bleed-start and .cc-bleed-end are a strip
     --media-w wide (three cells) at the card's start or end, as tall as the
     card, which becomes a row; .cc-fill is the card's whole ground, at least
     --media-h tall, with a scrim, the card's edge dropped and its words in
     white at its foot (a card of a frame and one body). */
  .media {
    --media-w: initial;
    --media-h: 12;
    --media-focus: 50% 50%;
    --media-radius: var(--r-1);
    --media-fill: var(--bg-sunken);
    --media-scrim: none;
    --media-w-px: calc(var(--u) * var(--media-w));
    position: relative;
    display: block; flex: none;
    inline-size: var(--media-w-px, auto);
    block-size: calc(var(--u) * var(--media-h));
    overflow: hidden;
    border-radius: var(--media-radius);
    background: var(--media-fill);
  }
  .media > :where(img, video, picture), .media > picture > img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; object-position: var(--media-focus); border-radius: 0; }
  .media::after { content: ""; position: absolute; inset: 0; background: var(--media-scrim); pointer-events: none; }
  .card .media { --media-radius: max(var(--r-q), calc(var(--card-radius) - min(var(--card-inset-inline), var(--card-inset-block)))); }
  .media.cc-round { --media-radius: var(--r-round); }
  .media:is(.cc-bleed-start, .cc-bleed-end) { --media-w: 3; }
  .media.cc-fill { --media-h: 18; --media-scrim: linear-gradient(to top, color-mix(in oklab, var(--black) 80%, transparent), transparent 70%); }
  .card > .media.cc-bleed { inline-size: auto; margin-inline: calc(var(--card-inset-inline) * -1); border-radius: 0; }
  .card > .media.cc-bleed:first-child { margin-block-start: calc(var(--card-inset-block) * -1); border-start-start-radius: var(--card-radius); border-start-end-radius: var(--card-radius); }
  .card > .media.cc-bleed:last-child { margin-block-end: calc(var(--card-inset-block) * -1); border-end-start-radius: var(--card-radius); border-end-end-radius: var(--card-radius); }
  .card:has(> .media:is(.cc-bleed-start, .cc-bleed-end)) { display: flex; flex-direction: row; align-items: flex-start; gap: var(--card-inset-inline); }
  .card:has(> .media.cc-bleed-start) > .media + *, .card:has(> .media.cc-bleed-end) > :first-child:not(.media) { flex: 1 1 0; min-width: 0; }
  .card > .media:is(.cc-bleed-start, .cc-bleed-end) { align-self: stretch; block-size: auto; margin-block: calc(var(--card-inset-block) * -1); border-radius: 0; }
  .card > .media.cc-bleed-start { margin-inline-start: calc(var(--card-inset-inline) * -1); border-start-start-radius: var(--card-radius); border-end-start-radius: var(--card-radius); }
  .card > .media.cc-bleed-end { margin-inline-end: calc(var(--card-inset-inline) * -1); border-start-end-radius: var(--card-radius); border-end-end-radius: var(--card-radius); }
  .card:has(> .media.cc-fill) { --card-border: transparent; isolation: isolate; display: grid; grid-template: minmax(0, auto) / minmax(0, 1fr); color: var(--white); }
  .card:has(> .media.cc-fill) > * { grid-area: 1 / 1; align-self: end; min-width: 0; }
  .card > .media.cc-fill { z-index: -1; align-self: stretch; inline-size: auto; block-size: auto; min-block-size: calc(var(--u) * var(--media-h)); margin: calc(var(--card-inset-block) * -1) calc(var(--card-inset-inline) * -1); border-radius: var(--card-radius); }
  /* A control with no fill of its own (a plain or ghost button, a tinted tag, a
     check, a switch, a tab, a slider) draws on the scrim there, so it reads white
     where it reads the page's ink: on the control, so a surface in the card keeps
     its own roles, and what carries its own fill (a primary button, a solid tag,
     a field) is not touched. The focus ring is white round any of them; the
     cover's is the card's, on the page. */
  :where(.button, .tag, .choice, .switch, .range, .tabs:not(.cc-seg) > .tab):where(.card:has(> .media.cc-fill) *):not(:where(.card:has(> .media.cc-fill) :is(.card, .list.cc-group, .float, .modal, [data-theme]) *)) {
    --text: var(--white);
    --text-secondary: color-mix(in oklab, var(--white) 85%, transparent);
    --text-tertiary: color-mix(in oklab, var(--white) 75%, transparent);
    --border-strong: color-mix(in oklab, var(--white) 60%, transparent);
    --btn-on-media: var(--white);   /* an outline button's ink there, whatever its kind */
  }
  :where(a[href]:not(.card-link), button, input, select, textarea, summary, .switch, [tabindex]):where(.card:has(> .media.cc-fill) *):not(:where(.card:has(> .media.cc-fill) :is(.card, .list.cc-group, .float, .modal, [data-theme]) *)) { --focus: var(--white); }

  /* Labels inside controls: the text box is trimmed to the cap height, so
     centering the box centers the capitals exactly. */
  .button-label, .tag-label, .options-card-label, .switch-label {
    display: block;
    white-space: nowrap;
  }
  /* A button or a tag never wider than its row, an option never wider than its
     card: a long label truncates sideways (rule 11). */
  .button-label, .tag-label, .options-card-label, .switch-label { min-width: 0; overflow-x: clip; overflow-y: visible; text-overflow: ellipsis; }
  @supports (text-box: trim-both cap alphabetic) {
    .button-label, .tag-label, .switch-label, .avatar-initials { text-box: trim-both cap alphabetic; line-height: 1; }
  }

  /* Button ------------------------------------------------------------- */
  .button {
    --btn-h: var(--density-control-h);
    --btn-fs: var(--density-control-fs);
    --btn-radius: var(--shape-control);
    --btn-bg: transparent;
    --btn-ink: var(--text);
    --btn-border: var(--border-strong);
    --btn-color: var(--text);    /* the color a kind fills with, and .cc-outline draws in */
    --btn-tint: 0%;              /* the share of it in an outline's ground */
    --btn-track: var(--btn-tracking, var(--button-tracking));
    /* Height grows with the label's type. Once the reader's text size passes
       the cell's cap, a label's font size (1em) can be taller than --btn-h;
       the button then adds whole cells until it fits. Choices, tags, inputs,
       tabs and badges do the same. */
    --btn-draw: calc(var(--btn-h) + max(0px, round(up, calc(1em - var(--btn-h)), var(--u))));
    --state-ink: var(--btn-ink); --state-fill: var(--btn-bg);
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-h);
    max-width: 100%;
    height: var(--btn-draw);
    padding-inline: calc(round(down, var(--btn-draw) / 2, var(--sp-h)) - var(--line));   /* half its height, in half cells: 30px gets 12 */
    border: var(--line) solid var(--btn-border);
    border-radius: var(--btn-radius);
    background: color-mix(in oklab, var(--state-tone) calc(var(--state-on) + var(--state-act)), var(--btn-bg));
    color: var(--btn-ink); text-decoration: none;
    font-family: var(--font-button, var(--font-sans));
    font-size: var(--btn-fs);
    font-weight: var(--fw-button, var(--fw-label));
    letter-spacing: var(--btn-track);
    text-indent: var(--btn-track);   /* letter spacing follows the last letter too: the label starts as far in, so it stays centered */
    text-transform: var(--button-case);
    transition: background var(--dur-out) var(--ease-in), border-color var(--dur-out) var(--ease-in);
  }
  .button.cc-primary { --btn-color: var(--accent); --btn-bg: var(--accent); --btn-border: var(--accent); --btn-ink: var(--accent-ink); }
  /* Kinds (D115): what a button does, in the status's color, under the names a
     tag has. Destructive is .cc-alert, confirm is .cc-ok. Filled, as a solid
     tag is, and its ink computed from the fill the same way (C4). */
  .button.cc-alert { --btn-color: var(--alert); }
  .button.cc-ok { --btn-color: var(--ok); }
  .button:is(.cc-alert, .cc-ok) { --btn-bg: var(--btn-color); --btn-border: var(--btn-color); --btn-ink: light-dark(var(--white), color-mix(in oklab, var(--btn-color) 18%, var(--black))); }
  @supports (color: oklch(from red l c h)) {
    .button:is(.cc-alert, .cc-ok) { --btn-ink: oklch(from var(--btn-color) clamp(.16, (var(--ink-flip) - l) * 1000, 1) calc(clamp(0, (l - var(--ink-flip)) * 1000, 1) * c * .3) h); }
  }
  .button.cc-ghost { --btn-border: transparent; }
  /* Outline: a kind with its fill taken away, as .cc-outline is on a tag. The
     edge and the label are its color, moved to where it reads as text on the
     page and on every raised level, hovered and pressed too: no lighter than
     .46 by day, no darker than .77 at night. A kind is destructive, confirm,
     or .cc-primary, the accent; with none, the text's ink; --btn-color in a
     context is any other. --btn-tint puts a share of the color in its ground. */
  .button.cc-outline {
    --btn-bg: color-mix(in oklab, var(--btn-color) var(--btn-tint), transparent);
    --btn-ink: var(--btn-on-media, var(--btn-color));
    --btn-border: var(--btn-ink);
  }
  @supports (color: oklch(from red l c h)) {
    .button.cc-outline {
      --btn-ink: var(--btn-on-media, light-dark(
        oklch(from var(--btn-color) min(l, .46) calc(c * min(1, .46 / max(l, .001))) h),
        oklch(from var(--btn-color) max(l, .77) calc(c * min(1, (1 - max(l, .77)) / max(1 - l, .001))) h)));
    }
  }
  /* Selected, its edge is two lines: the mark that a plain button's darker edge is. */
  .button.cc-outline[aria-pressed="true"]:not(:disabled, [aria-disabled="true"]) { --btn-border: var(--btn-ink); box-shadow: inset 0 0 0 var(--line) var(--btn-border); }
  .button.cc-sm { --btn-h: var(--size-control-sm); --btn-fs: var(--fs-control-sm); }
  .button.cc-md { --btn-h: var(--size-control-md); --btn-fs: var(--fs-control-md); }
  .button.cc-lg { --btn-h: var(--size-control-xl); --btn-fs: var(--fs-control-lg); }
  .button[aria-pressed="true"] { --btn-border: var(--text-tertiary); }
  .button:is(:disabled, [aria-disabled="true"]) { --btn-bg: var(--bg-sunken); --btn-border: var(--border-subtle); --btn-ink: var(--text-faint); }
  .icon-button { padding-inline: 0; width: var(--btn-draw); }
  .cc-dense .button { --btn-h: var(--size-control-md); --btn-fs: var(--fs-control-md); }

  /* Where the browser can round an intrinsic size, controls take a width of
     whole half-units, so a row of them keeps every edge on a line. The label
     stays centered in the extra space. */
  @supports (width: calc-size(fit-content, size)) {
    .button:not(.icon-button), .tag {
      width: calc-size(fit-content, round(up, size, var(--sp-h)));
      justify-content: center;
    }
  }
  /* Block: a button as wide as its container (a form's submit). */
  .button.cc-block { width: 100%; }

  /* CHOICE: the archetype (D109) -------------------------------------------
     Checkbox, radio and switch are one control: a box at the row's start, on
     half cells, half a cell before its label, in a row whole cells tall whose
     label centers its capitals on the box (rule 8). The variants change the
     box: a checkbox is a square a cell and a half across, a radio the same
     circle, a switch a track three cells long (.switch). On, the box fills
     with --choice-on and its mark takes --choice-ink; mixed is a bar, or a
     switch's thumb half way. On a coarse pointer the row's hit area is at
     least --hit-min. What they share is here; each box follows. */
  :where(.choice, .switch) {
    --choice-on: var(--accent);
    --choice-ink: var(--accent-ink);
    --choice-gap: var(--sp-h);
    --choice-row: var(--size-control-sm);
    position: relative;
    display: inline-flex; align-items: center;
    max-width: 100%;
    min-height: calc(var(--choice-row) + max(0px, round(up, calc(1em - var(--choice-row)), var(--u))));   /* grows by whole cells with its type, as a button does */
    color: var(--text);
    font-size: var(--fs-control); font-weight: var(--fw-label);
    cursor: pointer;
    user-select: none;
  }

  /* Switch: on or off, now. A button with role="switch" and aria-checked, or a
     label around a visually hidden checkbox with role="switch" (for a form). The
     track is 3 × 1½ cells, drawn before the label; the thumb is 1 cell, a quarter
     cell inside it. On, the thumb moves and the track fills with the accent;
     aria-checked="mixed" (a setting over a selection that differs) holds the
     thumb half way on the track's off fill. Its states are the shared layer, on
     the track. Markup:
     button.switch[role=switch][aria-checked] > .switch-label, or
     label.switch > input[type=checkbox][role=switch].u-sr-only + .switch-label. */
  .switch {
    --switch-w: var(--sp-3);
    --switch-h: var(--sp-1h);
    --switch-knob: var(--sp-1);
    --switch-off: color-mix(in oklab, var(--text) 32%, transparent);
    --switch-on: var(--choice-on);
    --switch-fill: var(--switch-off);
    --switch-thumb: var(--white);
    --switch-x: 0%;
    padding-inline-start: calc(var(--switch-w) + var(--choice-gap));
  }
  .switch::after {
    content: ""; position: absolute;
    inset-inline-start: 0; inset-block-start: calc(50% - var(--switch-h) / 2);
    width: var(--switch-w); height: var(--switch-h);
    border-radius: var(--r-round);
    background:
      radial-gradient(circle closest-side, var(--switch-thumb) calc(var(--switch-knob) / 2 - var(--line) / 2), transparent calc(var(--switch-knob) / 2 + var(--line) / 2))
        var(--switch-x) 50% / var(--switch-h) var(--switch-h) no-repeat,
      color-mix(in oklab, var(--text) var(--state-act), var(--switch-fill));
    transition: background-position var(--dur-in) var(--ease-spring), background-color var(--dur-out) var(--ease-in);
  }
  .switch:is([aria-checked="true"], :has(> input:checked)) { --switch-x: 100%; --switch-fill: var(--switch-on); --switch-thumb: var(--choice-ink); }
  .switch[aria-checked="mixed"] { --switch-x: 50%; }
  .switch:is(:disabled, [aria-disabled="true"], :has(> input:disabled)) { --switch-fill: color-mix(in oklab, var(--text) 10%, transparent); --switch-thumb: var(--bg-sunken); color: var(--text-faint); cursor: not-allowed; }
  .switch:has(> input:focus-visible) { outline: calc(var(--line) * 2) solid var(--focus); outline-offset: var(--line); }
  [dir="rtl"] .switch { --switch-x: 100%; }
  [dir="rtl"] .switch:is([aria-checked="true"], :has(> input:checked)) { --switch-x: 0%; }
  [dir="rtl"] .switch[aria-checked="mixed"] { --switch-x: 50%; }
  /* A switch in a menu row. The row is the control (role="menuitemcheckbox"
     with aria-checked), its label and hint at the start, and the switch an
     empty span at its end: it keeps no room for a label it doesn't have, it is
     lit by its row, and it lends the row no extra hit area, which would reach
     into the rows around it. The row is not washed as a chosen option (see the
     states). Markup: button.options-card-item[role=menuitemcheckbox]
     [aria-checked] > .options-card-label + span.switch[aria-hidden=true]. */
  .switch:empty { padding-inline-start: var(--switch-w); }
  .options-card-item > .switch { flex: none; margin-inline-start: auto; }
  .options-card-item > .switch::before { content: none; }
  .options-card-item[aria-checked="true"] > .switch { --switch-x: 100%; --switch-fill: var(--switch-on); --switch-thumb: var(--choice-ink); }
  .options-card-item[aria-checked="mixed"] > .switch { --switch-x: 50%; }
  [dir="rtl"] .options-card-item[aria-checked="true"] > .switch { --switch-x: 0%; }
  .options-card-item:is(:disabled, [aria-disabled="true"]) > .switch { --switch-fill: color-mix(in oklab, var(--text) 10%, transparent); --switch-thumb: var(--bg-sunken); }

  /* Checkbox and radio: the choice's square and circle. The box is the native
     input, drawn with appearance: none, so the keyboard (Space, a radio
     group's arrows), the form, :checked, :indeterminate, :disabled and
     :user-invalid are the browser's own. The box is a cell and a half
     (.cc-sm a cell, .cc-lg two), its edge a line of tertiary ink, a quarter
     cell corner; the mark is the input's ::before: a check, a bar for mixed,
     a dot a third of the radio. Mixed is the input's indeterminate property,
     set from script (React: a ref): a parent in a nested checklist whose
     children are partly done. Invalid is aria-invalid, or :user-invalid once
     the person has touched it; the edge takes the alert. Disabled quiets the
     box and the words. The whole row is the label, so the words take the
     click; on a coarse pointer it grows an invisible --hit-min around itself.
     Markup: label.choice > input[type=checkbox|radio] + .choice-label
     (.choice-label.cap-center where the words may wrap). With
     no words (a check beside text the person edits), label.choice >
     input[aria-label]: the box alone, with its row and hit area. */
  .choice {
    --choice-box: var(--sp-1h);
    --choice-radius: var(--r-q);
    --choice-edge: var(--text-tertiary);
    --choice-fill: transparent;
    --choice-line: var(--line);
    gap: var(--choice-gap);
    line-height: max(1lh, round(up, 1em, var(--u)));   /* the line it is in (1lh is its parent's), never shorter than its own type: past the cell's cap a wrapped label's lines ran into each other, too close to count */
  }
  .choice.cc-sm { --choice-box: var(--sp-1); font-size: var(--fs-control-sm); }
  .choice.cc-lg { --choice-box: var(--sp-2); --choice-row: var(--size-control-lg); font-size: var(--fs-control-lg); }
  .choice-label { display: block; min-width: 0; }
  @supports (text-box: trim-both cap alphabetic) {
    .choice-label { text-box: trim-both cap alphabetic; }
    /* A label that may wrap takes .cap-center: once it wraps, settle.js marks
       it, it hangs from the row's top line and rounds up (rule 8), and the box
       stays centered on its first line's capitals, reaching above the row by
       half the difference. */
    .choice:has(> .choice-label[data-trellis-wrap]) > input { align-self: flex-start; margin-block-start: calc((1cap - var(--choice-box)) / 2); }
  }
  .choice > input:is([type="checkbox"], [type="radio"]) {
    -webkit-appearance: none; appearance: none;
    flex: none;
    display: inline-grid; place-content: center;
    inline-size: var(--choice-box); block-size: var(--choice-box);
    margin: 0;
    border: var(--choice-line) solid var(--choice-edge);
    border-radius: var(--choice-radius);
    background: color-mix(in oklab, var(--text) var(--state-act), var(--choice-fill));
    color: var(--choice-ink);
    cursor: inherit;
    transition: background-color var(--dur-out) var(--ease-in), border-color var(--dur-out) var(--ease-in);
  }
  .choice > input:is([type="checkbox"], [type="radio"])::before {
    content: "";
    inline-size: calc(var(--choice-box) * .6); block-size: calc(var(--choice-box) * .6);
    background: currentColor;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
    transform: scale(0);
    transition: transform var(--dur-in) var(--ease-out);
  }
  .choice > input[type="radio"] { border-radius: 50%; }
  .choice > input[type="radio"]::before { inline-size: calc(var(--choice-box) / 3); block-size: calc(var(--choice-box) / 3); clip-path: none; border-radius: 50%; }
  .choice > input[type="checkbox"]:indeterminate::before { inline-size: calc(var(--choice-box) / 2); block-size: calc(var(--line) * 2); clip-path: none; }
  .choice > input:is(:checked, [type="checkbox"]:indeterminate) { --choice-fill: var(--choice-on); --choice-edge: var(--choice-on); }
  .choice > input:is(:checked, [type="checkbox"]:indeterminate)::before { transform: scale(1); }
  /* Invalid wins over checked: a checked box that is invalid keeps the alert's edge. */
  .choice > input:is([aria-invalid="true"], :user-invalid),
  .choice > input:is([aria-invalid="true"], :user-invalid):is(:checked, [type="checkbox"]:indeterminate) { --choice-edge: var(--alert); }
  .choice > input:disabled { --choice-edge: color-mix(in oklab, var(--text) 20%, transparent); --choice-fill: var(--bg-sunken); --choice-ink: var(--text-faint); }
  .choice > input:disabled:is(:checked, [type="checkbox"]:indeterminate) { --choice-fill: color-mix(in oklab, var(--text) 20%, transparent); --choice-edge: transparent; --choice-ink: var(--bg); }
  .choice:has(> input:disabled) { color: var(--text-faint); cursor: not-allowed; }
  @media (hover: hover) { .choice:hover > input:not(:disabled) { --state-act: var(--state-hover); } }
  .choice:active > input:not(:disabled) { --state-act: var(--state-press); }
  @media (pointer: coarse) {
    .choice::before { content: ""; position: absolute; inset: min(0px, calc((100% - var(--hit-min)) / 2)); }
  }
  @media (forced-colors: active) {
    .choice > input:is([type="checkbox"], [type="radio"]) { forced-color-adjust: none; border-color: CanvasText; background: Canvas; color: HighlightText; }
    .choice > input:is(:checked, [type="checkbox"]:indeterminate) { border-color: Highlight; background: Highlight; }
    .choice > input:disabled { border-color: GrayText; }
    .choice > input:disabled:is(:checked, [type="checkbox"]:indeterminate) { background: GrayText; }
    .choice > input:is([aria-invalid="true"], :user-invalid),
    .choice > input:is([aria-invalid="true"], :user-invalid):is(:checked, [type="checkbox"]:indeterminate) { border-color: Mark; }
  }
  /* A task list in prose (Markdown's li > input, an editor's li > label >
     input + div): the same box, a cell and a half, centered on the first
     line's capitals. A checkbox there records a state, so disabled (as
     Markdown writes it) keeps its full ink. A done item's own words go to the
     tertiary ink; a list nested in it keeps the text's. */
  .prose :where(li:has(> input[type="checkbox"], > label > input[type="checkbox"])) { list-style: none; }
  .prose :where(li > input[type="checkbox"], li > label > input[type="checkbox"]):not(.choice > *) {
    --choice-box: var(--sp-1h);
    --choice-on: var(--accent);
    --choice-ink: var(--accent-ink);
    --choice-edge: var(--text-tertiary);
    --choice-fill: transparent;
    -webkit-appearance: none; appearance: none;
    display: inline-block;   /* no line inside, so its baseline is its bottom edge, and vertical-align measures from there */
    inline-size: var(--choice-box); block-size: var(--choice-box);
    margin: 0; margin-inline-end: var(--sp-h);
    vertical-align: calc((1cap - var(--choice-box)) / 2);
    border: var(--line) solid var(--choice-edge); border-radius: var(--r-q);
    background: var(--choice-fill); color: var(--choice-ink);
  }
  .prose :where(li > input[type="checkbox"], li > label > input[type="checkbox"]):not(.choice > *)::before {
    content: ""; display: block;
    inline-size: calc(var(--choice-box) * .6); block-size: calc(var(--choice-box) * .6);
    margin: calc((var(--choice-box) * .4 - var(--line) * 2) / 2) auto 0;
    background: currentColor;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
    transform: scale(0);
  }
  .prose :where(li > input[type="checkbox"], li > label > input[type="checkbox"]):not(.choice > *):checked { --choice-fill: var(--choice-on); --choice-edge: var(--choice-on); }
  .prose :where(li > input[type="checkbox"], li > label > input[type="checkbox"]):not(.choice > *):checked::before { transform: scale(1); }
  .prose :where(li > input[type="checkbox"], li > label > input[type="checkbox"]):not(.choice > *):enabled { cursor: pointer; }
  .prose :where(li:has(> input[type="checkbox"]:checked, > label > input[type="checkbox"]:checked)) { color: var(--text-tertiary); }
  .prose :where(li:has(> input[type="checkbox"]:checked, > label > input[type="checkbox"]:checked) :is(ul, ol)) { color: var(--text); }
  /* An editor's item is a row: the label (one capital tall, trimmed to it, so
     its line's baseline is its bottom) holds the box as Markdown's line does,
     and the words start after it, two cells in. */
  .prose :where(li:has(> label > input[type="checkbox"])) { display: flex; }
  .prose :where(li > label:has(> input[type="checkbox"])) { flex: none; display: block; block-size: 1cap; text-box: trim-both cap alphabetic; }
  .prose :where(li:has(> label > input[type="checkbox"]) > :not(label)) { flex: 1; min-width: 0; }
  @media (forced-colors: active) {
    .prose :where(li > input[type="checkbox"], li > label > input[type="checkbox"]):not(.choice > *) { forced-color-adjust: none; border-color: CanvasText; background: Canvas; color: HighlightText; }
    .prose :where(li > input[type="checkbox"], li > label > input[type="checkbox"]):not(.choice > *):checked { border-color: Highlight; background: Highlight; }
  }

  /* A whole card that is a choice (D116). The card's title is its choice,
     label.choice.card-choice, whose ::before covers the card (the label's
     nearest positioned ancestor), so a press anywhere on the card is a press
     on the label and the native input does the rest: no script, and nothing
     wrapped round the card's other controls, which are raised above the cover
     as a .card-link card's are (D108). Chosen, the card lights: an edge two
     lines thick (--card-choice-edge) and a wash under its words
     (--card-choice-fill); mixed lights the edge alone; --card-choice-glow is
     a shadow a product may add. Invalid turns the edge to the alert, from the
     input or its radiogroup. Disabled sinks the ground. Hover and press are
     the shared state layer on the cover, and the one focus ring is drawn round
     the card. The choice is the card: a .card-link in it is a plain link, with
     its own click and ring and no cover. Markup: .card > label.choice.card-choice
     > input + .choice-label; what describes it, an aria-describedby. */
  .card-choice {
    --card-choice-edge: var(--choice-on);
    --card-choice-fill: color-mix(in oklab, var(--choice-on) 8%, transparent);
    --card-choice-glow: none;
    --card-choice-line: 0px;
    --card-choice-draw: transparent;
    --card-choice-ground: transparent;
    --card-choice-shadow: none;
    position: static;   /* the cover is the card's, not the row's */
    display: flex;
  }
  .card-choice::before {
    content: ""; position: absolute; z-index: 1;
    inset: 0 calc(var(--line) * -1) calc(var(--line) * -1) 0;   /* the card's own edge, plane on plane */
    border: var(--card-choice-line) solid var(--card-choice-draw);
    border-radius: var(--card-radius, 0px);
    background: color-mix(in oklab, var(--text) var(--state-act), transparent);
  }
  .card-choice::after {
    content: ""; position: absolute; z-index: -1; inset: 0;   /* over the card's ground, under what it holds */
    border-radius: var(--card-radius, 0px);
    background: var(--card-choice-ground);
    box-shadow: var(--card-choice-shadow);
    transition: background-color var(--dur-out) var(--ease-in);
  }
  .card-choice:where(:has(> input:is(:checked, [type="checkbox"]:indeterminate))) { --card-choice-line: calc(var(--line) * 2); --card-choice-draw: var(--card-choice-edge); }
  .card-choice:where(:has(> input:checked:not([type="checkbox"]:indeterminate))) { --card-choice-ground: var(--card-choice-fill); --card-choice-shadow: var(--card-choice-glow); }
  [role="radiogroup"][aria-invalid="true"] .card-choice > input:not(:disabled) { --choice-edge: var(--alert); }
  .card-choice:where(:has(> input:is([aria-invalid="true"], :user-invalid)), [role="radiogroup"][aria-invalid="true"] *):where(:not(:has(> input:disabled))) { --card-choice-line: calc(var(--line) * 2); --card-choice-draw: var(--alert); }
  .card-choice:where(:has(> input:disabled)) { --card-choice-draw: color-mix(in oklab, var(--text) 20%, transparent); --card-choice-ground: var(--bg-sunken); --card-choice-shadow: none; }
  /* The wash takes contrast from the third ink, so a lit card that holds no
     card reads it as the second. */
  .card:has(.card-choice > input:checked:not(:disabled)):not(:has(.card)) { --text-tertiary: var(--text-secondary); }
  .card-choice > input:focus-visible { outline: none; }
  .card-choice:has(> input:focus-visible)::before { outline: calc(var(--line) * 2) solid var(--focus); outline-offset: var(--line); }
  @media (hover: hover) { .card-choice:hover:not(:has(> input:disabled))::before { --state-act: var(--state-hover); } }
  .card-choice:active:not(:has(> input:disabled))::before { --state-act: var(--state-press); }
  .card:has(.card-choice):not(:has(.card)) .card-link { position: relative; z-index: 2; text-decoration: underline; }
  .card:has(.card-choice):not(:has(.card)) .card-link::before { content: none; }
  .card:has(.card-choice):not(:has(.card)) .card-link:focus-visible { outline: calc(var(--line) * 2) solid var(--focus); }
  /* A card of one line and little padding is still the touch target tall. */
  @media (pointer: coarse) { .card-choice { --choice-row: max(var(--size-control-sm), round(up, calc(var(--hit-min) - var(--card-inset-block, 0px) * 2), var(--u))); } }
  @media (forced-colors: active) {
    .card-choice:where(:has(> input:is(:checked, [type="checkbox"]:indeterminate))) { --card-choice-draw: Highlight; }
    .card-choice:where(:has(> input:is([aria-invalid="true"], :user-invalid)), [role="radiogroup"][aria-invalid="true"] *):where(:not(:has(> input:disabled))) { --card-choice-draw: Mark; }
    .card-choice:where(:has(> input:disabled)) { --card-choice-draw: GrayText; color: GrayText; }
  }

  /* SLIDER. A value along a line: an input[type=range] on the cells. The row
     is two cells tall, the track a quarter cell thick, the thumb a cell and a
     half across. The track is inked up to the thumb. CSS can't read how far
     along a range input is, so settle.js writes --range-at, 0 to 1, when a
     slider arrives and when it moves; a script that sets .value calls
     Trellis.range(el). Without the runtime the track is plain and the thumb
     still moves.
     A slider that draws a scale (a hue, a lightness) paints --range-fill
     itself, and may fill its thumb with --range-thumb-fill.
     .cc-zone inks the stretch between two values, --range-a to --range-b,
     each 0 to 1: where the value has an effect. */
  .range {
    --range-h: var(--sp-2);
    --range-track: var(--sp-q);
    --range-thumb: var(--sp-1h);
    --range-ink: var(--text-secondary);
    --range-rest: var(--border);
    --range-thumb-fill: var(--bg-raised);
    --range-at: 0;
    --range-to: right;
    --range-x: calc(var(--range-thumb) / 2 + (100% - var(--range-thumb)) * var(--range-at));
    --range-fill: linear-gradient(to var(--range-to), var(--range-ink) var(--range-x), var(--range-rest) 0);
    -webkit-appearance: none; appearance: none;
    display: block; inline-size: 100%; min-inline-size: 0; block-size: var(--range-h);
    margin: 0; padding: 0;
    background: none; border-radius: var(--r-round);
    cursor: pointer; touch-action: pan-y;
  }
  .range::-webkit-slider-runnable-track { block-size: var(--range-track); border-radius: var(--r-round); background: var(--range-fill); }
  .range::-moz-range-track { block-size: var(--range-track); border-radius: var(--r-round); background: var(--range-fill); }
  .range::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    box-sizing: border-box; inline-size: var(--range-thumb); block-size: var(--range-thumb);
    margin-block-start: calc((var(--range-track) - var(--range-thumb)) / 2);
    border: var(--line) solid var(--range-ink); border-radius: 50%;
    background: var(--range-thumb-fill);
  }
  .range::-moz-range-thumb {
    box-sizing: border-box; inline-size: var(--range-thumb); block-size: var(--range-thumb);
    border: var(--line) solid var(--range-ink); border-radius: 50%;
    background: var(--range-thumb-fill);
  }
  .range:is(:hover, :active, :focus-visible) { --range-ink: var(--text); }
  .range:disabled { --range-ink: var(--text-faint); --range-thumb-fill: var(--bg-sunken); cursor: not-allowed; }
  [dir="rtl"] .range { --range-to: left; }
  .range.cc-zone {
    --range-xa: calc(var(--range-thumb) / 2 + (100% - var(--range-thumb)) * var(--range-a, 0));
    --range-xb: calc(var(--range-thumb) / 2 + (100% - var(--range-thumb)) * var(--range-b, 1));
    --range-fill: linear-gradient(to var(--range-to), var(--range-rest) var(--range-xa), var(--range-ink) 0, var(--range-ink) var(--range-xb), var(--range-rest) 0);
  }
  /* Touch. The row is the target: the whole of it takes a drag. */
  @media (pointer: coarse) {
    .range { --range-thumb: var(--sp-2); --range-h: round(up, var(--hit-min), var(--u)); }
  }

  .icon { width: var(--icon-size, var(--size-icon)); height: var(--icon-size, var(--size-icon)); flex: none; fill: none; stroke: currentColor; stroke-width: var(--icon-stroke, 1.5); stroke-linecap: round; stroke-linejoin: round; }
  /* Icons (D118). Alone, .icon draws strokes in the drawing's own units. A
     Phosphor drawing takes .cc-phosphor: 256 units, its shapes filled unless
     they say otherwise, as every file Phosphor publishes is. Phosphor's raw files
     are strokes; with their stroke-width taken off they follow --icon-weight
     (thin 8, light 12, regular 16, bold 24). --icon-color is a role, and has no
     weight of its own: any color set on the icon, a disabled control and forced
     colors come first. .icon-tone is a duotone's second shape.
     Markup: svg.icon.cc-phosphor[aria-hidden] > use; or img.icon. */
  .icon.cc-phosphor { fill: currentColor; stroke: none; stroke-width: var(--icon-weight, 16); }
  :where(.icon) { color: var(--icon-color, inherit); }
  :where(:disabled:not(fieldset), [aria-disabled="true"]) :where(.icon) { color: inherit; }
  .icon-tone { fill: var(--icon-tone, color-mix(in oklab, currentColor 20%, transparent)); stroke: none; }
  .icon.cc-mirror:dir(rtl) { scale: -1 1; }
  img.icon { object-fit: contain; border-radius: 0; }
  @media (forced-colors: active) {
    :where(.icon) { color: inherit; }
    .icon-tone { fill: color-mix(in oklab, currentColor 20%, transparent); }
  }

  /* Tag: the archetype ---------------------------------------------------
     One anatomy: height, a padding equal to its corner (so the label starts
     where the curve ends), a hairline border and a tint, both mixed from
     one kind color. Kinds, emphases, sizes and contexts only change those
     variables. */
  .tag {
    --tag-h: var(--tag-default-h);
    --tag-fs: var(--tag-default-fs);
    --tag-color: var(--kind-topic);
    --tag-draw: calc(var(--tag-h) + max(0px, round(up, calc(1em - var(--tag-h)), var(--u))));   /* grows by whole cells with its type, as a button does */
    --tag-radius: max(var(--tag-r-fixed), calc(var(--tag-draw) * var(--tag-r-ratio)));
    --tag-pad: clamp(var(--sp-h), round(down, var(--tag-radius), var(--sp-h)), var(--sp-1));
    --tag-fill: 14%;
    --tag-edge: 42%;
    --tag-edge-style: solid;     /* dashed for what isn't here yet */
    --tag-ink: var(--text);
    --tag-gap: var(--sp-h);
    --state-ink: var(--tag-ink); --state-fill: color-mix(in oklab, var(--tag-color) var(--tag-fill), transparent);
    display: inline-flex; align-items: center; gap: var(--tag-gap);
    max-width: 100%;
    height: var(--tag-draw);
    padding-inline: calc(var(--tag-pad) - var(--line));
    border: var(--line) var(--tag-edge-style) color-mix(in oklab, var(--tag-color) var(--tag-edge), transparent);
    border-radius: var(--tag-radius);
    background: color-mix(in oklab, var(--state-tone) var(--state-act), var(--state-fill));
    color: var(--tag-ink);
    font-size: var(--tag-fs);
    font-weight: var(--fw-label);
    letter-spacing: var(--tag-tracking);
    text-transform: var(--tag-case);
    white-space: nowrap;
    vertical-align: middle;
  }
  /* kind */
  .tag.cc-person { --tag-color: var(--kind-person); }
  .tag.cc-group  { --tag-color: var(--kind-group); }
  .tag.cc-event  { --tag-color: var(--kind-event); }
  .tag.cc-course { --tag-color: var(--kind-course); }
  .tag.cc-ok     { --tag-color: var(--ok); }
  .tag.cc-warn   { --tag-color: var(--warn); }
  .tag.cc-alert  { --tag-color: var(--alert); }
  /* No kind: the neutral, for what is worth a label and not a color (D115).
     Its words step back too; solid or selected, they are the fill's ink. */
  .tag.cc-quiet  { --tag-color: var(--text-tertiary); --tag-ink: var(--text-secondary); }
  /* A stage (D107): the tint, the edge and, solid, the fill and its ink all follow the one color. */
  .tag.cc-stage-1 { --tag-color: var(--stage-1); }
  .tag.cc-stage-2 { --tag-color: var(--stage-2); }
  .tag.cc-stage-3 { --tag-color: var(--stage-3); }
  .tag.cc-stage-4 { --tag-color: var(--stage-4); }
  .tag.cc-stage-5 { --tag-color: var(--stage-5); }
  .tag.cc-stage-6 { --tag-color: var(--stage-6); }
  .tag.cc-stage-7 { --tag-color: var(--stage-7); }
  /* A color of the product's own (D117): --seed names it on the tag or round it. Solid or selected, the fill is the
     one a label reads on, whatever the color. */
  .tag.cc-seed { --tag-color: var(--seeded); }
  .tag.cc-seed:is(.cc-solid, [aria-pressed="true"], [aria-current]:not([aria-current="false"])) { --tag-color: var(--seeded-solid); }
  /* emphasis */
  .tag.cc-outline { --tag-fill: 0%; }
  .tag.cc-solid, .tag:is([aria-pressed="true"], [aria-current]:not([aria-current="false"])) {
    --tag-fill: 100%; --tag-edge: 100%;
    --tag-ink: light-dark(var(--white), color-mix(in oklab, var(--tag-color) 18%, var(--black)));
  }
  /* Ink on a solid fill is computed from the fill, as the accent's is: white
     below --ink-flip, a dark ink of the fill's hue above it (C4). */
  @supports (color: oklch(from red l c h)) {
    .tag.cc-solid, .tag:is([aria-pressed="true"], [aria-current]:not([aria-current="false"])) { --tag-ink: oklch(from var(--tag-color) clamp(.16, (var(--ink-flip) - l) * 1000, 1) calc(clamp(0, (l - var(--ink-flip)) * 1000, 1) * c * .3) h); }
    .badge:not(.cc-quiet, .cc-accent) { --badge-ink: oklch(from var(--badge-color) clamp(.16, (var(--ink-flip) - l) * 1000, 1) calc(clamp(0, (l - var(--ink-flip)) * 1000, 1) * c * .3) h); }
  }
  /* size */
  .tag.cc-sm { --tag-h: var(--size-control-xs); --tag-fs: var(--tag-fs-sm); --tag-gap: var(--sp-q); }
  .tag.cc-md { --tag-h: var(--size-control-sm); --tag-fs: var(--tag-fs-md); }
  .tag.cc-lg { --tag-h: var(--size-control-md); --tag-fs: var(--tag-fs-lg); }
  /* parts */
  .tag-dot { width: var(--sp-h); height: var(--sp-h); border-radius: 50%; background: var(--tag-color); flex: none; }
  .tag:is([aria-pressed="true"], [aria-current]:not([aria-current="false"])) .tag-dot { background: currentColor; }
  .tag-remove {
    display: grid; place-items: center; flex: none;
    width: calc(var(--tag-h) - var(--sp-h)); height: calc(var(--tag-h) - var(--sp-h));
    margin-inline-end: calc((var(--tag-pad) - var(--sp-q) - var(--line)) * -1);
    border-radius: max(var(--r-q), calc(var(--tag-radius) - var(--sp-q)));
    color: inherit; opacity: .7;
  }
  .tag-remove { background: color-mix(in oklab, currentColor var(--state-act), transparent); }
  @media (hover: hover) { .tag-remove:hover { opacity: 1; } }
  .tag-remove .icon { --icon-size: var(--size-icon-sm); }
  button.tag { cursor: pointer; }
  /* context */
  .cc-dense .tag { --tag-h: var(--size-control-xs); --tag-fs: var(--tag-fs-sm); --tag-gap: var(--sp-q); }
  .cc-on-media .tag {
    --tag-fill: 100%;
    background: color-mix(in oklab, var(--black) 55%, transparent);
    border-color: color-mix(in oklab, var(--white) 28%, transparent);
    --tag-ink: var(--white);
    backdrop-filter: blur(var(--sp-h));
  }

  /* Avatar ---------------------------------------------------------------
     The photo is the box, and it sits exactly on the cells. The gap and the
     ring are spread shadows outside it, drawn by the same geometry as the
     photo, so they are concentric all the way round at every size. */
  .avatar {
    --av-n: 2;
    --av-size: calc(var(--u) * var(--av-n));
    --av-gap: var(--line);
    --av-ring: calc(var(--line) * 2);
    --av-knock: 0px;
    --av-color: var(--kind-person);
    --av-radius: 50%;
    --av-hue: 30;
    position: relative;
    display: inline-grid; place-items: center; flex: none;
    width: var(--av-size); height: var(--av-size);
    border-radius: var(--av-radius);
    background-color: color-mix(in oklab, var(--av-color) 26%, var(--surface));
    background-size: cover; background-position: center;
    object-fit: cover;
    box-shadow:
      0 0 0 var(--av-gap) var(--surface),
      0 0 0 calc(var(--av-gap) + var(--av-ring)) var(--av-color),
      0 0 0 calc(var(--av-gap) + var(--av-ring) + var(--av-knock)) var(--surface);
    color: var(--text);
    font-size: calc(var(--av-size) * .38);
    font-weight: var(--fw-label);
    letter-spacing: .02em;
  }
  .avatar.cc-xs  { --av-n: 1; }
  .avatar.cc-sm  { --av-n: 2; }
  .avatar.cc-md  { --av-n: 3; }
  .avatar.cc-lg  { --av-n: 4; --av-gap: var(--sp-q); --av-ring: var(--sp-q); }
  .avatar.cc-xl  { --av-n: 6; --av-gap: var(--sp-q); --av-ring: var(--sp-q); }
  .avatar.cc-xxl { --av-n: 8; --av-gap: var(--sp-q); --av-ring: var(--sp-q); }
  .avatar.cc-hero { --av-n: 12; --av-gap: var(--sp-q); --av-ring: var(--sp-q); }
  .avatar.cc-group { --av-radius: calc(var(--av-size) / 4); --av-color: var(--kind-group); }
  /* Shape is kind: a circle is a person, a rounded square a group, and a
     rounded square in the accent a space (a project with people of its own: a
     collaboration, a workspace). In dense rows (an inbox, a thread) the ring is
     noise: .cc-plain draws neither the gap nor the ring. After the sizes, so it
     wins over the larger ones' ring. */
  .avatar.cc-space { --av-radius: calc(var(--av-size) / 4); --av-color: var(--accent); }
  .avatar.cc-plain { --av-gap: 0px; --av-ring: 0px; }
  .avatar-dot {
    position: absolute;
    width: var(--sp-h); height: var(--sp-h);
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 calc(var(--line) * 2) var(--surface);
    right:  calc(var(--av-size) * .1464 - var(--sp-h) / 2);
    bottom: calc(var(--av-size) * .1464 - var(--sp-h) / 2);
  }
  .avatar-stack { display: inline-flex; align-items: center; }
  .avatar-stack > .avatar { --av-knock: calc(var(--line) * 2); }
  .avatar-stack > * + * { margin-inline-start: calc(var(--sp-h) * -1); }
  .avatar-more {
    display: inline-grid; place-items: center;
    min-width: var(--av-size, var(--sp-2)); height: var(--av-size, var(--sp-2));
    padding-inline: var(--sp-q);
    border-radius: var(--r-round);
    background: var(--bg-sunken);
    box-shadow: 0 0 0 var(--line) var(--border), 0 0 0 calc(var(--line) * 3) var(--surface);
    font-size: var(--fs-control-xs); font-weight: var(--fw-label); color: var(--text-secondary);
  }

  /* Touch: on a coarse pointer a control's hit area grows to --hit-min
     around what it draws, so compact controls are still easy to tap. */
  @media (pointer: coarse) {
    :where(.button, .icon-button, button.tag, a.tag, .switch) { position: relative; }
    :where(.button, .icon-button, button.tag, a.tag, .switch)::before {
      content: ""; position: absolute;
      inset: min(0px, calc((100% - var(--hit-min)) / 2));
    }
  }

  /* Navigation --------------------------------------------------------------
     The parts the shell's navigation is made of. In a top bar (.shell.cc-top):
     .shell-brand, a .shell-menu button, .shell-links and .shell-nav-end.
     Markup: header.shell-nav > a.shell-brand + button.button.shell-menu.icon-button
     [popovertarget=id] + nav.shell-links#id[popover] > .shell-link… +
     .shell-nav-end. The links are one element at every width: wide, a
     [popover] shown in the bar; under 48rem, hidden until the menu button
     opens it as a left tray, so nothing is written twice. A popover gives
     Escape and a click outside for free, and opens after its button in the
     tab order; the page behind is locked while it is open. */
  .shell-brand {
    display: inline-flex; align-items: center; gap: var(--sp-h); flex: none;
    min-height: var(--size-control-sm);
    color: var(--text); text-decoration: none;
    font-size: var(--fs-control); font-weight: var(--fw-strong);
  }
  .shell-menu { display: none; }
  .shell-links { display: flex; align-items: center; gap: var(--sp-q2); min-width: 0; }
  .shell-links[popover] {
    position: static; inset: auto; width: auto; height: auto;
    margin: 0; padding: 0; border: 0; overflow: visible;
    background: none; color: inherit;
  }
  .shell-nav-end { display: flex; align-items: center; gap: var(--sp-h); margin-inline-start: auto; }
  .shell.cc-top .shell-link { min-height: var(--size-control-sm); }
  /* In a bar the current link's mark is under it, not beside it. */
  .shell.cc-top .shell-link[aria-current]:not([aria-current="false"]) { box-shadow: inset 0 calc(var(--line) * -2) 0 var(--accent); border-radius: var(--r-h) var(--r-h) 0 0; }
  @container shell (width < 48rem) {
    /* A tab bar holds destinations: a side column's brand is not one of them. */
    .shell:not(.cc-top) .shell-nav > .shell-brand { display: none; }
    .shell.cc-top .shell-menu { display: inline-flex; }
    .shell.cc-top .shell-links[popover]:not(:popover-open) { display: none; }
    .shell.cc-top .shell-links:popover-open {
      --tray-margin: var(--sp-2);
      position: fixed; inset: var(--tray-margin) auto var(--tray-margin) 0;
      width: min(calc(var(--u) * 32), calc(100% - var(--sp-4)));
      flex-direction: column; align-items: stretch; gap: var(--sp-q2);
      padding: var(--sp-1);
      overflow-y: auto; overscroll-behavior: contain;
      background: var(--bg-raised); color: var(--text);
      border-radius: 0 var(--shape-card) var(--shape-card) 0;
      outline: var(--line) solid var(--border); outline-offset: calc(var(--line) * -1);
      box-shadow: var(--lift);
      translate: 0;
      transition: translate var(--dur-tray-in) var(--ease-spring);
    }
    @starting-style { .shell.cc-top .shell-links:popover-open { translate: -100% 0; } }
    .shell.cc-top .shell-links::backdrop { background: color-mix(in oklab, var(--black) 60%, transparent); }
    .shell.cc-top .shell-links .shell-link {
      flex: none; flex-direction: row; justify-content: flex-start; gap: var(--sp-h);
      min-height: var(--size-control-md);
      padding-inline: var(--sp-h);
      font-size: var(--fs-control);
    }
    .shell.cc-top .shell-links .shell-link[aria-current]:not([aria-current="false"]) { box-shadow: inset calc(var(--line) * 2) 0 0 var(--accent); border-radius: var(--r-h); border-start-start-radius: 0; border-end-start-radius: 0; }
  }
  html:has(.shell.cc-top .shell-links:popover-open) { overflow: hidden; }

  /* A dropdown is a float that opens under its button: .float.cc-anchor
     [popover], opened by popovertarget from a .shell-link button (or any
     button). Where the browser has anchor positioning, core places it under
     its button and flips it when it would leave the screen; the button that
     opens a popover is its anchor, so no names are needed. Elsewhere the app
     places it, as rule 16 says. */
  @supports (position-area: block-end) {
    .float.cc-anchor[popover] {
      position-area: block-end span-inline-end;
      position-try-fallbacks: flip-inline, flip-block, flip-block flip-inline;
      margin-block: var(--sp-q);
    }
  }

  /* Outline: a knowledge base's contents. Nested lists of links (chapters,
     pages, a page's headings), each level a cell further in, every row whole
     cells; a level folds as a details whose summary is a row. The current
     link is marked as a current .shell-link is. Marking the heading in view
     is the app's job. Markup: nav.outline > ul > li > a.outline-link (+ ul),
     or li > details > summary.outline-link + ul. */
  .outline { --outline-indent: var(--sp-1); --outline-row: var(--size-control-sm); min-width: 0; }
  .outline :where(ul) { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
  .outline :where(ul ul) { padding-inline-start: var(--outline-indent); }
  .outline :where(details) { margin: 0; }
  .outline-link {
    position: relative;
    display: flex; align-items: center; gap: var(--sp-h);
    min-height: var(--outline-row);
    padding-inline: var(--sp-h);
    border-radius: var(--r-h);
    color: var(--text-secondary); text-decoration: none;
    font-size: var(--fs-control); font-weight: var(--fw-label);
    list-style: none; cursor: pointer;
    background: color-mix(in oklab, var(--text) calc(var(--state-on) + var(--state-act)), transparent);
  }
  .outline-link::-webkit-details-marker { display: none; }
  @media (hover: hover) { .outline-link:hover { color: var(--text); } }
  .outline-link[aria-current]:not([aria-current="false"]) { color: var(--text); box-shadow: inset calc(var(--line) * 2) 0 0 var(--accent); border-start-start-radius: 0; border-end-start-radius: 0; }
  /* A folding row's chevron: two sides of a square, turned, at the row's end. */
  summary.outline-link::after {
    content: ""; flex: none;
    width: var(--sp-h); height: var(--sp-h);
    margin-inline-start: auto;
    border-inline-end: calc(var(--line) * 1.5) solid var(--text-tertiary);
    border-block-end: calc(var(--line) * 1.5) solid var(--text-tertiary);
    transform: translateY(calc(var(--sp-h) * -.354)) rotate(45deg);
    transition: transform var(--dur-in) var(--ease-out);
  }
  details:not([open]) > summary.outline-link::after { transform: translateX(calc(var(--sp-h) * -.354)) rotate(-45deg); }

  /* Breadcrumbs: where this page sits. Markup: nav[aria-label] > ol.crumbs >
     li > a, the last li holding the page itself with aria-current="page".
     Rows are whole cells, so wrapping keeps what follows on a line. In a box
     under 30rem only the parent shows, as a link back. */
  .crumbs {
    display: flex; flex-wrap: wrap; align-items: center;
    margin: 0; padding: 0; list-style: none;
    font-size: var(--fs-control-sm); font-weight: var(--fw-label);
    color: var(--text-tertiary);
  }
  .crumbs > li { display: inline-flex; align-items: center; min-height: var(--sp-2); }
  .crumbs > li + li::before {
    content: "/" / "";
    padding-inline: var(--sp-h);
    color: var(--text-faint);
  }
  .crumbs a { color: var(--text-secondary); text-decoration: none; border-radius: var(--r-q); }
  @media (hover: hover) { .crumbs a:hover { color: var(--text); text-decoration: underline; } }
  .crumbs [aria-current]:not([aria-current="false"]) { color: var(--text); }
  @container (width < 30rem) {
    .crumbs > li:not(:nth-last-child(2)) { display: none; }
    .crumbs > li:nth-last-child(2)::before { content: "\2190" / ""; padding-inline: 0 var(--sp-h); color: var(--text-secondary); }
  }

  /* Skip link: the first thing in the page, hidden until it takes focus, then
     drawn over the page's start like a primary button. Its target is main,
     given tabindex="-1" so every browser moves focus there. */
  .skip-link {
    position: fixed; inset-block-start: var(--sp-1); inset-inline-start: var(--sp-1);
    z-index: var(--z-toast);
    display: inline-flex; align-items: center;
    min-height: var(--size-control-lg);
    padding-inline: var(--sp-1h);
    border-radius: var(--shape-control);
    background: var(--accent); color: var(--accent-ink);
    font-size: var(--fs-control); font-weight: var(--fw-label);
    text-decoration: none;
    translate: 0 calc(-100% - var(--sp-2));
  }
  .skip-link:focus { translate: none; }

  /* Interaction presets (D82) ---------------------------------------------------
     Each is off until an element asks for it with a data attribute. Fade and
     press are CSS alone; glow, reveal, detents, swipe and share need the
     optional presets.js. Under reduced motion each still works and nothing
     travels: the durations collapse, press does not sink, and view
     transitions stand down. */

  /* Fade: a scroller's edges fade where there is more to see, from a mask
     that a scroll-driven animation opens and closes. data-trellis-fade="x"
     or "y"; --fade-size, three cells. Where the browser has no scroll-driven
     animation there is no fade; on a box that doesn't scroll, none either. */
  @keyframes trellis-fade-start { from { --fade-start: 0px; } to { --fade-start: var(--fade-size); } }
  @keyframes trellis-fade-end { from { --fade-end: var(--fade-size); } to { --fade-end: 0px; } }
  @supports (animation-timeline: scroll()) {
    [data-trellis-fade] {
      --fade-size: var(--sp-3);
      --fade-dir: to right;
      mask-image: linear-gradient(var(--fade-dir), transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent);
      animation: trellis-fade-start linear both, trellis-fade-end linear both;
      animation-timeline: scroll(self x), scroll(self x);
      animation-range: 0 var(--fade-size), calc(100% - var(--fade-size)) 100%;
    }
    [data-trellis-fade="y"] { --fade-dir: to bottom; animation-timeline: scroll(self y), scroll(self y); }
  }

  /* Press: a pressed control sinks, at once, by --press-scale. It returns
     the same way, so no transition of the control's is replaced. */
  [data-trellis-press] { --press-scale: .97; }
  [data-trellis-press]:active:not(:disabled, [aria-disabled="true"]) { scale: var(--press-scale); }
  @media (prefers-reduced-motion: reduce) { [data-trellis-press]:active { scale: none; } }

  /* Glow: light under the finger on a field that scrolls (presets.js writes
     --glow-x and --glow-y). It is the field's own background, so the content
     never moves; --glow-size, --glow-color. Touch and pen; "all" adds a mouse. */
  [data-trellis-glow] {
    --glow-size: calc(var(--u) * 12);
    --glow-color: var(--accent);
    background-image: radial-gradient(circle var(--glow-size) at var(--glow-x, 50%) var(--glow-y, 50%), color-mix(in oklab, var(--glow-color) var(--glow-a), transparent), transparent);
    transition: --glow-a var(--dur-out) var(--ease-in);
  }
  [data-trellis-glow][data-trellis-glowing] { --glow-a: 18%; transition-duration: var(--dur-in); }

  /* Reveal: a scrollbar that shows while the field scrolls or a pointer is
     over it (presets.js marks the scrolling). */
  [data-trellis-reveal]:not([data-trellis-scrolling], :hover) { --scrollbar-thumb: transparent; --scrollbar-thumb-hover: transparent; }

  /* Swipe: a row slides toward its start to show its actions
     (.list-item[data-trellis-swipe] > … + .list-actions). The actions wait
     past the row's end, clipped; presets.js moves everything by --swipe-x. */
  .list-item[data-trellis-swipe] { overflow-x: clip; touch-action: pan-y; }
  .list-item[data-trellis-swipe] :where(a, img) { -webkit-user-drag: none; }
  .list-item[data-trellis-swipe] > * { translate: var(--swipe-x, 0px) 0; transition: translate var(--dur-in) var(--ease-spring); }
  .list-item[data-trellis-swipe][data-trellis-dragging] > * { transition: none; }
  .list-actions { position: absolute; inset-block: 0; inset-inline-start: 100%; display: flex; align-items: stretch; }
  .list-actions > * { height: auto; border-radius: 0; }

  /* Share: an element that carries across a change of view
     (data-trellis-share="name"; presets.js names it and runs the change). */
  :root:has([data-trellis-share])::view-transition-group(*) { animation-duration: var(--dur-in-slow); animation-timing-function: var(--ease-spring); }
  @media (prefers-reduced-motion: reduce) {
    ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none; }
  }

  /* Floating surfaces -----------------------------------------------------
     One surface for every popover, options card and tooltip, in the top layer
     at a fixed position, with its motion defined once. Open it as a popover
     (popover="manual" for one a script opens) and place it through
     --float-x and --float-y. Placing it by its anchor, following the anchor
     and closing it are float.js's, or the app's (rule 16). */
  .float {
    --float-pad: var(--sp-h);
    --float-radius: var(--shape-float);
    --surface: var(--bg-raised);
    --float-ink: var(--text);   /* a float on a ground of your own sets the two together: --surface and --float-ink */
    background: var(--surface);
    color: var(--float-ink);
    outline: var(--line) solid var(--border);
    outline-offset: calc(var(--line) * -1);
    border: 0;
    border-radius: var(--float-radius);
    box-shadow: var(--lift);
    padding: var(--float-pad);
  }
  /* A float opens as a manual popover and is placed through two variables,
     which float.js writes (or an app's own script): its left and top on the
     screen. Unset, it sits where the browser puts it. */
  .float[popover] {
    position: fixed; inset: auto; margin: 0;
    left: var(--float-x, auto); top: var(--float-y, auto);
    z-index: var(--z-float);
    opacity: 0; scale: .98;
    transition: opacity var(--dur-out) var(--ease-in), scale var(--dur-out) var(--ease-in),
                display var(--dur-out) allow-discrete, overlay var(--dur-out) allow-discrete;
  }
  /* Closed, it is gone. A primitive's own display (.options-card is a flex
     column) is an author rule and beats the browser's rule for a closed
     popover, so without this a closed float is laid out unseen and takes
     clicks. The exit fade survives: display is in the transition above. */
  .float[popover]:not(:popover-open) { display: none; }
  .float[popover]:popover-open { opacity: 1; scale: 1; transition-duration: var(--dur-in); transition-timing-function: var(--ease-out); }
  @starting-style { .float[popover]:popover-open { opacity: 0; scale: .98; } }

  .options-card {
    --float-pad: var(--density-options-pad);
    --options-w: var(--sp-16);
    --options-max-h: calc(var(--u) * 24);
    --option-h: var(--density-option-h);   /* an item's height and type: a compact card sets the two together */
    --option-fs: var(--density-option-fs);
    container-type: inline-size;   /* a surface with a set width is a container */
    display: flex; flex-direction: column;
    width: var(--options-w);
    max-height: var(--options-max-h);
    overflow-y: auto;
    overflow-x: clip;   /* it scrolls down, never sideways: a long label truncates instead */
  }
  /* Past the cap (D111). When the reader's text size passes the cell's cap,
     type keeps growing but the cell doesn't, so the card widens in
     proportion, in whole cells, as a control grows by whole cells. Its width
     is --options-w times --u-type / --u-base, which is exactly 1 at default
     sizes, so nothing moves there. It goes no wider than the screen less half
     a cell each side (float.js's margin), or its container; past that a label
     truncates. Where a browser can't divide a length by a length, it stays
     --options-w wide. */
  @supports (width: calc(100vw / 1px * 1px)) {
    .options-card {
      --options-grow: max(1, var(--u-type) / var(--u-base));
      width: max(var(--options-w), min(
        round(up, calc(var(--options-w) * var(--options-grow)), var(--u)),
        round(down, calc(var(--fit-width, 100vw) - var(--u)), var(--u)),
        100%));
    }
  }
  .options-card-item {
    display: flex; align-items: center; gap: var(--sp-h);
    width: 100%;
    min-height: var(--option-h, var(--density-option-h));   /* the fallbacks: an item outside a card */
    padding-inline: var(--sp-h);
    border-radius: max(var(--r-q), calc(var(--float-radius) - var(--float-pad)));
    font-size: var(--option-fs, var(--density-option-fs));
    text-align: start;
    color: var(--text); text-decoration: none;
  }
  .options-card-item { background: color-mix(in oklab, var(--text) calc(var(--state-on) + var(--state-act)), transparent); }
  .options-card-item .icon.cc-end { margin-inline-start: auto; color: var(--accent); }
  /* Inside a float everything sums to whole half-cells: heading 2u + ½u after
     it, rule ½u including its line, items 2½u. The heading's capitals sit one
     cell below the card's edge, and its words about one cell above the first
     item's ground. The air after it is a margin: padding would be rounded into
     the heading's own whole cells and not show. */
  .options-card-heading { padding-inline: var(--sp-h); padding-block-start: calc(var(--sp-1) - var(--float-pad)); margin-block: 0 var(--sp-h); color: var(--text-tertiary); }
  .options-card-rule { height: var(--line); margin-block: calc((var(--sp-h) - var(--line)) / 2); background: var(--border-subtle); }

  .tooltip {
    --float-pad: var(--sp-q);
    --float-radius: var(--r-q);
    --surface: var(--text);
    --float-ink: var(--bg);
    outline-color: transparent;
    padding-inline: var(--sp-h);
    font-size: var(--fs-control-sm);
  }

  /* Field and input: the archetype for everything typed or chosen ------------
     One box for input, select and textarea: it occupies whole cells, so a field
     in a stack keeps what follows on a line; a real border given back in its
     padding; a label that hangs above it.
     The label and the hint start where the input's text does (--field-inset).
     States change variables. Markup: .field > label.field-label + .input +
     p.field-hint. */
  .field {
    --stack-gap: var(--sp-1);
    --field-inset: var(--sp-1);
    display: flex; flex-direction: column;
    gap: var(--stack-gap);
    min-width: 0;
  }
  .field-label { color: var(--text-secondary); }
  .field-hint { color: var(--text-tertiary); }
  .field-label, .field-hint { padding-inline-start: var(--field-inset); }
  .cc-dense .field, .field:has(> .input.cc-sm) { --field-inset: var(--sp-h); }
  .field:has(:is(.input, .input-control)[aria-invalid="true"]) .field-hint { color: var(--alert); }
  .input {
    --input-h: var(--density-control-h);
    --input-fs: var(--density-control-fs);
    --input-radius: var(--shape-input);
    --input-bg: var(--bg-raised);
    --input-ink: var(--text);
    --input-border: var(--border);
    --input-pad: var(--sp-1);
    --input-hit: 0px;
    --input-draw: calc(max(var(--input-h), var(--input-hit)) + max(0px, round(up, calc(1em - max(var(--input-h), var(--input-hit))), var(--u))));   /* grows by whole cells with its type, as a button does */
    display: block;
    width: 100%;
    height: var(--input-draw);
    /* It draws at the product's control height, so it matches a button beside it,
       and occupies whole cells, so what follows stays on a line. */
    margin-block-end: calc(round(up, var(--input-draw), var(--u)) - var(--input-draw));
    padding: 0 calc(var(--input-pad) - var(--line));
    border: var(--line) solid var(--input-border);
    border-radius: var(--input-radius);
    background-color: var(--input-bg);
    color: var(--input-ink);
    font-size: var(--input-fs);
    transition: border-color var(--dur-out) var(--ease-in), background-color var(--dur-out) var(--ease-in);
  }
  .input::placeholder { color: var(--text-tertiary); opacity: 1; }
  @media (hover: hover) { .input:hover:not(:disabled, [aria-invalid="true"]) { --input-border: var(--border-strong); } }   /* an invalid edge stays the alert */
  .input:disabled { --input-bg: var(--bg-sunken); --input-ink: var(--text-tertiary); --input-border: var(--border-subtle); cursor: not-allowed; }
  .input:read-only:not(select, div) { --input-bg: var(--bg-sunken); }
  .input[aria-invalid="true"] { --input-border: var(--alert); }
  .input.cc-sm { --input-h: var(--size-control-sm); --input-fs: var(--fs-control-sm); --input-pad: var(--sp-h); }
  .input.cc-lg { --input-h: var(--size-control-xl); --input-fs: var(--fs-control-lg); }
  .cc-dense .input { --input-h: var(--size-control-sm); --input-fs: var(--fs-control-sm); --input-pad: var(--sp-h); }
  /* Lines of a textarea are whole cells, so its height is too: 1 cell of padding
     plus 2 cells a line. */
  textarea.input {
    --input-rows: 3;
    height: auto;
    margin-block-end: 0;
    min-height: max(calc(var(--sp-2) * var(--input-rows) + var(--sp-1)), var(--input-hit));
    padding-block: calc(var(--sp-h) - var(--line));
    line-height: var(--sp-2);
    resize: vertical;
    field-sizing: content;
  }
  /* A chevron drawn from two gradients, so it follows the ink in both themes. */
  select:is(.input, .input-control) {
    appearance: none; -webkit-appearance: none;
    --chevron: calc(var(--sp-q) + var(--line) * 2);
    --chevron-color: currentColor;
    padding-inline-end: var(--sp-3);
    /* A choice longer than the box is cut at the box: WebKit lets a select's
       text overflow it, and on a phone at large text the page scrolled sideways. */
    overflow: clip; text-overflow: ellipsis; white-space: nowrap;
    background-image: linear-gradient(45deg, transparent 50%, var(--chevron-color) 50%), linear-gradient(135deg, var(--chevron-color) 50%, transparent 50%);
    background-position: right calc(var(--sp-1) + var(--chevron)) center, right var(--sp-1) center;
    background-size: var(--chevron) var(--chevron);
    background-repeat: no-repeat;
    cursor: pointer;
  }
  [dir="rtl"] select:is(.input, .input-control) { background-position: left var(--sp-1) center, left calc(var(--sp-1) + var(--chevron)) center; }
  /* A field with something in its box (D116): a unit, an icon, a button that
     shows a password or clears a search. The box is a div.input.cc-slots,
     which draws what an input draws (its height, its edge, its ground, its
     corner, its sizes and every context that sets them) and holds a bare
     .input-control, an input or a select. What comes before it stands at the
     box's start and what comes after at its end: an .icon or an .input-unit,
     which are drawn and nothing more, or a .button.icon-button, which is its
     own control. The box takes the one focus ring and the invalid, disabled
     and read-only states from its control. The control's own box runs on
     under the slots to the box's edges (padding to its words, a negative
     margin back out), so a click on a unit or an icon is a click on the field
     and a browser's autofill fills the whole box; its words, a number's
     spinner and a search's clear button stay between the slots. A unit is as
     wide as its words, up to --input-unit and half the box, which is how far
     the control runs under it, so it never ends short of the edge. A select takes a start slot; its end is its chevron. A
     textarea takes none: controls round lines of text are the composer.
     Markup: .field > label.field-label + .input.cc-slots > .icon or .input-unit
     or .button.icon-button, .input-control, then the same at the end. */
  .input.cc-slots {
    --input-unit: 6em;   /* a unit's longest, and how far the control runs under one */
    --input-slot-ink: var(--text-secondary);
    --input-inset: calc(var(--input-pad) - var(--line));
    --input-slot: calc(max(var(--input-h), var(--input-hit)) - var(--sp-h));
    display: flex; align-items: center; gap: var(--sp-h);
    overflow: clip; isolation: isolate;
    cursor: text;
  }
  .input.cc-slots > :not(.input-control) { flex: none; z-index: 1; }
  .input.cc-slots > :is(.icon, .input-unit) { color: var(--input-slot-ink); pointer-events: none; }
  .input-unit { max-inline-size: min(50%, var(--input-unit, 6em)); overflow-x: clip; white-space: nowrap; text-overflow: ellipsis; }
  .input.cc-slots > .button {
    --btn-h: var(--input-slot); --btn-fs: var(--fs-control-sm);
    --btn-radius: max(var(--r-q), calc(var(--input-radius) - var(--sp-q)));
    max-block-size: 100%;
    outline-offset: calc(var(--line) * -2);   /* the box clips, so its ring is inside it */
  }
  .input.cc-slots > .button:first-child { margin-inline-start: calc(var(--sp-q) - var(--input-pad)); }
  .input.cc-slots > .button:last-child { margin-inline-end: calc(var(--sp-q) - var(--input-pad)); }
  .input-control {
    --control-start: var(--input-inset);
    --control-end: var(--input-inset);
    -webkit-appearance: none; appearance: none;
    flex: 1 1 0; align-self: stretch;
    min-inline-size: 0;
    margin-block: 0;
    margin-inline: calc(var(--control-start) * -1) calc(var(--control-end) * -1);
    padding-block: 0;
    padding-inline: var(--control-start) var(--control-end);
    border: 0; border-radius: 0;
    background-color: transparent;
    color: inherit;
  }
  .icon + .input-control { --control-start: calc(var(--input-inset) + var(--size-icon) + var(--sp-h)); }
  .input-control:has(+ .icon) { --control-end: calc(var(--input-inset) + var(--size-icon) + var(--sp-h)); }
  .input-unit + .input-control { --control-start: calc(var(--input-inset) + var(--input-unit) + var(--sp-h)); }
  .input-control:has(+ .input-unit) { --control-end: calc(var(--input-inset) + var(--input-unit) + var(--sp-h)); }
  .button + .input-control { --control-start: calc(var(--sp-q) - var(--line) + var(--input-slot) + var(--sp-h)); }
  .input-control:has(+ .button) { --control-end: calc(var(--sp-q) - var(--line) + var(--input-slot) + var(--sp-h)); }
  .input-control:has(+ .button:not(.icon-button)), .input-control:has(+ * + *) { --control-end: calc(var(--input-inset) + var(--input-slot) + var(--input-unit) + var(--sp-1)); }
  .button:not(.icon-button) + .input-control, * + * + .input-control { --control-start: calc(var(--input-inset) + var(--input-slot) + var(--input-unit) + var(--sp-1)); }
  .input-control::placeholder { color: var(--text-tertiary); opacity: 1; }
  .input-control:focus-visible { outline: none; }
  .input.cc-slots:has(> .input-control:focus-visible) { outline: calc(var(--line) * 2) solid var(--focus); outline-offset: var(--line); }
  .input.cc-slots:has(> .input-control:read-only:not(select)) { --input-bg: var(--bg-sunken); }
  .input.cc-slots:has(> .input-control[aria-invalid="true"]) { --input-border: var(--alert); }
  .input.cc-slots:has(> .input-control:disabled) { --input-bg: var(--bg-sunken); --input-ink: var(--text-tertiary); --input-slot-ink: var(--text-tertiary); --input-border: var(--border-subtle); cursor: not-allowed; }
  .input-control:disabled { cursor: not-allowed; }
  /* A button of the app's at the end is the one that clears or shows: the
     browser's own (a search's clear, Edge's reveal) goes. */
  .input-control[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
  .input-control:has(+ .button)::-webkit-search-cancel-button { display: none; }
  .input-control:has(+ .button)::-ms-reveal { display: none; }
  .input-control:has(+ .button)::-ms-clear { display: none; }
  @media (forced-colors: active) {
    /* An invalid field's edge is the system's Mark, as a choice's is (D83): the alert is gone
       here. A box whose control is disabled is GrayText, as it is quiet, not alert, by day. */
    .input:is([aria-invalid="true"], .cc-slots:has(> .input-control[aria-invalid="true"])) { border-color: Mark; }
    .input.cc-slots:has(> .input-control:disabled) { border-color: GrayText; }
  }

  /* Composer: one box for writing a message. Leading controls (attach), the
     text, trailing controls (emoji), then the send button, all inside one edge
     on the raised ground. The text grows a line at a time up to --composer-max,
     then scrolls; where field-sizing is missing settle.js writes its height
     (--composer-h). The box is the field: it takes the focus ring, not the
     textarea. Send wakes with text, in CSS alone: quiet while the placeholder
     shows, the accent once there are words, so the textarea needs a placeholder.
     A one-line box is three cells: a 2½-cell control and a quarter cell round
     it; each line more is two cells. Its name may be an aria-label or a
     visually hidden label: the placeholder names the recipient, so a visible
     label is optional here. Markup: .field > .composer > .button.icon-button… +
     textarea.composer-input + .button.icon-button… + .button.icon-button.composer-send,
     then an optional p.field-hint, which starts where the text does. */
  .composer {
    --composer-radius: var(--shape-input);
    --composer-pad: var(--sp-q);
    --composer-control: var(--size-control-md);
    --composer-line: var(--sp-2);
    --composer-max: calc(var(--composer-control) + var(--composer-line) * 4);   /* a control and four lines more: keep it a control plus whole lines */
    --composer-fs: var(--fs-control-lg);
    --composer-edge: var(--border);
    --composer-send-rest: var(--bg-hover);
    --composer-send-ready: var(--accent);
    --composer-send-ink: var(--accent-ink);
    display: flex; align-items: flex-end; gap: var(--composer-pad);
    min-width: 0;
    /* Top and bottom: half of what the control is short of whole cells, from
       the cell itself (--sp-q is snapped to device pixels), so the box is
       whole cells at any cell. */
    --composer-pad-block: calc((round(up, calc(var(--composer-control) + var(--composer-pad)), var(--u)) - var(--composer-control)) / 2);
    padding: var(--composer-pad-block) var(--composer-pad);
    border-radius: var(--composer-radius);
    background: var(--bg-raised);
    box-shadow: inset 0 0 0 var(--line) var(--composer-edge);   /* an inset shadow, which takes no layout space; a border would snap to device pixels */
    cursor: text;
    transition: box-shadow var(--dur-out) var(--ease-in);
  }
  @media (hover: hover) { .composer:hover { --composer-edge: var(--border-strong); } }
  .composer:has(> .composer-input:focus-visible) { outline: calc(var(--line) * 2) solid var(--focus); outline-offset: var(--line); }
  .composer > .button {
    --btn-h: var(--composer-control); --btn-fs: var(--fs-control-md);
    --btn-radius: max(var(--r-q), calc(var(--composer-radius) - var(--composer-pad)));
    flex: none; cursor: pointer;
  }
  .composer-input {
    flex: 1 1 0; min-width: 0;
    min-height: var(--composer-control);
    max-height: var(--composer-max);
    margin: 0;
    padding: calc((var(--composer-control) - var(--composer-line)) / 2) var(--sp-q);
    border: 0; border-radius: 0;
    background: none;
    color: var(--text);
    font: inherit; font-size: var(--composer-fs);
    line-height: var(--composer-line);
    resize: none; overflow-y: auto;
    field-sizing: content;
  }
  .composer-input:focus-visible { outline: none; }
  .composer-input::placeholder { color: var(--text-tertiary); opacity: 1; }
  @supports not (field-sizing: content) { .composer-input { height: var(--composer-h, auto); } }
  .composer-send { --btn-bg: var(--composer-send-rest); --btn-ink: var(--text-tertiary); --btn-border: transparent; }
  .composer:has(> .composer-input:not(:placeholder-shown)) > .composer-send { --btn-bg: var(--composer-send-ready); --btn-ink: var(--composer-send-ink); }
  /* Its hint starts at the text: past the leading control, when there is one.
     It names keys, and a touch keyboard has none of them: there it is gone. */
  .field:has(> .composer) { --field-inset: calc(var(--sp-q) * 2); }
  .field:has(> .composer > .button:first-child) { --field-inset: calc(var(--sp-q) * 3 + var(--size-control-md)); }
  .field:has(> .composer) > .field-hint { overflow-x: clip; white-space: nowrap; text-overflow: ellipsis; }
  @media (pointer: coarse) { .field:has(> .composer) > .field-hint { display: none; } }
  /* Touch. A replaced element has no ::before to grow, so the box itself reaches
     the target, in whole cells. And iOS zooms the page when a focused input's
     type is under 16px. */
  @media (pointer: coarse) {
    .input { --input-hit: round(up, var(--hit-min), var(--u)); font-size: max(1rem, var(--input-fs)); }
  }

  /* Tabs: whole cells tall, on a baseline that is a plane after its coordinate.
     The selected tab's indicator sits on that plane. .cc-seg is the same tabs
     as a segmented control. Markup: .tabs[role=tablist] > button.tab. */
  .tabs {
    --tab-h: var(--size-control-lg);
    --tab-fs: var(--fs-control);
    --tab-pad: var(--sp-1);
    --tab-rule: var(--border-subtle);
    --tab-mark: var(--text);
    --tab-mark-h: calc(var(--line) * 2);
    --tab-on-bg: transparent;
    --tab-radius: 0px;
    display: flex; gap: var(--tab-gap, 0px);
    overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: none;
    box-shadow: inset 0 calc(var(--line) * -1) 0 var(--tab-rule);
  }
  .tab {
    position: relative; flex: none;
    display: inline-flex; align-items: center; gap: var(--sp-h);
    height: calc(var(--tab-h) + max(0px, round(up, calc(1em - var(--tab-h)), var(--u))));   /* grows by whole cells with its type, as a button does */
    padding-inline: var(--tab-pad);
    border-radius: var(--tab-radius);
    color: var(--text-secondary);
    font-size: var(--tab-fs); font-weight: var(--fw-label);
    white-space: nowrap;
  }
  .tab { --state-ink: var(--text); --state-fill: var(--tab-bg, transparent); background: color-mix(in oklab, var(--state-tone) var(--state-act), var(--state-fill)); }
  @media (hover: hover) { .tab:hover { color: var(--text); } }
  /* A tab that is a link (a view, a filter, a page) is the current one by aria-current, and
     carries no underline: its mark says it is a control (D101). A segmented
     control written as radios (role="radio") is selected by aria-checked. */
  a.tab, a.tag { text-decoration: none; }
  .tab:is([aria-selected="true"], [aria-checked="true"], [aria-current]:not([aria-current="false"])) { --tab-bg: var(--tab-on-bg); color: var(--text); }
  .tab:is([aria-selected="true"], [aria-checked="true"], [aria-current]:not([aria-current="false"]))::after {
    content: ""; position: absolute;
    inset-inline: 0; inset-block-end: 0;
    height: var(--tab-mark-h);
    background: var(--tab-mark);
  }
  .tabs.cc-seg {
    --tab-h: var(--density-seg-h); --tab-fs: var(--fs-control-sm); --tab-mark-h: 0px; --tab-on-bg: var(--bg-raised);
    --tab-radius: max(var(--r-q), calc(var(--shape-control) - var(--sp-q)));
    --tab-gap: var(--line);
    width: fit-content; max-width: 100%;
    /* Its tabs plus the ring around them: the large control height, until a tab
       outgrows its own. A compact one sets the two together, --tab-h and
       --seg-pad (a product: --density-seg-h and --density-seg-pad): 1½ cells
       and ¼ make a control two cells tall. */
    --seg-pad: var(--density-seg-pad);
    height: auto;
    padding: var(--seg-pad);
    border-radius: var(--shape-control);
    background: var(--bg-sunken);
    box-shadow: inset 0 0 0 var(--line) var(--border-subtle);
  }
  .cc-dense .tabs { --tab-h: var(--size-control-sm); --tab-fs: var(--fs-control-sm); --tab-pad: var(--sp-h); }

  /* Chat item: an avatar and a body, for messages, walls and system lines. A
     bubble is a shaped ground with no edge, so no message reads as a button
     (D122): a faint wash of the text over the surface (--chat-bubble-wash),
     a corner rounder than a control's (--chat-shape), and on the first message
     of a run the top corner on the speaker's side square (--chat-head), under
     the name. It hangs its text from a cell. Your own message (.cc-own) is at
     the end of the row, on a faint wash of the accent (--chat-own-wash) in the
     text's ink, with no avatar and its meta after the bubble. A product's
     --chat-bubble-bg and --chat-own-bg are laid over the wash (an opaque color
     replaces it), --chat-own-ink is your words' ink, and --chat-bubble-edge
     draws an edge. Third ink on a bubble's ground reads as the second. A
     message that continues the one before it from the same speaker (.cc-cont)
     shares its avatar and its meta: the avatar keeps its place, unseen, the
     meta shows once (above the first of others' runs, under the last of
     yours), its corners are all round, and the run is --chat-run-gap apart, a
     cell. .cc-own, .cc-cont, .cc-wall, .cc-system and .cc-removed only change
     variables. Markup: .chat-item > .avatar + .chat-item-body >
     .chat-item-meta + .chat-item-bubble; in a flat thread a continuing message
     may hold a .chat-item-time before its body, and any message a
     .chat-item-actions. */
  .chat-item {
    --chat-dir: row;
    --chat-align: flex-start;
    --chat-items: flex-start;
    --chat-bg: color-mix(in oklab, var(--text) var(--chat-bubble-wash), var(--surface));
    --chat-over: var(--chat-bubble-bg, transparent);
    --chat-ink: currentColor;
    --chat-tertiary: var(--text-secondary);
    --chat-edge: var(--chat-bubble-edge, transparent);
    --chat-edge-style: solid;
    --chat-style: normal;
    --chat-pad: var(--chat-bubble-pad);
    --chat-radius: var(--chat-shape);
    --chat-head: 0px;
    --chat-tail: var(--chat-radius);
    --chat-head-start: var(--chat-head);
    --chat-head-end: var(--chat-radius);
    --chat-tail-start: var(--chat-tail);
    --chat-tail-end: var(--chat-radius);
    --chat-measure: calc(var(--u) * 40);
    --chat-avatar: inline-grid;
    --chat-avatar-seen: visible;
    --chat-avatar-n: 2;
    --chat-meta: flex;
    --chat-meta-order: 0;
    --chat-name-ink: inherit;
    --chat-name-weight: inherit;
    --chat-time: none;
    --chat-time-seen: hidden;
    --chat-actions: flex;
    --chat-actions-seen: hidden;
    --chat-run-gap: var(--sp-1);
    --chat-row: 0%;
    --chat-outset: calc(var(--outset) * var(--u));
    position: relative; isolation: isolate;
    display: flex; flex-direction: var(--chat-dir); align-items: var(--chat-items);
    gap: var(--sp-1);
    min-width: 0;
  }
  /* The row's fill on hover, a positioned ::before that takes no layout space.
     It reaches half the run gap above and below and steps out like a list
     row, so the fills of a run's rows meet. */
  .chat-item::before {
    content: ""; position: absolute; z-index: -1;
    inset-block: calc(var(--chat-run-gap) / -2);
    inset-inline: calc(var(--chat-outset) * -1);
    border-radius: var(--r-h);
    background: color-mix(in oklab, var(--text) var(--chat-row), transparent);
    pointer-events: none;
  }
  .chat-item > .avatar { display: var(--chat-avatar); visibility: var(--chat-avatar-seen); align-self: flex-start; }
  .chat-item-body { display: flex; flex-direction: column; align-items: var(--chat-align); gap: var(--sp-1); min-width: 0; flex: 0 1 var(--chat-measure); }
  .chat-item-meta { display: var(--chat-meta); order: var(--chat-meta-order); flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-h); color: var(--text-tertiary); }   /* wraps when the reader's text is large */
  .chat-item-name { color: var(--chat-name-ink); font-weight: var(--chat-name-weight); }
  .chat-item-bubble {
    position: relative;
    max-width: 100%;
    padding: var(--chat-pad);
    border-radius: var(--chat-radius);
    border-start-start-radius: var(--chat-head-start);
    border-start-end-radius: var(--chat-head-end);
    border-end-start-radius: var(--chat-tail-start);
    border-end-end-radius: var(--chat-tail-end);
    background: linear-gradient(var(--chat-over), var(--chat-over)) var(--chat-bg);
    --text-tertiary: var(--chat-tertiary);
    color: var(--chat-ink);
    font-style: var(--chat-style);
    outline: var(--line) var(--chat-edge-style) var(--chat-edge);
    outline-offset: calc(var(--line) * -1);
  }
  /* A message is typed text: a bubble of words and inline marks keeps its line
     breaks and its spaces, as the composer showed them (D112). A bubble that
     holds markup of its own (prose, a paragraph, a list, a line break) sets its
     own lines, and the spaces between its tags mean nothing. */
  :where(.chat-item-bubble:not(.prose, :has(> :is(br, p, div, ul, ol, dl, pre, blockquote, figure, table, details, section, article, form, hr, h1, h2, h3, h4, h5, h6, .chat-quote, .chat-file, .chat-link, .chat-reactions)))) { white-space: pre-wrap; }
  /* Prose in a bubble, or a bubble that is one. A .prose is a size container,
     and a container's width can't come from what it holds (D74): in a bubble
     that shrinks to its content it had no width at all. There it is not one,
     and its type answers to the thread, as the words in the bubbles beside it
     do. What needs a width to measure from takes the message's measure
     instead: code and an embed, and a wall post, which has no bubble to
     shrink. Flat rows are already as wide as the row. */
  :is(.chat-item-bubble.prose, .chat-item-bubble .prose) { container-type: var(--chat-prose, normal); }
  .chat-item-bubble:is(.prose, :has(.prose)):is(.chat-item.cc-wall .chat-item-bubble, :has(:is(pre, iframe))) { --chat-prose: inline-size; align-self: stretch; }
  /* Code steps out of its column as far as the bubble's padding, no further. */
  .chat-item:not(.cc-wall, .cc-flat, .chat-thread.cc-flat > *) :is(.chat-item-bubble.prose, .chat-item-bubble .prose) > pre { margin-inline: max(var(--outset) * var(--u) * -1, var(--chat-pad) * -1); }
  /* A continuing message's own time, in the avatar's column, shown on hover and
     focus: as wide as the column and clipped to it, on the text's baseline. */
  .chat-item-time {
    display: var(--chat-time); visibility: var(--chat-time-seen);
    flex: none;
    width: calc(var(--u) * var(--chat-avatar-n));
    height: 0; min-height: 0;   /* on the text's baseline, it never makes the row taller */
    overflow-x: clip; white-space: nowrap; text-align: center;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
  }
  /* React, reply, more: on the row's top edge at its end, over the run gap,
     when the row is hovered or holds focus. Markup: .chat-item-actions >
     .button.icon-button.cc-ghost.cc-sm… */
  .chat-item-actions {
    position: absolute; z-index: var(--z-raised);
    inset-block-start: calc(var(--sp-1h) * -1); inset-inline-end: 0;
    display: var(--chat-actions); visibility: var(--chat-actions-seen);
    gap: var(--sp-q);
    padding: var(--sp-q);
    border-radius: var(--r-1);
    background: var(--surface);
    box-shadow: 0 0 0 var(--line) var(--border-subtle);
  }
  @media (hover: hover) { .chat-item:hover { --chat-actions-seen: visible; } }
  .chat-item:focus-within { --chat-actions-seen: visible; }
  .chat-item.cc-own {
    --chat-dir: row-reverse; --chat-align: flex-end;
    --chat-bg: color-mix(in oklab, var(--accent) var(--chat-own-wash), var(--surface));
    --chat-over: var(--chat-own-bg, transparent);
    --chat-ink: var(--chat-own-ink, var(--text)); --chat-edge: transparent;
    --chat-head-start: var(--chat-radius); --chat-head-end: var(--chat-head);
    --chat-tail-start: var(--chat-radius); --chat-tail-end: var(--chat-tail);
    --chat-avatar: none; --chat-meta-order: 1;
  }
  /* A run from one speaker: --chat-run-gap apart, whatever the stack's gap, never
     less. Only the first of a run has the square corner. */
  .chat-item.cc-cont { --chat-head: var(--chat-radius); --chat-avatar-seen: hidden; --chat-meta: none; margin-block-start: min(0px, calc(var(--chat-run-gap) - var(--stack-gap, var(--sp-1)))); }
  .chat-item.cc-own.cc-cont:not(.cc-flat, .chat-thread.cc-flat > *) { --chat-meta: flex; }
  .chat-item.cc-own:not(.cc-flat, .chat-thread.cc-flat > *):has(+ .chat-item.cc-own.cc-cont) { --chat-meta: none; }
  .chat-item.cc-wall { --chat-bg: transparent; --chat-over: transparent; --chat-tertiary: var(--text-tertiary); --chat-edge: transparent; --chat-edge-style: none; --chat-pad: 0px; --chat-measure: 100%; }
  .chat-item.cc-system { --chat-bg: transparent; --chat-over: transparent; --chat-tertiary: var(--text-tertiary); --chat-edge: transparent; --chat-edge-style: none; --chat-pad: 0px; --chat-measure: 100%; color: var(--text-tertiary); }
  .chat-item.cc-system .chat-item-body { align-items: center; }
  /* A wall, a system line and a flat row have no bubble, and no edge (--chat-edge-style: none):
     in forced colors the system draws a transparent outline in its text color, and
     round a box trimmed to its capitals it runs through the words. */
  .cc-dense .chat-item { --chat-pad: var(--sp-h); --chat-radius: min(var(--chat-shape), var(--r-1)); }

  /* Chat thread: the column a conversation sits in. Messages, dividers and the
     typing line, a stack apart (two cells: a run is closer, --chat-run-gap).
     Nothing in it shrinks, so a scroller never clips its first divider.
     --chat-inset is where a message's text starts, past the avatar's column:
     the typing line starts there. Markup: .chat-thread > .chat-divider,
     .chat-item…, .chat-typing. */
  .chat-thread {
    --stack-gap: var(--sp-2);
    --chat-inset: calc(var(--u) * 2 + var(--sp-1));
    display: flex; flex-direction: column; gap: var(--stack-gap);
    min-width: 0;
  }
  .chat-thread > * { flex-shrink: 0; }
  /* Flat rows (.chat-thread.cc-flat, or .cc-flat on an item): everyone at the
     start, no bubble, the text at full measure. Your own message changes only
     its name. A group's head shows a three-cell avatar, the name in the strong
     weight and the time on one baseline; the rest of the run keeps the
     avatar's column for its own time, which shows on hover. The row is filled
     on hover, stepped out like a list row, so actions have a place. */
  .chat-thread.cc-flat { --chat-inset: calc(var(--u) * 3 + var(--sp-1)); }
  :is(.chat-thread.cc-flat > .chat-item, .chat-item.cc-flat) {
    --chat-dir: row; --chat-align: stretch; --chat-items: baseline;
    --chat-bg: transparent; --chat-over: transparent; --chat-tertiary: var(--text-tertiary); --chat-ink: currentColor; --chat-edge: transparent; --chat-edge-style: none;
    --chat-pad: 0px; --chat-measure: 100%;
    --chat-avatar: inline-grid; --chat-meta-order: 0;
    --chat-avatar-n: 3;
    --chat-prose: inline-size;
    --chat-name-ink: var(--text); --chat-name-weight: var(--fw-strong);
  }
  :is(.chat-thread.cc-flat > .chat-item, .chat-item.cc-flat) > .avatar { --av-n: var(--chat-avatar-n); --av-gap: 0px; --av-ring: 0px; }
  :is(.chat-thread.cc-flat > .chat-item, .chat-item.cc-flat).cc-cont:has(> .chat-item-time) { --chat-avatar: none; --chat-time: block; }
  @media (hover: hover) { :is(.chat-thread.cc-flat > .chat-item, .chat-item.cc-flat):hover { --chat-row: var(--state-hover); --chat-time-seen: visible; } }
  :is(.chat-thread.cc-flat > .chat-item, .chat-item.cc-flat):focus-within { --chat-row: var(--state-hover); --chat-time-seen: visible; }
  .chat-item.cc-system:is(.cc-flat, .chat-thread.cc-flat > *) { --chat-row: 0%; }
  /* Removed: its words in the faint ink and italic, no actions. A bubble keeps
     its place as a dashed edge; a wall post and a system line have none. */
  .chat-item.cc-removed { --chat-actions: none; --chat-tertiary: var(--text-tertiary); }
  .chat-item.cc-removed .chat-item-bubble { --chat-ink: var(--text-tertiary); --chat-style: italic; }
  .chat-item.cc-removed:not(.cc-flat, .cc-wall, .cc-system, .chat-thread.cc-flat > *) .chat-item-bubble { --chat-bg: transparent; --chat-over: transparent; --chat-edge: var(--border); --chat-edge-style: dashed; }
  /* "(edited)" after a message's words: a mark in running text, smaller and faint. */
  .chat-edited { color: var(--text-tertiary); font-size: var(--fs-control-xs); line-height: 0; white-space: nowrap; }

  /* A day, and the unread line (.cc-new): a rule each side of the words, on
     their capitals' middle. Markup: div.chat-divider > span.t-xs. */
  .chat-divider {
    --chat-divider-rule: var(--border-subtle);
    display: flex; align-items: center; gap: var(--sp-1);
    color: var(--text-tertiary);
  }
  .chat-divider::before, .chat-divider::after { content: ""; flex: 1 1 0; height: var(--line); background: var(--chat-divider-rule); }
  .chat-divider.cc-new { --chat-divider-rule: color-mix(in oklab, var(--accent) 50%, transparent); color: var(--accent); }
  /* Someone is typing: three dots and the words, from the text's column. The
     dots wait, still, where motion is reduced. Markup: .chat-typing >
     span.chat-typing-dots > i×3, then span.t-xs. */
  .chat-typing { display: flex; align-items: center; gap: var(--sp-h); padding-inline-start: var(--chat-inset, 0px); color: var(--text-tertiary); }
  .chat-typing-dots { display: inline-flex; gap: var(--sp-q); flex: none; }
  .chat-typing-dots > * { width: var(--sp-q); height: var(--sp-q); border-radius: 50%; background: currentColor; opacity: .3; animation: trellis-typing var(--dur-skeleton) var(--ease-out) infinite; }
  .chat-typing-dots > :nth-child(2) { animation-delay: var(--dur-in); }
  .chat-typing-dots > :nth-child(3) { animation-delay: calc(var(--dur-in) * 2); }
  @keyframes trellis-typing { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
  @media (prefers-reduced-motion: reduce) { .chat-typing-dots > * { animation: none; opacity: .6; } }

  /* What a message can carry. Each is drawn the same in a bubble and a flat
     row. Inside, a half-cell rhythm; each block rounds up to whole cells. */
  /* The message this one replies to: who wrote it, and two lines of it, after
     a two-line rule. Clickable: a link or a button to the original. Markup:
     a.chat-quote > span.chat-quote-author.t-xs + span.chat-quote-text.t-xs. */
  .chat-quote {
    --chat-quote-rule: var(--border-strong);
    display: flex; flex-direction: column; gap: var(--sp-h);
    max-width: 100%;
    padding-inline-start: calc(var(--sp-1) - var(--line) * 2);
    border-inline-start: calc(var(--line) * 2) solid var(--chat-quote-rule);
    color: var(--text-secondary); text-decoration: none; text-align: start;
  }
  :is(a, button).chat-quote { cursor: pointer; }
  @media (hover: hover) { :is(a, button).chat-quote:hover { --chat-quote-rule: var(--text-tertiary); color: var(--text); } }
  .chat-quote-author { color: var(--text); font-weight: var(--fw-label); }
  /* Two lines, and the third hidden. The box is held open by its letters'
     reach (padding given back as margin), as it was, so nothing moves; but the
     clip is measured from the top, as .u-clamp's is (D105, D122), not from the
     box, which a role rounds up to whole cells and so showed the top of the
     third line. Where a clamp's box is trimmed (with calc-size, today), the
     clip is two lines from the capitals' top and a descender's depth, no
     nearer the hidden line than its tall letters; where it is not (Safari),
     the text starts at the first line's top and the clip is two whole lines,
     which hold their descenders. */
  .chat-quote-text {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
    overflow: hidden; padding-block: .3em; margin-block: -.3em;
    clip-path: inset(-1em -1em calc(100% - .3em - 2lh) -1em);
  }
  @supports (text-box: trim-both cap alphabetic) and (height: calc-size(fit-content, size)) {
    .chat-quote-text { clip-path: inset(-1em -1em calc(100% - (.3em + 1lh + 1cap + max(0px, min(.24em, .5lh - 1cap + .33em)))) -1em); }
  }
  /* A file: a mark tinted by its kind (--chat-file-tint), its name, its size
     and type. Four cells tall; the same shape as an attachment chip. Markup:
     a.chat-file > span.chat-file-mark > svg.icon, then .pair > .t-sm.u-truncate
     + .t-xs. */
  .chat-file {
    --chat-file-tint: var(--accent);
    display: flex; align-items: center; gap: var(--sp-1);
    width: fit-content; max-width: min(100%, calc(var(--u) * 26));
    padding: var(--sp-h) var(--sp-1h) var(--sp-h) var(--sp-h);
    border-radius: var(--r-1);
    background: var(--bg-raised);
    box-shadow: inset 0 0 0 var(--line) var(--border-subtle);
    color: inherit; text-decoration: none;
  }
  .chat-file > .pair { flex: 1 1 auto; }
  .chat-file .pair > :last-child { color: var(--text-tertiary); }
  .chat-file-mark {
    display: inline-grid; place-items: center; flex: none;
    width: var(--size-control-lg); height: var(--size-control-lg);
    border-radius: var(--r-h);
    background: color-mix(in oklab, var(--chat-file-tint) 18%, transparent);
    color: var(--chat-file-tint);
  }
  /* A link's preview: its site, its title, an optional image, after a rule in
     the accent. Markup: a.chat-link > span.chat-link-site.t-xs +
     span.chat-link-title.t-sm + img.chat-link-media. */
  .chat-link {
    --chat-link-rule: var(--accent);
    display: flex; flex-direction: column; gap: var(--sp-h);
    max-width: min(100%, calc(var(--u) * 32));
    padding-inline-start: calc(var(--sp-1) - var(--line) * 2);
    border-inline-start: calc(var(--line) * 2) solid var(--chat-link-rule);
    color: inherit; text-decoration: none;
  }
  .chat-link-site { color: var(--text-tertiary); }
  @media (hover: hover) { a.chat-link:hover .chat-link-title { text-decoration: underline; text-underline-offset: .2em; } }
  .chat-link-media { display: block; width: 100%; height: calc(var(--u) * 16); margin-block-start: var(--sp-h); object-fit: cover; border-radius: var(--r-1); background: var(--bg-sunken); }
  /* Reactions: chips under the message, an emoji and a count. Yours
     (.cc-mine, or aria-pressed="true" on a toggle) in an accent tint and edge.
     The emoji is drawn in a color emoji face at the large control size, so it
     reads at the size of the count beside it. Markup: .chat-reactions >
     button.chat-reaction > span.chat-reaction-emoji + span. */
  .chat-reactions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-h) var(--sp-q); }
  .chat-reaction {
    --reaction-bg: var(--surface);
    --reaction-edge: var(--border-subtle);
    --reaction-ink: var(--text-secondary);
    --state-ink: var(--reaction-ink); --state-fill: var(--reaction-bg);
    display: inline-flex; align-items: center; gap: var(--sp-q);
    height: var(--size-control-sm);
    padding-inline: calc(var(--sp-h) - var(--line));
    border: var(--line) solid var(--reaction-edge);
    border-radius: var(--r-round);
    background: color-mix(in oklab, var(--state-tone) var(--state-act), var(--reaction-bg));
    color: var(--reaction-ink);
    font-size: var(--fs-control-sm); font-weight: var(--fw-label); font-variant-numeric: tabular-nums;
    line-height: 1;
  }
  button.chat-reaction { cursor: pointer; }
  .chat-reaction:is(.cc-mine, [aria-pressed="true"]) { --reaction-bg: color-mix(in oklab, var(--accent) 16%, var(--surface)); --reaction-edge: color-mix(in oklab, var(--accent) 60%, transparent); --reaction-ink: var(--text); }
  .chat-reaction-emoji { font-family: var(--font-emoji); font-size: var(--fs-control-lg); font-weight: 400; line-height: 1; }

  /* Member tile: a card with a person in it. A column by default; .cc-row puts
     the avatar beside the words. Markup: .card.member-tile > .avatar +
     .member-tile-body + .cluster. */
  .member-tile { --tile-dir: column; --tile-align: flex-start; display: flex; flex-direction: var(--tile-dir); align-items: var(--tile-align); gap: var(--sp-2); }
  .member-tile.cc-row { --tile-dir: row; }
  .member-tile > .cluster { max-width: 100%; }   /* never wider than its tile, so a long tag in it truncates (rule 11) */
  .member-tile-body { --stack-gap: var(--sp-1); display: flex; flex-direction: column; gap: var(--stack-gap); flex: 1 1 auto; min-width: 0; align-self: stretch; }
  .cc-dense .member-tile { gap: var(--sp-1); }

  /* Badge and dot: a count, and the smallest mark of a state. */
  .badge {
    --badge-color: var(--alert);
    --badge-ink: var(--white);
    --badge-h: var(--size-control-xs);
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    --badge-draw: calc(var(--badge-h) + max(0px, round(up, calc(1em - var(--badge-h)), var(--u))));   /* grows by whole cells with its type, as a button does */
    min-width: var(--badge-draw); height: var(--badge-draw);
    padding-inline: var(--sp-q);
    border-radius: var(--r-round);
    background: var(--badge-color);
    color: var(--badge-ink);
    font-size: var(--fs-control-xs); font-weight: var(--fw-strong);
    font-variant-numeric: tabular-nums;
    line-height: 1;
  }
  .badge.cc-quiet { --badge-color: color-mix(in oklab, var(--text) 10%, var(--surface)); --badge-ink: var(--text-secondary); }
  .badge.cc-accent { --badge-color: var(--accent); --badge-ink: var(--accent-ink); }
  /* On its icon button's corner, as the button's child (D115). Its inner corner
     is a quarter cell short of the button's middle and no more than a cell and
     a quarter in, so one figure leaves the icon's middle clear at every size:
     on a button of three cells and up it stands a quarter cell past the
     corner. More figures grow inward. Past the cell's cap a badge grows with
     its type: it grows outward, and the button keeps that many whole cells
     (none, at default sizes) above it and after it, so nothing is covered. */
  .icon-button > .badge.cc-corner {
    --badge-in: min(50% - var(--sp-q), var(--u) * 1.25 - var(--line));
    position: absolute;
    inset-block-end: calc(100% - var(--badge-in));
    inset-inline-end: calc(var(--badge-in) - var(--badge-h) - var(--badge-over, 0px));
    letter-spacing: 0; text-indent: 0; text-transform: none;   /* a count, whatever the button's face */
  }
  .icon-button:has(> .badge.cc-corner) {
    --badge-over: max(0px, round(up, calc(var(--fs-control-xs) - var(--size-control-xs)), var(--u)));
    position: relative;
    margin-block-start: var(--badge-over); margin-inline-end: var(--badge-over);
  }
  .dot {
    --dot-color: var(--alert);
    --dot-size: var(--sp-h);
    display: inline-block; flex: none;
    width: var(--dot-size); height: var(--dot-size);
    border-radius: 50%;
    background: var(--dot-color);
  }
  .dot.cc-ok { --dot-color: var(--ok); }
  .dot.cc-warn { --dot-color: var(--warn); }
  .dot.cc-quiet { --dot-color: var(--text-faint); }
  .dot.cc-accent { --dot-color: var(--accent); }
  /* A ring (.cc-ring): the same mark, not yet filled, for a state before it is
     reached (an idea, a plan) beside the dots of the states after it (D103). Its
     line is a quarter of the dot, never under one line or over two, so a
     half-cell bead draws a finer ring than a one-cell mark; --dot-ring sets it.
     Its inside is clear. On a line (a rail, a rule) --dot-fill: var(--surface)
     keeps the line out of it. A border, so it adds no size and needs no shadow.
     A line is thinner than a fill, so a quiet ring takes the next ink up. */
  .dot.cc-ring {
    --dot-ring: clamp(var(--line), calc(var(--dot-size) / 4), calc(var(--line) * 2));
    --dot-fill: transparent;
    border: var(--dot-ring) solid var(--dot-color);
    background: var(--dot-fill) padding-box;
  }
  .dot.cc-ring.cc-quiet { --dot-color: var(--text-tertiary); }
  /* Stages (.cc-stage-1 to -7, D107): a step of a process, in its product's
     color. A dot is the stage's fill, which may be pale. A ring is a line, so it
     takes the stage's ink, which reads on every ground. */
  .dot.cc-stage-1 { --dot-color: var(--stage-1); }
  .dot.cc-stage-2 { --dot-color: var(--stage-2); }
  .dot.cc-stage-3 { --dot-color: var(--stage-3); }
  .dot.cc-stage-4 { --dot-color: var(--stage-4); }
  .dot.cc-stage-5 { --dot-color: var(--stage-5); }
  .dot.cc-stage-6 { --dot-color: var(--stage-6); }
  .dot.cc-stage-7 { --dot-color: var(--stage-7); }
  .dot.cc-ring.cc-stage-1 { --dot-color: var(--stage-1-ink); }
  .dot.cc-ring.cc-stage-2 { --dot-color: var(--stage-2-ink); }
  .dot.cc-ring.cc-stage-3 { --dot-color: var(--stage-3-ink); }
  .dot.cc-ring.cc-stage-4 { --dot-color: var(--stage-4-ink); }
  .dot.cc-ring.cc-stage-5 { --dot-color: var(--stage-5-ink); }
  .dot.cc-ring.cc-stage-6 { --dot-color: var(--stage-6-ink); }
  .dot.cc-ring.cc-stage-7 { --dot-color: var(--stage-7-ink); }
  /* The same of a color of the product's own (.cc-seed, D117). */
  .dot.cc-seed { --dot-color: var(--seeded); }
  .dot.cc-ring.cc-seed { --dot-color: var(--seeded-ink); }

  /* Skeleton: a surface's real structure, shimmering, while its data is on its
     way. A text slot keeps its role, so its block settles to the same cells and
     nothing moves when the words arrive; it needs placeholder copy. The shimmer
     clips to the content box, so it covers the words and not the settling space.
     Anything that draws itself (a button, an avatar ring, an icon) can't be a
     text slot: use .cc-block in its place, sized in cells. */
  .skeleton {
    --skel-lo: color-mix(in oklab, var(--text) 8%, transparent);
    --skel-hi: color-mix(in oklab, var(--text) 16%, transparent);
    --skel-radius: var(--r-q);
    color: transparent;
    background-image: linear-gradient(90deg, var(--skel-lo), var(--skel-hi), var(--skel-lo));
    background-size: 200% 100%;
    background-clip: content-box;
    border-radius: var(--skel-radius);
    animation: trellis-skeleton var(--dur-skeleton) linear infinite;
    user-select: none;
    pointer-events: none;
  }
  .skeleton * { visibility: hidden; }
  .skeleton.cc-block { display: block; width: var(--skel-w, 100%); height: var(--skel-h, var(--sp-1)); }
  @keyframes trellis-skeleton { to { background-position: -200% 0; } }

  /* Modal and tray: one archetype, on the native <dialog>, opened with
     showModal(). That gives the top layer, the focus trap, Escape and an inert
     page for nothing. Its motion:
     the card fades and scales from .96 in 200ms, the backdrop fades slower at
     250ms, everything leaves in 150ms. A tray (.cc-tray) slides in from a side
     on the spring curve: flush to its edge, its two ends inset by --tray-margin,
     its free side's corners round. On the left by default; .cc-right, .cc-top,
     .cc-bottom. On a narrow screen a centered modal is a bottom tray and a side
     tray stays a drawer. A tray only changes variables. The dialog is the
     full-screen scroller, so a modal taller than the screen scrolls to its top
     (margin: auto, not align-items: center). Markup: dialog.modal > .modal-inner
     > .modal-header + .modal-body + .modal-footer. */
  .modal {
    --modal-w: calc(var(--u) * 40);
    --modal-pad: var(--sp-2);
    --modal-gutter: var(--sp-2);
    --modal-gutter-block: var(--modal-gutter);
    --modal-gutter-inline: var(--modal-gutter);
    --modal-radius: var(--shape-card);
    --modal-r-tl: var(--modal-radius);
    --modal-r-tr: var(--modal-radius);
    --modal-r-br: var(--modal-radius);
    --modal-r-bl: var(--modal-radius);
    --modal-max-h: none;
    --modal-margin: auto;
    --modal-from: scale(.96);
    --modal-from-opacity: 0;
    --modal-in: var(--dur-in);
    --modal-in-ease: var(--ease-out);
    --modal-out: var(--dur-out);
    --modal-out-ease: var(--ease-in);
    --modal-scrim: color-mix(in oklab, var(--black) 60%, transparent);
    --surface: var(--bg-raised);
    position: fixed; inset: 0;
    width: 100%; max-width: none;
    height: 100%; max-height: none;
    margin: 0;
    padding: var(--modal-gutter-block) var(--modal-gutter-inline);
    border: 0;
    overflow-y: auto; overscroll-behavior: contain;
    background: transparent;
    color: var(--text);
    transition: display var(--modal-out) allow-discrete, overlay var(--modal-out) allow-discrete;
  }
  .modal[open] { display: flex; }
  .modal::backdrop {
    background: var(--modal-scrim);
    opacity: 0;
    transition: opacity var(--modal-out) var(--modal-out-ease), display var(--modal-out) allow-discrete, overlay var(--modal-out) allow-discrete;
  }
  .modal[open]::backdrop { opacity: 1; transition: opacity var(--dur-in-slow) var(--ease-out), display var(--modal-out) allow-discrete, overlay var(--modal-out) allow-discrete; }
  .modal-inner {
    position: relative;
    container-type: inline-size;
    display: flex; flex-direction: column;
    width: min(100%, var(--modal-w));
    max-height: var(--modal-max-h);
    margin: var(--modal-margin);
    border-radius: var(--modal-r-tl) var(--modal-r-tr) var(--modal-r-br) var(--modal-r-bl);
    background: var(--surface);
    outline: var(--line) solid var(--border);
    outline-offset: calc(var(--line) * -1);
    box-shadow: var(--lift);
    opacity: var(--modal-from-opacity);
    transform: var(--modal-from);
    transition: opacity var(--modal-out) var(--modal-out-ease), transform var(--modal-out) var(--modal-out-ease);
  }
  /* translate carries what moves an open modal: a detent (--tray-offset, the
     detents preset) and a step back under another (--modal-step). */
  .modal[open] .modal-inner {
    opacity: 1; transform: none;
    translate: 0 calc(var(--tray-offset, 0px) - var(--sp-2) * var(--modal-step, 0));
    transition: opacity var(--modal-in) var(--modal-in-ease), transform var(--modal-in) var(--modal-in-ease), translate var(--dur-tray-in) var(--ease-spring);
  }
  .modal[data-trellis-dragging] .modal-inner { transition: none; }
  /* A tray with detents never scrolls as a whole (its body does), or showing
     what has focus would scroll it back up past its detent. */
  .modal[data-trellis-detents] { overflow: clip; }
  .modal[data-trellis-detents] .modal-inner { height: var(--modal-max-h); }
  @starting-style {
    .modal[open] .modal-inner { opacity: var(--modal-from-opacity); transform: var(--modal-from); }
    .modal[open]::backdrop { opacity: 0; }
  }
  .modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-1); padding: var(--modal-pad); padding-block-end: var(--sp-1); }
  .modal-body { --stack-gap: var(--sp-1); display: flex; flex-direction: column; gap: var(--stack-gap); padding-inline: var(--modal-pad); padding-block: var(--sp-1); min-height: 0; }
  .modal-footer { display: flex; justify-content: flex-end; gap: var(--sp-h); padding: var(--modal-pad); padding-block-start: var(--sp-1); }
  /* A tray changes variables. On the left by default: flush to the screen's
     left edge, the full height less --tray-margin at each end, its right
     corners round. A side tray's body scrolls and its footer stays at the end. */
  .modal.cc-tray, .modal.cc-tray.cc-left {
    --tray-margin: var(--sp-2);
    --tray-w: calc(var(--u) * 32);
    --modal-w: var(--tray-w);
    --modal-gutter-block: var(--tray-margin); --modal-gutter-inline: 0px;
    --modal-margin: 0 auto 0 0;
    --modal-r-tl: 0px; --modal-r-bl: 0px;
    --modal-from: translateX(-100%); --modal-from-opacity: 1;
    --modal-in: var(--dur-tray-in); --modal-in-ease: var(--ease-spring);
    --modal-out: var(--dur-tray-out); --modal-out-ease: var(--ease-spring);
  }
  .modal.cc-tray.cc-right {
    --modal-margin: 0 0 0 auto;
    --modal-r-tl: var(--modal-radius); --modal-r-bl: var(--modal-radius); --modal-r-tr: 0px; --modal-r-br: 0px;
    --modal-from: translateX(100%);
  }
  .modal.cc-tray:is(.cc-top, .cc-bottom) {
    --modal-w: 100%; --modal-max-h: 90svh;
    --modal-gutter-block: 0px; --modal-gutter-inline: var(--tray-margin);
    --modal-r-tl: var(--modal-radius); --modal-r-tr: var(--modal-radius); --modal-r-br: var(--modal-radius); --modal-r-bl: var(--modal-radius);
  }
  .modal.cc-tray.cc-top { --modal-margin: 0 0 auto; --modal-r-tl: 0px; --modal-r-tr: 0px; --modal-from: translateY(-100%); }
  .modal.cc-tray.cc-bottom { --modal-margin: auto 0 0; --modal-r-bl: 0px; --modal-r-br: 0px; --modal-from: translateY(100%); }
  .modal.cc-tray .modal-body { flex: 1 1 auto; overflow-y: auto; }
  /* The grabber: a pill on a bottom tray's top edge, a cell tall, where a drag
     begins (the detents preset). Elsewhere it is not drawn. */
  .modal-grabber { display: none; flex: none; height: var(--sp-1); align-items: center; justify-content: center; }
  .modal-grabber::before { content: ""; width: var(--sp-3); height: var(--sp-q); border-radius: var(--r-round); background: color-mix(in oklab, var(--text) 24%, transparent); }
  .modal:is(.cc-tray.cc-bottom, .cc-sheet) .modal-grabber { display: flex; }
  /* Trays over trays. settle.js numbers the open modals in the order they
     opened (--modal-index) and marks those under the top one
     (data-trellis-depth, 1 and 2); a fourth replaces the third. A modal or a
     bottom tray under another steps up two cells for each level, so it peeks
     above the one in front by whole cells. A side tray stays put. Only the
     top one takes input: the dialog does that. */
  .modal:is(:not(.cc-tray), .cc-tray.cc-bottom)[data-trellis-depth="1"] { --modal-step: 1; }
  .modal:is(:not(.cc-tray), .cc-tray.cc-bottom)[data-trellis-depth="2"] { --modal-step: 2; }

  .modal:is(.cc-tray.cc-bottom, .cc-sheet) .modal-footer { padding-block-end: max(var(--modal-pad), env(safe-area-inset-bottom, 0px)); }
  /* .cc-sheet is the bottom tray as it was, edge to edge: an alias for one minor.
     Use .cc-tray.cc-bottom. */
  .modal.cc-sheet {
    --modal-w: 100%; --modal-gutter: 0px; --modal-margin: auto 0 0; --modal-max-h: 90svh;
    --modal-r-bl: 0px; --modal-r-br: 0px;
    --modal-from: translateY(100%); --modal-from-opacity: 1;
    --modal-in: var(--dur-tray-in); --modal-in-ease: var(--ease-spring);
    --modal-out: var(--dur-tray-out); --modal-out-ease: var(--ease-spring);
  }
  .modal.cc-sheet .modal-body { overflow-y: auto; }
  /* A modal is measured against the screen it covers, so this asks the window.
     A centered modal becomes a bottom tray; a side tray stays a drawer and
     leaves a strip of the page to tap. */
  @media (width < 48rem) {
    .modal:not(.cc-tray, .cc-sheet) {
      --modal-w: 100%; --modal-max-h: 90svh;
      --modal-gutter-block: 0px; --modal-gutter-inline: var(--sp-2);
      --modal-margin: auto 0 0;
      --modal-r-bl: 0px; --modal-r-br: 0px;
      --modal-from: translateY(100%); --modal-from-opacity: 1;
      --modal-in: var(--dur-tray-in); --modal-in-ease: var(--ease-spring);
      --modal-out: var(--dur-tray-out); --modal-out-ease: var(--ease-spring);
    }
    .modal:not(.cc-tray, .cc-sheet) .modal-body { overflow-y: auto; }
    .modal:not(.cc-tray, .cc-sheet) .modal-grabber { display: flex; }
    .modal:not(.cc-tray, .cc-sheet) .modal-footer { padding-block-end: max(var(--modal-pad), env(safe-area-inset-bottom, 0px)); }
    .modal.cc-tray:not(.cc-top, .cc-bottom) { --modal-w: min(calc(100% - var(--sp-4)), var(--tray-w)); }
  }
  /* The page behind holds still, for any number of open modals, with no counting.
     On <html> only: locking <body> too would make it a scroller and every sticky
     nav would stick to it. The gutter stops the page jumping as its scrollbar goes. */
  html:has(.modal[open]) { overflow: hidden; scrollbar-gutter: stable; }

  /* States ----------------------------------------------------------------
     Every control uses the same state rules. Hover, press and selected mix a
     share of the control's own ink into its own fill (--state-hover, -press,
     -selected), which works on a light fill, a solid one or none.
     Each primitive paints color-mix(its ink calc(--state-on + --state-act),
     its fill). Hover only where a pointer can hover, so a tap never leaves it
     stuck. Selected keeps a mark of its own as well (a border, an edge, a
     check, a solid tag, a tab's line), so it doesn't look merely hovered.
     Disabled drops hover and press. Focus uses one shared ring everywhere.
     A control of your own takes the same layer with .u-state: set
     --state-fill and --state-ink on it, and every state follows.
     Which way the share goes follows the ink (D120). Each control names its
     label's ink and its fill (--state-ink, --state-fill), and what it mixes in
     is --state-tone: the ink, unless the fill is opaque and near the flip,
     between .4 and .75 of lightness, where the label has least to spare. There
     the tone moves away from the label: black under a white label (a primary,
     destructive or confirm button, a solid tag), white under a dark one. So
     the label gains contrast as the state deepens, in both themes. A fill far
     from the flip (a white surface, a night's raised ground) and a tint or no
     fill keep the ink: their label has room, and white over white would show
     nothing. Picked with one color each step: the fill gives black or white,
     at full alpha where it is in the band and none elsewhere, and mixing that
     99.99% into the ink keeps whichever is there; the alpha is then restored.
     At rest the tone is the ink itself, so nothing at rest is drawn otherwise. */
  :is(.button, .tag, .tab, .chat-reaction, .u-state) { --state-tone: var(--state-ink, currentColor); }
  @supports (color: oklch(from red l c h)) {
    :is(.button, .tag, .tab, .chat-reaction, .u-state):is(:hover, :active, [aria-pressed="true"], [aria-checked="true"], [aria-current]:not([aria-current="false"]), [aria-selected="true"]) {
      --state-tone: oklab(from color-mix(in oklab,
          oklch(from var(--state-fill, transparent) clamp(0, (l - var(--ink-flip)) * 1000, 1) 0 0 / calc(clamp(0, (alpha - .999) * 100000, 1) * clamp(0, (l - .4) * 1000, 1) * clamp(0, (.75 - l) * 1000, 1))) 99.99%,
          var(--state-ink, currentColor)) l a b / calc(alpha * 10000));
    }
  }
  @media (hover: hover) {
    :is(.button, .icon-button, .tag:is(button, a), .tag-remove, .tab, .shell-link, .outline-link, .list-item:is(a, button), .options-card-item, .u-state, .switch, .prose summary, button.chat-reaction):hover { --state-act: var(--state-hover); }
  }
  :is(.button, .icon-button, .tag:is(button, a), .tag-remove, .tab, .shell-link, .outline-link, .list-item:is(a, button), .options-card-item, .u-state, .switch, .prose summary, button.chat-reaction):active { --state-act: var(--state-press); }
  :is(.button, .icon-button, .tag:is(button, a), .tag-remove, .tab, .shell-link, .outline-link, .list-item:is(a, button), .options-card-item, .u-state):is([aria-pressed="true"], [aria-checked="true"], [aria-current]:not([aria-current="false"]), [aria-selected="true"]) { --state-on: var(--state-selected); }
  /* A row that holds a switch shows its state on the switch alone. */
  .options-card-item:has(> .switch):is([aria-pressed="true"], [aria-checked="true"], [aria-current]:not([aria-current="false"]), [aria-selected="true"]) { --state-on: 0%; }
  :is(.button, .icon-button, .tag:is(button, a), .tag-remove, .tab, .shell-link, .list-item:is(a, button), .options-card-item, .u-state, .switch):is(:disabled, [aria-disabled="true"]) { --state-act: 0%; cursor: not-allowed; }
}

/* --------------------------------------------------------------------------
   UTILITIES: a small fixed set, each a token
   -------------------------------------------------------------------------- */
@layer trellis.utilities {
  .u-text-secondary { color: var(--text-secondary); }
  .u-text-tertiary { color: var(--text-tertiary); }
  /* Truncation clips sideways only: a trimmed text box ends at the baseline,
     so overflow: hidden would cut off every descender. */
  .u-truncate { overflow-x: clip; overflow-y: visible; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  /* A clamp (.u-clamp): --lines lines, two by default, and an ellipsis (D105). It
     has to clip, and a trimmed box ends at its last baseline, so a plain clamp
     cuts the tail off every g, p and y; and a role rounds its box up to whole
     cells, which lets the top of the next, hidden line show under the last.
     So the clip is measured from the top: the lines, and --clamp-reach under
     the last baseline, a descender's depth, never as far as the tall letters of
     the next line. It is drawn, not laid out: the box is the role's own, on the
     same cells as text that is not clamped. On a type role; one line is
     .u-truncate.
     How near the next line comes depends on who trims. A browser that trims a
     clamp's box moves the hidden lines up by what it trimmed, to about half a
     line less a capital, plus a third of an em, under the baseline. A
     browser that leaves the box untrimmed (Safari today) gets the plain clamp,
     whole and a few pixels off its line, until settle.js measures the trim: it
     marks the clamp (data-trellis-clamp), pulls the text up by --clamp-top and
     holds the box at --clamp-h, whole cells for a role; there the next line
     keeps its distance, a line less a capital. */
  .u-clamp {
    --lines: 2;
    --clamp-reach: .24em;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--lines);
    overflow: hidden; min-width: 0;
  }
  @supports (text-box: trim-both cap alphabetic) {
    .u-clamp { text-box: trim-both cap alphabetic; }
    .u-clamp[data-trellis-clamp] {
      overflow: visible;
      clip-path: inset(-1em -1em calc(100% - (var(--t-stand, 0px) + (var(--lines) - 1) * 1lh + 1cap + max(0px, min(var(--clamp-reach), 1lh - 1cap - .05em)))) -1em);
      height: var(--clamp-h, auto); min-height: 0;
    }
    .u-clamp[data-trellis-clamp]::before { content: ""; display: block; margin-block-start: calc(var(--clamp-top, 0px) * -1); }
  }
  @supports (text-box: trim-both cap alphabetic) and (height: calc-size(fit-content, size)) {
    .u-clamp:not([data-trellis-clamp]) {
      overflow: visible;
      clip-path: inset(-1em -1em calc(100% - (var(--t-stand, 0px) + (var(--lines) - 1) * 1lh + 1cap + max(0px, min(var(--clamp-reach), .5lh - 1cap + .33em)))) -1em);
    }
  }
  .u-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .u-align-end { align-items: end; }
  /* The state layer for a control of your own (see States, in the primitives). */
  .u-state {
    cursor: pointer;
    background-color: color-mix(in oklab, var(--state-tone) calc(var(--state-on) + var(--state-act)), var(--state-fill, transparent));
    transition: background-color var(--dur-out) var(--ease-in);
  }
  /* Half and quarter gaps are for clusters only. Between stacked blocks, space
     is whole cells (rule 6), so these don't reach a stack. */
  .u-gap-q  { --cluster-gap: var(--sp-q); }
  /* .settle: any block (a code sample, a figure) rounds its height up to whole
     cells, so what follows starts on a line. Defined with the type rules.
     Without calc-size, settle.js gives clusters and .settle blocks the missing
     space as end margin: important, because their own padding is theirs. */
  @supports not (height: calc-size(fit-content, size)) {
    .cluster, .settle, .field, .pair, .chat-item-meta, .chat-quote, .chat-link, .chat-reactions, :where(.prose :is(pre, table, figure, details, dl, video, audio), .prose > :not(h1, h2, h3, h4, h5, h6, p, ul, ol, hr, blockquote, iframe, div:not([class]))) { margin-block-end: var(--settle, 0px) !important; }
    /* A cluster at a surface's end takes it above its row, inside its box (D92). */
    :is(.card, .modal-body, .member-tile) > .cluster:last-child { margin-block-end: 0 !important; padding-block-start: var(--settle, 0px) !important; }
  }
  .u-gap-h  { --cluster-gap: var(--sp-h); }
  .u-gap-1  { --stack-gap: var(--sp-1);  --cluster-gap: var(--sp-1); }
  .u-gap-2  { --stack-gap: var(--sp-2);  --cluster-gap: var(--sp-2); }
  .u-gap-4  { --stack-gap: var(--sp-4);  --cluster-gap: var(--sp-4); }
  .cc-scroll-thick { --scrollbar-width: auto; --scrollbar-size: var(--sp-1); }
  .cc-scroll-none  { --scrollbar-width: none; --scrollbar-size: 0px; }
}

/* Forced colors (C5). The system replaces every color and removes every
   shadow, so whatever carried meaning with a shadow or a fill alone is drawn
   again here in system colors: current and selected marks (Highlight), the
   switch, dots, a badge's pill and an avatar's ring (CanvasText). Card edges,
   focus rings and bordered controls survive on their own. */
@layer trellis.utilities {
  @media (forced-colors: active) {
    :is(.shell-link, .outline-link, .list-item, .tab, .options-card-item):is([aria-current]:not([aria-current="false"]), [aria-selected="true"]),
    .tab[aria-checked="true"],
    .list-item:has(.list-link:is([aria-current]:not([aria-current="false"]), [aria-selected="true"])) {
      outline: calc(var(--line) * 2) solid Highlight; outline-offset: calc(var(--line) * -2);
    }
    .tab:is([aria-selected="true"], [aria-checked="true"], [aria-current]:not([aria-current="false"]))::after { forced-color-adjust: none; background: Highlight; }
    .switch::after { forced-color-adjust: none; outline: var(--line) solid CanvasText; outline-offset: calc(var(--line) * -1); --switch-fill: Canvas; --switch-thumb: CanvasText; }
    :is(.switch:is([aria-checked="true"], :has(> input:checked)), .options-card-item[aria-checked="true"] > .switch)::after { --switch-fill: Highlight; --switch-thumb: HighlightText; outline-color: Highlight; }
    .switch:is(:disabled, [aria-disabled="true"], :has(> input:disabled))::after { --switch-thumb: GrayText; outline-color: GrayText; }
    .dot { forced-color-adjust: none; background: CanvasText; }
    .dot.cc-ring { border-color: CanvasText; background: Canvas; }
    .badge { outline: var(--line) solid CanvasText; outline-offset: calc(var(--line) * -1); }
    .badge.cc-corner { background: Canvas; }   /* its button's edge passes under it */
    /* A translucent bar is opaque here: the words on it are the system's (D115). */
    .shell-nav { background: Canvas; backdrop-filter: none; }
    .avatar { outline: var(--av-ring) solid CanvasText; outline-offset: var(--av-gap); }
    /* The conversation's parts drawn with a fill or a shadow alone (D122): a
       divider's rules (the unread line's in Highlight), the typing dots, a file's edge. */
    .chat-divider::before, .chat-divider::after, .chat-typing-dots > * { forced-color-adjust: none; background: CanvasText; }
    .chat-divider.cc-new::before, .chat-divider.cc-new::after { background: Highlight; }
    .chat-file { outline: var(--line) solid CanvasText; outline-offset: calc(var(--line) * -1); }
    /* A nested surface has no edge of its own (D88), and here its ground is gone too. */
    :is(.card, .list.cc-group, .modal-inner, .float) .card { --card-border: CanvasText; }
  }
}

@layer trellis.tokens {
  @media (prefers-reduced-motion: reduce) {
    :root { --dur-out: 1ms; --dur-in: 1ms; --dur-in-slow: 1ms; --dur-tray-in: 1ms; --dur-tray-out: 1ms; --dur-skeleton: 0s; }
  }
}
