/* _engines/ui/ui.css — the one design system of the umbrella (Materia, Cellverse, the home, whatever joins later).
 * A separable library: names no product. A page links this file, puts class="ui" on <body>, picks an accent with
 * data-ui-accent on <html> or <body> (gold, beryl, ink — or sets --ui-accent itself) and uses the ui-* classes.
 * Usage and the component list: README.md next to this file. ui.js adds the few behaviours (top bar, toast, progress,
 * sheet drag, remembered Advanced).
 *
 * The idea: the instrument's bezel around a live specimen. The specimen (a molecule, a crystal) owns the colour; the
 * chrome is slate glass, warm paper ink, one accent per product, and numbers that always say where they come from.
 * Rules the components keep:
 *   - every control is at least 44 px tall (a thumb); only a fine pointer on a wide screen gets the 36 px compact size;
 *   - no text under 13 px; labels are sentence case, never tracked capitals;
 *   - a number shows its provenance (measured / computed / approximate / predicted) and its uncertainty, or says
 *     "unknown" plainly — the hatched badge — never a made-up value;
 *   - motion answers an action (open, close, confirm) and stops under prefers-reduced-motion.
 * Sections: 1 font + tokens, 2 accents, 3 base, 4 surfaces, 5 buttons + chips + toggle, 6 field + search, 7 tabs,
 * 8 badges + numbers, 9 top bar + product menu, 10 sheet, 11 Advanced, 12 toast, 13 progress, 14 lists + facts,
 * 15 responsive + motion. */

/* ---------- 1. font + tokens ---------- */
@font-face {
  font-family: "Bricolage";
  src: url("../fonts/BricolageGrotesque-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
}

:root {
  /* colour: slate glass, paper ink */
  --ui-bg: #10141b;              /* the field behind everything: blue slate, not black */
  --ui-bg-deep: #090c11;         /* wells, the bottom of gradients */
  --ui-surface: rgba(18, 23, 31, 0.74);        /* glass over a scene */
  --ui-surface-solid: #161b24;                 /* the same, where nothing shows through */
  --ui-surface-strong: rgba(17, 21, 29, 0.92); /* sheets: legible over any scene */
  --ui-raise: rgba(255, 255, 255, 0.06);       /* a control on glass */
  --ui-raise-hover: rgba(255, 255, 255, 0.11);
  --ui-line: rgba(255, 255, 255, 0.09);        /* inner light, hairlines */
  --ui-line-strong: rgba(255, 255, 255, 0.17);
  --ui-ink: #edebe5;                           /* warm paper */
  --ui-ink-dim: rgba(237, 235, 229, 0.72);
  --ui-ink-faint: rgba(237, 235, 229, 0.54);   /* still ≥ 4.5:1 on --ui-bg */
  --ui-scrim: rgba(9, 12, 17, 0.62);

  /* provenance and state: the four origins of a number, plus the plain signals */
  --ui-measured: #5ccb94;
  --ui-computed: #74a9ff;
  --ui-approx: #e7b24c;
  --ui-predicted: #b490ff;
  --ui-good: #5ccb94;
  --ui-warn: #e7b24c;
  --ui-bad: #ff6f6f;

  /* type: one family, Bricolage Grotesque (vendored, OFL) — a scale on a 1.2 ratio from 15 px, never under 13 */
  --ui-font: "Bricolage", "Avenir Next", "Helvetica Neue", system-ui, sans-serif;
  --ui-t-meta: 13px;     /* hints, units, captions */
  --ui-t-small: 14px;    /* secondary text, chips */
  --ui-t-body: 15px;
  --ui-t-lead: 17px;     /* buttons on a phone, list titles */
  --ui-t-h3: 20px;
  --ui-t-h2: 26px;
  --ui-t-h1: clamp(30px, 6.4vw, 48px);
  --ui-t-display: clamp(40px, 7.4vw, 76px);
  --ui-lh: 1.45;
  --ui-lh-tight: 1.08;
  --ui-track-display: -0.035em;
  --ui-stretch-display: 88%;

  /* space: a 4 px grid */
  --ui-s1: 4px; --ui-s2: 8px; --ui-s3: 12px; --ui-s4: 16px; --ui-s5: 20px; --ui-s6: 24px; --ui-s7: 32px; --ui-s8: 48px;
  --ui-pad: 16px;                      /* page edge on a phone; wider screens raise it */
  --ui-touch: 44px;                    /* the smallest thing a finger has to hit */
  --ui-control: 44px;                  /* a button's height (36 px with a fine pointer on a wide screen) */
  --ui-topbar-h: 60px;

  /* radius: by rank, not one value everywhere */
  --ui-r-badge: 6px;                   /* badges, inline marks */
  --ui-r-tile: 12px;                   /* tiles, list rows, fields inside a card */
  --ui-r-card: 18px;                   /* cards, menus */
  --ui-r-sheet: 24px;                  /* sheets */
  --ui-r-pill: 999px;                  /* buttons, chips, the top bar groups */

  /* depth */
  --ui-blur: blur(22px) saturate(1.5);
  --ui-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.78);
  --ui-shadow-sheet: 0 -18px 50px -20px rgba(0, 0, 0, 0.8);
  --ui-inner: inset 0 1px 0 var(--ui-line);

  /* motion */
  --ui-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ui-fast: 140ms;
  --ui-mid: 240ms;
  --ui-slow: 380ms;

  --ui-safe-t: env(safe-area-inset-top, 0px);
  --ui-safe-b: env(safe-area-inset-bottom, 0px);

  /* the accent: one per product (section 2); ink by default, for the umbrella itself */
  --ui-accent: #edebe5;
  --ui-accent-ink: #10141b;
  --ui-accent-soft: rgba(237, 235, 229, 0.14);
  --ui-accent-glow: rgba(237, 235, 229, 0.4);
}

/* ---------- 2. accents: chosen by colour, not by product name ---------- */
[data-ui-accent="gold"] {   /* warm: ligands, the lit side of a molecule */
  --ui-accent: #f2c46b; --ui-accent-ink: #1d1406; --ui-accent-soft: rgba(242, 196, 107, 0.16); --ui-accent-glow: rgba(242, 196, 107, 0.5);
}
[data-ui-accent="beryl"] {  /* cool mineral light */
  --ui-accent: #7fe3d6; --ui-accent-ink: #052420; --ui-accent-soft: rgba(127, 227, 214, 0.15); --ui-accent-glow: rgba(127, 227, 214, 0.45);
}
[data-ui-accent="ink"] {
  --ui-accent: #edebe5; --ui-accent-ink: #10141b; --ui-accent-soft: rgba(237, 235, 229, 0.14); --ui-accent-glow: rgba(237, 235, 229, 0.4);
}

/* ---------- 3. base (zero specificity: a product's own rules always win) ---------- */
:where(.ui) { margin: 0; background: var(--ui-bg); color: var(--ui-ink); font: 400 var(--ui-t-body)/var(--ui-lh) var(--ui-font);
  font-stretch: 100%; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; font-feature-settings: "ss01", "kern"; -webkit-text-size-adjust: 100%; }
:where(.ui) *, :where(.ui) *::before, :where(.ui) *::after { box-sizing: border-box; }
:where(.ui) :where(button, input, select, textarea) { font: inherit; color: inherit; font-stretch: inherit; }
:where(.ui) :where(button) { -webkit-tap-highlight-color: transparent; }
:where(.ui) :where(a) { color: inherit; }
:where(.ui) [hidden] { display: none !important; }
:where(.ui) :focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.ui-num, .ui-tabular { font-variant-numeric: tabular-nums; }
.ui-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 4. surfaces ---------- */
.ui-glass { background: var(--ui-surface); backdrop-filter: var(--ui-blur); -webkit-backdrop-filter: var(--ui-blur); box-shadow: var(--ui-inner), var(--ui-shadow); }
.ui-card { background: var(--ui-surface-solid); border-radius: var(--ui-r-card); box-shadow: var(--ui-inner); }

/* ---------- 5. buttons, chips, toggle ---------- */
.ui-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--ui-s2); min-height: var(--ui-control); min-width: var(--ui-touch);
  padding: 0 18px; border: 0; border-radius: var(--ui-r-pill); background: var(--ui-raise); color: var(--ui-ink); box-shadow: var(--ui-inner);
  font-size: var(--ui-t-body); font-weight: 560; line-height: 1.1; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background var(--ui-fast), color var(--ui-fast), transform var(--ui-fast) var(--ui-ease); }
.ui-btn:hover { background: var(--ui-raise-hover); }
.ui-btn:active { transform: scale(0.97); }
.ui-btn:disabled, .ui-btn[aria-disabled="true"] { opacity: 0.42; cursor: default; transform: none; }
.ui-btn svg { width: 18px; height: 18px; flex: none; }
.ui-btn--primary, .ui-btn.is-on, .ui-btn.on, .ui-btn[aria-pressed="true"] { background: var(--ui-accent); color: var(--ui-accent-ink); font-weight: 640; box-shadow: none; }
.ui-btn--primary:hover, .ui-btn.is-on:hover, .ui-btn.on:hover, .ui-btn[aria-pressed="true"]:hover { background: color-mix(in srgb, var(--ui-accent) 86%, white); }
.ui-btn--quiet { background: transparent; box-shadow: none; color: var(--ui-ink-dim); }
.ui-btn--quiet:hover { color: var(--ui-ink); background: var(--ui-raise); }
.ui-btn--icon { width: var(--ui-touch); padding: 0; }
.ui-btn--block { display: flex; width: 100%; }
.ui-x { display: inline-grid; place-items: center; width: var(--ui-touch); height: var(--ui-touch); padding: 0; border: 0; border-radius: 50%; flex: none;
  background: var(--ui-raise); color: var(--ui-ink-dim); font-size: 22px; line-height: 1; cursor: pointer; transition: background var(--ui-fast), color var(--ui-fast); }
.ui-x:hover { background: var(--ui-raise-hover); color: var(--ui-ink); }

/* a chip: a choice among several (filters, examples, colourings); same touch height, lighter weight */
.ui-chip { display: inline-flex; align-items: center; gap: var(--ui-s2); min-height: var(--ui-control); padding: 0 15px; border: 0; border-radius: var(--ui-r-pill);
  background: transparent; color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-line-strong); font-size: var(--ui-t-small); font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background var(--ui-fast), box-shadow var(--ui-fast); }
.ui-chip:hover { background: var(--ui-raise); }
.ui-chip.is-on, .ui-chip.on, .ui-chip[aria-pressed="true"], .ui-chip[aria-checked="true"] { background: var(--ui-accent-soft); box-shadow: inset 0 0 0 1.5px var(--ui-accent); color: var(--ui-ink); }
.ui-row { display: flex; flex-wrap: wrap; gap: var(--ui-s2); align-items: center; }

/* a toggle: the native checkbox, drawn the same everywhere; the label is the 44 px target */
.ui-toggle { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-s3); min-height: var(--ui-touch); cursor: pointer; font-size: var(--ui-t-body); }
.ui-toggle input { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 46px; height: 28px; margin: 0; border-radius: 14px;
  background: var(--ui-raise-hover); box-shadow: var(--ui-inner); cursor: pointer; transition: background var(--ui-mid); }
.ui-toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ui-ink); transition: transform var(--ui-mid) var(--ui-ease); }
.ui-toggle input:checked { background: var(--ui-accent); }
.ui-toggle input:checked::after { transform: translateX(18px); background: var(--ui-accent-ink); }

/* ---------- 6. field + search ---------- */
.ui-field { display: block; width: 100%; height: 48px; padding: 0 16px; border: 0; border-radius: var(--ui-r-tile); background: var(--ui-raise); color: var(--ui-ink);
  box-shadow: inset 0 0 0 1px var(--ui-line); font-size: 16px; outline: none; transition: box-shadow var(--ui-fast); }   /* 16 px: iOS does not zoom */
.ui-field::placeholder { color: var(--ui-ink-faint); }
.ui-field:focus-visible, .ui-field:focus { box-shadow: inset 0 0 0 1.5px var(--ui-accent); outline: none; }
textarea.ui-field { height: auto; min-height: 72px; padding: 12px 16px; resize: vertical; line-height: 1.4; }
.ui-search { position: relative; display: block; }
.ui-search::before { content: ""; position: absolute; left: 17px; top: 50%; width: 13px; height: 13px; margin-top: -9px; border: 2px solid var(--ui-ink-faint); border-radius: 50%; pointer-events: none; }
.ui-search::after { content: ""; position: absolute; left: 30px; top: 50%; width: 7px; height: 2px; margin-top: 4px; background: var(--ui-ink-faint); transform: rotate(45deg); border-radius: 1px; pointer-events: none; }
.ui-search input { display: block; width: 100%; height: 52px; padding: 0 18px 0 48px; border: 0; border-radius: var(--ui-r-pill); background: var(--ui-raise); color: var(--ui-ink);
  box-shadow: inset 0 0 0 1px var(--ui-line-strong); font-size: 16px; outline: none; -webkit-appearance: none; appearance: none; transition: box-shadow var(--ui-fast), background var(--ui-fast); }
.ui-search input::placeholder { color: var(--ui-ink-faint); }
.ui-search input:focus { box-shadow: inset 0 0 0 1.5px var(--ui-accent); background: var(--ui-raise-hover); }
.ui-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------- 7. tabs: a segmented row; [role=tab][aria-selected] or .is-on ---------- */
.ui-tabs { display: flex; gap: 2px; padding: 3px; border-radius: var(--ui-r-pill); background: var(--ui-raise); box-shadow: var(--ui-inner); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.ui-tabs::-webkit-scrollbar { display: none; }
.ui-tabs > * { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: calc(var(--ui-control) - 6px); min-width: var(--ui-touch); padding: 0 14px;
  border: 0; border-radius: var(--ui-r-pill); background: transparent; color: var(--ui-ink-dim); font-size: var(--ui-t-small); font-weight: 560; white-space: nowrap; cursor: pointer;
  transition: background var(--ui-fast), color var(--ui-fast); }
.ui-tabs > *:hover { color: var(--ui-ink); }
.ui-tabs > [aria-selected="true"], .ui-tabs > .is-on, .ui-tabs > .on { background: var(--ui-ink); color: var(--ui-bg); }

/* ---------- 8. badges and numbers ---------- */
/* provenance letter: M measured, C computed, A approximate, P predicted; ? unknown. The title says it in words. */
.ui-badge { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 5px; border-radius: var(--ui-r-badge);
  font-size: 13px; font-weight: 700; line-height: 1; letter-spacing: 0; font-variant-numeric: tabular-nums; vertical-align: 0.08em;
  color: var(--ui-ink); background: var(--ui-raise-hover); cursor: help; }
.ui-badge--measured, .ui-badge.b-M { color: #062015; background: var(--ui-measured); }
.ui-badge--computed, .ui-badge.b-C { color: #06142e; background: var(--ui-computed); }
.ui-badge--approx, .ui-badge.b-A { color: #2a1a02; background: var(--ui-approx); }
.ui-badge--predicted, .ui-badge.b-P { color: #1a0b33; background: var(--ui-predicted); }
/* unknown: hatched, never a colour that could pass for a value */
.ui-badge--unknown, .ui-unknown { color: var(--ui-ink-dim); background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0 3px, transparent 3px 7px); box-shadow: inset 0 0 0 1px var(--ui-line-strong); }
.ui-unknown { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: var(--ui-r-badge); font-size: var(--ui-t-meta); font-weight: 600; font-style: normal; }
/* a value: 7.85 ± 0.02 g/cm³ [M] — the number reads first, the uncertainty and the unit step back */
.ui-value { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; font-variant-numeric: tabular-nums; }
.ui-value > b { font-size: var(--ui-t-lead); font-weight: 650; letter-spacing: -0.01em; }
.ui-value > .ui-unc { font-size: var(--ui-t-meta); color: var(--ui-ink-dim); }
.ui-value > .ui-unit { font-size: var(--ui-t-meta); color: var(--ui-ink-faint); }
.ui-value > .ui-badge { align-self: center; }
/* a count: how many in a list or a tab */
.ui-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--ui-r-pill); background: var(--ui-raise-hover); color: var(--ui-ink-dim); font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* the reliability badge in words (measured, calculated, estimated, unknown), the letter in Advanced: badgeHTML() of
   lab-number.js, moved here from Materia's style.css so every lab draws the same one */
/* opaque tints (the old 12-14 % alpha over white): over a dark scene the translucent ones fell to 1.0-2.1:1. Text on its own
   tint ≥ 6.3:1 whatever lies behind (M 6.40, C 6.35, S 6.47, D 6.93, I 8.67; WCAG 2 relative luminance) */
.badge.word { font-style: normal; display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: 0.01em; line-height: 1.5; vertical-align: 1px; cursor: help; text-shadow: none; background: #e2efed; color: #0a5f55; white-space: nowrap; }
.badge.word .l, body.advanced .badge.word .w { display: none; }
body.advanced .badge.word .l { display: inline; }
.badge.word[data-b="C"] { background: #e4eaf5; color: #1d4fa8; }
.badge.word[data-b="S"] { background: #f6ebdb; color: #7a4800; }
.badge.word[data-b="D"] { background: #ebe6f6; color: #5b2fb0; }
.badge.word[data-b="I"] { background: #ecedee; color: #3d4246; }
/* <lab-number> (lab-number.js): the number is a quiet button; its dialog is fixed to the viewport, so a scrolling sheet never clips it */
lab-number { display: inline; font-variant-numeric: tabular-nums; }
lab-number .ln-btn { display: inline; pointer-events: auto; padding: 0 2px; margin: 0 -2px; border: 0; border-radius: 6px; background: none; color: inherit; font: inherit; text-align: inherit; cursor: pointer;
  text-decoration: underline dotted var(--ui-line-strong); text-underline-offset: 4px; text-decoration-thickness: 1px; }
lab-number .ln-btn:hover, lab-number.is-open .ln-btn { background: var(--ui-raise); text-decoration-color: var(--ui-ink-faint); }
lab-number .ln-btn:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
lab-number .ln-btn .x { margin-left: 3px; color: var(--ui-ink-dim); }
lab-number .ln-nounc { margin-left: 4px; padding: 0 4px; border-radius: 5px; font-size: 12px; font-weight: 600; color: var(--ui-ink-dim); box-shadow: inset 0 0 0 1px var(--ui-line-strong); }
lab-number .ln-pop { position: fixed; z-index: 60; box-sizing: border-box; padding: 12px 14px 12px; border-radius: 14px; background: var(--ui-surface-solid); color: var(--ui-ink);
  box-shadow: var(--ui-shadow), inset 0 0 0 1px var(--ui-line-strong); font-size: 14px; line-height: 1.4; text-align: left; white-space: normal; text-shadow: none; pointer-events: auto; cursor: auto; }
lab-number .ln-pop[hidden] { display: none; }
lab-number .ln-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; font-size: 14px; }
lab-number .ln-big { margin: 2px 0 8px; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
lab-number .ln-pop dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0 0 10px; font-size: 13px; }
lab-number .ln-pop dt { color: var(--ui-ink-dim); }
lab-number .ln-pop dd { margin: 0; overflow-wrap: anywhere; }
lab-number .ln-act { display: flex; gap: 8px; flex-wrap: wrap; }
lab-number .ln-act button { flex: 1 1 auto; min-height: var(--ui-control, 44px); padding: 0 12px; border: 0; border-radius: 10px; background: var(--ui-raise); color: var(--ui-ink); font: 600 13.5px/1 var(--ui-font); cursor: pointer; }
lab-number .ln-act button:hover { background: var(--ui-raise-hover); }
lab-number .ln-act button:first-child { background: var(--ui-accent); color: var(--ui-accent-ink); }
lab-number .ln-said { margin: 6px 0 0; min-height: 0; font-size: 13px; color: var(--ui-ink-dim); }
lab-number .ln-said:empty { display: none; }
lab-number textarea { width: 100%; margin-top: 6px; font: 12px/1.35 ui-monospace, Menlo, monospace; color: var(--ui-ink); background: var(--ui-raise); border: 0; border-radius: 8px; padding: 6px; }

/* ---------- 9. top bar + the umbrella's product menu ---------- */
.ui-topbar { position: fixed; z-index: 20; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: var(--ui-s2);
  height: calc(var(--ui-topbar-h) + var(--ui-safe-t)); padding: var(--ui-safe-t) var(--ui-pad) 0; pointer-events: none; }
.ui-topbar > * { pointer-events: auto; }
.ui-topbar--solid { position: sticky; background: linear-gradient(var(--ui-bg) 70%, transparent); }
.ui-topbar__end { display: flex; align-items: center; gap: var(--ui-s2); min-width: 0; }
.ui-topbar__end .ui-btn { min-height: var(--ui-touch); }
/* the product menu: the mark of the umbrella, then the product you are in; a tap lists the others */
.ui-products { position: relative; min-width: 0; }
.ui-products__btn { display: inline-flex; align-items: center; gap: 10px; height: var(--ui-touch); max-width: 100%; padding: 0 14px 0 6px; border: 0; border-radius: var(--ui-r-pill);
  background: var(--ui-surface); backdrop-filter: var(--ui-blur); -webkit-backdrop-filter: var(--ui-blur); box-shadow: var(--ui-inner); color: var(--ui-ink); cursor: pointer; white-space: nowrap; }
.ui-products__btn:hover { background: var(--ui-surface-strong); }
.ui-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--ui-bg-deep); box-shadow: inset 0 0 0 1px var(--ui-line-strong); }
.ui-mark svg { width: 20px; height: 20px; }
.ui-products__name { font-size: var(--ui-t-lead); font-weight: 680; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; }
.ui-products__btn::after { content: ""; width: 7px; height: 7px; margin: -4px 0 0 2px; border-right: 1.8px solid var(--ui-ink-faint); border-bottom: 1.8px solid var(--ui-ink-faint); transform: rotate(45deg); flex: none; transition: transform var(--ui-mid) var(--ui-ease); }
.ui-products.is-open .ui-products__btn::after { transform: translateY(4px) rotate(-135deg); }
.ui-products__menu { position: absolute; top: calc(100% + 8px); left: 0; width: min(340px, calc(100vw - 2 * var(--ui-pad))); padding: 8px; border-radius: var(--ui-r-card);
  background: var(--ui-surface-strong); backdrop-filter: var(--ui-blur); -webkit-backdrop-filter: var(--ui-blur); box-shadow: var(--ui-inner), var(--ui-shadow);
  opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity var(--ui-mid) var(--ui-ease), transform var(--ui-mid) var(--ui-ease); }
.ui-products.is-open .ui-products__menu { opacity: 1; transform: none; pointer-events: auto; }
.ui-products__menu a { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 2px 12px; align-items: baseline; min-height: 56px; padding: 10px 12px; border-radius: var(--ui-r-tile); text-decoration: none; }
.ui-products__menu a:hover { background: var(--ui-raise); }
.ui-products__menu a i { width: 9px; height: 9px; border-radius: 50%; background: var(--dot, var(--ui-ink-faint)); align-self: center; grid-row: span 2; }
.ui-products__menu a b { font-size: var(--ui-t-lead); font-weight: 650; letter-spacing: -0.01em; }
.ui-products__menu a small { grid-column: 2; font-size: var(--ui-t-meta); color: var(--ui-ink-dim); line-height: 1.35; }
.ui-products__menu a[aria-current="page"] { background: var(--ui-accent-soft); }
.ui-products__menu a[aria-current="page"] i { background: var(--ui-accent); box-shadow: 0 0 10px var(--ui-accent-glow); }
.ui-products__menu .ui-products__home { min-height: var(--ui-touch); margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--ui-line); border-radius: 0 0 var(--ui-r-tile) var(--ui-r-tile); color: var(--ui-ink-dim); font-size: var(--ui-t-small); }

/* ---------- 10. sheet: from the bottom on a phone, a side panel on a wide screen ---------- */
.ui-sheet { position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; max-height: 72vh; max-height: 72dvh;
  border-radius: var(--ui-r-sheet) var(--ui-r-sheet) 0 0; background: var(--ui-surface-strong); backdrop-filter: var(--ui-blur); -webkit-backdrop-filter: var(--ui-blur);
  box-shadow: var(--ui-inner), var(--ui-shadow-sheet); color: var(--ui-ink); padding-bottom: var(--ui-safe-b);
  transform: translateY(calc(100% + 24px)); transition: transform var(--ui-slow) var(--ui-ease), max-height var(--ui-slow) var(--ui-ease); }
.ui-sheet.is-open { transform: none; }
.ui-sheet.is-tall { max-height: calc(100vh - var(--ui-topbar-h) - var(--ui-safe-t)); max-height: calc(100dvh - var(--ui-topbar-h) - var(--ui-safe-t)); }
.ui-sheet__head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--ui-s3); padding: 22px var(--ui-pad) 10px; flex: none; }
.ui-sheet__head > div { min-width: 0; }
.ui-sheet__head h2 { margin: 0; font-size: var(--ui-t-h3); font-weight: 680; letter-spacing: -0.02em; line-height: 1.15; }
.ui-sheet__head p { margin: 3px 0 0; font-size: var(--ui-t-small); color: var(--ui-ink-dim); }
.ui-grip { position: absolute; top: 8px; left: 50%; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: rgba(255, 255, 255, 0.3); touch-action: none; cursor: grab; }
.ui-grip::before { content: ""; position: absolute; inset: -14px -40px; }    /* a thumb-sized handle */
.ui-sheet__body { overflow: auto; padding: 2px var(--ui-pad) var(--ui-s5); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--ui-line-strong) transparent; }

/* section labels inside a sheet or card: sentence case, quiet */
.ui-label { display: block; margin: var(--ui-s5) 0 var(--ui-s2); font-size: var(--ui-t-small); font-weight: 620; color: var(--ui-ink-faint); letter-spacing: 0; }
.ui-label:first-child { margin-top: var(--ui-s1); }
.ui-hint { font-size: var(--ui-t-meta); color: var(--ui-ink-faint); line-height: 1.45; }
.ui-lede { font-size: var(--ui-t-lead); line-height: 1.45; color: var(--ui-ink); }

/* ---------- 11. Advanced: complexity folded away, one tap to open, remembered by ui.js ---------- */
/* the Simple/Pro switch (mode.js): always visible, it is the mode's badge. .ui-pro / .ui-simple show in one mode only */
.ui-mode { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--ui-r-pill); background: var(--ui-raise); box-shadow: var(--ui-inner); flex: none; }
.ui-mode > button { min-height: calc(var(--ui-control) - 6px); min-width: var(--ui-touch); padding: 0 12px; border: 0; border-radius: var(--ui-r-pill); background: none; color: var(--ui-ink-dim); font: 600 var(--ui-t-small)/1 var(--ui-font); cursor: pointer; }
.ui-mode > button[aria-checked="true"] { background: var(--ui-accent); color: var(--ui-accent-ink); }
.ui-mode > button[aria-checked="false"]:hover { color: var(--ui-ink); }
.ui-mode--float { position: fixed; z-index: 40; top: calc(env(safe-area-inset-top, 0px) + 10px); right: calc(env(safe-area-inset-right, 0px) + 10px); background: var(--ui-surface); backdrop-filter: var(--ui-blur); -webkit-backdrop-filter: var(--ui-blur); }
html[data-ui-mode="simple"] .ui-pro, html[data-ui-mode="pro"] .ui-simple { display: none !important; }

.ui-adv { margin: var(--ui-s4) 0 0; border-top: 1px solid var(--ui-line); }
.ui-adv > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-s3); min-height: 52px; padding: 0 2px; cursor: pointer; list-style: none;
  font-size: var(--ui-t-body); font-weight: 620; color: var(--ui-ink-dim); }
.ui-adv > summary::-webkit-details-marker { display: none; }
.ui-adv > summary::after { content: ""; width: 8px; height: 8px; margin-right: 6px; border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor; transform: translateY(-3px) rotate(45deg); transition: transform var(--ui-mid) var(--ui-ease); }
.ui-adv[open] > summary { color: var(--ui-ink); }
.ui-adv[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.ui-adv > summary small { margin-left: auto; font-size: var(--ui-t-meta); font-weight: 500; color: var(--ui-ink-faint); }
.ui-adv > .ui-adv__body { padding: 0 0 var(--ui-s3); }

/* ---------- 12. toast: one line, what just happened ---------- */
.ui-toast { position: fixed; z-index: 40; left: 50%; bottom: calc(var(--ui-toast-b, 24px) + var(--ui-safe-b)); max-width: calc(100vw - 2 * var(--ui-pad));
  padding: 12px 18px; border-radius: var(--ui-r-card); background: var(--ui-surface-strong); backdrop-filter: var(--ui-blur); -webkit-backdrop-filter: var(--ui-blur);
  box-shadow: var(--ui-inner), var(--ui-shadow); color: var(--ui-ink); font-size: var(--ui-t-body); text-align: center;
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none; transition: opacity var(--ui-mid) var(--ui-ease), transform var(--ui-mid) var(--ui-ease); }
.ui-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.ui-toast--bad { box-shadow: inset 0 0 0 1px var(--ui-bad), var(--ui-shadow); }

/* ---------- 13. progress: progressive loading, the steps named, the current one live ---------- */
.ui-progress { display: grid; gap: var(--ui-s2); width: min(360px, calc(100vw - 2 * var(--ui-pad))); padding: 14px 16px; border-radius: var(--ui-r-card);
  background: var(--ui-surface-strong); backdrop-filter: var(--ui-blur); -webkit-backdrop-filter: var(--ui-blur); box-shadow: var(--ui-inner), var(--ui-shadow); }
.ui-progress__label { font-size: var(--ui-t-body); font-weight: 600; }
.ui-progress__bar { position: relative; height: 4px; border-radius: 2px; background: var(--ui-raise-hover); overflow: hidden; }
.ui-progress__bar > i { position: absolute; inset: 0 auto 0 0; width: calc(var(--p, 0) * 100%); border-radius: 2px; background: var(--ui-accent); box-shadow: 0 0 10px var(--ui-accent-glow); transition: width var(--ui-mid) var(--ui-ease); }
.ui-progress.is-indeterminate .ui-progress__bar > i { width: 32%; animation: ui-sweep 1.2s var(--ui-ease) infinite; }
.ui-progress__steps { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; list-style: none; font-size: var(--ui-t-meta); color: var(--ui-ink-faint); }
.ui-progress__steps li { display: inline-flex; align-items: center; gap: 6px; }
.ui-progress__steps li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px currentColor; }
.ui-progress__steps li.is-done { color: var(--ui-ink-dim); }
.ui-progress__steps li.is-done::before { background: var(--ui-ink-dim); box-shadow: none; }
.ui-progress__steps li.is-now { color: var(--ui-ink); }
.ui-progress__steps li.is-now::before { background: var(--ui-accent); box-shadow: 0 0 8px var(--ui-accent-glow); }
/* mission.js: a guided path of steps; glossary.js: a tap-to-open word */
.ui-mission__title { margin: 0 0 var(--ui-s2); font-size: var(--ui-t-title, 1.2rem); }
.ui-mission__steps { display: grid; gap: var(--ui-s3); margin: var(--ui-s4) 0 0; padding: 0; list-style: none; }
.ui-mission__step { padding: 14px 16px; border-radius: var(--ui-r-card); background: var(--ui-raise); box-shadow: var(--ui-inner); opacity: 0.55; }
.ui-mission__step.is-now, .ui-mission__step.is-done { opacity: 1; }
.ui-mission__step.is-now { box-shadow: inset 0 0 0 1.5px var(--ui-accent), var(--ui-inner); }
.ui-mission__step h4 { margin: 2px 0 var(--ui-s2); font-size: var(--ui-t-body); }
.ui-mission__n { margin: 0; font-size: var(--ui-t-meta); color: var(--ui-ink-faint); }
.ui-mission__step.is-done .ui-mission__n::before { content: "✓ "; color: var(--ui-accent); }
.ui-mission__say { line-height: 1.5; }
.ui-mission__say p { margin: 0 0 var(--ui-s2); }
.ui-mission__why > summary { cursor: pointer; color: var(--ui-ink-dim); font-size: var(--ui-t-meta); min-height: 44px; display: flex; align-items: center; }
.ui-mission__src { margin: var(--ui-s2) 0 0; font-size: var(--ui-t-meta); color: var(--ui-ink-dim); }
.ui-mission__err { color: var(--ui-bad, #d66); }
.ui-mission__step .ui-progress { width: auto; box-shadow: none; background: none; padding: 4px 0; }
.ui-mission__done { margin: var(--ui-s4) 0 0; font-weight: 600; color: var(--ui-accent); }
/* pointer-events: a word inside a click-through overlay (a title over the 3D view) still opens */
.ui-term { position: relative; display: inline; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; pointer-events: auto; }
.ui-term[aria-expanded="true"] { text-decoration-style: solid; color: var(--ui-accent); }
.ui-term__def { display: block; pointer-events: auto; max-width: 34em; margin: 4px 0 6px; padding: 8px 10px; border-radius: 10px; background: var(--ui-surface-strong); color: var(--ui-ink); font-size: var(--ui-t-meta); line-height: 1.45; text-align: left; white-space: normal; }
.ui-term__here, .ui-term__src { display: block; margin-top: 4px; color: var(--ui-ink-dim); }
.ui-term__src { min-height: 32px; display: flex; align-items: center; color: var(--ui-accent); }
@keyframes ui-sweep { from { transform: translateX(-100%); } to { transform: translateX(320%); } }

/* ---------- 14. lists and facts ---------- */
.ui-list { list-style: none; margin: 0; padding: 0; }
.ui-list > li, .ui-list > a { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-s3); min-height: 52px; padding: 8px 12px; border-radius: var(--ui-r-tile); cursor: pointer; text-decoration: none; }
.ui-list > li:hover, .ui-list > a:hover, .ui-list > .is-on { background: var(--ui-raise); }
.ui-facts { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 8px 16px; margin: var(--ui-s2) 0; font-size: var(--ui-t-small); }
.ui-facts dt { color: var(--ui-ink-faint); }
.ui-facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- 15. responsive + motion ---------- */
@media (min-width: 760px) {
  :root { --ui-pad: 20px; --ui-topbar-h: 64px; }
  .ui-sheet { left: auto; top: calc(var(--ui-topbar-h) + var(--ui-safe-t)); right: var(--ui-pad); bottom: var(--ui-pad); width: 400px; max-height: none;
    border-radius: var(--ui-r-sheet); box-shadow: var(--ui-inner), var(--ui-shadow); transform: translateX(calc(100% + 40px)); }
  .ui-sheet.is-tall { max-height: none; }
  .ui-grip { display: none; }
  .ui-sheet__head { padding-top: 18px; }
}
/* compact controls only where the pointer is precise and there is room */
@media (min-width: 760px) and (pointer: fine) {
  :root { --ui-control: 38px; }
  .ui-btn, .ui-chip { font-size: var(--ui-t-small); }
}
@media (min-width: 1200px) { :root { --ui-pad: 28px; } }
@media (prefers-reduced-motion: reduce) {
  .ui-btn, .ui-chip, .ui-sheet, .ui-toast, .ui-products__menu, .ui-toggle input::after, .ui-adv > summary::after, .ui-progress__bar > i { transition: none !important; }
  .ui-progress.is-indeterminate .ui-progress__bar > i { animation: none; width: 100%; opacity: 0.5; }
}
