/* Noor design system. Principles, tokens and component rules: DESIGN.md.
   Clear and minimalist: one clear action, content over chrome, color only where
   it means something, progressive disclosure.

   Component rules use tokens only (checked by `cargo test`): no raw px font
   sizes, radii, padding/margin/gap, and no raw colors. Themes and breakpoints
   change token values, never names. */

[hidden] { display: none !important; }

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --elevated: #ffffff;
  --text: #1d1d1f;
  --secondary: #6e6e73;
  --tertiary: #aeaeb2;
  --separator: rgba(60, 60, 67, 0.12);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --accent: #0066cc;         /* 5.1:1 on --bg; white on it 5.6:1 */
  --accent-soft: rgba(0, 102, 204, 0.1);
  --green: #1f7a36; /* 5.4:1 on white; was #248a3d (4.4:1) */
  --green-soft: rgba(52, 199, 89, 0.14);
  --red: #d70015;
  --red-soft: rgba(255, 59, 48, 0.12);
  --orange: #c93400;
  --chart-green: #34c759;
  --chart-red: #ff3b30;
  --switch-on: #34c759;
  /* Text and marks on colored fills, logos, overlays, session dots */
  --on-accent: #ffffff;
  --switch-knob: #ffffff;
  /* Keyboard focus ring: at least 3:1 against every surface */
  --focus: var(--accent);
  --logo-bg: #ffffff;
  --logo-ring: rgba(0, 0, 0, 0.08);
  --backdrop: rgba(0, 0, 0, 0.35);
  --amber: #ff9f0a;
  /* The quote of the day, pressed into the page: a highlight below the letters, a shade above */
  --emboss-light: rgba(255, 255, 255, 0.9);
  --emboss-shade: rgba(0, 0, 0, 0.1);

  /* ---- Type: by role ---- */
  --font-family-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-family-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  --font-caption: 12px;      /* chart axes, tiny labels */
  --font-footnote: 13px;     /* secondary lines, hints, control labels */
  --font-body: 15px;         /* rows, paragraphs */
  --font-headline: 17px;     /* emphasis, sheet titles, lesson text */
  --font-title: 22px;        /* section titles, key numbers */
  --font-large-title: 34px;  /* page titles, stock price */
  --font-display: 56px;      /* the portfolio balance */
  --font-input: 16px;        /* fields on touch screens: iOS zooms in on anything smaller */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  /* ---- Spacing: 4px grid, nothing in between ---- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* ---- Shape ---- */
  --radius-s: 8px;      /* inputs, small controls */
  --radius-m: 12px;     /* menus, popovers, chips, icons */
  --radius-l: 18px;     /* cards, sheets */
  --radius-full: 999px; /* pills, round buttons, dots */

  /* ---- Elevation: cards barely lift, overlays float; nothing in between ---- */
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-overlay: 0 20px 60px rgba(0, 0, 0, 0.25);

  /* ---- Motion: functional only ---- */
  --tabbar-height: 56px;   /* phone tab bar, above the home indicator */
  --duration-fast: 150ms;  /* hovers, toggles */
  --duration-base: 250ms;  /* views, sheets, charts */
  --ease: cubic-bezier(.2, .9, .3, 1);

  /* ---- Component tokens: what a theme may restyle, as values ---- */
  --border-surface: none;                 /* cards, lists, menus, sheets */
  --radius-button: var(--radius-full);    /* buttons, chips */
  --radius-control: var(--radius-m);      /* inputs, search, choices, large buttons */
  --control-bg: var(--fill);              /* inputs, search, choices, secondary buttons */
  --control-border: 1px solid transparent;
  --link-decoration: none;                /* text buttons and links */

  color-scheme: light;
}
/* Smaller screens: same names, smaller display sizes. */
@media (max-width: 640px) {
  :root { --font-display: 44px; --font-large-title: 28px; }
}
/* Classic, dark. Applied when <html data-mode="dark"> (see themes.js). */
:root[data-mode="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --elevated: #2c2c2e;
  --text: #f5f5f7;
  --secondary: #98989d;
  --tertiary: #636366;
  --separator: rgba(84, 84, 88, 0.6);
  --fill: rgba(118, 118, 128, 0.24);
  --fill-strong: rgba(118, 118, 128, 0.36);
  --accent: #4aa1ff;         /* 5.2:1 on --elevated; text on it is dark (--on-accent) */
  --accent-soft: rgba(74, 161, 255, 0.18);
  --on-accent: #000000;
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.18);
  --red: #ff6961;             /* 4.9:1 on --elevated */
  --red-soft: rgba(255, 105, 97, 0.18);
  --orange: #ff9f0a;
  --shadow-card: none;
  --shadow-overlay: 0 20px 60px rgba(0, 0, 0, 0.6);
  --logo-ring: rgba(255, 255, 255, 0.08);
  --backdrop: rgba(0, 0, 0, 0.5);
  --chart-green: #30d158;
  --chart-red: #ff453a;
  --emboss-light: rgba(255, 255, 255, 0.07);
  --emboss-shade: rgba(0, 0, 0, 0.9);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family-text);
  font-size: var(--font-body);
  line-height: 1.47;
  letter-spacing: -0.01em;
  overflow-wrap: break-word; /* a word too long for its box (a long Armenian term in a tile) breaks rather than spilling out */
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-family-display); letter-spacing: -0.02em; margin: 0; }
h1 { font-size: var(--font-large-title); font-weight: var(--weight-semibold); line-height: 1.1; }
h2 { font-size: var(--font-title); font-weight: var(--weight-semibold); }
h3 { font-size: var(--font-body); font-weight: var(--weight-semibold); }
a { color: var(--accent); text-decoration: none; }
p { margin: 0; }
.secondary { color: var(--secondary); }
.footnote { color: var(--secondary); font-size: var(--font-footnote); line-height: 1.4; }
.group-foot { margin: var(--space-2) var(--space-1) 0; }
.center { text-align: center; }
.up { color: var(--green); }
.down { color: var(--red); }
.warn { color: var(--orange); }
.error { color: var(--red); font-size: var(--font-body); min-height: 1em; }

/* ---------- controls ---------- */
button { font: inherit; letter-spacing: inherit; cursor: pointer; border: none; background: none; color: inherit; }
button:disabled { opacity: 0.4; cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-s); }

.primary {
  background: var(--accent); color: var(--on-accent); border-radius: var(--radius-button); border: 1px solid transparent;
  padding: var(--space-2) var(--space-5); font-weight: var(--weight-medium); font-size: var(--font-body); white-space: nowrap;
}
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.primary.large { width: 100%; padding: var(--space-4); font-size: var(--font-headline); border-radius: var(--radius-control); }
.secondary-btn {
  background: var(--control-bg); color: var(--accent); border-radius: var(--radius-button); border: var(--control-border);
  padding: var(--space-2) var(--space-4); font-weight: var(--weight-medium); white-space: nowrap;
}
.secondary-btn:hover:not(:disabled) { background: var(--fill-strong); }
/* A label that comes from content (a lesson's "Try it", "Next: <title>", the streak's ways, a
   long translation) wraps onto more lines instead of running off a phone's screen; so does any
   button the width of its column. Short interface labels stay on one line. */
.long-label, .primary.large { max-width: 100%; white-space: normal; text-wrap: balance; }
.text-btn { color: var(--accent); padding: var(--space-1) 0; font-weight: var(--weight-regular); text-decoration: var(--link-decoration); text-underline-offset: 3px; }
a.back, .attribution a { text-decoration: var(--link-decoration); text-underline-offset: 3px; }
.text-btn:hover { text-decoration: underline; }
.text-btn.danger { color: var(--red); }
.center-block { display: block; margin: var(--space-3) auto 0; }

input, select, textarea {
  font: inherit; letter-spacing: inherit; color: var(--text);
  background: var(--control-bg); border: var(--control-border); border-radius: var(--radius-control);
  padding: var(--space-3) var(--space-3); width: 100%; transition: border-color var(--duration-fast), background var(--duration-fast);
}
input::placeholder, textarea::placeholder { color: var(--secondary); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--card); outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
textarea { display: block; min-height: 120px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--secondary) 50%), linear-gradient(135deg, var(--secondary) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: var(--space-6); }

/* iOS segmented control */
.segmented { display: inline-flex; background: var(--fill); border-radius: var(--radius-s); padding: var(--space-1); gap: var(--space-1); }
.segmented button { padding: var(--space-2) var(--space-4); border-radius: var(--radius-s); font-size: var(--font-footnote); font-weight: var(--weight-medium); color: var(--text); transition: background var(--duration-fast), box-shadow var(--duration-fast); }
.segmented button.on { background: var(--elevated); box-shadow: var(--shadow-card), 0 0 0 .5px var(--separator); }
.segmented.wide { display: flex; width: 100%; }
.segmented.wide button { flex: 1; }
.segmented.small button { padding: var(--space-1) var(--space-3); font-size: var(--font-footnote); }

/* switch */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--fill-strong); border-radius: var(--radius-full); transition: background var(--duration-fast); cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: var(--radius-full); background: var(--switch-knob); box-shadow: var(--shadow-card), 0 0 0 .5px var(--separator); transition: transform var(--duration-fast); }
.switch input:checked + span { background: var(--switch-on); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch.small { width: 36px; height: 22px; }
.switch.small span::after { width: 18px; height: 18px; }
.switch.small input:checked + span::after { transform: translateX(14px); }

/* "?" help button */
.q {
  display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: var(--radius-full);
  background: var(--fill); color: var(--secondary); font-size: var(--font-caption); font-weight: var(--weight-semibold);
  vertical-align: 2px; margin-left: var(--space-1); line-height: 1;
}
.q:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- layout ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--space-5);
  height: 52px; padding: 0 max(var(--space-5), env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--separator);
}
.logo { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-semibold); font-size: var(--font-headline); color: var(--text); letter-spacing: -0.02em; }
/* Wordmark (static/brand, inlined so it takes the theme's text color). The kit asks for
   at least 120px of width including clear space, so it never goes below 28px tall. */
/* Heights include the crown above the second "o" (the viewBox is 124 units tall, letters 100),
   so the letters themselves are 24px in the header, 28px on standalone pages, 40px on sign-up
   and 72px on About. The negative top margin lets the crown rise above the letters'
   centerline, keeping them aligned with the Beta badge. */
.wordmark { display: block; height: 35px; width: auto; flex: none; margin-top: -7px; }
.bar .wordmark { height: 30px; margin-top: -6px; } /* header: slightly under the kit's minimum, by choice */
.auth-card .wordmark { height: 50px; margin-top: 0; }
.wordmark-large { height: 89px; margin: 0 auto; }
.beta-badge { margin-left: calc(-1 * var(--space-1)); padding: 0 var(--space-2); border-radius: var(--radius-full); background: var(--fill-strong); color: var(--secondary); font-size: var(--font-caption); font-weight: var(--weight-medium); line-height: 1.6; letter-spacing: 0; }
.tabs { display: flex; gap: var(--space-1); margin: 0 auto; }
.tabs a { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--secondary); padding: var(--space-2) var(--space-4); border-radius: var(--radius-full); font-size: var(--font-footnote); font-weight: var(--weight-medium); }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); background: var(--fill); }
.bar-actions { display: flex; align-items: center; gap: var(--space-2); position: relative; }
.icon-btn { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-full); color: var(--secondary); }
.icon-btn:hover { background: var(--fill); color: var(--text); }
/* The streak badge: flame and run length, grey until something counts today. */
.bar-streak { display: inline-flex; align-items: center; gap: var(--space-1); height: 34px; padding: 0 var(--space-2); border-radius: var(--radius-full); color: var(--secondary); font-size: var(--font-body); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.bar-streak[hidden] { display: none; }
.bar-streak .icon { width: 18px; height: 18px; }
.bar-streak:hover { background: var(--fill); }
.bar-streak.lit { color: var(--text); }
.bar-streak.lit .icon { color: var(--orange); }
/* The account button: tinted with the accent and ringed, so it reads as the place
   for Settings, Getting started, About and Log out. */
.icon-btn.avatar { width: 36px; height: 36px; background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 35%, transparent); font-size: var(--font-body); font-weight: var(--weight-semibold); text-transform: uppercase; }
.icon-btn.avatar:hover, .icon-btn.avatar[aria-expanded="true"] { background: var(--accent); color: var(--on-accent); }
.menu { border: var(--border-surface); position: absolute; top: 42px; right: 0; min-width: 220px; background: var(--elevated); border-radius: var(--radius-m); box-shadow: var(--shadow-overlay); padding: var(--space-2); z-index: 30; }
.menu-email { padding: var(--space-3) var(--space-3); color: var(--secondary); font-size: var(--font-footnote); border-bottom: .5px solid var(--separator); margin-bottom: var(--space-1); overflow: hidden; text-overflow: ellipsis; }
.menu :is(button, a) { display: flex; align-items: center; gap: var(--space-3); width: 100%; text-align: left; padding: var(--space-2) var(--space-3); border-radius: var(--radius-s); color: var(--text); font-size: var(--font-body); }
.menu :is(button, a):hover { background: var(--fill); }
.menu-sep { border: none; border-top: .5px solid var(--separator); margin: var(--space-1) 0; }

main { max-width: 760px; margin: 0 auto; padding: var(--space-5) var(--space-5) var(--space-7); }
.view { animation: fade var(--duration-base) ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-title { margin: var(--space-2) 0 var(--space-5); }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.title-row .page-title { margin-bottom: var(--space-5); }
.center-row { display: flex; justify-content: center; }
.inline { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }

.group { margin-top: var(--space-6); }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin: 0 var(--space-1) var(--space-3); }
.card { background: var(--card); border: var(--border-surface); border-radius: var(--radius-l); padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-card); }

/* inset grouped list */
.list { background: var(--card); border: var(--border-surface); border-radius: var(--radius-l); overflow: hidden; box-shadow: var(--shadow-card); }
.list:empty { display: none; }
.row {
  display: flex; align-items: center; gap: var(--space-4); width: 100%;
  padding: var(--space-3) var(--space-5); text-align: left; position: relative; color: inherit;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 70px; right: 0; border-top: .5px solid var(--separator); }
.row.plain + .row.plain::before, .row.no-icon + .row.no-icon::before { left: 20px; }
a.row:hover, button.row:hover { background: var(--fill); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: var(--weight-semibold); }
.row .sub { color: var(--secondary); font-size: var(--font-footnote); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; flex: none; }
/* A key number inside a secondary line, e.g. a holding's total value */
.row .sub b { color: var(--text); font-weight: var(--weight-medium); }
.row .end .sub { white-space: nowrap; }
.wrap-sub .row .main .sub { white-space: normal; }
.row .chev { color: var(--tertiary); flex: none; }
.empty-row { padding: var(--space-5) var(--space-5); color: var(--secondary); text-align: center; }

.ticker-icon {
  width: 40px; height: 40px; border-radius: var(--radius-m); flex: none;
  display: grid; place-items: center; font-size: var(--font-caption); font-weight: var(--weight-semibold); letter-spacing: 0;
  background: var(--fill-strong); color: var(--text);
}
.pill { display: inline-block; padding: var(--space-1) var(--space-2); border-radius: var(--radius-s); font-size: var(--font-footnote); font-weight: var(--weight-semibold); min-width: 64px; text-align: center; }
.pill.up { background: var(--green-soft); }
.pill.down { background: var(--red-soft); }
.pill.flat { background: var(--fill); color: var(--secondary); }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { background: var(--card); box-shadow: var(--shadow-card); border: var(--border-surface); border-radius: var(--radius-button); padding: var(--space-2) var(--space-4); font-size: var(--font-body); color: var(--text); }
.chip:hover { background: var(--fill); }
.chip b { font-weight: var(--weight-semibold); margin-right: var(--space-1); }
.chip.soft { background: var(--accent-soft); color: var(--accent); box-shadow: none; font-weight: var(--weight-medium); }
.chip.soft:disabled { background: var(--fill); color: var(--secondary); opacity: 1; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--space-5) var(--space-4); }
.auth-card { width: 100%; max-width: 400px; text-align: left; }
.auth-card .logo { margin-bottom: var(--space-6); }
.auth-card h1 { font-size: var(--font-large-title); margin-bottom: var(--space-4); }
.auth-card > p.secondary { font-size: var(--font-headline); margin-bottom: var(--space-6); }
.auth-card .segmented { margin-bottom: var(--space-4); }
.invite-field input { text-transform: uppercase; letter-spacing: 0.04em; }
.invite-field input::placeholder { text-transform: none; letter-spacing: 0; }
.invite-field .footnote { margin-top: var(--space-2); }
.stack { display: grid; gap: var(--space-3); }
.stack input { padding: var(--space-4); font-size: var(--font-headline); border-radius: var(--radius-m); }
.stack .primary { margin-top: var(--space-2); }
.auth-card > .footnote { margin-top: var(--space-5); }

/* ---------- landing page + the way in (landing.js) ---------- */
.auth:has(.landing:not([hidden])) { display: block; padding: 0; }
/* The way in starts at the same height on every step, so screens don't jump. */
.auth:has(.join:not([hidden])) { place-items: start center; padding-top: var(--space-7); }
.landing { max-width: 1040px; margin: 0 auto; padding: var(--space-4) var(--space-5) var(--space-7); }
.landing-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; }
.landing-bar .logo { display: flex; align-items: center; gap: var(--space-2); color: var(--text); }
.landing-bar .wordmark { height: 30px; margin-top: -6px; }
.landing-bar-end { display: flex; align-items: center; gap: var(--space-3); }
.landing-bar .auth-lang { margin: 0; }
.landing-hero { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: var(--space-7); align-items: center; padding: var(--space-7) 0; }
.hero-copy h1 { font-family: var(--font-family-display); font-size: var(--font-display); line-height: 1.05; letter-spacing: -0.03em; margin: 0 0 var(--space-4); }
.hero-sub { font-size: var(--font-title); line-height: 1.35; color: var(--secondary); margin: 0 0 var(--space-6); max-width: 30em; }
.hero-ask { font-size: var(--font-footnote); font-weight: var(--weight-semibold); color: var(--secondary); margin: 0 0 var(--space-3); }
.goal-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-5); }
.goal-chip { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius-button); background: var(--card); border: var(--border-surface); box-shadow: var(--shadow-card); color: var(--text); font-size: var(--font-body); font-weight: var(--weight-medium); transition: background var(--duration-fast) var(--ease); }
.goal-chip .icon { width: 18px; height: 18px; color: var(--accent); }
.goal-chip:hover { background: var(--accent-soft); }
.hero-cta { max-width: 320px; margin-bottom: var(--space-3); }
.hero-copy > .footnote { margin: 0; }

/* The lesson preview: a phone-shaped card with one real step. */
.hero-preview { margin: 0; display: grid; gap: var(--space-3); justify-items: center; }
.hero-preview figcaption { text-align: center; }
.phone { width: 100%; max-width: 340px; display: grid; gap: var(--space-3); background: var(--card); border: var(--border-surface); border-radius: var(--radius-l); box-shadow: var(--shadow-overlay); padding: var(--space-5) var(--space-4); }
.phone-top { display: flex; align-items: center; gap: var(--space-2); }
.phone-flame { display: grid; place-items: center; color: var(--tertiary); transition: color var(--duration-base) var(--ease), transform var(--duration-base) var(--ease); }
.phone-flame .icon { width: 22px; height: 22px; }
.phone-flame.lit { color: var(--orange); transform: scale(1.2); }
.phone-streak { font-size: var(--font-footnote); font-weight: var(--weight-semibold); }
.phone-progress { flex: 1; margin: 0 0 0 var(--space-2); }
.phone-text { margin: 0; font-size: var(--font-body); line-height: 1.45; }
.phone-q { margin: 0; font-size: var(--font-headline); font-weight: var(--weight-semibold); line-height: 1.35; }
.phone-options { display: grid; gap: var(--space-2); }
.phone-options .choice { padding: var(--space-3) var(--space-4); }
.phone-options .choice.right { background: var(--green-soft); color: var(--green); font-weight: var(--weight-semibold); }
.phone-options .choice.wrong { background: var(--red-soft); color: var(--red); }
.phone-options .choice:disabled { opacity: 1; cursor: default; }
.phone-why { margin: 0; font-size: var(--font-footnote); color: var(--secondary); line-height: 1.4; }

/* Three tiles with a small drawn mock each, then the trust line. */
.landing-tiles { padding: var(--space-6) 0 0; }
.landing-tiles > h2 { font-size: var(--font-large-title); margin: 0 0 var(--space-5); text-align: center; }
.tiles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.ltile { background: var(--card); border: var(--border-surface); border-radius: var(--radius-l); box-shadow: var(--shadow-card); padding: var(--space-5); }
.ltile h3 { font-size: var(--font-headline); margin: var(--space-4) 0 var(--space-2); }
.ltile p { margin: 0; color: var(--secondary); font-size: var(--font-body); line-height: 1.45; }
.ltile-mock { display: grid; gap: var(--space-2); align-content: center; min-height: 104px; padding: var(--space-4); border-radius: var(--radius-m); background: var(--fill); }
.ltile-mock .progress { margin: 0; }
.mock-bar-60 { width: 60%; }
.mock-row { display: flex; align-items: center; gap: var(--space-2); font-size: var(--font-body); }
.mock-row b { font-weight: var(--weight-semibold); }
.mock-flame { display: grid; color: var(--orange); }
.mock-flame .icon { width: 20px; height: 20px; }
.mock-week { display: flex; gap: var(--space-2); }
.mock-week i { width: 14px; height: 14px; border-radius: var(--radius-full); background: var(--fill-strong); }
.mock-week i.on { background: var(--orange); }
.mock-week i.today { background: none; box-shadow: inset 0 0 0 2px var(--green); }
.mock-label { font-size: var(--font-caption); color: var(--secondary); font-weight: var(--weight-medium); }
.mock-balance { font-family: var(--font-family-display); font-size: var(--font-large-title); font-weight: var(--weight-semibold); letter-spacing: -0.02em; line-height: 1.1; }
.mock-pill { justify-self: start; color: var(--green); }
.mock-term { font-weight: var(--weight-semibold); }
.mock-help { display: grid; place-items: center; width: 18px; height: 18px; border-radius: var(--radius-full); background: var(--accent-soft); color: var(--accent); font-size: var(--font-caption); font-weight: var(--weight-semibold); }
.mock-explain { margin: 0; font-size: var(--font-footnote); color: var(--secondary); }
.landing-trust { margin: var(--space-5) 0 0; text-align: center; color: var(--secondary); font-size: var(--font-footnote); }
.landing-end { display: grid; justify-items: center; gap: var(--space-4); padding: var(--space-7) 0 0; text-align: center; }
.landing-end h2 { font-size: var(--font-large-title); margin: 0; }
.landing-end .primary.large { max-width: 320px; }
.landing-end .footnote { margin: 0; }

/* Drawn charts (landing and About): illustrative shapes in neutral tokens, one accent at
   most each. `.draw` lines have pathLength="1"; a `.viz.pending` (landing.js) hides them
   until they scroll into view. Reduced motion turns the drawing off (see the media rule). */
.draw { stroke-dasharray: 1; stroke-dashoffset: 0; transition: stroke-dashoffset calc(var(--duration-base) * 5) var(--ease); }
.viz.pending .draw { stroke-dashoffset: 1; }
.viz-donut { width: 64px; height: 64px; flex: none; transition: opacity calc(var(--duration-base) * 3) var(--ease), transform calc(var(--duration-base) * 3) var(--ease); }
.viz-donut.small { width: 48px; height: 48px; }
.viz.pending .viz-donut { opacity: 0; transform: rotate(-60deg) scale(.9); }
.viz-donut circle { fill: none; stroke-width: 6; }
.d-track { stroke: var(--fill); }
.d-a { stroke: var(--accent); }
.d-b { stroke: var(--tertiary); }
.d-c { stroke: var(--fill-strong); }
.viz-spark { display: block; width: 100%; height: 40px; overflow: visible; }
.spark-line { fill: none; stroke: var(--secondary); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.spark-area { fill: var(--fill); transition: opacity calc(var(--duration-base) * 4) var(--ease); }
.viz.pending .spark-area { opacity: 0; }
.mix-body { display: flex; align-items: center; gap: var(--space-4); }
.mix-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); font-size: var(--font-caption); color: var(--secondary); }
.mix-legend li { display: flex; align-items: center; gap: var(--space-2); }
.mix-legend i { width: 8px; height: 8px; border-radius: var(--radius-full); }
.mix-legend .k-a { background: var(--accent); }
.mix-legend .k-b { background: var(--tertiary); }
.mix-legend .k-c { background: var(--fill-strong); }

/* The portfolio card peeking out behind the lesson phone: a donut and a line, no text the phone would cut. */
.hero-preview { position: relative; }
.hero-preview .phone { position: relative; z-index: 1; }
.hero-preview figcaption { position: relative; z-index: 1; }
.mix-card { position: absolute; z-index: 0; left: -84px; bottom: 72px; width: 210px; display: grid; gap: var(--space-3); padding: var(--space-4); background: var(--card); border: var(--border-surface); border-radius: var(--radius-l); box-shadow: var(--shadow-card); transform: rotate(-5deg); }
.mix-line-head { font-size: var(--font-caption); color: var(--secondary); }
.mix-card .viz-spark { height: 36px; }

/* Growth band: 10,000 over 30 years, cash against 7% a year. */
.growth-band { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: var(--space-6); align-items: center; margin: var(--space-6) 0 var(--space-5); padding: var(--space-5) var(--space-6); background: var(--card); border: var(--border-surface); border-radius: var(--radius-l); box-shadow: var(--shadow-card); }
.growth-copy h2 { font-size: var(--font-title); margin: 0 0 var(--space-2); }
.growth-copy p { margin: 0; color: var(--secondary); font-size: var(--font-body); line-height: 1.5; }
.growth-figure { position: relative; }
.growth-chart { display: block; width: 100%; height: auto; overflow: visible; }
.g-grid { stroke: var(--separator); stroke-width: 1; }
.g-cash { fill: none; stroke: var(--tertiary); stroke-width: 2; stroke-linecap: round; }
.g-inv { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.g-dot { transition: opacity var(--duration-base) var(--ease) calc(var(--duration-base) * 4); }
.g-dot-inv { fill: var(--accent); }
.g-dot-cash { fill: var(--tertiary); }
.viz.pending .g-dot { opacity: 0; transition: none; }
.g-label { position: absolute; right: 10%; font-size: var(--font-footnote); color: var(--secondary); white-space: nowrap; }
.g-label b { color: var(--text); font-weight: var(--weight-semibold); }
.gl-inv { top: 6%; }
.gl-cash { top: 68%; }
.g-axis { position: absolute; bottom: -4%; font-size: var(--font-caption); color: var(--secondary); }
.gl-now { left: 7%; }
.gl-end { right: 7%; }

/* The small charts inside the tiles, and About's cards. */
.mock-spark-row { display: flex; align-items: center; gap: var(--space-3); }
.mock-spark-row .mock-pill { flex: none; }
.mock-spark { height: 28px; }
.mock-mix { gap: var(--space-3); }
.about-way-icon.flame { background: none; color: var(--orange); }
.about-way-icon.viz { background: var(--fill); padding: var(--space-1); }
.about-way-icon .viz-donut { width: 32px; height: 32px; }
.about-way-icon .viz-spark { height: 24px; }
.about .draw { animation: viz-draw calc(var(--duration-base) * 5) var(--ease) both; }
.about .viz-donut { animation: viz-turn calc(var(--duration-base) * 3) var(--ease) both; }
@keyframes viz-draw { from { stroke-dashoffset: 1; } }
@keyframes viz-turn { from { opacity: 0; transform: rotate(-60deg) scale(.9); } }

@media (max-width: 860px) {
  .landing-hero { grid-template-columns: 1fr; gap: var(--space-6); padding: var(--space-5) 0; }
  .tiles-grid { grid-template-columns: 1fr; }
  .mix-card { display: none; }
  .growth-band { grid-template-columns: 1fr; gap: var(--space-4); padding: var(--space-5); }
}
@media (max-width: 640px) {
  .landing { padding: var(--space-3) var(--space-4) var(--space-7); }
  .goal-chips { display: grid; }
  .hero-cta { max-width: none; }
  .landing-bar .beta-badge { display: none; }
  .gl-inv { top: -4%; right: 12%; }
  .gl-cash { top: 56%; right: 12%; }
  .landing-bar-end { gap: var(--space-2); }
}

/* The way in: goal, level, then the account form or the waiting list. */
.join-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: var(--space-6); }
.join-top .text-btn { justify-self: start; }
.join-top .dots { margin: 0; }
.join h1 { font-size: var(--font-large-title); margin: 0 0 var(--space-2); }
.join-sub { font-size: var(--font-headline); margin: 0 0 var(--space-5); }
.join-switch { margin: var(--space-4) 0 0; }
#wait-form h1 { margin-bottom: 0; }
#wait-form .join-sub { margin-bottom: var(--space-2); }
.join .error:empty { display: none; }

/* ---------- portfolio ---------- */
.hero { text-align: center; margin: var(--space-6) 0 var(--space-2); }
.hero-label { color: var(--secondary); font-size: var(--font-body); font-weight: var(--weight-medium); }
.hero-value { font-size: var(--font-display); font-weight: var(--weight-semibold); letter-spacing: -0.03em; line-height: 1.1; margin: var(--space-2) 0; font-family: var(--font-family-display); }
.hero-sub { font-size: var(--font-headline); font-weight: var(--weight-medium); }
/* The landing page's .hero-sub caps its width; the balance line stays centered under the balance. */
.hero .hero-sub { max-width: none; }
.hero-chip { display: inline-flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); padding: var(--space-2) var(--space-4); border-radius: var(--radius-full); background: var(--fill); font-size: var(--font-body); }
.hero-chip.up { background: var(--green-soft); }
.hero-chip.down { background: var(--red-soft); }
.hero-actions { display: flex; justify-content: center; gap: var(--space-3); margin-top: var(--space-5); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: var(--space-3); margin-top: var(--space-6); }
@media (max-width: 520px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--card); border: var(--border-surface); border-radius: var(--radius-l); padding: var(--space-4) var(--space-4); box-shadow: var(--shadow-card); }
.stat .label { color: var(--secondary); font-size: var(--font-footnote); }
.stat .value { font-size: var(--font-title); font-weight: var(--weight-semibold); margin-top: var(--space-1); letter-spacing: -0.02em; }

.alloc-bar { display: flex; height: 10px; border-radius: var(--radius-full); overflow: hidden; background: var(--fill); gap: var(--space-1); }
.alloc-bar span { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: var(--space-4); font-size: var(--font-body); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: var(--radius-full); margin-right: var(--space-2); vertical-align: 1px; }
.legend .t { color: var(--secondary); }
#rebalance { margin-top: var(--space-4); padding-top: var(--space-4); border-top: .5px solid var(--separator); }
#rebalance:empty { display: none; }
details.rebal > summary { margin: 0; font-weight: var(--weight-semibold); }
details.rebal[open] > summary { margin-bottom: var(--space-2); }
.summary-note { color: var(--secondary); font-size: var(--font-body); }
.rebal-line { display: flex; justify-content: space-between; padding: var(--space-1) 0; font-size: var(--font-body); }

details.disclosure > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--space-2); margin: 0 var(--space-1) var(--space-3); }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "›"; color: var(--tertiary); font-size: var(--font-title); transition: transform var(--duration-fast); }
details.disclosure[open] > summary::after { transform: rotate(90deg); }
details.disclosure .text-btn { margin: var(--space-4) var(--space-1) 0; }

/* ---------- explore ---------- */
.search { display: flex; align-items: center; gap: var(--space-2); background: var(--control-bg); border: var(--control-border); border-radius: var(--radius-control); padding: 0 var(--space-3); color: var(--secondary); }
.search input { background: transparent; border: none; padding: var(--space-3) 0; font-size: var(--font-headline); }
.search input:focus { background: transparent; outline: none; }
.search:focus-within { border-color: var(--accent); }
.search:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- stock ---------- */
.stock-head { display: block; margin: var(--space-2) 0 var(--space-4); }
.eyebrow { color: var(--secondary); font-size: var(--font-footnote); font-weight: var(--weight-semibold); letter-spacing: .02em; }
.stock-head h1 { margin: var(--space-1) 0 var(--space-1); }
.stock-price { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-4); }
/* Market session: a round icon plus text (the text carries the meaning, not the color). */
.session-line { flex-basis: 100%; color: var(--secondary); font-size: var(--font-footnote); line-height: 1.6; }
.session-line .ext { color: var(--text); font-size: var(--font-body); }
.hero-session { margin-top: var(--space-2); }
/* Only an open market gets color; pre-market, after hours and closed stay grey (inactive). */
.session-badge { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: var(--radius-full); margin-right: var(--space-2); vertical-align: middle; position: relative; top: -1px; background: var(--fill); color: var(--secondary); }
.session-badge .icon { width: 13px; height: 13px; }
.session-badge.open { background: var(--green-soft); color: var(--green); }
/* The market's state on Today and Portfolio reads as a small label, like a status line. */
.market-status, .hero-session { text-transform: uppercase; letter-spacing: .03em; }
:is(.market-status, .hero-session) .help { text-transform: none; }
.market-status { margin: calc(-1 * var(--space-2)) 0 var(--space-4); }
/* Under a section heading (Explore's Market map): in line with the heading. */
.group-head + .market-status { margin: calc(-1 * var(--space-1)) var(--space-1) var(--space-3); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--radius-full); margin-right: var(--space-2); vertical-align: 1px; background: var(--tertiary); }
.dot.open { background: var(--chart-green); }
.trade-session { margin: var(--space-1) 0 0; }
.nowrap { white-space: nowrap; }
/* Exchange times: hover for the viewer's local time. */
.local-hint { position: relative; text-decoration: underline dotted; text-decoration-color: var(--tertiary); text-underline-offset: 2px; cursor: help; }
/* Instant hint (the browser's own title tooltip waits about a second). Shows on hover, tap or keyboard focus. */
.local-hint:is(:hover, :focus)::after {
  content: attr(data-hint); position: absolute; bottom: calc(100% + var(--space-1)); left: 50%; transform: translateX(-50%);
  z-index: 10; white-space: nowrap; pointer-events: none;
  padding: var(--space-1) var(--space-2); border-radius: var(--radius-s);
  background: var(--text); color: var(--bg); font-size: var(--font-caption); font-weight: var(--weight-medium);
  box-shadow: var(--shadow-overlay);
}
.local-hint:focus { outline: none; }
.local-hint:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.price { font-size: var(--font-large-title); font-weight: var(--weight-semibold); letter-spacing: -0.02em; }
.stock-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.chart-card { padding: var(--space-3) var(--space-3) var(--space-4); }
.chart { height: 260px; }
.chart-card .segmented { margin-top: var(--space-2); }

/* Stock page tabs: stick under the header while the page scrolls. */
.stock-tabs {
  position: sticky; top: 52px; z-index: 15;
  display: flex; gap: var(--space-5); margin-top: var(--space-5);
  background: var(--bg); border-bottom: .5px solid var(--separator);
}
.stock-tabs button {
  position: relative; flex: 0 1 auto; min-width: 0; padding: var(--space-3) 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: var(--font-headline); font-weight: var(--weight-medium); color: var(--secondary);
  transition: color var(--duration-fast);
}
.stock-tabs button:hover { color: var(--text); }
.stock-tabs button.on { color: var(--text); }
.stock-tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: var(--radius-full); background: var(--accent); }
.stock-panel > .group:first-child { margin-top: var(--space-5); }

/* Key statistics: two ranges with today's price marked, then label/value pairs. */
.key-stats { display: grid; gap: var(--space-4); }
.ks-range { display: grid; gap: var(--space-2); }
.ks-range-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline; gap: var(--space-2); }
.ks-range-head .ks-num { font-weight: var(--weight-semibold); white-space: nowrap; }
.ks-range-head .ks-num:last-child { text-align: right; }
.ks-label { color: var(--secondary); font-size: var(--font-footnote); text-align: center; }
.ks-track { position: relative; height: 6px; border-radius: var(--radius-full); background: var(--fill-strong); }
.ks-pos { position: absolute; left: 0; top: 0; bottom: 0; }
.ks-pos::after {
  content: ""; position: absolute; right: -7px; top: -4px; width: 14px; height: 14px;
  border-radius: var(--radius-full); background: var(--text); box-shadow: 0 0 0 2px var(--card);
}
.ks-grid { display: grid; grid-template-columns: repeat(2, 1fr); column-gap: var(--space-5); margin: 0; }
.ks-cell { padding: var(--space-3) 0; border-bottom: 1px dashed var(--separator); }
.ks-cell dt { color: var(--secondary); font-size: var(--font-footnote); }
.ks-cell dd { margin: var(--space-1) 0 0; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }

.glance { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
.tile { background: var(--card); border: var(--border-surface); border-radius: var(--radius-l); padding: var(--space-4) var(--space-4); box-shadow: var(--shadow-card); }
.tile .q-title { color: var(--secondary); font-size: var(--font-footnote); font-weight: var(--weight-medium); }
.tile .answer { font-size: var(--font-title); font-weight: var(--weight-semibold); margin: var(--space-1) 0 var(--space-1); letter-spacing: -0.02em; }
.tile .explain { color: var(--secondary); font-size: var(--font-body); line-height: 1.4; }
.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.clamp.open { -webkit-line-clamp: unset; }
#st-about { color: var(--text); }

.check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--font-footnote); color: var(--secondary); }
.check input { width: auto; }
.plain-list { margin: var(--space-4) 0 0; padding-left: var(--space-4); }
.plain-list li { margin-bottom: var(--space-1); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-3); align-content: start; }
.form-grid.single { grid-template-columns: 1fr; gap: var(--space-4); margin: var(--space-4) 0 var(--space-5); }
.form-grid label { display: grid; gap: var(--space-1); font-size: var(--font-footnote); color: var(--secondary); }
.form-grid label.check { display: inline-flex; gap: var(--space-2); }
.form-grid .secondary-btn { grid-column: 1 / -1; justify-self: start; }

/* ---------- sheets ---------- */
dialog.sheet {
  border: var(--border-surface); padding: 0; background: var(--elevated); color: var(--text);
  width: min(440px, calc(100vw - 24px)); border-radius: var(--radius-l); box-shadow: var(--shadow-overlay);
  max-height: calc(100vh - 40px);
}
dialog.sheet[open] { animation: sheet-in var(--duration-base) var(--ease); }
dialog.sheet::backdrop { background: var(--backdrop); animation: fade var(--duration-fast); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
/* Closing (app.js keeps the sheet open until this ends): the way it came in, backwards. */
dialog.sheet.closing { animation: sheet-out var(--duration-base) var(--ease) forwards; pointer-events: none; }
dialog.sheet.closing::backdrop { animation: backdrop-out var(--duration-base) var(--ease) forwards; }
@keyframes sheet-out { to { opacity: 0; transform: translateY(24px) scale(.98); } }
@keyframes backdrop-out { to { opacity: 0; } }
/* A sheet is open: the page behind it doesn't scroll. */
html:has(dialog.sheet[open]) { overflow: hidden; }
dialog.sheet form { padding: var(--space-4) var(--space-5) var(--space-5); display: grid; gap: var(--space-4); }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: var(--space-1); }
.sheet-head h2 { font-size: var(--font-headline); }
.sheet-head .text-btn { justify-self: start; }
.big-input { font-size: var(--font-title); font-weight: var(--weight-semibold); text-transform: uppercase; padding: var(--space-3) var(--space-4); }
.big-input::placeholder { text-transform: none; font-weight: var(--weight-regular); }
.qty-row { display: flex; align-items: center; gap: var(--space-3); }
.qty-input { font-size: var(--font-large-title); font-weight: var(--weight-semibold); padding: var(--space-2) var(--space-4); letter-spacing: -0.02em; }
.preview { color: var(--secondary); font-size: var(--font-body); min-height: 2.8em; }
.preview b { color: var(--text); font-weight: var(--weight-semibold); }
#targets-list .row { padding: var(--space-3) var(--space-4); }
#targets-list input { width: 84px; text-align: right; padding: var(--space-2) var(--space-3); }
.sum-row { display: flex; justify-content: space-between; font-weight: var(--weight-semibold); padding: 0 var(--space-1); }
.band-row { display: block; color: var(--secondary); font-size: var(--font-body); line-height: 2; }
.band-row input { width: 56px; display: inline-block; padding: var(--space-1) var(--space-2); text-align: center; }

/* ---------- popover & toast ---------- */
.popover {
  position: fixed; z-index: 60; width: min(320px, calc(100vw - 24px));
  background: var(--elevated); border-radius: var(--radius-l); box-shadow: var(--shadow-overlay); border: var(--border-surface);
  padding: var(--space-4) var(--space-4); font-size: var(--font-body); line-height: 1.45;
}
.popover h3 { font-size: var(--font-headline); margin-bottom: var(--space-2); }
.popover p + p { margin-top: var(--space-2); }
.popover .lbl { font-weight: var(--weight-semibold); }
/* Toast: centred, as wide as its text up to a readable line, then wrapping into a
   rounded card (a pill only works for one line). */
.toast {
  position: fixed; left: 0; right: 0; bottom: 28px; margin: 0 auto; width: fit-content; max-width: min(440px, calc(100vw - 32px));
  display: flex; align-items: center; justify-content: center; gap: var(--space-3);
  background: var(--text); color: var(--bg); padding: var(--space-3) var(--space-5); border-radius: var(--radius-l);
  font-size: var(--font-body); font-weight: var(--weight-medium); line-height: 1.35; text-align: center;
  z-index: 70; box-shadow: var(--shadow-overlay);
}
.toast:popover-open { animation: toast-in var(--duration-base) var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  .stock-tabs { top: calc(52px + env(safe-area-inset-top)); gap: var(--space-3); }
  .stock-tabs button { font-size: var(--font-body); }
  .bar { gap: var(--space-3); padding: env(safe-area-inset-top) max(var(--space-4), env(safe-area-inset-right)) 0 max(var(--space-4), env(safe-area-inset-left)); height: calc(52px + env(safe-area-inset-top)); }
  .tabs { margin: 0; }
  .bar-actions { margin-left: auto; }
  main { padding: var(--space-4) max(var(--space-4), env(safe-area-inset-right)) calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--space-6)) max(var(--space-4), env(safe-area-inset-left)); }
  .glance { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .row { padding: var(--space-3) var(--space-4); }
  .row + .row::before { left: 66px; }
  dialog.sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--radius-l) var(--radius-l) 0 0; max-height: 92vh; }
}

.row[data-href], .row[data-edit] { cursor: pointer; }
.row[data-href]:hover, .row[data-edit]:hover { background: var(--fill); }
.row .text-btn { flex: none; }

input::-webkit-calendar-picker-indicator { display: none !important; }
.attribution { margin: var(--space-3) var(--space-1) 0; }
.form-grid label > span { display: inline-flex; align-items: center; gap: var(--space-1); }

/* ---------- learn ---------- */
.progress-card { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); }
.progress-card > div { flex: 1; }
.today-title { margin: var(--space-1) 0; font-size: var(--font-headline); font-weight: var(--weight-semibold); }
.today-summary { color: var(--secondary); font-size: var(--font-footnote); }
.today-lesson .progress { margin-top: var(--space-3); }
.today-know { margin: var(--space-3) 0 0; }
.today-know .text-btn { padding: 0; }
.quote-more { justify-self: start; margin-top: calc(var(--space-2) * -1); padding-left: 0; }
/* On Today the streak card shows the run, so the top bar's flame steps aside. */
body.on-today .bar-streak { display: none; }
.progress { height: 6px; background: var(--fill); border-radius: var(--radius-full); overflow: hidden; margin-top: var(--space-3); max-width: 360px; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: var(--radius-full); transition: width var(--duration-base); }
.step-num { width: 32px; height: 32px; border-radius: var(--radius-full); display: grid; place-items: center; flex: none; background: var(--fill); color: var(--secondary); font-weight: var(--weight-semibold); font-size: var(--font-footnote); }
.step-num.done { background: var(--accent-soft); color: var(--accent); }
.step-num.next { background: var(--accent); color: var(--on-accent); }
.row + .row.lesson-row::before { left: 66px; }


/* questionnaire */
.question { display: grid; gap: var(--space-3); }
.question h3 { font-size: var(--font-title); line-height: 1.3; margin: var(--space-1) 0 var(--space-2); }
.choice { display: block; width: 100%; text-align: left; padding: var(--space-4) var(--space-4); border-radius: var(--radius-control); background: var(--control-bg); border: var(--control-border); color: var(--text); font-size: var(--font-body); }
.choice small { display: block; color: var(--secondary); font-size: var(--font-footnote); margin-top: var(--space-1); }
.choice:hover { background: var(--fill-strong); }
.dots { display: flex; justify-content: center; gap: var(--space-2); margin-top: var(--space-1); }
.dots i { width: 6px; height: 6px; border-radius: var(--radius-full); background: var(--fill-strong); }
.dots i.on { background: var(--accent); }
/* onboarding survey (onboarding.js): the saved answer is marked when the survey is reopened */
.survey .choice.on { box-shadow: inset 0 0 0 2px var(--accent); }
.survey h3 + .footnote { margin: calc(-1 * var(--space-2)) 0 0; }
.welcome-paths { display: grid; gap: var(--space-3); }
.about-summary { margin: 0 0 var(--space-2); color: var(--text); font-size: var(--font-body); }
#people-who:not(:empty) { margin-bottom: var(--space-6); } /* /admin → People: "Who joined" above the list */
.notice { background: var(--accent-soft); border-radius: var(--radius-m); padding: var(--space-3) var(--space-4); font-size: var(--font-body); }
.notice.warn-bg { background: color-mix(in srgb, var(--orange) 14%, transparent); }
.why-list { margin: var(--space-1) 0 0; padding-left: var(--space-4); color: var(--secondary); font-size: var(--font-body); }
.why-list li { margin-bottom: var(--space-1); }

/* lesson page */
.lesson { max-width: 640px; margin: 0 auto; }
.back { display: inline-block; margin-bottom: var(--space-4); font-size: var(--font-body); }
.lesson h1 { font-size: var(--font-large-title); margin: var(--space-2) 0 var(--space-3); }
.lede { font-size: var(--font-headline); color: var(--secondary); line-height: 1.45; }
/* ---------- lesson videos (lesson-video.js) ---------- */
/* Video is always shown on black, in every theme, like any video player. */
:root {
  --video-bg: #000000;
  --video-fg: #ffffff;
  --video-scrim: rgba(0, 0, 0, 0.6);
  --video-control-bg: rgba(0, 0, 0, 0.45);
  --video-track: rgba(255, 255, 255, 0.3);
  --video-buffered: rgba(255, 255, 255, 0.55);
  --video-progress-soft: rgba(255, 255, 255, 0.8);   /* the phone player's played line: quiet, not the accent */
  --video-menu-bg: rgba(44, 44, 46, 0.72);   /* frosted, like the Apple TV app's menus */
  --video-menu-edge: rgba(255, 255, 255, 0.12);
  --video-highlight: #0a84ff;
}
.lesson-video { margin: var(--space-4) 0; }
/* Desktop: a YouTube-style thumbnail, then the player in the same 16:9 frame. */
.lesson-video.lv-thumb, .lesson-video.lv-player { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-l); overflow: hidden; background: var(--video-bg); box-shadow: var(--shadow-card); }
.lesson-video.lv-player:has(.vp.full) { border-radius: 0; }
.video-thumb { position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.video-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.video-thumb-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 68px; height: 68px; border-radius: var(--radius-full); background: var(--video-control-bg); color: var(--video-fg); transition: background var(--duration-fast), color var(--duration-fast); }
.video-thumb-play .icon { width: 28px; height: 28px; }
.video-thumb:hover .video-thumb-play, .video-thumb:focus-visible .video-thumb-play { background: var(--accent); color: var(--on-accent); }
.video-chip { position: absolute; right: var(--space-2); bottom: var(--space-3); padding: var(--space-1) var(--space-2); border-radius: var(--radius-s); background: var(--video-scrim); color: var(--video-fg); font-size: var(--font-caption); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }
.video-watched-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--accent); }
/* Phones: a compact 9:16 tile beside its label; the player opens full screen. */
.video-tile { display: flex; align-items: center; gap: var(--space-4); width: 100%; padding: var(--space-3); border: 0; border-radius: var(--radius-l); background: var(--card); box-shadow: var(--shadow-card); color: var(--text); text-align: start; cursor: pointer; }
.video-tile-img { flex: none; width: 34%; max-width: 140px; aspect-ratio: 9 / 16; border-radius: var(--radius-m); overflow: hidden; background: var(--video-bg); }
.video-tile-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.video-tile-text { display: grid; gap: var(--space-1); }
.video-tile-label { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--accent); font-size: var(--font-headline); font-weight: var(--weight-semibold); }
.video-tile-label .icon { width: 14px; height: 14px; }
.video-tile-hint { color: var(--secondary); font-size: var(--font-footnote); }

/* The players */
.vp { position: relative; width: 100%; height: 100%; overflow: hidden; background: var(--video-bg); color: var(--video-fg); }
.vp video { display: block; width: 100%; height: 100%; object-fit: contain; }
.vp:focus-visible { outline-offset: -2px; }
.vp-btn { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--radius-full); background: none; color: var(--video-fg); cursor: pointer; transition: background var(--duration-fast); }
.vp-btn .icon { width: 22px; height: 22px; }
.vp-btn:hover { background: var(--video-control-bg); }
.vp-btn:focus-visible { outline-color: var(--video-fg); }
.vp-spinner { position: absolute; inset: 0; z-index: 2; width: 44px; height: 44px; margin: auto; border: 3px solid var(--video-track); border-top-color: var(--video-fg); border-radius: var(--radius-full); animation: vp-spin calc(var(--duration-base) * 3) linear infinite; pointer-events: none; }
@keyframes vp-spin { to { transform: rotate(360deg); } }
.vp-end, .vp-error { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); padding: var(--space-4); background: var(--video-scrim); text-align: center; }
.vp-error p { font-size: var(--font-body); }
.vp .secondary-btn { border: 0; background: var(--video-control-bg); color: var(--video-fg); }
.vp .secondary-btn:hover { background: var(--video-scrim); }
.vp .secondary-btn:focus-visible { outline-color: var(--video-fg); }
.vp.vp-desk .vp-end, .vp.vp-desk .vp-error { bottom: 56px; background: none; }
.vp.vp-desk.ended video, .vp.vp-desk:has(.vp-error:not([hidden])) video { opacity: .35; }

/* Seek bar: a 4px track (thin 3px line on phones) in a taller hit area. */
.vp-seek { position: relative; height: 16px; cursor: pointer; touch-action: none; }
.vp-seek::before, .vp-buffered, .vp-played { content: ""; position: absolute; left: 0; top: 50%; height: 4px; transform: translateY(-50%); border-radius: var(--radius-full); }
.vp-seek::before { right: 0; background: var(--video-track); }
.vp-buffered { width: 0; background: var(--video-buffered); }
.vp-played { width: 0; background: var(--accent); }
.vp-knob { position: absolute; top: 50%; left: 0; width: 13px; height: 13px; border-radius: var(--radius-full); background: var(--accent); transform: translate(-50%, -50%) scale(0); transition: transform var(--duration-fast); }
.vp-seek:hover .vp-knob, .vp-seek.dragging .vp-knob, .vp-seek:focus-visible .vp-knob { transform: translate(-50%, -50%) scale(1); }
.vp-seek:focus-visible { outline-color: var(--video-fg); }

/* Desktop bar, shown on hover and while paused, hidden after a still moment of playback. */
.vp-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: var(--space-6) var(--space-3) var(--space-1); background: linear-gradient(to top, var(--video-scrim), transparent); transition: opacity var(--duration-base); }
.vp-desk.idle .vp-bar { opacity: 0; pointer-events: none; } /* hidden controls can't be clicked; moving the mouse shows them */
.vp-desk.idle { cursor: none; }
.vp-row { display: flex; align-items: center; gap: var(--space-1); }
.vp-time { padding: 0 var(--space-2); font-size: var(--font-footnote); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vp-spacer { flex: 1; }
/* Volume: our own slider, so muted is at the very left and 100% fills it (lesson-video.js: wireVolume). */
.vp-volume { position: relative; flex: none; width: 80px; height: 24px; margin: 0 var(--space-2); cursor: pointer; touch-action: none; }
.vp-volume::before, .vp-volume-fill { content: ""; position: absolute; left: 0; top: 50%; height: 4px; transform: translateY(-50%); border-radius: var(--radius-full); }
.vp-volume::before { right: 0; background: var(--video-track); }
.vp-volume-fill { width: 0; background: var(--video-fg); }
.vp-volume-knob { position: absolute; top: 50%; left: 0; width: 12px; height: 12px; border-radius: var(--radius-full); background: var(--video-fg); transform: translate(-50%, -50%); }
.vp-volume:focus-visible { outline-color: var(--video-fg); }
.vp-speed-wrap { position: relative; }
.vp-btn.vp-speed { width: auto; min-width: 48px; padding: 0 var(--space-3); border-radius: var(--radius-button); font-size: var(--font-footnote); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
/* Speed menu, Apple TV-style: a frosted panel, a check column, the row in reach filled blue. */
.vp-menu { position: absolute; right: 0; bottom: 48px; display: grid; gap: var(--space-1); min-width: 136px; padding: var(--space-2); border: 1px solid var(--video-menu-edge); border-radius: var(--radius-l); background: var(--video-menu-bg); -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6); box-shadow: var(--shadow-overlay); }
.vp-menu button { display: grid; grid-template-columns: 24px auto; align-items: center; padding: var(--space-2) var(--space-4) var(--space-2) var(--space-2); border: 0; border-radius: var(--radius-m); background: none; color: var(--video-fg); font-size: var(--font-headline); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; text-align: start; cursor: pointer; }
.vp-menu button:hover, .vp-menu button:focus-visible { background: var(--video-highlight); outline: none; }
.vp-check { visibility: hidden; font-weight: var(--weight-semibold); }
.vp-menu [aria-checked="true"] .vp-check { visibility: visible; }
.vp.full video { object-fit: contain; }

/* Phones: full screen over everything, Shorts-style. */
.vp-lock, .vp-lock body { overflow: hidden; background: var(--video-bg); }
.vp.vp-shorts { position: fixed; inset: 0; z-index: 80; width: auto; height: auto; transition: transform var(--duration-base) var(--ease); }
.vp-shorts.dragging { transition: none; }
.vp-touch { position: absolute; inset: 0; z-index: 1; touch-action: none; }
.vp-top { position: absolute; top: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: space-between; padding: var(--space-3); padding-top: max(var(--space-3), env(safe-area-inset-top)); background: linear-gradient(var(--video-scrim), transparent); }
.vp-shorts .vp-btn { background: var(--video-control-bg); }
.vp-top-end { display: flex; align-items: center; gap: var(--space-2); }
/* On phones the speed menu drops down from the top row. */
.vp-shorts .vp-menu { top: 48px; bottom: auto; }
.vp-info { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: var(--space-7) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--video-scrim)); pointer-events: none; }
.vp-title { font-size: var(--font-headline); font-weight: var(--weight-semibold); }
.vp-sub { margin-top: var(--space-1); font-size: var(--font-footnote); opacity: .85; }
.vp-seek.vp-thin { position: absolute; left: 0; right: 0; bottom: env(safe-area-inset-bottom); z-index: 3; height: 28px; }
.vp-thin::before, .vp-thin .vp-buffered, .vp-thin .vp-played { top: auto; bottom: 0; height: 3px; transform: none; border-radius: 0; }
.vp-thin.dragging::before, .vp-thin.dragging .vp-buffered, .vp-thin.dragging .vp-played { height: 6px; }
.vp-thin .vp-played { background: var(--video-progress-soft); }
.vp-thin .vp-buffered { display: none; }
.vp-shorts.ended .vp-info, .vp-shorts.ended .vp-thin { visibility: hidden; }
.vp-flash { position: absolute; left: 50%; top: 50%; z-index: 2; display: grid; place-items: center; min-width: 72px; height: 72px; padding: 0 var(--space-4); border-radius: var(--radius-full); background: var(--video-control-bg); font-size: var(--font-headline); font-weight: var(--weight-semibold); opacity: 0; transform: translate(-50%, -50%); pointer-events: none; }
.vp-flash .icon { width: 32px; height: 32px; }
.vp-flash.left { left: 20%; }
.vp-flash.right { left: 80%; }
.vp-flash.on { animation: vp-flash calc(var(--duration-base) * 3) var(--ease) forwards; }
@keyframes vp-flash {
  from { opacity: 1; transform: translate(-50%, -50%) scale(.9); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .vp-flash.on { animation: none; opacity: 1; }
  .vp.vp-shorts, .vp-bar, .vp-knob, .video-thumb-play { transition: none; }
  .vp-spinner { animation-duration: calc(var(--duration-base) * 8); }
}
/* ---------- the landing page's intro video (landing.js → renderIntroVideo) ----------
   Its own poster card, the full width of the landing column like the sections around it; 9:16 and
   centred on phones held upright. A tap swaps in a plain <video> with the browser's controls. */
.landing-intro { position: relative; margin: var(--space-6) 0 var(--space-5); aspect-ratio: 16 / 9; border-radius: var(--radius-l); overflow: hidden; background: var(--video-bg); box-shadow: var(--shadow-card); }
.landing-intro.vertical { aspect-ratio: 9 / 16; width: min(100%, 70vh * 9 / 16); width: min(100%, 70svh * 9 / 16); margin-inline: auto; }
.landing-intro img, .landing-intro video { display: block; width: 100%; height: 100%; object-fit: cover; }
.intro-poster { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
/* One large round play button in the middle, accent-filled like the page's main action. */
.intro-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 88px; height: 88px; border-radius: var(--radius-full); background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-overlay); transition: transform var(--duration-fast) var(--ease); }
.intro-play .icon { width: 34px; height: 34px; transform: translateX(3px); } /* the triangle's weight sits left of its box */
.intro-poster:hover .intro-play { transform: translate(-50%, -50%) scale(1.06); }
.lesson-body { margin-top: var(--space-5); font-size: var(--font-headline); line-height: 1.6; }
.lesson-body p + p { margin-top: var(--space-4); }
.takeaway { margin-top: var(--space-6); background: var(--card); box-shadow: var(--shadow-card); border-radius: var(--radius-l); padding: var(--space-4) var(--space-5); font-size: var(--font-body); }
.takeaway b { display: block; font-size: var(--font-footnote); color: var(--accent); margin-bottom: var(--space-1); letter-spacing: .02em; text-transform: uppercase; }
.try { margin-top: var(--space-4); }
.widget { margin-top: var(--space-5); }
.widget .controls { display: grid; gap: var(--space-4); }
.widget label { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-3); font-size: var(--font-body); color: var(--secondary); align-items: center; }
.widget label b { color: var(--text); font-weight: var(--weight-semibold); }
.widget input[type=range] { grid-column: 1 / -1; padding: 0; background: none; accent-color: var(--accent); }
.widget .out { display: flex; gap: var(--space-5); flex-wrap: wrap; margin-top: var(--space-4); padding-top: var(--space-4); border-top: .5px solid var(--separator); }
.widget .out div { font-size: var(--font-footnote); color: var(--secondary); }
.widget .out b { display: block; font-size: var(--font-title); color: var(--text); letter-spacing: -0.02em; }
.split { display: flex; height: 10px; border-radius: var(--radius-full); overflow: hidden; margin-top: var(--space-4); background: var(--fill); }
.split span { height: 100%; }

.qcard { margin-bottom: var(--space-3); }
.starter-card { display: grid; gap: var(--space-4); justify-items: start; }
.starter-card > form, form.starter-card { justify-items: stretch; }
.starter-q { margin: 0; font-size: var(--font-headline); font-weight: var(--weight-semibold); }
.starter-guess { display: grid; gap: var(--space-2); }
.starter-guess.qcard { margin-bottom: 0; }
.starter-guess .choice.on { box-shadow: inset 0 0 0 2px var(--accent); }
.starter-answer { margin: 0 0 var(--space-2); font-size: var(--font-title); font-weight: var(--weight-semibold); }
.starter-reveal p:last-child, .starter-card p { margin: 0; }
/* The optional first name on the public page, under the guess. */
.starter-name { display: grid; gap: var(--space-1); color: var(--secondary); font-size: var(--font-footnote); }
/* An answer that arrived since Today was last opened. */
.new-tag { margin-inline-end: var(--space-2); padding: 0 var(--space-2); border-radius: var(--radius-full); background: var(--accent-soft); color: var(--accent); font-size: var(--font-caption); font-weight: var(--weight-semibold); }
/* "Copy link" sits under a sent starter's lines, so the question keeps the full width. */
.row .sent-copy { display: block; margin-top: var(--space-1); font-size: var(--font-footnote); }
/* The dot on the Today tab while such an answer is waiting. */
.tab-dot { display: inline-block; width: 8px; height: 8px; flex: none; border-radius: var(--radius-full); background: var(--red); }
.starter-page .card { margin-top: var(--space-5); }
.starter-page .card h2 { margin: 0; }
.starter-page .error:empty { display: none; }
/* A glossary term's public page (static/term.html): the entry as the glossary shows it,
   then one next step and the languages it's in. */
.term-card .term-name { margin: var(--space-1) 0 var(--space-3); font-size: var(--font-title); }
.term-body p { margin: 0 0 var(--space-3); }
.term-body p:last-child { margin-bottom: 0; }
.term-body .lbl { font-weight: var(--weight-semibold); }
.term-page a.primary.large { display: block; text-align: center; box-sizing: border-box; }
.term-langs { margin-top: var(--space-5); text-align: center; }
.term-langs [aria-current] { color: var(--text); font-weight: var(--weight-medium); }
/* A lesson video's public page (static/video.html): the plain browser player, 16:9 like the app's. */
.vpage-summary { margin: 0 0 var(--space-4); color: var(--secondary); }
.vpage-video { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-m); background: var(--video-bg); }
.vpage-missing .notice { margin: 0 0 var(--space-2); }
.vpage-elsewhere { margin: 0; }
/* "Share" under a lesson's video card (lesson-video.js), the same icon as everywhere. */
.lv-share { margin: calc(-1 * var(--space-2)) 0 var(--space-3) -6px; }
.lv-share .icon { width: 22px; height: 22px; }
.vp-end .vp-share { color: inherit; }
.vp-end .vp-share .icon { width: 22px; height: 22px; }
/* "Share" under a glossary entry, in its "?" card and on the glossary page. */
/* The icon sits on the text's left edge; the round hover area reaches past it, as on the quote card. */
.gloss-share { margin: var(--space-1) 0 0 -6px; }
.gloss-share .icon { width: 22px; height: 22px; }
.locked-card p { margin: 0 0 var(--space-3); color: var(--secondary); }
.locked-actions { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
/* A unit's review (app.js → openReview): the unit, what passing takes, the questions, the result. */
.review-unit { margin: 0 0 var(--space-1); }
.review-intro { margin: 0 0 var(--space-3); }
.review-result p { margin: 0 0 var(--space-4); }
.qcard .q-text { font-weight: var(--weight-semibold); font-size: var(--font-headline); margin-bottom: var(--space-3); }
.qcard .choice { margin-top: var(--space-2); position: relative; }
.qcard .choice.right { background: var(--green-soft); color: var(--green); font-weight: var(--weight-semibold); }
.qcard .choice.wrong { background: var(--red-soft); color: var(--red); }
.qcard .choice:disabled { opacity: 1; cursor: default; }
.qcard .explain { margin-top: var(--space-3); font-size: var(--font-body); color: var(--secondary); }
/* Step-by-step lessons (app.js: renderSteps, renderQuestion). */
.lesson-step { margin-top: var(--space-6); }
/* "Step 3 of 5" with a small bar of segments, one per step, filled up to this one. */
.step-head { display: flex; align-items: center; gap: var(--space-3); }
.step-bar { display: flex; gap: var(--space-1); }
.step-bar i { width: 16px; height: 4px; border-radius: var(--radius-full); background: var(--fill-strong); }
.step-bar i.on { background: var(--accent); }
.lesson-step:first-child { margin-top: var(--space-4); }
.lesson-step > p { margin: var(--space-2) 0 var(--space-3); }
.step-next { display: block; margin: var(--space-4) auto 0; min-width: 160px; }
.qcard.pair .q-options { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.qcard.pair .q-options .choice { margin-top: 0; }
@media (max-width: 400px) { .qcard.pair .q-options { grid-template-columns: 1fr; } }
.qcard .choice .order-num { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: var(--space-2); border-radius: var(--radius-full); background: var(--fill-strong); font-weight: var(--weight-semibold); font-size: var(--font-footnote); vertical-align: middle; }
.qcard .choice .order-num:empty { background: transparent; box-shadow: inset 0 0 0 1px var(--separator); }
.qcard .choice.on { box-shadow: inset 0 0 0 2px var(--accent); }
.qcard .choice.on .order-num { background: var(--accent); color: var(--on-accent); }
.qcard .choice.shown { background: var(--fill); }
.lesson-done { margin-top: var(--space-5); text-align: center; }
.lesson-done .big-check { width: 56px; height: 56px; border-radius: var(--radius-full); background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: var(--font-title); margin: 0 auto var(--space-3); }
.lesson-done h2 { margin-bottom: var(--space-2); }
.lesson-done .primary { margin-top: var(--space-4); }
/* What comes next, in a line, above the button that opens it. */
.lesson-done .next-why { max-width: 46ch; margin: var(--space-5) auto 0; color: var(--secondary); }
.lesson-done .next-why + .primary { margin-top: var(--space-3); }
/* A unit's wrap-up after its last lesson: what you can do now, what's next, its review. */
.lesson-done .unit-wrap { display: grid; gap: var(--space-2); justify-items: start; margin-top: var(--space-5); text-align: left; }
.unit-wrap p { margin: 0; }
.unit-wrap .unit-can { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-1); }

/* Learn: a level's units, each a card with its picture, its question, what you'll be able to do
   after it, then its lessons (app.js → renderPath). */

/* A unit's picture (lessons.js → UNITS icon) beside its number and question, in both layouts
   and on the wrap-up once it's done: the accent once the unit is reached, neutral
   while it's ahead, so the path shows how far you've come (DESIGN.md → Icons). */
.unit-top { display: flex; align-items: center; gap: var(--space-3); }
.unit-top-text { flex: 1; min-width: 0; }
.unit-art { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: var(--radius-m); background: var(--fill); color: var(--secondary); }
.unit-art .icon { width: 28px; height: 28px; }
.unit-art.reached { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 640px) {
  .unit-art { width: 44px; height: 44px; }
  .unit-art .icon { width: 24px; height: 24px; }
}

/* Learn's two layouts, switched by two icons above the levels: tiles in unit cards, and lists. */
.learn-view-row { display: flex; justify-content: flex-end; margin: var(--space-5) var(--space-1) 0; }
.segmented.icons button { display: grid; place-items: center; padding: var(--space-1) var(--space-3); }
.segmented.icons .icon { width: 18px; height: 18px; }
.lt-dots { display: inline-flex; gap: var(--space-1); }
.lt-dots i { width: 6px; height: 6px; border-radius: var(--radius-full); background: var(--fill-strong); }
.lt-dots i.on { background: var(--accent); }
.lt-next { padding: 0 var(--space-2); border-radius: var(--radius-full); background: var(--accent); color: var(--on-accent); font-size: var(--font-caption); font-weight: var(--weight-semibold); line-height: 1.6; }
.lt-action { color: var(--accent); }

/* Blend: each unit a card (Khan) holding its lessons as tiles (EdClub): a big number, the
   lesson's kind in the middle (a ✓ once finished), its title under a line; the next lesson is
   ringed in the accent and the unit's review is the last tile. Inside the card the tiles sit
   on the page's own colour, so they don't read as cards in a card. */
.unit-blend { scroll-margin-top: 72px; }
.unit-blend + .unit-blend { margin-top: var(--space-3); }
.unit-blend h3 { margin-top: var(--space-1); font-size: var(--font-headline); }
.unit-blend > .footnote { margin: var(--space-3) 0 0; }
.ub-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); color: var(--secondary); font-size: var(--font-caption); font-weight: var(--weight-semibold); letter-spacing: .04em; text-transform: uppercase; }
.ub-state { display: inline-flex; align-items: center; gap: var(--space-1); font-weight: var(--weight-medium); letter-spacing: 0; text-transform: none; }
.unit-blend.done .ub-state { color: var(--accent); }
.lesson-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: var(--space-3); margin-top: var(--space-4); }
.lesson-tile { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; min-width: 0; min-height: 140px; padding: 0; background: var(--bg); border: none; border-radius: var(--radius-m); color: var(--text); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.lesson-tile:hover { box-shadow: inset 0 0 0 1px var(--separator); }
.lt-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-3) var(--space-3) 0; min-height: 34px; }
.lt-n { font-family: var(--font-family-display); font-size: var(--font-title); font-weight: var(--weight-semibold); line-height: 1; color: var(--secondary); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.lt-art { display: grid; place-items: center; min-height: 48px; color: var(--secondary); }
.lt-title { padding: var(--space-3) var(--space-2); border-top: .5px solid var(--separator); font-size: var(--font-footnote); text-align: center; line-height: 1.3; }
/* The cut to two lines sits on the words alone, so the padding around them can't show a third. */
.lt-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lesson-tile.done .lt-art { color: var(--accent); }
.lesson-tile.next { box-shadow: inset 0 0 0 2px var(--accent); }
.lesson-tile.next .lt-n { color: var(--accent); }
.review-tile { background: var(--fill); }
.review-tile .lt-n { font-family: var(--font-family-text); font-size: var(--font-caption); color: var(--secondary); letter-spacing: .02em; }
.review-tile .lt-art { color: var(--secondary); }
.review-tile .lt-title { border-top-color: var(--separator); font-weight: var(--weight-medium); }
/* Phones: two tiles a row, so a title fits on two lines (three at most, for a long translation). */
@media (max-width: 640px) {
  .lesson-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .lesson-tile { min-height: 128px; }
  .lt-art { min-height: 40px; }
  .lt-n { font-size: var(--font-headline); }
  .lt-title { padding: var(--space-2) var(--space-3); }
  .lt-name { -webkit-line-clamp: 3; }
}

/* After Khan Academy: in both layouts the units go down the side on wide screens, in words only;
   List makes each unit a card listing its lessons in two columns, the lesson's kind in a small
   box (a ✓ once finished). */
.learn-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); margin-top: var(--space-3); }
.unit-index { display: none; }
.unit-cards .level + .level { margin-top: var(--space-6); }
.unit-card { scroll-margin-top: 72px; }
.unit-card + .unit-card { margin-top: var(--space-4); }
.unit-card h3 { font-size: var(--font-headline); }
.unit-card-line { margin: var(--space-3) 0; padding-bottom: var(--space-3); border-bottom: .5px solid var(--separator); }
.unit-card-lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-1) var(--space-5); }
.lesson-item { display: flex; align-items: center; gap: var(--space-3); min-width: 0; padding: var(--space-2) 0; color: var(--text); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.lesson-item:hover .li-title { color: var(--accent); }
.li-icon { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: var(--radius-s); box-shadow: inset 0 0 0 1px var(--separator); color: var(--secondary); }
.lesson-item.done .li-icon { background: var(--accent-soft); box-shadow: none; color: var(--accent); }
.lesson-item.passed .li-icon { background: var(--fill); box-shadow: none; }
.lesson-item.next .li-icon { background: var(--accent); box-shadow: none; color: var(--on-accent); }
.lesson-item.next .li-title { font-weight: var(--weight-semibold); }
.li-title { flex: 1; min-width: 0; font-size: var(--font-body); }
.li-meta { flex: none; color: var(--secondary); font-size: var(--font-caption); }
.review-item .li-title { color: var(--secondary); }
.review-item .li-meta { color: var(--accent); }
@media (min-width: 900px) {
  .learn-split { grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
  .unit-index { position: sticky; top: 68px; display: grid; max-height: calc(100vh - 88px); overflow-y: auto; padding-bottom: var(--space-5); }
}
@media (min-width: 1140px) {
  main:has(#view-learn:not([hidden]) .learn-split) { max-width: 1080px; }
  .learn-split { grid-template-columns: 260px minmax(0, 1fr); }
}
/* The unit index, after Khan Academy's course page: each level's name and how many units it has,
   then its units as rows split by hairlines, "UNIT 1" small over the question. The current unit
   is tinted, with an accent edge on its left. */
.unit-index-level { margin-top: var(--space-5); padding: 0 var(--space-3) var(--space-3); border-bottom: .5px solid var(--separator); }
.unit-index-level:first-child { margin-top: 0; }
.uil-name { margin: 0; font-weight: var(--weight-semibold); }
.uil-count { margin: 0; color: var(--secondary); font-size: var(--font-caption); font-weight: var(--weight-semibold); letter-spacing: .04em; text-transform: uppercase; }
.unit-index-item { display: grid; gap: var(--space-1); width: 100%; padding: var(--space-3); border-bottom: .5px solid var(--separator); color: var(--text); font: inherit; text-align: left; }
.unit-index-item:hover { background: var(--fill); }
.unit-index-item.current { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.ui-n { color: var(--secondary); font-size: var(--font-caption); font-weight: var(--weight-semibold); letter-spacing: .04em; text-transform: uppercase; }
.ui-q { line-height: 1.35; }

/* The warm-up that opens a lesson: a question on the idea it builds on, or a link to it. */
.warmup { margin-top: var(--space-5); }
.warmup > .eyebrow { margin: 0 var(--space-1) var(--space-2); }
.warmup-link p { margin: 0 0 var(--space-2); }
.warmup .qcard { margin-bottom: 0; }

/* A lesson term that opens its glossary card (CONTENT.md → Terms): semibold where the lesson
   teaches it, plain where it's met again; the dotted line says it can be tapped. */
.q.term { display: inline; width: auto; height: auto; margin: 0; padding: 0; border-radius: 0; background: none; color: inherit; font: inherit; vertical-align: baseline; line-height: inherit; text-decoration: underline dotted var(--tertiary); text-underline-offset: 4px; cursor: pointer; }
.q.term.taught { font-weight: var(--weight-semibold); }
.q.term::before { inset: calc(-1 * var(--space-1)); } /* the "?"'s larger tap area would reach the lines around */
.q.term:hover { background: none; color: var(--accent); text-decoration-color: var(--accent); }
@media (max-width: 640px) { .tabs a { padding: var(--space-2) var(--space-3); } }

/* allocation donut */
#alloc-view { margin-bottom: var(--space-2); }
.donut-wrap { display: grid; place-items: center; padding: var(--space-4) 0 var(--space-3); position: relative; }
.donut-wrap svg { width: 210px; height: 210px; transform: rotate(-90deg); }
.donut-wrap circle { fill: none; transition: stroke-dasharray var(--duration-base) ease, stroke-dashoffset var(--duration-base) ease; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center b { display: block; font-size: var(--font-title); font-weight: var(--weight-semibold); letter-spacing: -0.02em; }
.donut-center span { color: var(--secondary); font-size: var(--font-footnote); }
.legend-list { display: grid; }
.legend-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-1); font-size: var(--font-body); }
.legend-row + .legend-row { border-top: .5px solid var(--separator); }
.legend-row i { width: 10px; height: 10px; border-radius: var(--radius-full); flex: none; }
.legend-row .lbl { flex: 1; font-weight: var(--weight-medium); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row .lbl small { color: var(--secondary); font-weight: var(--weight-regular); margin-left: var(--space-2); }
.legend-row .pct { font-weight: var(--weight-semibold); }
.legend-row .tgt { color: var(--secondary); font-size: var(--font-footnote); min-width: 64px; text-align: right; }
#alloc-note { margin-top: var(--space-2); }
.legend-list { grid-template-columns: minmax(0, 1fr); }
.legend-row .pct, .legend-row .tgt { flex: none; }

/* The popover and toast live in the top layer (Popover API); undo the
   browser's default [popover] centering, border and colors. */
.popover[popover] { inset: auto; margin: 0; border: none; color: var(--text); overflow: visible; }
.toast[popover] { inset: auto 0 28px 0; margin: 0 auto; border: none; overflow: visible; }

/* live result under fields that accept math, e.g. "20 × 150" */
.calc-result { min-height: 1.2em; font-size: var(--font-footnote); color: var(--secondary); }
.calc-result.ok { color: var(--accent); font-weight: var(--weight-medium); }
.calc-result.bad { color: var(--red); }

/* ticker autocomplete */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5;
  background: var(--elevated); border-radius: var(--radius-m); box-shadow: var(--shadow-overlay); border: var(--border-surface);
  padding: var(--space-2); max-height: 300px; overflow-y: auto;
}
.ac-item { display: flex; gap: var(--space-3); align-items: center; width: 100%; text-align: left; padding: var(--space-2) var(--space-3); border-radius: var(--radius-m); color: var(--text); }
.ac-item.on, .ac-item:hover { background: var(--fill); }
.ac-item .ticker-icon { width: 32px; height: 32px; border-radius: var(--radius-s); font-size: var(--font-caption); }
.ac-item .main { min-width: 0; flex: 1; }
.ac-item b { font-weight: var(--weight-semibold); font-size: var(--font-body); text-transform: none; }
.ac-item small { display: block; color: var(--secondary); font-size: var(--font-caption); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
input[data-ticker]:not(:placeholder-shown) { text-transform: uppercase; }
/* Larger screens: a sheet taller than the window scrolls. The two sheets with a ticker
   field (order, holding) are short forms and instead let their suggestion list extend
   past the sheet's edge. */
@media (min-width: 641px) {
  dialog.sheet { overflow-y: auto; overscroll-behavior: contain; }
  dialog.sheet:has(input[data-ticker]) { overflow: visible; }
}

/* Buy / Sell on practice holdings rows */
.row-actions { display: flex; gap: var(--space-2); flex: none; }
.mini { padding: var(--space-1) var(--space-3); border-radius: var(--radius-button); font-size: var(--font-footnote); font-weight: var(--weight-semibold); }
.mini.buy { background: var(--green-soft); color: var(--green); }
.mini.sell { background: var(--red-soft); color: var(--red); }
.mini:hover { filter: brightness(0.95); }
:root[data-mode="dark"] .mini:hover { filter: brightness(1.2); }
@media (max-width: 640px) {
  .row-actions { flex-direction: column; gap: var(--space-1); }
  .mini { padding: var(--space-1) var(--space-3); font-size: var(--font-caption); }
}

/* No spinner arrows on number fields (cleaner, and typing is easier anyway). */
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* settings */
.setting + .setting { margin-top: var(--space-5); }
.setting h3 { display: flex; align-items: center; gap: var(--space-2); margin: 0 var(--space-1) var(--space-3); color: var(--secondary); font-size: var(--font-footnote); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: .03em; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: var(--space-3); }
.theme-opt { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-1); border-radius: var(--radius-m); font-size: var(--font-footnote); font-weight: var(--weight-medium); color: var(--text); }
.theme-opt:hover { background: var(--fill); }
.theme-opt .sw { width: 54px; height: 54px; border-radius: var(--radius-full); position: relative; overflow: hidden; box-shadow: inset 0 0 0 1px var(--separator); }
.theme-opt .sw i { position: absolute; inset: 50% 0 0 0; }
.theme-opt.on .sw { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--accent); }
.theme-opt .check { display: none; color: var(--accent); margin-right: var(--space-1); }
.theme-opt.on .check { display: inline; }
.lang-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: var(--space-3); }
.theme-opt .sw.flag img { width: 100%; height: 100%; object-fit: cover; display: block; }
.theme-opt .sw.flag::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--separator); }
.auth-lang { display: flex; justify-content: center; margin-top: var(--space-4); }
.auth-lang select { width: auto; padding-top: var(--space-2); padding-bottom: var(--space-2); font-size: var(--font-footnote); }

/* ==========================================================================
   Crafted themes (Groundly, Harbor, Clay, Plum), light + dark.
   Each theme only defines --t-* tokens; the component rules below are shared.
   Groundly: exact values from groundly-theme.css. Harbor, Clay, Plum: generated
   with the same token relationships and contrast targets (see commit notes).
   --------------------------------------------------------------------------
   Groundly theme, light + dark.
   Source of truth: groundly-theme.css + groundly-theme-handoff.txt (light + dark).
   The handoff selects the mode with data-theme on <html>; this app already uses
   data-theme for the theme id, so the mode is data-mode (set by themes.js,
   before first paint, following Light / Dark / System).
   ========================================================================== */
:root[data-theme="groundly"] {
  /* Groundly role tokens, light (verbatim) */
  --t-bg: #F6F3EC;
  --t-surface: #FFFFFF;
  --t-surface-alt: #FCFAF6;
  --t-text: #202B27;
  --t-text-secondary: #53615A;
  --t-text-muted: #657167;
  --t-border: #DCDDD2;
  --t-border-strong: #7D897E;
  --t-primary: #24483F;
  --t-on-primary: #FFFFFF;
  --t-primary-hover: #1B3932;
  --t-primary-active: #142C26;
  --t-primary-soft: #E7EDE6;
  --t-accent-soft: #EDF1E9;
  --t-focus: #386F60;
  --t-selected-text: #24483F;
  --t-link: #24483F;
  --t-positive: #2F6B4F;
  --t-positive-bg: #E6F0E9;
  --t-negative: #A63D40;
  --t-negative-bg: #F8E8E7;
  --t-warning: #8A5A12;
  --t-warning-bg: #F8EED9;
  --t-info: #355C7D;
  --t-info-bg: #E8EFF5;
  --t-shadow: 0 2px 8px rgb(32 43 39 / 4%);
  /* Brand swatches (immutable) */
  --t-decor: #A9B8A4;
  /* App-specific: text on chart-colored icons, and the sheet backdrop */
  --t-on-series: #FFFFFF;
  --t-backdrop: rgb(32 43 39 / 30%);
  color-scheme: light;
}
:root[data-theme="groundly"][data-mode="dark"] {
  /* Groundly role tokens, dark (verbatim) */
  --t-bg: #121A17;
  --t-surface: #1B2621;
  --t-surface-alt: #233029;
  --t-text: #F2F1E9;
  --t-text-secondary: #BCC8BD;
  --t-text-muted: #9BAC9E;
  --t-border: #35473C;
  --t-border-strong: #6E8575;
  --t-primary: #A9C4AE;
  --t-on-primary: #14271C;
  --t-primary-hover: #BCD2BF;
  --t-primary-active: #93B39B;
  --t-primary-soft: #2B4034;
  --t-accent-soft: #28352C;
  --t-focus: #BDD8C1;
  --t-selected-text: #D9E8D8;
  --t-link: #BFD5C3;
  --t-positive: #9BCBA8;
  --t-positive-bg: #20382A;
  --t-negative: #F1AAA7;
  --t-negative-bg: #422A2B;
  --t-warning: #E3C27F;
  --t-warning-bg: #3C3320;
  --t-info: #ADCBDC;
  --t-info-bg: #253643;
  --t-shadow: 0 2px 8px rgb(0 0 0 / 14%);
  --t-on-series: #14271C;
  --t-backdrop: rgb(0 0 0 / 50%);
  color-scheme: dark;
}

:root[data-theme="harbor"] {
  /* Harbor, light */
  --t-bg: #EFF2F3;
  --t-surface: #FFFFFF;
  --t-surface-alt: #F9FAFB;
  --t-text: #21272C;
  --t-text-secondary: #525A60;
  --t-text-muted: #646C73;
  --t-border: #D4DADD;
  --t-border-strong: #747E86;
  --t-primary: #26455E;
  --t-on-primary: #FFFFFF;
  --t-primary-hover: #1F384C;
  --t-primary-active: #182B3A;
  --t-primary-soft: #E7EBEE;
  --t-accent-soft: #EDF0F2;
  --t-focus: #345774;
  --t-selected-text: #26455E;
  --t-link: #26455E;
  --t-positive: #2F6B4F;
  --t-positive-bg: #E6F0E9;
  --t-negative: #A63D40;
  --t-negative-bg: #F8E8E7;
  --t-warning: #8A5A12;
  --t-warning-bg: #F8EED9;
  --t-info: #355C7D;
  --t-info-bg: #E8EFF5;
  --t-shadow: 0 2px 8px rgb(0 0 0 / 4%);
  --t-on-series: #FFFFFF;
  --t-backdrop: rgb(0 0 0 / 30%);
  --t-decor: var(--t-border-strong);
  color-scheme: light;
}
:root[data-theme="harbor"][data-mode="dark"] {
  /* Harbor, dark */
  --t-bg: #12161A;
  --t-surface: #1B2025;
  --t-surface-alt: #23292F;
  --t-text: #E9EFF2;
  --t-text-secondary: #BCC2C8;
  --t-text-muted: #9BA4AB;
  --t-border: #343E46;
  --t-border-strong: #6C7984;
  --t-primary: #A6B9C9;
  --t-on-primary: #142029;
  --t-primary-hover: #B9C8D5;
  --t-primary-active: #92A8B9;
  --t-primary-soft: #2D3943;
  --t-accent-soft: #272F35;
  --t-focus: #BDCEDB;
  --t-selected-text: #D9E1E8;
  --t-link: #BFCDD9;
  --t-positive: #9BCBA8;
  --t-positive-bg: #20382A;
  --t-negative: #F1AAA7;
  --t-negative-bg: #422A2B;
  --t-warning: #E3C27F;
  --t-warning-bg: #3C3320;
  --t-info: #ADCBDC;
  --t-info-bg: #253643;
  --t-shadow: 0 2px 8px rgb(0 0 0 / 14%);
  --t-on-series: #142029;
  --t-backdrop: rgb(0 0 0 / 50%);
  --t-decor: var(--t-border-strong);
  color-scheme: dark;
}
:root[data-theme="clay"] {
  /* Clay, light */
  --t-bg: #F6F2EC;
  --t-surface: #FFFFFF;
  --t-surface-alt: #FCFAF8;
  --t-text: #2C2621;
  --t-text-secondary: #605952;
  --t-text-muted: #736B64;
  --t-border: #DDDAD4;
  --t-border-strong: #867C74;
  --t-primary: #5D4128;
  --t-on-primary: #FFFFFF;
  --t-primary-hover: #4B3420;
  --t-primary-active: #392818;
  --t-primary-soft: #EEEAE7;
  --t-accent-soft: #F2F0ED;
  --t-focus: #725236;
  --t-selected-text: #5D4128;
  --t-link: #5D4128;
  --t-positive: #2F6B4F;
  --t-positive-bg: #E6F0E9;
  --t-negative: #A63D40;
  --t-negative-bg: #F8E8E7;
  --t-warning: #8A5A12;
  --t-warning-bg: #F8EED9;
  --t-info: #355C7D;
  --t-info-bg: #E8EFF5;
  --t-shadow: 0 2px 8px rgb(0 0 0 / 4%);
  --t-on-series: #FFFFFF;
  --t-backdrop: rgb(0 0 0 / 30%);
  --t-decor: var(--t-border-strong);
  color-scheme: light;
}
:root[data-theme="clay"][data-mode="dark"] {
  /* Clay, dark */
  --t-bg: #1A1512;
  --t-surface: #25201B;
  --t-surface-alt: #2F2823;
  --t-text: #F2EEE9;
  --t-text-secondary: #C8C1BC;
  --t-text-muted: #ABA39B;
  --t-border: #463D34;
  --t-border-strong: #84776C;
  --t-primary: #C9B6A6;
  --t-on-primary: #291E14;
  --t-primary-hover: #D5C6B9;
  --t-primary-active: #B9A492;
  --t-primary-soft: #43372D;
  --t-accent-soft: #352D27;
  --t-focus: #DBCBBD;
  --t-selected-text: #E8E0D9;
  --t-link: #D9CBBF;
  --t-positive: #9BCBA8;
  --t-positive-bg: #20382A;
  --t-negative: #F1AAA7;
  --t-negative-bg: #422A2B;
  --t-warning: #E3C27F;
  --t-warning-bg: #3C3320;
  --t-info: #ADCBDC;
  --t-info-bg: #253643;
  --t-shadow: 0 2px 8px rgb(0 0 0 / 14%);
  --t-on-series: #291E14;
  --t-backdrop: rgb(0 0 0 / 50%);
  --t-decor: var(--t-border-strong);
  color-scheme: dark;
}
:root[data-theme="plum"] {
  /* Plum, light */
  --t-bg: #F3EFF3;
  --t-surface: #FFFFFF;
  --t-surface-alt: #FBF9FB;
  --t-text: #29212C;
  --t-text-secondary: #5C5260;
  --t-text-muted: #6E6473;
  --t-border: #DDD4DD;
  --t-border-strong: #807486;
  --t-primary: #493252;
  --t-on-primary: #FFFFFF;
  --t-primary-hover: #3B2942;
  --t-primary-active: #2D1F33;
  --t-primary-soft: #ECE7EE;
  --t-accent-soft: #F1EDF2;
  --t-focus: #5B4266;
  --t-selected-text: #493252;
  --t-link: #493252;
  --t-positive: #2F6B4F;
  --t-positive-bg: #E6F0E9;
  --t-negative: #A63D40;
  --t-negative-bg: #F8E8E7;
  --t-warning: #8A5A12;
  --t-warning-bg: #F8EED9;
  --t-info: #355C7D;
  --t-info-bg: #E8EFF5;
  --t-shadow: 0 2px 8px rgb(0 0 0 / 4%);
  --t-on-series: #FFFFFF;
  --t-backdrop: rgb(0 0 0 / 30%);
  --t-decor: var(--t-border-strong);
  color-scheme: light;
}
:root[data-theme="plum"][data-mode="dark"] {
  /* Plum, dark */
  --t-bg: #17121A;
  --t-surface: #221B25;
  --t-surface-alt: #2B232F;
  --t-text: #F2E9F2;
  --t-text-secondary: #C4BCC8;
  --t-text-muted: #A79BAB;
  --t-border: #413446;
  --t-border-strong: #7D6C84;
  --t-primary: #BFA6C9;
  --t-on-primary: #231429;
  --t-primary-hover: #CDB9D5;
  --t-primary-active: #AE92B9;
  --t-primary-soft: #3D2D43;
  --t-accent-soft: #312735;
  --t-focus: #D2BDDB;
  --t-selected-text: #E3D9E8;
  --t-link: #D1BFD9;
  --t-positive: #9BCBA8;
  --t-positive-bg: #20382A;
  --t-negative: #F1AAA7;
  --t-negative-bg: #422A2B;
  --t-warning: #E3C27F;
  --t-warning-bg: #3C3320;
  --t-info: #ADCBDC;
  --t-info-bg: #253643;
  --t-shadow: 0 2px 8px rgb(0 0 0 / 14%);
  --t-on-series: #231429;
  --t-backdrop: rgb(0 0 0 / 50%);
  --t-decor: var(--t-border-strong);
  color-scheme: dark;
}

:root[data-theme="pomegranate"] {
  /* Pomegranate (brand), light. Loss is terracotta, not red, so it never matches the garnet accent. */
  --t-bg: #F7F1EF;
  --t-surface: #FFFFFF;
  --t-surface-alt: #FDF9F8;
  --t-text: #2C1F22;
  --t-text-secondary: #5F5053;
  --t-text-muted: #726266;
  --t-border: #E6D7D7;
  --t-border-strong: #8A7478;
  --t-primary: #8C1D3A;
  --t-on-primary: #FFFFFF;
  --t-primary-hover: #74172F;
  --t-primary-active: #5C1225;
  --t-primary-soft: #F5E4E7;
  --t-accent-soft: #F8EEEF;
  --t-focus: #A8324F;
  --t-selected-text: #8C1D3A;
  --t-link: #8C1D3A;
  --t-positive: #2F6B4F;
  --t-positive-bg: #E6F0E9;
  --t-negative: #A8461F;
  --t-negative-bg: #FAEADF;
  --t-warning: #8A5A12;
  --t-warning-bg: #F8EED9;
  --t-info: #355C7D;
  --t-info-bg: #E8EFF5;
  --t-shadow: 0 2px 8px rgb(44 31 34 / 4%);
  --t-on-series: #FFFFFF;
  --t-backdrop: rgb(44 31 34 / 30%);
  --t-decor: var(--t-border-strong);
  color-scheme: light;
}
:root[data-theme="pomegranate"][data-mode="dark"] {
  /* Pomegranate (brand), dark */
  --t-bg: #1A1214;
  --t-surface: #251A1D;
  --t-surface-alt: #2F2225;
  --t-text: #F5EAEC;
  --t-text-secondary: #CDBDC1;
  --t-text-muted: #AD9AA0;
  --t-border: #46333A;
  --t-border-strong: #866D75;
  --t-primary: #E58A9E;
  --t-on-primary: #2E0B15;
  --t-primary-hover: #EDA3B3;
  --t-primary-active: #D9718A;
  --t-primary-soft: #45232D;
  --t-accent-soft: #362329;
  --t-focus: #F0AEBD;
  --t-selected-text: #F5D3DB;
  --t-link: #EFA5B6;
  --t-positive: #9BCBA8;
  --t-positive-bg: #20382A;
  --t-negative: #F0A27F;
  --t-negative-bg: #43291F;
  --t-warning: #E3C27F;
  --t-warning-bg: #3C3320;
  --t-info: #ADCBDC;
  --t-info-bg: #253643;
  --t-shadow: 0 2px 8px rgb(0 0 0 / 14%);
  --t-on-series: #2E0B15;
  --t-backdrop: rgb(0 0 0 / 50%);
  --t-decor: var(--t-border-strong);
  color-scheme: dark;
}

/* App roles → Groundly roles (both modes) */
:root[data-style="crafted"], :root[data-style="crafted"][data-mode="dark"] {
  --bg: var(--t-bg);
  --card: var(--t-surface);
  --elevated: var(--t-surface);
  --text: var(--t-text);
  --secondary: var(--t-text-secondary);
  --tertiary: var(--t-text-muted);
  --separator: var(--t-border);
  --fill: var(--t-accent-soft);
  --fill-strong: var(--t-primary-soft);
  --accent: var(--t-primary);
  --accent-soft: var(--t-primary-soft);
  --green: var(--t-positive);
  --green-soft: var(--t-positive-bg);
  --red: var(--t-negative);
  --red-soft: var(--t-negative-bg);
  --orange: var(--t-warning);
  --chart-green: var(--t-positive);
  --chart-red: var(--t-negative);
  --switch-on: var(--t-primary);
  --shadow-card: var(--t-shadow);
  --shadow-overlay: 0 12px 40px rgb(0 0 0 / 18%);
  --on-accent: var(--t-on-primary);
  --switch-knob: var(--t-on-primary);
  --focus: var(--t-focus);
  --logo-ring: var(--t-border);
  --backdrop: var(--t-backdrop);
  --amber: var(--t-warning);
  /* Crafted shape and type: tighter corners, 16px body, plain system stack */
  --radius-m: 8px;
  --radius-l: 12px;
  --font-body: 16px;
  --font-family-text: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-family-display: var(--font-family-text);
  /* Crafted components: outlined controls, fine borders, 8px corners, underlined links */
  --border-surface: 1px solid var(--t-border);
  --radius-button: var(--radius-s);
  --radius-control: var(--radius-s);
  --control-bg: var(--t-surface);
  --control-border: 1px solid var(--t-border-strong);
  --link-decoration: underline;
}

/* Typography: 16px body (a token value above), tabular numbers (rule 8) */
:root[data-style="crafted"] body { letter-spacing: 0; }
:root[data-style="crafted"] ::placeholder { color: var(--t-text-secondary); opacity: 1; }

/* Focus: 2px ring, 3px offset, never removed (rule 5) */
:root[data-style="crafted"] :focus-visible { outline: 2px solid var(--t-focus); outline-offset: 3px; border-radius: var(--radius-s); }
:root[data-style="crafted"] input:focus, :root[data-style="crafted"] select:focus { outline: 2px solid var(--t-focus); outline-offset: 1px; }

/* Cards, lists and sheets: fine border, 12px corners, minimal shadow (rule 8): token values above */
:root[data-style="crafted"] .bar { background: color-mix(in srgb, var(--t-bg) 92%, transparent); }

/* Primary buttons: primary fill + on-primary text (dark green in dark mode, rule 3) */
:root[data-style="crafted"] .primary { border-color: var(--t-primary); }
:root[data-style="crafted"] .primary:hover:not(:disabled) { filter: none; background: var(--t-primary-hover); border-color: var(--t-primary-hover); }
:root[data-style="crafted"] .primary:active:not(:disabled) { background: var(--t-primary-active); border-color: var(--t-primary-active); }
:root[data-style="crafted"] :is(.primary, .secondary-btn):disabled {
  opacity: 1; background: var(--t-primary-soft); color: var(--t-text-secondary); border-color: var(--t-border); cursor: not-allowed;
}

/* Secondary buttons: surface with a visible control outline */
:root[data-style="crafted"] .secondary-btn { color: var(--t-link); }
:root[data-style="crafted"] .secondary-btn:hover:not(:disabled) { background: var(--t-accent-soft); }
:root[data-style="crafted"] .mini:hover, :root[data-style="crafted"][data-mode="dark"] .mini:hover { filter: none; box-shadow: inset 0 0 0 1px currentColor; }

/* Inputs: surface with an outline that identifies the control (rule 4): token values above */

/* Selected states: soft primary fill, selected-text, plus a visible marker (rule 5) */
:root[data-style="crafted"] .segmented { background: var(--t-surface-alt); border: 1px solid var(--t-border); }
:root[data-style="crafted"] .segmented button { color: var(--t-text-secondary); }
:root[data-style="crafted"] .segmented button.on {
  background: var(--t-primary-soft); color: var(--t-selected-text); font-weight: var(--weight-semibold); box-shadow: inset 0 0 0 1.5px var(--t-primary);
}
:root[data-style="crafted"] .tabs a { color: var(--t-text-secondary); }
:root[data-style="crafted"] .tabs a.on { background: var(--t-primary-soft); color: var(--t-selected-text); font-weight: var(--weight-semibold); box-shadow: inset 0 -2px 0 var(--t-primary); border-radius: var(--radius-s) var(--radius-s) 0 0; }
:root[data-style="crafted"] .chip.soft { background: var(--t-primary-soft); color: var(--t-selected-text); }
:root[data-style="crafted"] .choice:hover { background: var(--t-accent-soft); }
:root[data-style="crafted"] .qcard .choice.right { border-color: var(--t-positive); }
:root[data-style="crafted"] .qcard .choice.wrong { border-color: var(--t-negative); }
:root[data-style="crafted"] .theme-opt.on .sw { box-shadow: 0 0 0 3px var(--t-surface), 0 0 0 5px var(--t-primary); }
:root[data-style="crafted"] .theme-opt .check { color: var(--t-selected-text); }

/* Links: link color, underlined (rule 3) */
:root[data-style="crafted"] :is(.text-btn, a.back, .attribution a) { color: var(--t-link); }
:root[data-style="crafted"] .text-btn.danger { color: var(--t-negative); }
:root[data-style="crafted"] .row.plain .title { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--t-border-strong); }

/* Text on colored fills uses the matching "on" color, never assumed white */
:root[data-style="crafted"] .tab-dot { background: var(--t-negative); }
:root[data-style="crafted"] .new-tag { background: var(--t-accent-soft); color: var(--t-link); }
:root[data-style="crafted"] :is(.step-num.next, .lesson-done .big-check) { background: var(--t-primary); color: var(--t-on-primary); }
:root[data-style="crafted"] .step-num.done { background: var(--t-primary-soft); color: var(--t-selected-text); }

/* Status colors only for status; progress uses primary (rule 7) */
:root[data-style="crafted"] .notice { background: var(--t-info-bg); color: var(--t-info); }
:root[data-style="crafted"] .notice.warn-bg { background: var(--t-warning-bg); color: var(--t-warning); }
:root[data-style="crafted"] .takeaway b { color: var(--t-selected-text); }

dialog.sheet:focus { outline: none; }
:root[data-theme] dialog.sheet:focus-visible, :root[data-theme] dialog.sheet:focus { outline: none; }

/* Average price + total paid side by side; either one can be entered. */
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2) var(--space-3); }
.field-pair label { display: grid; gap: var(--space-1); font-size: var(--font-footnote); color: var(--secondary); align-content: start; }
.field-pair .pair-hint { grid-column: 1 / -1; margin: 0; }

/* Company logos over the letter icon (letters show if there's no logo). */
.ticker-icon { position: relative; overflow: hidden; }
.ticker-icon img.logo {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  background: var(--logo-bg); padding: var(--space-1); border-radius: inherit; opacity: 0; transition: opacity var(--duration-fast);
  box-shadow: inset 0 0 0 1px var(--logo-ring);
}
.ticker-icon img.logo.loaded { opacity: 1; }
.ticker-icon.big { width: 56px; height: 56px; border-radius: var(--radius-m); font-size: var(--font-body); flex: none; }
.st-title { display: flex; align-items: center; gap: var(--space-4); }
.ticker-icon.has-logo { background: var(--logo-bg) !important; color: transparent !important; box-shadow: inset 0 0 0 1px var(--logo-ring); }
.ticker-icon.has-logo img.logo { box-shadow: none; }

/* Holdings "Market" view: sparkline + price + tappable metric pill */
.market-row .spark { width: 64px; height: 32px; flex: none; display: block; }
.market-row .spark svg { display: block; }
.market-row .end .title { font-weight: var(--weight-semibold); }
.metric-pill { min-width: 78px; padding: var(--space-1) var(--space-2); border-radius: var(--radius-s); font-size: var(--font-footnote); font-weight: var(--weight-semibold); cursor: pointer; margin-top: var(--space-1); }
.metric-pill.up { background: var(--green); color: var(--card); }
.metric-pill.down { background: var(--red); color: var(--card); }
.metric-pill.flat { background: var(--fill-strong); color: var(--secondary); }
#rows-view { align-self: center; }
.head-controls { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
.ext-toggle { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--secondary); font-size: var(--font-footnote); cursor: pointer; white-space: nowrap; }
@media (max-width: 640px) { .market-row .spark { width: 52px; } .market-row .spark svg { width: 52px; } }

/* Analysis */
.an-legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); padding: var(--space-1) var(--space-2) var(--space-2); font-size: var(--font-footnote); color: var(--secondary); }
.an-key i { display: inline-block; width: var(--space-3); height: 2px; margin-right: var(--space-2); vertical-align: middle; border-radius: var(--radius-full); }
.an-key i.mine { background: var(--accent); }
.an-key i.bench { background: none; border-top: 2px dashed var(--secondary); height: 0; }
.an-key b { font-weight: var(--weight-semibold); }
.an-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.an-note { margin: var(--space-3) var(--space-2) 0; }
.an-gap { margin-top: var(--space-3); }
.an-income-big { font-size: var(--font-title); font-weight: var(--weight-semibold); }
.hero-actions .secondary-btn { display: inline-flex; align-items: center; }

/* Legal pages (terms.html, privacy.html, disclaimer.html) */
.legal { max-width: 640px; margin: 0 auto; padding: var(--space-6) var(--space-4) var(--space-7); }
.legal h1 { margin: var(--space-1) 0 var(--space-4); }
.legal .lesson-body { margin-top: var(--space-5); }
.legal .lesson-body h2 { font-size: var(--font-headline); margin: var(--space-5) 0 var(--space-2); }
.legal .plain-list li + li { margin-top: var(--space-2); }
.legal-links { margin-top: var(--space-4); }

/* QR page for presentations (qr.html): one screen, the code as large as the screen allows.
   The code itself is black on white in every theme so cameras read it. */
.qr-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); padding: var(--space-5) var(--space-4); text-align: center; }
.qr-page .qr-wordmark { height: 50px; margin: 0; }
.qr-page h1 { margin: var(--space-2) 0 0; font-size: var(--font-large-title); }
.qr-sub { margin: 0; font-size: var(--font-headline); }
.qr-code { width: min(56vh, 86vw, 560px); aspect-ratio: 1; margin: var(--space-3) 0; border-radius: var(--radius-l); overflow: hidden; box-shadow: var(--shadow-card); }
.qr-code svg { display: block; width: 100%; height: 100%; }
.qr-local { max-width: 480px; margin: 0; }
.qr-invite { margin: 0; font-size: var(--font-headline); }
.qr-invite-code { font-size: var(--font-title); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.qr-url { margin: 0; font-size: var(--font-title); font-weight: var(--weight-semibold); }

/* Brand home link on standalone pages, About page */
.legal .home { margin-bottom: var(--space-6); }
.about { text-align: center; }
.about .lesson-body { text-align: left; }
.about h1 { margin: var(--space-4) 0 var(--space-3); }
.about-home { color: var(--text); display: inline-block; }
.about-word { color: var(--secondary); font-size: var(--font-body); }
.about .lesson-body .about-lead { font-size: var(--font-headline); color: var(--text); }
.about .legal-links { margin-top: var(--space-6); }
.about-ways { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.about-ways li { display: flex; gap: var(--space-4); align-items: flex-start; background: var(--card); border: var(--border-surface); border-radius: var(--radius-l); box-shadow: var(--shadow-card); padding: var(--space-4); }
.about-ways h3 { font-size: var(--font-headline); margin: 0 0 var(--space-1); }
.about-ways p { margin: 0; font-size: var(--font-body); color: var(--secondary); line-height: 1.45; }
.about-way-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: var(--radius-m); background: var(--accent-soft); color: var(--accent); }
.about-way-icon .icon { width: 22px; height: 22px; }
.about .about-cta { display: block; max-width: 320px; margin: var(--space-6) auto 0; text-align: center; text-decoration: none; }
.about .home { display: flex; width: max-content; }

/* Settings → Account */
.account-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.delete-confirm { justify-self: center; font-weight: var(--weight-semibold); padding: var(--space-3) 0; }

/* Small modifiers that replaced inline styles */
.ticker-icon.cash { background: var(--fill-strong); color: var(--secondary); font-size: var(--font-headline); }
.empty-action { margin-top: var(--space-4); }
.footnote.below { margin-top: var(--space-3); }
.row .title.wrap { font-weight: var(--weight-medium); white-space: normal; }
.split .paid { background: var(--accent); }
.split .growth { background: var(--green); }
.flush-top { margin-top: 0; }
.sheet-head .done-btn { justify-self: end; font-weight: var(--weight-semibold); }

/* Keyboard shortcuts: ⌘K quick switcher and the shortcut sheet (static/shortcuts.js) */
kbd { display: inline-block; padding: 0 var(--space-2); border-radius: var(--radius-s); background: var(--fill); color: var(--secondary); font: inherit; font-size: var(--font-caption); font-weight: var(--weight-medium); line-height: 1.8; white-space: nowrap; }
.kbd-hint { flex: none; padding: 0 var(--space-2); border-radius: var(--radius-s); background: var(--fill); color: var(--secondary); font-size: var(--font-caption); font-weight: var(--weight-medium); line-height: 1.8; }
@media (hover: none), (pointer: coarse) { .kbd-only { display: none !important; } }
/* A control's shortcut, shown under it on hover or keyboard focus (shortcuts.js fills data-keys).
   Only where there is a keyboard and a pointer that can hover. */
.menu :is(button, a) > span { white-space: nowrap; }
.menu kbd { margin-left: auto; }
@media (hover: hover) and (pointer: fine) {
  [data-shortcut] { position: relative; }
  [data-keys]:is(:hover, :focus-visible)::after {
    content: attr(data-keys); position: absolute; top: calc(100% + var(--space-2)); left: 50%; transform: translateX(-50%);
    z-index: 40; white-space: nowrap; pointer-events: none;
    padding: 0 var(--space-2); border-radius: var(--radius-s); line-height: 1.8;
    background: var(--elevated); color: var(--secondary); box-shadow: var(--shadow-overlay), 0 0 0 .5px var(--separator);
    font-size: var(--font-caption); font-weight: var(--weight-medium); letter-spacing: normal; text-transform: none;
  }
  [data-keys][data-shortcut-side="right"]:is(:hover, :focus-visible)::after { top: 50%; left: calc(100% + var(--space-2)); transform: translateY(-50%); }
}
.keys-body .group { margin: 0; }
.keys-body .group + .group { margin-top: var(--space-4); }
.keys-body h3 { margin: 0 var(--space-1) var(--space-2); color: var(--secondary); font-size: var(--font-footnote); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: .03em; }
dialog.palette { margin-top: 12vh; margin-bottom: auto; width: min(560px, calc(100vw - 24px)); overflow: hidden; }
.palette-box { padding: var(--space-3); border-bottom: .5px solid var(--separator); }
.palette-box input { width: 100%; border: none; background: transparent; font-size: var(--font-headline); padding: var(--space-2) var(--space-2); }
.palette-box input:focus { background: transparent; }
.palette-list { max-height: min(420px, 60vh); overflow-y: auto; padding: var(--space-2); }
.palette-head { padding: var(--space-2) var(--space-3) var(--space-1); color: var(--secondary); font-size: var(--font-caption); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: .03em; }
.palette-row { width: 100%; text-align: left; border-radius: var(--radius-m); padding: var(--space-2) var(--space-3); min-height: 0; }
.palette-row .title { font-size: var(--font-body); }
.palette-row.on { background: var(--fill); }
.palette-row .ticker-icon { width: var(--space-6); height: var(--space-6); }
@media (max-width: 640px) { dialog.palette { margin: var(--space-3) auto auto; border-radius: var(--radius-l); } }

/* Living style page (#design, local development only) */
.ds-note { margin: 0 var(--space-1) var(--space-3); }
.ds-modes { margin-left: var(--space-2); }
.ds-gap { margin-top: var(--space-3); }
.ds-stack { display: grid; gap: var(--space-4); justify-items: start; }
.ds-principles p + p { margin-top: var(--space-2); }
.ds-type-display { font-size: var(--font-display); font-weight: var(--weight-semibold); line-height: 1.1; }
.ds-type-large-title { font-size: var(--font-large-title); font-weight: var(--weight-semibold); }
.ds-type-title { font-size: var(--font-title); font-weight: var(--weight-semibold); }
.ds-type-headline { font-size: var(--font-headline); font-weight: var(--weight-semibold); }
.ds-type-body { font-size: var(--font-body); }
.ds-type-footnote { font-size: var(--font-footnote); }
.ds-type-caption { font-size: var(--font-caption); }
.ds-weight-regular { font-weight: var(--weight-regular); font-size: var(--font-headline); }
.ds-weight-medium { font-weight: var(--weight-medium); font-size: var(--font-headline); }
.ds-weight-semibold { font-weight: var(--weight-semibold); font-size: var(--font-headline); }
.ds-space-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-1) 0; }
.ds-space-bar { height: var(--space-3); background: var(--accent-soft); border-radius: var(--radius-full); }
.ds-space-1 { width: var(--space-1); }
.ds-space-2 { width: var(--space-2); }
.ds-space-3 { width: var(--space-3); }
.ds-space-4 { width: var(--space-4); }
.ds-space-5 { width: var(--space-5); }
.ds-space-6 { width: var(--space-6); }
.ds-space-7 { width: var(--space-7); }
.ds-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--space-4); }
.ds-swatch-cell { display: grid; gap: var(--space-2); justify-items: start; }
.ds-radius, .ds-shadow { width: 72px; height: 56px; background: var(--card); border: 1px solid var(--separator); }
.ds-radius-s { border-radius: var(--radius-s); }
.ds-radius-m { border-radius: var(--radius-m); }
.ds-radius-l { border-radius: var(--radius-l); }
.ds-radius-full { border-radius: var(--radius-full); }
.ds-shadow { border: none; border-radius: var(--radius-l); }
.ds-shadow-card { box-shadow: var(--shadow-card); }
.ds-shadow-overlay { box-shadow: var(--shadow-overlay); }
.ds-color { width: 72px; height: 40px; border-radius: var(--radius-m); box-shadow: inset 0 0 0 1px var(--separator); }

/* Motion is functional only, and off for people who ask for less. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ============================================================
   Onboarding: welcome sheet and Getting started checklist
   ============================================================ */
dialog.sheet form.welcome { gap: var(--space-3); text-align: center; }
.welcome-mark .wordmark { height: 50px; margin: var(--space-2) auto 0; color: var(--text); }
.welcome h2 { font-size: var(--font-title); margin: var(--space-2) 0 0; }
.welcome-lead { color: var(--secondary); margin: 0 auto; max-width: 34em; }
.welcome .question { text-align: left; margin-top: var(--space-3); }
.welcome .question h3 { font-size: var(--font-body); color: var(--secondary); font-weight: var(--weight-medium); margin: 0; }
.choice.with-glyph { display: flex; align-items: center; gap: var(--space-4); }
.choice-glyph { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: var(--radius-m); background: var(--accent-soft); color: var(--accent); }
.choice-text { min-width: 0; }
.choice-text > span { font-weight: var(--weight-semibold); }
button.row.onb-step { width: 100%; text-align: left; font: inherit; color: inherit; }
.onb-step.done .title { color: var(--secondary); font-weight: var(--weight-medium); }
.onb-done { margin: 0 var(--space-1) var(--space-3); }
.trade-picks { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.trade-picks .footnote { margin: 0; }
.picks-group { display: grid; gap: var(--space-2); margin-top: var(--space-2); }
.picks-group h4 { margin: 0; font-size: var(--font-footnote); font-weight: var(--weight-medium); color: var(--secondary); display: flex; align-items: center; gap: var(--space-1); }
#picks-more { justify-self: start; }
.chip.pick { display: inline-flex; align-items: center; gap: var(--space-2); padding-left: var(--space-2); }
.chip.pick.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ticker-icon.small { width: 24px; height: 24px; border-radius: var(--radius-s); font-size: var(--font-caption); }

/* ============================================================
   Admin page (/admin, src/admin/): invites and accounts
   ============================================================ */
.admin .bar { gap: var(--space-3); }
.admin-back { margin-left: auto; }
.admin-new { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.admin-field { display: grid; gap: var(--space-1); }
.admin-field input[name=count], .admin-field input[name=uses] { width: 88px; }
.admin-field.grow { flex: 1; min-width: 180px; }
.admin-new .error { flex-basis: 100%; min-height: 0; margin: 0; }
.admin-new .error:empty { display: none; }
.admin-sub { margin: var(--space-5) var(--space-1) var(--space-2); color: var(--secondary); font-size: var(--font-footnote); font-weight: var(--weight-medium); }
.admin-level { margin: var(--space-6) var(--space-1) 0; font-size: var(--font-title); }
.admin-row { flex-wrap: wrap; }
.admin-row .main { min-width: 200px; }
.admin .row .sub { white-space: normal; }
.admin-code { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.admin-tag { margin-left: var(--space-2); padding: 0 var(--space-2); border-radius: var(--radius-full); background: var(--fill); color: var(--secondary); font-size: var(--font-caption); font-weight: var(--weight-medium); vertical-align: middle; }
.admin-row .row-actions { gap: var(--space-4); }
.admin-row.is-done .title { color: var(--secondary); }
.text-btn.armed { font-weight: var(--weight-semibold); }
@media (max-width: 640px) {
  .admin .bar .logo { display: inline-flex; }
  .admin .bar .wordmark { height: 26px; margin-top: -5px; }
  .admin-row .main { flex-basis: 100%; }
  .admin .row-actions { flex-direction: row; gap: var(--space-5); margin-top: calc(-1 * var(--space-2)); }
}
.admin .title-row { flex-wrap: wrap; }
.admin-row a.main { color: inherit; text-decoration: none; }
#people-fit, #waiting-mail { margin-bottom: var(--space-3); }
.row .sub.admin-note { margin-top: var(--space-1); color: var(--text); white-space: pre-wrap; overflow: visible; overflow-wrap: anywhere; }
.person-head { align-items: flex-start; margin: var(--space-4) var(--space-1) 0; }
.person-head h2 { margin-bottom: var(--space-1); overflow-wrap: anywhere; }
.person-head .main { flex: 1; min-width: 0; }
.admin .person-head .row-actions { margin-top: var(--space-1); }

/* ============================================================
   Touch and phones (see DESIGN.md → Phones)
   ============================================================ */
.bar-back { display: none; }
.tabbar { display: none; }
html { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, .tabbar a, .chip, .row[data-href] { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
:root[data-style="crafted"] .search input:focus { outline: none; }
:root[data-style="crafted"] .search:focus-within { outline: 2px solid var(--t-focus); outline-offset: 1px; }

/* Larger tap areas without changing the look: "?", header icons, text buttons. */
.q, .text-btn { position: relative; }
.q::before, .icon-btn::before, .text-btn::before { content: ""; position: absolute; }
.q::before { inset: calc(-1 * var(--space-3)); }
.icon-btn::before { inset: calc(-1 * var(--space-1)); }
.text-btn::before { inset: calc(-1 * var(--space-2)) calc(-1 * var(--space-1)); }

/* Touch screens: no hover, so taps show a brief pressed state instead. */
@media (hover: none) {
  button:active:not(:disabled), a:not(.row):active, .chip:active { opacity: .6; }
  .row[data-href]:active, .row[data-edit]:active, a.row:active, button.row:active { opacity: 1; background: var(--fill); }
  /* The local-time hint shows as a toast on tap (app.js). */
  .local-hint:is(:hover, :focus)::after { display: none; }
}

/* Fields of 16px or more, so iOS doesn't zoom in when one is tapped. */
@media (pointer: coarse), (max-width: 640px) {
  input, select, textarea, .auth-lang select { font-size: var(--font-input); }
}

@media (max-width: 640px) {
  /* Header: logo (or Back on deeper pages), search, account. Sections move to the tab bar. */
  .bar .logo { display: inline-flex; }
  .bar .wordmark { height: 26px; margin-top: -5px; }
  .bar .tabs, .bar .logo .beta-badge { display: none; }
  /* Today on phones: the lesson card keeps Continue small on the right, without the summary
     or the unit's question; the quote is body size, three lines, with More. */
  .today-lesson { gap: var(--space-3); }
  .today-lesson .today-summary, .today-lesson .wide-only { display: none; }
  .today-lesson .primary { flex: none; padding: var(--space-2) var(--space-4); }
  .quote-text { font-size: var(--font-body); }
  .quote-text.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  body.deep .bar .logo { display: none; }
  .bar-back { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--accent); font-size: var(--font-headline); padding: var(--space-2) 0; }
  .view > a.back { display: none; }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: .5px solid var(--separator);
  }
  .tabbar a {
    position: relative; display: grid; justify-items: center; align-content: center; gap: var(--space-1);
    height: var(--tabbar-height); color: var(--secondary); font-size: var(--font-caption); font-weight: var(--weight-medium);
  }
  .tabbar a.on { color: var(--accent); }
  .tabbar svg { width: 24px; height: 24px; }
  .tabbar .tab-dot { position: absolute; top: var(--space-2); left: calc(50% + 10px); }

  .toast, .toast[popover] { bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--space-3)); }
  .toast[popover] { inset: auto 0 calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--space-3)) 0; }
  .auth { min-height: 100dvh; padding-top: calc(var(--space-5) + env(safe-area-inset-top)); padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); }

  /* Bottom sheets: a grab handle, sized to the visible area and kept above the keyboard
     (--vvh and --kb come from app.js), with room for the home indicator. */
  dialog.sheet { max-height: calc(var(--vvh, 100dvh) - var(--space-6)); margin: auto 0 var(--kb, 0); overscroll-behavior: contain; }
  dialog.sheet::before { content: ""; display: block; width: 36px; height: 5px; border-radius: var(--radius-full); background: var(--fill-strong); margin: var(--space-2) auto 0; }
  dialog.sheet.palette::before { display: none; }
  dialog.sheet form { padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); }
  dialog.sheet .primary.large { position: sticky; bottom: var(--space-3); z-index: 1; }
  dialog.sheet.dragging { animation: none; transition: none; }
  dialog.sheet.settling { transition: transform var(--duration-fast) var(--ease); }
  /* Closing slides down off the screen (from wherever a swipe left it). */
  dialog.sheet.closing { animation-name: sheet-down; }
  @keyframes sheet-down { to { transform: translateY(calc(100% + var(--kb, 0px) + var(--space-6))); } }
  /* Ticker suggestions push the form down instead of spilling past the sheet. */
  dialog.sheet .ac-list { position: static; margin-top: var(--space-2); max-height: 240px; box-shadow: none; border: .5px solid var(--separator); }

  /* Controls tapped often get visibly bigger. */
  .segmented button { min-height: 36px; }
  .segmented.small button { padding: var(--space-2) var(--space-3); }
  .segmented.wide button { flex: 1 1 auto; padding-left: var(--space-1); padding-right: var(--space-1); }
  .chart-card .segmented { display: flex; width: 100%; }
  .chart-card .segmented button { flex: 1 1 0; min-width: 0; padding-left: 0; padding-right: 0; }
  .row-actions { flex-direction: row; gap: var(--space-2); }
  .mini { padding: var(--space-2) var(--space-3); font-size: var(--font-footnote); }
  .switch.small { width: 51px; height: 31px; }
  .switch.small span::after { width: 27px; height: 27px; }
  .switch.small input:checked + span::after { transform: translateX(20px); }
}
.toast-action { flex: none; color: inherit; font-weight: var(--weight-semibold); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 640px) {
  /* Practice holdings: Buy and Sell on their own line, so the row's numbers aren't cut off. */
  .row:has(> .row-actions) { flex-wrap: wrap; row-gap: var(--space-2); }
  .row > .row-actions { flex-basis: 100%; padding-left: calc(var(--space-7) + var(--space-2)); }
  .row > .row-actions .mini { min-width: 72px; }
  .admin .row > .row-actions { padding-left: 0; }
  /* Stock page: the main action on its own line, the other two side by side. */
  .stock-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .stock-actions > :first-child { grid-column: 1 / -1; }
}

/* ============================================================
   Stock page: Dividends & earnings (app.js: loadResults)
   ============================================================ */
.results-takeaway, .results-held { margin: 0 var(--space-1) var(--space-4); line-height: 1.45; }
.results-held { color: var(--secondary); font-size: var(--font-footnote); }
.results-sub { margin: var(--space-5) var(--space-1) var(--space-3); font-size: var(--font-headline); font-weight: var(--weight-semibold); }
.results-takeaway + .results-sub, .results-held + .results-sub { margin-top: 0; }
.year-bars { display: grid; gap: var(--space-3); }
.results-sub-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3); margin: var(--space-5) var(--space-1) var(--space-3); }
.results-sub-row .results-sub { margin: 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); color: var(--secondary); font-size: var(--font-footnote); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: var(--radius-full); margin-right: var(--space-2); vertical-align: -1px; }
.chart-legend .key-dot.act { background: var(--secondary); }
.chart-legend .key-dot.est { border: 1.5px dashed var(--secondary); }

/* A fund's top holdings: a weight bar under each name, scaled to the largest. */
.hold-track { display: block; height: 4px; margin-top: var(--space-2); border-radius: var(--radius-full); background: var(--fill); overflow: hidden; }
.hold-fill { display: block; height: 100%; border-radius: var(--radius-full); background: var(--accent); }

/* Analysts: what most say, recommendation trends, rating changes, price targets. */
.an-caution { margin: 0 0 var(--space-4); color: var(--text); font-size: var(--font-footnote); }
.an-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
.an-card { display: grid; gap: var(--space-3); align-content: start; }
.an-title { margin: 0; font-size: var(--font-headline); font-weight: var(--weight-semibold); }
.an-bars { display: grid; gap: var(--space-3); }
.an-bar { display: grid; grid-template-columns: minmax(6.5em, auto) 1fr 2.6em; align-items: center; gap: var(--space-3); font-size: var(--font-footnote); }
.an-label { white-space: nowrap; }
.an-track { display: block; height: 8px; border-radius: var(--radius-full); background: var(--fill); overflow: hidden; }
.an-fill { display: block; height: 100%; border-radius: var(--radius-full); background: var(--tertiary); }
.an-bar.lead .an-fill { background: var(--accent); }
.an-bar.lead .an-label, .an-bar.lead .an-n { font-weight: var(--weight-semibold); }
.an-n { text-align: right; font-variant-numeric: tabular-nums; }
.an-changes .list { margin: 0 calc(-1 * var(--space-5)); background: transparent; box-shadow: none; border: none; border-radius: 0; }
/* Rows keep the card's own side padding (phones give plain rows less), so their text lines up with the title. */
.an-changes .row { padding-left: var(--space-5); padding-right: var(--space-5); }
.an-changes .row + .row::before { left: var(--space-5); }
.an-changes .text-btn { justify-self: start; }
.an-act.up { color: var(--green); }
.an-act.down { color: var(--red); }
.an-targets { display: grid; gap: var(--space-3); margin-top: var(--space-3); }
.pt-line { position: relative; height: 24px; margin: 0 var(--space-2); }
.pt-line::before { content: ""; position: absolute; left: 0; right: 0; top: calc(50% - 1px); border-top: 2px dashed var(--fill-strong); }
.pt-range { position: absolute; top: calc(50% - 1px); height: 2px; background: var(--tertiary); }
.pt-end { position: absolute; top: 50%; width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--tertiary); transform: translate(-50%, -50%); }
.pt-mark { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: var(--radius-full); transform: translate(-50%, -50%); }
.pt-mark.avg { background: var(--card); border: 2px solid var(--text); }
.pt-mark.cur { background: var(--accent); box-shadow: 0 0 0 2px var(--card); z-index: 1; }
.pt-ends { display: flex; justify-content: space-between; gap: var(--space-3); color: var(--secondary); font-size: var(--font-footnote); }
.chart-legend .pt-key.cur { background: var(--accent); }
.chart-legend .pt-key.avg { border: 2px solid var(--text); }
#changes-intro { margin: 0 var(--space-1) var(--space-3); }
@media (max-width: 640px) { .an-grid { grid-template-columns: 1fr; } }

/* Earnings per share: actual (filled, green for a beat, red for a miss) over the estimate (dotted). */
.eps-chart { display: grid; gap: var(--space-4); }
.eps-cols { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--space-2); }
.eps-plot { position: relative; height: 120px; }
.eps-dot { position: absolute; left: 50%; width: 22px; height: 22px; border-radius: var(--radius-full); transform: translate(-50%, 50%); }
.eps-dot.act { background: var(--secondary); }
.eps-dot.act.up { background: var(--chart-green); }
.eps-dot.act.down { background: var(--chart-red); }
.eps-dot.est { border: 2px dashed var(--secondary); z-index: 1; }
.eps-q, .eps-v, .eps-d { text-align: center; white-space: nowrap; }
.eps-q { font-size: var(--font-footnote); font-weight: var(--weight-medium); margin-top: var(--space-2); }
.eps-v { font-size: var(--font-footnote); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.eps-d { font-size: var(--font-caption); color: var(--secondary); min-height: 1.3em; }
.eps-d.up { color: var(--green); }
.eps-d.down { color: var(--red); }
.eps-col.next .eps-q, .eps-col.next .eps-v { color: var(--secondary); }

/* Revenue vs earnings: paired bars on a zero-based axis, amounts under each period. */
.rev-chart { display: grid; gap: var(--space-3); }
.rev-plot { position: relative; height: 200px; margin-top: var(--space-2); }
.rev-tick { position: absolute; left: 0; right: 0; height: 0; border-top: .5px solid var(--separator); }
.rev-tick.zero { border-top-color: var(--tertiary); }
.rev-tick span { position: absolute; left: 0; transform: translateY(-50%); color: var(--secondary); font-size: var(--font-caption); white-space: nowrap; }
.rev-groups { position: absolute; left: 60px; right: 0; top: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.rev-group { position: relative; display: flex; justify-content: center; gap: var(--space-1); }
.rev-slot { position: relative; width: 30%; max-width: 32px; height: 100%; }
.rev-bar { position: absolute; left: 0; right: 0; border-radius: var(--radius-s) var(--radius-s) 0 0; }
.rev-labels { justify-self: end; width: calc(100% - 60px); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; text-align: center; }
.rev-period { font-size: var(--font-footnote); font-weight: var(--weight-medium); }
.rev-v { color: var(--secondary); font-size: var(--font-caption); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rev-v.down { color: var(--red); }
.rev-v i { display: inline-block; width: 6px; height: 6px; border-radius: var(--radius-full); margin-right: var(--space-1); vertical-align: 1px; }
/* One grid for all years, so the bars line up whatever the label ("2026 so far"). */
.card.year-bars { grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3); }
.year-bar { display: contents; font-size: var(--font-body); }
.yb-year { color: var(--secondary); font-size: var(--font-footnote); white-space: nowrap; }
.yb-track { display: block; height: 8px; border-radius: var(--radius-full); background: var(--fill); overflow: hidden; }
.yb-fill { display: block; height: 100%; border-radius: var(--radius-full); background: var(--accent); }
.yb-fill.partial { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.yb-amount { font-weight: var(--weight-semibold); text-align: right; white-space: nowrap; }

/* Password fields with a show/hide eye (app.js). */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: calc(var(--space-7) - var(--space-1)); }
.pw-wrap input::-ms-reveal { display: none; }
.pw-toggle { position: absolute; top: 0; bottom: 0; right: var(--space-1); width: 44px; display: grid; place-items: center; color: var(--secondary); border-radius: var(--radius-control); }
.pw-toggle:hover { color: var(--text); }
.pw-toggle svg { width: 22px; height: 22px; }
.pw-toggle .eye-off, .pw-toggle[aria-pressed="true"] .eye { display: none; }
.pw-toggle[aria-pressed="true"] .eye-off { display: block; }

/* ---------- market map (Explore) ----------
   An SVG treemap: positions are attributes, colours are the classes below. The move
   is always written on a tile as well, so colour is never the only signal. */
.map-card { display: grid; gap: var(--space-3); }
.map-summary { font-weight: var(--weight-medium); }
#map-range button, #map-view button { white-space: nowrap; }
.map-bar { display: flex; align-items: center; gap: var(--space-3); }
.map-bar b { flex: 1; min-width: 0; }
.market-map { display: block; width: 100%; border-radius: var(--radius-s); overflow: hidden; }
.market-map .tile, .market-map .sector { cursor: pointer; }
.market-map .tile rect { fill: var(--fill-strong); stroke: var(--card); stroke-width: 1; }
.market-map .tile:hover rect { stroke: var(--text); }
.market-map text { fill: var(--text); pointer-events: none; font-size: var(--font-caption); }
.market-map .t-name { font-weight: var(--weight-semibold); }
.market-map .big { font-size: var(--font-body); }
.market-map .s-head { fill: var(--card); }
.market-map .s-name { font-weight: var(--weight-semibold); fill: var(--secondary); }
.market-map .s-frame { fill: none; stroke: var(--card); stroke-width: 3; pointer-events: none; }
.market-map .mv-u1 rect, .swatch.mv-u1 { fill: var(--chart-green); fill-opacity: .2; }
.market-map .mv-u2 rect, .swatch.mv-u2 { fill: var(--chart-green); fill-opacity: .4; }
.market-map .mv-u3 rect, .swatch.mv-u3 { fill: var(--chart-green); fill-opacity: .6; }
.market-map .mv-d1 rect, .swatch.mv-d1 { fill: var(--chart-red); fill-opacity: .2; }
.market-map .mv-d2 rect, .swatch.mv-d2 { fill: var(--chart-red); fill-opacity: .4; }
.market-map .mv-d3 rect, .swatch.mv-d3 { fill: var(--chart-red); fill-opacity: .6; }
.map-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.map-foot .segmented { margin-left: auto; }
.map-legend { display: flex; }
.swatch { width: 30px; height: 20px; display: grid; place-items: center; font-size: var(--font-caption); color: var(--text); background: var(--fill-strong); }
.swatch.mv-u1 { background: color-mix(in srgb, var(--chart-green) 20%, var(--card)); }
.swatch.mv-u2 { background: color-mix(in srgb, var(--chart-green) 40%, var(--card)); }
.swatch.mv-u3 { background: color-mix(in srgb, var(--chart-green) 60%, var(--card)); }
.swatch.mv-d1 { background: color-mix(in srgb, var(--chart-red) 20%, var(--card)); }
.swatch.mv-d2 { background: color-mix(in srgb, var(--chart-red) 40%, var(--card)); }
.swatch.mv-d3 { background: color-mix(in srgb, var(--chart-red) 60%, var(--card)); }
.map-list { display: grid; gap: var(--space-2); }
.map-sec > summary { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; cursor: pointer; list-style: none; }
.map-sec > summary::-webkit-details-marker { display: none; }
.map-sec > summary .main { flex: 1; min-width: 0; display: grid; }
.map-sec > summary .title { font-weight: var(--weight-semibold); }
.map-sec > summary .sub { color: var(--secondary); font-size: var(--font-footnote); }
.map-sec .list { box-shadow: none; background: var(--fill); }
.map-row { width: 100%; text-align: left; }
.map-row .main { display: grid; }
#map-group > .footnote { margin: var(--space-3) var(--space-1) 0; }
.chip span.up, .chip span.down { font-weight: var(--weight-medium); }
.map-facts { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-5); }
.map-facts > div { display: grid; gap: var(--space-1); justify-items: start; }
.map-facts .sub { color: var(--secondary); font-size: var(--font-footnote); }
.map-why { background: var(--fill); border-radius: var(--radius-m); padding: var(--space-3) var(--space-4); display: grid; gap: var(--space-1); }
.map-why h3 { font-size: var(--font-footnote); color: var(--secondary); font-weight: var(--weight-medium); }
.map-why a { color: var(--accent); }

/* ---------- streak (Today) ---------- */
.streak-card { display: grid; gap: var(--space-3); margin-bottom: var(--space-5); padding-top: var(--space-3); padding-bottom: var(--space-3); }
.streak-top { display: flex; align-items: center; gap: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--separator); }
/* Wide: the week on the left, the run block beside it on the right. */
@media (min-width: 720px) {
  .streak-card { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: var(--space-5); }
  .streak-card .streak-week { width: 300px; }
  /* A hairline between the week and the run instead of the line above it. */
  .streak-top { padding: var(--space-1) 0 var(--space-1) var(--space-5); border-top: 0; border-left: 1px solid var(--separator); }
}
.streak-flame { display: grid; place-items: center; width: 32px; height: 32px; flex: none; color: var(--orange); }
.streak-flame .icon { width: 28px; height: 28px; }
.streak-text { min-width: 0; }
.streak-head { font-size: var(--font-headline); font-weight: var(--weight-semibold); }
.streak-head.count { text-transform: uppercase; }
.streak-sub { color: var(--secondary); font-size: var(--font-footnote); }
.streak-week { display: flex; justify-content: space-between; gap: var(--space-1); }
/* The week comes first on the card, the run block after it. */
.streak-card .streak-week { order: -1; }
.streak-day { position: relative; display: grid; justify-items: center; gap: var(--space-1); flex: 1; }
.streak-letter { font-size: var(--font-caption); color: var(--secondary); }
.streak-dot { display: grid; place-items: center; width: 26px; height: 26px; border-radius: var(--radius-full); box-sizing: border-box; background: var(--fill); }
/* A day that counted: an orange flame on a soft orange circle, the streak's own color. */
.streak-dot .icon { width: 16px; height: 16px; color: var(--orange); }
/* The soft orange sits behind the dot, and reaches over the gap to a neighbour that
   counted too (half the week's gap each side), so a run is one band. */
.streak-day.done::before { content: ""; position: absolute; top: 0; height: 26px; left: calc(50% - 13px); right: calc(50% - 13px); border-radius: var(--radius-full); background: color-mix(in srgb, var(--orange) 16%, transparent); }
.streak-day.join-l::before { left: calc(var(--space-1) / -2); border-top-left-radius: 0; border-bottom-left-radius: 0; }
.streak-day.join-r::before { right: calc(var(--space-1) / -2); border-top-right-radius: 0; border-bottom-right-radius: 0; }
.streak-day.done .streak-dot { position: relative; background: none; }
.streak-day.done .streak-letter, .streak-day.today .streak-letter { color: var(--text); font-weight: var(--weight-semibold); }
/* Today, nothing counted yet: a green ring, waiting to be filled. */
.streak-day.today .streak-dot { background: none; border: 2px solid var(--green); }
.streak-day:is(.rest, .spare, .repaired) .streak-dot { background: none; border: 2px solid var(--green-soft); }
.streak-day.missed .streak-dot, .streak-day.before .streak-dot, .streak-day.ahead .streak-dot { background: var(--fill); }
.streak-day.before .streak-dot { opacity: .5; }
.streak-inline { color: var(--secondary); font-size: var(--font-footnote); margin: 0 var(--space-1) var(--space-3); }

/* ---------- Quote of the day (quote-of-day.js) ----------
   No card: the words sit on the page itself, pressed in like letterpress. */
.quote-card { display: grid; gap: var(--space-3); margin: var(--space-2) 0 var(--space-6); }
.quote-text { margin: 0; font-size: var(--font-headline); line-height: 1.5; color: var(--secondary); text-shadow: 0 1px 0 var(--emboss-light), 0 -1px 0 var(--emboss-shade); }
.quote-text a { color: inherit; text-decoration: underline dotted; text-underline-offset: .2em; }
.quote-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.quote-name { display: block; font-weight: var(--weight-semibold); color: var(--secondary); }
.quote-src { display: block; color: var(--secondary); font-size: var(--font-footnote); }
.quote-card :is(.quote-name, .quote-src) { text-shadow: 0 1px 0 var(--emboss-light); }
.quote-card .icon-btn { flex: none; }
.quote-card .icon-btn .icon { width: 22px; height: 22px; }
.quote-lesson { margin: 0; color: var(--secondary); font-size: var(--font-footnote); }
/* The landing page's quote, under the growth chart: the same block, a size up. */
.landing-quote { margin: var(--space-6) var(--space-5) var(--space-5); }
.landing-quote .quote-text { font-size: var(--font-title); }

/* ---------- What's new (whats-new.js) ---------- */
.news-note { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); width: 100%; margin-bottom: var(--space-4); text-align: start; }
.news-note .eyebrow { display: block; }
.news-note-title { display: block; margin-top: var(--space-1); font-weight: var(--weight-semibold); }
.news-note-go { color: var(--accent); flex: none; }
.news-list { display: grid; gap: var(--space-4); }
.news-item { display: grid; gap: var(--space-1); justify-items: start; }
.news-item + .news-item { border-top: .5px solid var(--separator); padding-top: var(--space-4); }
.news-title { font-weight: var(--weight-semibold); }
.news-item p { margin: 0; color: var(--secondary); }
@media (min-width: 641px) { .news-body { max-height: 70vh; overflow-y: auto; } }

/* ---------- Icons (static/icons.svg, from Ionicons; DESIGN.md: Icons) ----------
   Outline everywhere; a selected tab swaps to the filled version. */
.icon { flex: none; fill: currentColor; }
.menu .icon, .setting h3 .icon { color: var(--secondary); }
.tabs .icon { width: 16px; height: 16px; }
.i-on, a.on > .i-off { display: none; }
a.on > .i-on { display: block; }
/* The header has no room for tab icons on a narrow window; the labels stay. */
@media (max-width: 860px) { .tabs a > .icon { display: none; } }

/* ---------- weekly quiz (weekly-quiz.js, quiz.html) ---------- */
.quiz-card { display: grid; gap: var(--space-3); }
/* Daily practice (practice.js) and Redo (app.js): step 22. */
.ls-title-row { display: flex; align-items: flex-start; gap: var(--space-2); }
.ls-title-row h1 { flex: 1; min-width: 0; }
.ls-redo { flex: none; margin-top: var(--space-2); color: var(--accent); }
.practice-lesson { display: inline-block; margin-top: var(--space-2); padding: 0; }
.quiz-card p { margin: 0; }
.quiz-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.quiz-body { display: grid; gap: var(--space-3); }
.quiz-body p, .quiz-body h3 { margin: 0; }
.quiz-body .qcard { margin-bottom: 0; }
.quiz-body .text-btn { justify-self: start; padding-left: 0; }
.quiz-fig { float: right; font-weight: var(--weight-regular); font-variant-numeric: tabular-nums; }
.quiz-verdict { font-weight: var(--weight-semibold); }
.quiz-score { font-size: var(--font-title); font-weight: var(--weight-semibold); }
.quiz-review { display: grid; gap: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--separator); }
.quiz-page .quiz-progress { color: var(--secondary); font-size: var(--font-footnote); }
.quiz-page .quiz-right { color: var(--green); }
.quiz-page .quiz-wrong { color: var(--red); }
/* The review of five questions is taller than most sheets; it scrolls on wide screens too. */
.session-line time.local-hint { white-space: nowrap; }
.starters-sent { margin-top: var(--space-4); }
.starters-sent .eyebrow { margin: 0 var(--space-1) var(--space-2); }

/* ---------- streak celebration (streak.js): the first time a day counts ---------- */
.cheer { display: grid; justify-items: center; gap: var(--space-4); padding: var(--space-5) 0 var(--space-2); text-align: center; }
.cheer > * { min-width: 0; }
.cheer-flame { color: var(--orange); line-height: 0; }
.cheer-flame .icon { width: 96px; height: 96px; }
.cheer-count { display: grid; justify-items: center; }
.cheer-n { font-family: var(--font-family-display); font-size: var(--font-display); font-weight: var(--weight-semibold); line-height: 1; font-variant-numeric: tabular-nums; }
.cheer-label { font-size: var(--font-headline); font-weight: var(--weight-semibold); color: var(--orange); }
.cheer .streak-week { width: 100%; max-width: 340px; padding: var(--space-3); border-radius: var(--radius-m); background: var(--fill); box-sizing: border-box; }
.cheer .streak-day.ahead .streak-dot, .cheer .streak-day.missed .streak-dot, .cheer .streak-day.before .streak-dot { background: var(--fill-strong); }
.cheer-line { margin: 0; color: var(--secondary); font-size: var(--font-footnote); max-width: 32ch; }
.cheer .primary { width: 100%; max-width: 340px; }
.cheer-n.pop { animation: cheer-pop calc(var(--duration-base) * 2) cubic-bezier(.2, 1.6, .4, 1); }
.streak-day.drop .streak-dot { animation: cheer-drop calc(var(--duration-base) * 2) cubic-bezier(.2, 1.4, .4, 1); }
@keyframes cheer-pop { from { transform: scale(.6); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes cheer-drop { from { transform: translateY(-14px) scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .cheer-n.pop, .streak-day.drop .streak-dot { animation: none; } }

/* ---------- streak sheet (streak.js) ---------- */
.streak-open { margin-left: auto; }
.streak-open + .streak-open { margin-left: 0; }
.streak-spares { margin: 0; }
.streak-open .icon { width: 22px; height: 22px; }
#streak-head { cursor: pointer; }
.streak-sheet h3 { margin: 0 0 var(--space-2); }
.streak-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.streak-stats > div { display: grid; gap: var(--space-1); padding: var(--space-3); border-radius: var(--radius-m); background: var(--fill); text-align: center; }
.streak-stats b { font-size: var(--font-headline); }
.streak-stats span { color: var(--secondary); font-size: var(--font-caption); }
.streak-way { align-items: center; gap: var(--space-3); }
.streak-way-mark { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: var(--radius-full); border: 2px solid var(--fill-strong); box-sizing: border-box; }
.streak-way.done .streak-way-mark { background: var(--green); border-color: var(--green); color: var(--on-accent); }
.streak-way-mark .icon { width: 14px; height: 14px; }
.streak-way .secondary-btn { flex: none; padding: var(--space-2) var(--space-3); font-size: var(--font-footnote); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); }
.cal-head h3 { margin: 0; }
.cal-head h3::first-letter { text-transform: uppercase; } /* "Ноябрь 2026 г.", not every word ("Г.", "Թ.") */
.cal-head .icon-btn { font-size: var(--font-title); }
.cal-head .icon-btn:disabled { opacity: .3; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--space-1); justify-items: center; }
.cal-wd { color: var(--secondary); font-size: var(--font-caption); padding-bottom: var(--space-1); }
.cal-day { width: 36px; height: 36px; border-radius: var(--radius-full); box-sizing: border-box; font-size: var(--font-footnote); color: var(--text); font-variant-numeric: tabular-nums; }
.cal-day.done { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--text); font-weight: var(--weight-semibold); }
.cal-day:is(.rest, .spare, .repaired) { border: 2px solid var(--green-soft); }
.cal-day.today { border: 2px solid var(--green); font-weight: var(--weight-semibold); }
.cal-day.missed, .cal-day.before { color: var(--secondary); }
.cal-day.ahead { color: var(--secondary); }
.cal-day.picked { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
#cal-day { margin-top: var(--space-2); min-height: 2.6em; }

.streak-sheet > * { min-width: 0; }

/* ---------- achievements (achievements.js) ----------
   Flat round medals in the app's own colors, like the streak's days: the kind's icon in its
   group's color (--orange for coming back, the streak's own; --green for learning; --accent
   for friends) on a 16% tint of it, inside a ring of the same color. A tier number sits on a
   plate over the bottom of the ring, a repeat count at the top right. Grey until earned. The
   card on Today is calm: no confetti, no motion. */
/* Badge light and shade: the same in light and dark, like an object under one light. */
:root {
  --badge-light: #ffffff;
  --badge-shade: #000000;
}
.medal { --tone: var(--orange); --size: 76px; --shape: none; position: relative; isolation: isolate; display: grid; place-items: center; width: var(--size); height: var(--size); flex: none; color: var(--badge-light);
  filter: drop-shadow(0 calc(var(--size) * .04) calc(var(--size) * .05) color-mix(in srgb, var(--badge-shade) 22%, transparent)); }
/* Two layers in the badge's shape, in flat colors: the rim, a 40% tint of the group's color,
   and the face in the full color, which casts a soft shadow onto the rim (no hard lines).
   A clipped shape can't carry its own shadow, so the face's wrapper holds the shadow and
   its ::before the shape. */
.medal::before { content: ""; position: absolute; inset: 0; z-index: -2; clip-path: var(--shape); background: color-mix(in srgb, var(--tone) 40%, var(--elevated)); }
.medal-face { position: absolute; inset: 13%; z-index: -1; filter: drop-shadow(0 calc(var(--size) * .015) calc(var(--size) * .03) color-mix(in srgb, var(--badge-shade) 35%, transparent)); }
.medal-face::before { content: ""; position: absolute; inset: 0; clip-path: var(--shape); background: var(--tone); }
.medal.shape-circle::before, .medal.shape-circle .medal-face::before { border-radius: var(--radius-full); }
.medal.shape-shield { --shape: polygon(12% 0, 88% 0, 100% 10%, 100% 58%, 50% 100%, 0 58%, 0 10%); }
.medal.shape-pentagon { --shape: polygon(50% 0, 100% 37%, 81% 100%, 19% 100%, 0 37%); }
.medal.shape-hexagon { --shape: polygon(50% 0, 94% 25%, 94% 75%, 50% 100%, 6% 75%, 6% 25%); }
.medal.shape-shield .icon { margin-bottom: 10%; }
.medal.shape-pentagon .icon { margin-top: 8%; }
/* The icon, embossed: a thin shadow below it. */
.medal .icon { width: 38%; height: 38%; filter: drop-shadow(0 1px 1px color-mix(in srgb, var(--badge-shade) 35%, transparent)); }
.medal.tone-learn { --tone: var(--green); }
.medal.tone-friends { --tone: var(--accent); }
.medal.big { --size: 120px; }
.medal.small { --size: 40px; }
.medal.small :is(.medal-n, .medal-count) { display: none; }
.medal-n { position: absolute; bottom: calc(var(--space-2) * -1); padding: 0 var(--space-2); border-radius: var(--radius-full); background: var(--card); color: var(--tone); box-shadow: inset 0 0 0 1.5px var(--tone); font-size: var(--font-caption); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; line-height: 1.5; }
.medal-count { position: absolute; top: calc(var(--space-1) * -1); right: calc(var(--space-1) * -1); padding: 0 var(--space-2); border-radius: var(--radius-full); background: var(--card); color: var(--tone); box-shadow: inset 0 0 0 1.5px var(--tone); font-size: var(--font-caption); font-style: normal; font-weight: var(--weight-semibold); line-height: 1.5; }
/* Locked: the same shape and light in solid greys (mixed with the sheet's color, so nothing
   shows through), a lighter shadow, and the icon pressed in rather than raised. */
.medal.locked { --tone: var(--secondary); color: var(--secondary); filter: drop-shadow(0 calc(var(--size) * .03) calc(var(--size) * .04) color-mix(in srgb, var(--badge-shade) 12%, transparent)); }
.medal.locked::before { background: color-mix(in srgb, var(--secondary) 30%, var(--elevated)); }
.medal.locked .medal-face { filter: drop-shadow(0 calc(var(--size) * .01) calc(var(--size) * .025) color-mix(in srgb, var(--badge-shade) 18%, transparent)); }
.medal.locked .medal-face::before { background: color-mix(in srgb, var(--secondary) 14%, var(--elevated)); }
.medal.locked .icon { opacity: .8; filter: drop-shadow(0 1px 0 color-mix(in srgb, var(--badge-light) 40%, transparent)); }
.medal.locked :is(.medal-n, .medal-count) { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--secondary) 30%, var(--elevated)); }
/* The banner when one is unlocked: from the top, over everything (top layer), hiding by
   itself. The badge starts grey and fills with its color with a small pop. */
.ach-banner { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 8px); margin: 0 auto; width: fit-content; max-width: min(440px, calc(100vw - 16px)); box-sizing: border-box;
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-6) var(--space-3) var(--space-3); border-radius: var(--radius-full);
  background: var(--elevated); color: var(--text); border: var(--border-surface); box-shadow: var(--shadow-overlay); z-index: 80; touch-action: none;
  transform: translateY(calc(-100% - 16px)); transition: transform var(--duration-base) var(--ease); }
.ach-banner[popover] { inset: calc(env(safe-area-inset-top) + 8px) 0 auto 0; margin: 0 auto; overflow: visible; }
.ach-banner.in { transform: none; }
.ach-banner.text-only { padding-left: var(--space-6); }
.ach-banner-medal { display: grid; place-items: center; flex: none; }
/* The banner's small badge keeps its repeat count (the one sign that it was earned again). */
.ach-banner .medal.small .medal-count { display: block; top: calc(var(--space-1) * -1); right: calc(var(--space-2) * -1); padding: 0 var(--space-1); font-size: var(--font-caption); line-height: 1.3; }
.ach-banner .medal-count[hidden] { display: none; }
.ach-banner-text { display: grid; min-width: 0; }
.ach-banner-label { color: var(--secondary); font-size: var(--font-caption); font-weight: var(--weight-medium); }
.ach-banner-name { font-size: var(--font-footnote); font-weight: var(--weight-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ach-banner .medal::before, .ach-banner .medal-face::before { transition: background var(--duration-base) var(--ease); }
.ach-banner .medal .icon { transition: color var(--duration-base) var(--ease); }
.medal.pop { animation: medal-pop calc(var(--duration-base) * 2) cubic-bezier(.2, 1.6, .4, 1); }
@keyframes medal-pop { from { transform: scale(.7); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .ach-banner, .ach-banner .medal::before, .ach-banner .medal-face::before { transition: none; }
  .medal.pop { animation: none; }
}
.ach-sheet > * { min-width: 0; }
.ach-groups { display: grid; gap: var(--space-6); }
.ach-group { min-width: 0; }
.ach-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.ach-group-head h3 { margin: 0; }
/* A row of medals that scrolls sideways, each snapping into place. */
.ach-row { display: flex; gap: var(--space-2); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 calc(var(--space-5) * -1); padding: var(--space-2) var(--space-5) var(--space-1); }
.ach-row { scroll-padding-inline: var(--space-5); }
.ach-row::-webkit-scrollbar { display: none; }
/* Wide screens have no swipe: the medals wrap instead. */
@media (min-width: 641px) {
  .ach-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4) var(--space-1); overflow: visible; margin: 0; padding: var(--space-2) 0 0; }
  .ach-row .ach-badge { width: auto; }
}
.ach-badge { display: grid; justify-items: center; align-content: start; gap: var(--space-1); width: 96px; flex: none; scroll-snap-align: start; padding: 0; background: none; border: 0; color: var(--text); text-align: center; }
.ach-badge .medal { margin-bottom: var(--space-3); }
.ach-name { font-size: var(--font-footnote); font-weight: var(--weight-semibold); line-height: 1.25; }
.ach-sub { color: var(--secondary); font-size: var(--font-caption); }
.ach-badge:has(.locked) .ach-name { color: var(--secondary); }
.ach-detail { display: grid; justify-items: center; gap: var(--space-3); text-align: center; }
.ach-detail .ach-back { justify-self: start; padding-left: 0; }
.ach-detail-medal { margin: var(--space-2) 0 var(--space-3); }
.ach-detail-name { margin: 0; font-size: var(--font-title); }
.ach-detail-name:focus { outline: none; }
.ach-detail p { margin: 0; max-width: 34ch; }
.ach-detail-tier { color: var(--secondary); font-weight: var(--weight-medium); }
.ach-detail-share { display: inline-flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.ach-detail-share .icon { width: 18px; height: 18px; }
.ach-new { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-5); }
.ach-new-text { display: grid; gap: var(--space-1); min-width: 0; flex: 1; }
.ach-new-title { font-weight: var(--weight-semibold); }
.ach-new-line { color: var(--secondary); font-size: var(--font-footnote); }
.ach-new-actions { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.ach-new-actions .text-btn { padding-left: 0; padding-right: 0; }
.ach-new-close .icon { width: 18px; height: 18px; }
.ach-new-close { flex: none; margin: calc(var(--space-2) * -1) calc(var(--space-2) * -1) 0 0; }

/* ---------- Morning brief (brief.js) ---------- */
.brief-card { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); color: var(--text); }
.brief-card-text { display: grid; gap: var(--space-1); min-width: 0; }
.brief-card-title { font-weight: var(--weight-semibold); }
.brief-card-go { color: var(--accent); flex: none; }
.brief-indexes { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-size: var(--font-footnote); color: var(--secondary); }
.brief-index { white-space: nowrap; }
.brief-date { margin: 0 0 var(--space-4); }
.brief-numbers { display: grid; gap: var(--space-2); margin-bottom: var(--space-5); }
.brief-numbers .brief-indexes { font-size: var(--font-body); }
.brief-stories { display: grid; gap: var(--space-4); }
.brief-story { display: grid; gap: var(--space-2); justify-items: start; }
.brief-story p { margin: 0; }
.brief-story-title { margin: 0; font-size: var(--font-headline); font-weight: var(--weight-semibold); }
.brief-story .lbl { font-weight: var(--weight-semibold); }
.brief-mine-news { color: var(--secondary); text-decoration: var(--link-decoration); }
.brief-foot { margin-top: var(--space-4); }

/* Learn → Glossary: every term, A to Z, each opening to what / why / common mistake. */
.gloss-search { margin-bottom: var(--space-3); }
.gloss-list details + details { border-top: .5px solid var(--separator); }
/* #glossary/<term> scrolls its entry to the top: clear the sticky bar, as the unit cards do. */
.gloss-list details { scroll-margin-top: 72px; }
.gloss-list summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); font-weight: var(--weight-semibold); }
.gloss-list summary::-webkit-details-marker { display: none; }
.gloss-list summary::after { content: "›"; margin-left: auto; color: var(--tertiary); font-size: var(--font-title); transition: transform var(--duration-fast); }
.gloss-list details[open] > summary::after { transform: rotate(90deg); }
.gloss-list .gloss-body { padding: 0 var(--space-5) var(--space-4); color: var(--secondary); }
.gloss-list .gloss-body p { margin: 0 0 var(--space-2); }
.gloss-list .gloss-body p:last-child { margin-bottom: 0; }
.gloss-list .lbl { color: var(--text); font-weight: var(--weight-medium); }
@media (prefers-reduced-motion: reduce) { .gloss-list summary::after { transition: none; } }
/* Letter headings down the A–Z list, small and quiet like the unit index's level counts. */
.gloss-list .gloss-letter { margin: 0; padding: var(--space-3) var(--space-5) var(--space-1); border-top: .5px solid var(--separator); color: var(--secondary); font-size: var(--font-caption); font-weight: var(--weight-semibold); letter-spacing: .04em; }
.gloss-list .gloss-letter:first-child { border-top: 0; }
.gloss-count { margin: calc(-1 * var(--space-2)) var(--space-1) var(--space-4); }
/* A term named inside a glossary entry: in a help card it swaps the card, on the page it opens
   that entry. Dotted like a lesson's terms, so it reads as tappable without shouting. */
.gloss-term { display: inline; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; line-height: inherit; text-decoration: underline dotted var(--tertiary); text-underline-offset: 4px; cursor: pointer; }
.gloss-term:hover { color: var(--accent); text-decoration-color: var(--accent); }
#popover .gloss-back { display: block; margin: 0 0 var(--space-2); padding: 0; font-size: var(--font-footnote); }
/* Learn's way to the glossary under the units, and the same at the end of the unit index. */
.gloss-link-row { display: block; margin-top: var(--space-5); color: inherit; text-decoration: none; }
.gloss-link-row .main { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 var(--space-2); }
/* The note under Learn: centered and quiet, a caption in the faintest grey. */
.learn-disclaimer { margin: var(--space-5) 0 0; text-align: center; color: var(--tertiary); font-size: var(--font-caption); }
.unit-index-gloss { margin-top: var(--space-5); border-top: .5px solid var(--separator); text-decoration: none; }

/* ---------- Lesson pictures (static/visuals.js; CONTENT.md → Visuals) ----------
   Colour means one thing: accent is what you put in (and the share), gain is growth and
   money coming back, loss is a fall. Muted is the line to compare against. */
/* In a step, the picture and its question are one card: the picture is the question's context. */
.step-visual { margin-top: var(--space-3); }
.step-visual .visual { border-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; box-shadow: none; padding-bottom: var(--space-2); }
.step-visual + .step-ask .qcard { border-top: .5px solid var(--separator); border-top-left-radius: 0; border-top-right-radius: 0; }
.visual { margin: 0; padding: var(--space-3) var(--space-4); }
.visual svg { display: block; width: 100%; height: auto; overflow: visible; }
.visual text { fill: var(--text); font-size: var(--font-footnote); }
.visual .v-caption { fill: var(--secondary); font-size: var(--font-caption); }
.visual .v-strong { font-weight: var(--weight-semibold); }
.visual .v-on-fill { fill: var(--on-accent); font-size: var(--font-caption); font-weight: var(--weight-semibold); }
.visual .v-axis { stroke: var(--separator); stroke-width: 1; }
.visual .v-dash { stroke-dasharray: 3 3; }
.visual .v-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.visual .v-band { fill: var(--fill); }
.visual .v-node { fill: var(--fill); }
.visual .v-ring { fill: none; stroke: var(--text); stroke-width: 1.5; }
.visual .v-fill-dim { fill: var(--fill-strong); }
.visual .v-mark-loss { stroke: var(--chart-red); stroke-width: 2.5; }
.visual .v-stroke-accent { stroke: var(--accent); }
.visual .v-stroke-gain { stroke: var(--chart-green); }
.visual .v-stroke-loss { stroke: var(--chart-red); }
.visual .v-stroke-muted { stroke: var(--tertiary); }
.visual .v-stroke-second { stroke: var(--orange); }
.visual .v-fill-accent { fill: var(--accent); }
.visual .v-fill-gain { fill: var(--chart-green); }
.visual .v-fill-loss { fill: var(--chart-red); }
.visual .v-fill-muted { fill: var(--tertiary); }
.visual .v-fill-second { fill: var(--orange); }
.visual .v-ink-accent { fill: var(--accent); }
.visual .v-ink-gain { fill: var(--green); }
.visual .v-ink-loss { fill: var(--red); }
.visual .v-ink-muted { fill: var(--secondary); }
.visual .v-ink-second { fill: var(--orange); }
.ds-visual-row { display: flex; gap: var(--space-2); margin-top: var(--space-2); }

/* Very narrow phones: there's no room beside the next lesson's title, so its small button goes
   under it. */
@media (max-width: 379px) {
  .today-lesson { flex-direction: column; align-items: flex-start; }
}
