/* ==========================================================================
   App Kit v1 — the shared factory standard for every small app on the site.
   Built on the site's design system v5 (11-system.css): token names kept
   (--font-sans, --font-num, --r-1..4, --r-pill, --sh-1..3, --spring,
   --ease-out, --grain, .btn).

   Three materials, picked by one class on <body>:
     .mat-paper   paper background, solid soft cards       (apps you read in)
     .mat-frost   pale drifting paper + light frosted slabs (apps you read in, with depth)
     .mat-glass   deep drifting colour + dark glass slabs  (immersive apps)
   Each app sets exactly one accent:  body { --accent: #xxxxxx; }

   Type roles (do not mix):
     serif  --font-serif  reading text, big Chinese page titles
     sans   --font-sans   everything you touch: buttons, labels, inputs, tabs
     number --font-num    figures, always tabular
   ========================================================================== */

@font-face { font-family: "Inter UI"; src: url("fonts/inter-400.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter UI"; src: url("fonts/inter-500.woff") format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter UI"; src: url("fonts/inter-600.woff") format("woff"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Inter UI Display"; src: url("fonts/inter-display-600.woff") format("woff"); font-weight: 500 800; font-display: swap; }

/* ---------- 1. Tokens ---------- */
:root {
  --font-sans: "Inter UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-num: "Inter UI Display", "Inter UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC", serif;

  /* type scale (px): caption 12 · small 14 · body 16 · lead 18 · title 22 · page 30 · hero 64–88 */
  --fs-cap: 12px; --fs-sm: 14px; --fs-body: 16px; --fs-lead: 18px; --fs-title: 22px; --fs-page: 30px;

  --r-1: 10px; --r-2: 16px; --r-3: 24px; --r-4: 32px; --r-pill: 999px;
  --sh-1: 0 1px 1px rgba(20, 16, 10, .04), 0 2px 6px rgba(20, 16, 10, .06);
  --sh-2: 0 1px 2px rgba(20, 16, 10, .05), 0 8px 24px -6px rgba(20, 16, 10, .16), 0 24px 48px -24px rgba(20, 16, 10, .22);
  --sh-3: 0 2px 4px rgba(0, 0, 0, .08), 0 20px 40px -12px rgba(0, 0, 0, .35), 0 50px 90px -40px rgba(0, 0, 0, .45);

  /* motion: press 120 · state 220 · move 380 · sheet 520 */
  --d-1: 120ms; --d-2: 220ms; --d-3: 380ms; --d-4: 520ms;
  --spring: cubic-bezier(.34, 1.56, .64, 1);          /* small things that pop back */
  --spring-soft: cubic-bezier(.2, 1.18, .36, 1);       /* big things that land (sheet, indicator) */
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);                /* exits */

  /* sizes */
  --tap: 44px;          /* minimum hit target */
  --h-ctl: 48px;        /* default button / input height */
  --h-ctl-lg: 56px;
  --gutter: 20px;
  --col: 440px;         /* phone column width on large screens */

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  /* site palette */
  --paper: #ecebe7; --ink-0: #141413; --cinnabar: #c23a22;
}

/* Paper, light (default) */
.mat-paper {
  --accent: var(--cinnabar);
  --on-accent: #fff;
  --bg: #ecebe7;
  --bg-outer: #e1dfd9;            /* calm backdrop around the column on large screens */
  --surface: #f6f5f1;             /* cards */
  --surface-2: #ecebe6;           /* modules inside a card */
  --surface-3: #e2e1db;
  --ink: #141413; --ink-2: #3d3c39; --ink-3: #65645f;   /* ink-3 ≥ 4.5:1 on bg and surface */
  --line: rgba(20, 20, 19, .10);
  --line-2: rgba(20, 20, 19, .16);
  --press: rgba(20, 20, 19, .06); --press-2: rgba(20, 20, 19, .10);
  --track: rgba(20, 20, 19, .08);
  --danger: #b8361f; --danger-soft: rgba(194, 58, 34, .10);
  --ok: #2d6a48; --warn: #9a6a12;
  --scrim: rgba(28, 26, 22, .32);
  --bar-bg: rgba(246, 245, 241, .78);   /* floating tab bar */
  --sheet-bg: #f6f5f1;
  --hi: rgba(255, 255, 255, .7);        /* top highlight on raised things */
  --seg-bg: rgba(20, 20, 19, .06); --seg-on: #fff;
  --row-bg: var(--surface);
  color-scheme: light;
}
/* Paper, dark: system setting unless forced light; or forced dark */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mat-paper {
    --bg: #131312; --bg-outer: #0c0c0b; --surface: #1d1d1b; --surface-2: #262624; --surface-3: #30302d;
    --ink: #ecebe7; --ink-2: #c9c7c0; --ink-3: #9d9b94;
    --line: rgba(236, 235, 231, .10); --line-2: rgba(236, 235, 231, .16);
    --press: rgba(236, 235, 231, .08); --press-2: rgba(236, 235, 231, .13);
    --track: rgba(236, 235, 231, .10);
    --danger: #ec7258; --danger-soft: rgba(236, 114, 88, .14); --ok: #6fbf8f; --warn: #e0b25a;
    --scrim: rgba(0, 0, 0, .55); --bar-bg: rgba(32, 32, 30, .78); --sheet-bg: #1d1d1b; --hi: rgba(255, 255, 255, .06);
    --seg-bg: rgba(236, 235, 231, .08); --seg-on: #3a3a37;
 --accent: #e8735a; --on-accent: #1a0904; /* cinnabar lifted for dark; apps override both */
    color-scheme: dark;
  }
}
:root[data-theme="dark"] .mat-paper {
  --bg: #131312; --bg-outer: #0c0c0b; --surface: #1d1d1b; --surface-2: #262624; --surface-3: #30302d;
  --ink: #ecebe7; --ink-2: #c9c7c0; --ink-3: #9d9b94;
  --line: rgba(236, 235, 231, .10); --line-2: rgba(236, 235, 231, .16);
  --press: rgba(236, 235, 231, .08); --press-2: rgba(236, 235, 231, .13);
  --track: rgba(236, 235, 231, .10);
  --danger: #ec7258; --danger-soft: rgba(236, 114, 88, .14); --ok: #6fbf8f; --warn: #e0b25a;
  --scrim: rgba(0, 0, 0, .55); --bar-bg: rgba(32, 32, 30, .78); --sheet-bg: #1d1d1b; --hi: rgba(255, 255, 255, .06);
  --seg-bg: rgba(236, 235, 231, .08); --seg-on: #3a3a37;
 --accent: #e8735a; --on-accent: #1a0904; /* cinnabar lifted for dark; apps override both */
  color-scheme: dark;
}

/* Glass: always dark. The backdrop colours are per app (--glow-1..3, --glow-base). */
.mat-glass {
  --accent: #e8c27a;
  --on-accent: #1a1408;
  --glow-base: #0d0f14; --glow-1: #3a2d58; --glow-2: #17505a; --glow-3: #7a3a26;
  --bg: var(--glow-base); --bg-outer: var(--glow-base);
  --glass: rgba(10, 12, 14, .40);       /* slab fill over the drifting colour */
  --glass-blur: 28px;
  --rim: rgba(255, 255, 255, .16);       /* hairline bright rim */
  --rim-top: rgba(255, 255, 255, .28);
  --surface: var(--glass);
  --surface-2: rgba(255, 255, 255, .07);
  --surface-3: rgba(255, 255, 255, .12);
  --ink: #f5f3ee; --ink-2: rgba(245, 243, 238, .80); --ink-3: rgba(245, 243, 238, .64);
  --line: rgba(255, 255, 255, .10); --line-2: rgba(255, 255, 255, .22);
  --press: rgba(255, 255, 255, .08); --press-2: rgba(255, 255, 255, .14);
  --track: rgba(255, 255, 255, .10);
  --danger: #ff8f73; --danger-soft: rgba(255, 143, 115, .14); --ok: #8fd6a8; --warn: #f0c46a;
  --scrim: rgba(0, 0, 0, .45);
  --bar-bg: rgba(18, 20, 22, .72);
  --sheet-bg: rgba(22, 24, 26, .82);
  --hi: rgba(255, 255, 255, .10);
  --seg-bg: rgba(255, 255, 255, .07); --seg-on: rgba(255, 255, 255, .92);
  --row-bg: var(--surface-2);
  color-scheme: dark;
}

/* Frost: light only. Pale warm paper with a slow, barely-there colour field;
   slabs are translucent white glass with a hairline bright rim. The field colours
   are per app (--field-1..3) and must stay pale (no saturated hues). */
.mat-frost {
  --accent: #2c6a4a;
  --on-accent: #fff;
  --field-base: #ecebe4; --field-1: #f7efdf; --field-2: #dce7dc; --field-3: #eadfc4;
  --bg: var(--field-base); --bg-outer: var(--field-base);
  --glass: rgba(255, 255, 255, .58);    /* slab fill over the field */
  --glass-2: rgba(255, 255, 255, .42);  /* quieter slab */
  --glass-blur: 26px;
  --rim: rgba(255, 255, 255, .78);      /* hairline bright rim */
  --rim-top: rgba(255, 255, 255, .98);  /* inner top highlight */
  --edge: rgba(70, 60, 30, .08);        /* faint outer hairline so a white rim reads on pale ground */
  --sh-frost: 0 1px 2px rgba(70, 60, 30, .05), 0 18px 40px -22px rgba(70, 60, 30, .30);
  --surface: var(--glass); --surface-solid: #f8f7f3;
  --surface-2: rgba(80, 70, 40, .05);   /* modules sit slightly recessed in the slab */
  --surface-3: rgba(80, 70, 40, .08);
  --ink: #171613; --ink-2: #3b3a35; --ink-3: #5c5a53;   /* ink-3 ≥ 4.5:1 on the darkest field tone */
  --line: rgba(60, 52, 30, .10); --line-2: rgba(60, 52, 30, .17);
  --press: rgba(60, 52, 30, .055); --press-2: rgba(60, 52, 30, .09);
  --track: rgba(60, 52, 30, .09);
  --danger: #b2341d; --danger-soft: rgba(194, 58, 34, .10); --ok: #2c6a4a; --warn: #855a0c;
  --scrim: rgba(52, 48, 34, .24);
  --bar-bg: rgba(255, 255, 255, .74);
  --sheet-bg: rgba(250, 249, 246, .94);
  --hi: rgba(255, 255, 255, .95);
  --seg-bg: rgba(60, 52, 30, .065); --seg-on: #fff;
  --row-bg: transparent;
  color-scheme: light;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.mat-paper, body.mat-glass, body.mat-frost {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font: 400 var(--fs-body)/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
:where(.mat-paper, .mat-glass, .mat-frost) :where(h1, h2, h3, h4, p) { margin: 0; }
:where(.mat-paper, .mat-glass, .mat-frost) button { font: inherit; color: inherit; }
:where(.mat-paper, .mat-glass, .mat-frost) ::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Paper: faint grain on the whole sheet */
.mat-paper::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: var(--grain); background-size: 160px; opacity: .10; mix-blend-mode: multiply;
}

/* Glass: the deep, slowly drifting colour field */
.mat-glass { background: var(--glow-base); }
.mat-glass::before, .mat-glass::after {
  content: ""; position: fixed; inset: -12vmax; pointer-events: none; z-index: 0;
}
.mat-glass::before {
  background:
    radial-gradient(44vmax 38vmax at 26% 20%, var(--glow-1), transparent 72%),
    radial-gradient(46vmax 42vmax at 74% 52%, var(--glow-2), transparent 72%),
    radial-gradient(42vmax 38vmax at 36% 90%, var(--glow-3), transparent 72%);
  filter: saturate(1.1);
  animation: kit-drift 46s var(--ease-out) infinite alternate;
}
.mat-glass::after {
  inset: 0;
  background: radial-gradient(130% 90% at 50% 10%, transparent 50%, rgba(0, 0, 0, .3) 100%), var(--grain);
  background-size: auto, 160px; opacity: .9; mix-blend-mode: normal;
}
/* Frost: pale paper with a slow, soft colour field (never saturated) */
.mat-frost { background: var(--field-base); }
.mat-frost::before, .mat-frost::after { content: ""; position: fixed; pointer-events: none; z-index: 0; }
.mat-frost::before {
  inset: -12vmax;
  background:
    radial-gradient(46vmax 40vmax at 18% 14%, var(--field-1), transparent 70%),
    radial-gradient(44vmax 40vmax at 84% 46%, var(--field-2), transparent 70%),
    radial-gradient(48vmax 40vmax at 30% 92%, var(--field-3), transparent 70%);
  animation: kit-drift 64s var(--ease-out) infinite alternate;
}
.mat-frost::after { inset: 0; background-image: var(--grain); background-size: 160px; opacity: .06; mix-blend-mode: multiply; }
@keyframes kit-drift {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  50%  { transform: translate3d(4vmax, -3vmax, 0) rotate(8deg) scale(1.06); }
  100% { transform: translate3d(-3vmax, 4vmax, 0) rotate(-6deg) scale(1.02); }
}

/* ---------- 3. App column ---------- */
.app {
  position: relative; z-index: 1;
  width: 100%; max-width: var(--col); margin: 0 auto; min-height: 100dvh;
  padding: calc(var(--safe-t) + 12px) calc(var(--gutter) + var(--safe-r)) calc(var(--safe-b) + 112px) calc(var(--gutter) + var(--safe-l));
}
/* Large screens: the phone column sits on a calm backdrop */
@media (min-width: 640px) {
  .mat-paper { background: var(--bg-outer); }
  .mat-paper .app {
    background: var(--bg); min-height: 100dvh;
    box-shadow: 0 0 0 1px var(--line), 0 30px 80px -30px rgba(20, 16, 10, .25);
  }
  .mat-paper .app::before { /* grain inside the column too */
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image: var(--grain); background-size: 160px; opacity: .10; mix-blend-mode: multiply;
  }
}

/* Header: eyebrow + large title + trailing actions */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 6px 0 16px; }
.head__title { font: 700 var(--fs-page)/1.15 var(--font-serif); letter-spacing: .02em; }
.mat-glass .head__title { font-weight: 600; }
.head__eyebrow { font: 500 var(--fs-sm)/1.3 var(--font-sans); color: var(--ink-3); margin-bottom: 6px; }
.head__actions { display: flex; gap: 8px; }

.stack { display: grid; gap: 12px; }
.stack--lg { display: grid; gap: 20px; }
.cluster { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.section-label { font: 600 var(--fs-sm)/1.2 var(--font-sans); color: var(--ink-3); padding: 20px 4px 10px; letter-spacing: .02em; }

/* Type roles */
.t-num { font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.t-eyebrow { font: 600 var(--fs-cap)/1.2 var(--font-sans); letter-spacing: .08em; color: var(--ink-3); }
.t-cap { font: 500 var(--fs-cap)/1.45 var(--font-sans); color: var(--ink-3); }
.t-small { font-size: var(--fs-sm); color: var(--ink-2); }
.t-title { font: 600 var(--fs-title)/1.3 var(--font-sans); letter-spacing: .005em; }
.t-read { font: 400 17px/1.85 var(--font-serif); color: var(--ink-2); letter-spacing: .02em; }
.mat-glass .t-read { font-family: var(--font-sans); line-height: 1.75; }
.t-accent { color: var(--accent); }
.t-danger { color: var(--danger); }
.t-ok { color: var(--ok); }

/* Sample mark for mock pages */
.sample-mark {
  position: fixed; z-index: 60; top: calc(var(--safe-t) + 8px); left: 50%; transform: translateX(-50%);
  font: 500 11px/1 var(--font-sans); letter-spacing: .08em; color: var(--ink-2);
  padding: 5px 10px; border-radius: var(--r-pill); background: var(--press); pointer-events: none;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

/* ---------- 4. Surfaces: card, panel, inset module ---------- */
.card, .panel {
  position: relative; border-radius: var(--r-3);
  background: var(--surface); padding: 20px;
  box-shadow: inset 0 1px 0 var(--hi), var(--sh-1);
  --row-bg: var(--surface-2);
}
.panel { border-radius: var(--r-4); padding: 24px; box-shadow: inset 0 1px 0 var(--hi), var(--sh-2); }
.inset { border-radius: var(--r-2); background: var(--surface-2); padding: 14px 16px; }
.mat-glass .card, .mat-glass .panel {
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.5); backdrop-filter: blur(var(--glass-blur)) saturate(1.5);
  box-shadow: inset 0 0 0 1px var(--rim), inset 0 1px 0 var(--rim-top), 0 30px 60px -30px rgba(0, 0, 0, .6);
}
.card--accent { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.card__eyebrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card__title { font: 600 var(--fs-title)/1.3 var(--font-sans); }
.card__text { margin-top: 6px; font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.card__actions { display: flex; gap: 10px; margin-top: 18px; }
.card__actions > .btn { flex: 1; }
.divider { height: 1px; background: var(--line); border: 0; margin: 16px 0; }

/* ---------- 5. Buttons: primary / secondary / icon + destructive ---------- */
.btn {
  --b-bg: var(--press); --b-ink: var(--ink); --b-sh: inset 0 1px 0 var(--hi), inset 0 0 0 1px var(--line);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--h-ctl); padding: 0 22px; border: 0; border-radius: var(--r-pill);
  background: var(--b-bg); color: var(--b-ink); box-shadow: var(--b-sh);
  font: 600 16px/1 var(--font-sans); letter-spacing: .02em; text-decoration: none; white-space: nowrap;
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  transition: transform var(--d-3) var(--spring), background-color var(--d-2), box-shadow var(--d-2), opacity var(--d-2);
}
.btn svg { width: 18px; height: 18px; flex: none; }
@media (hover: hover) { .btn:hover { filter: brightness(1.04); } .btn--secondary:hover, .btn--icon:hover, .btn--ghost:hover { background: var(--press-2); filter: none; } }
.btn:active, .btn.is-pressed { transform: scale(.96); transition-duration: var(--d-1); transition-timing-function: var(--ease-out); box-shadow: inset 0 1px 0 var(--hi); }
.btn:focus-visible, .btn.is-focus { outline: none; box-shadow: var(--b-sh), 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .38; cursor: not-allowed; transform: none; filter: none; }

/* tier 1: one per screen */
.btn--primary {
  --b-bg: var(--accent); --b-ink: var(--on-accent);
  --b-sh: inset 0 1px 0 rgba(255, 255, 255, .22), 0 8px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn--primary:active, .btn--primary.is-pressed { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 3px 8px -4px color-mix(in srgb, var(--accent) 60%, transparent); }
.mat-glass .btn--primary { --b-bg: #f4efe4; --b-ink: #16140f; --b-sh: inset 0 1px 0 #fff, 0 10px 24px -10px rgba(0, 0, 0, .6); }
/* tier 2 */
.btn--secondary { --b-bg: var(--press); --b-ink: var(--ink); }
.mat-glass .btn--secondary { --b-bg: transparent; --b-sh: inset 0 0 0 1px var(--line-2); }
.mat-glass .btn--secondary:active { box-shadow: inset 0 0 0 1px var(--line-2); background: var(--press); }
/* tier 3: icon, 44px circle */
.btn--icon { --b-bg: var(--press); width: var(--tap); min-height: var(--tap); height: var(--tap); padding: 0; border-radius: 50%; }
.btn--icon svg { width: 20px; height: 20px; }
.mat-glass .btn--icon { --b-bg: rgba(255, 255, 255, .09); --b-sh: inset 0 0 0 1px var(--line); }
/* quiet text button, still 44px tall */
.btn--ghost { --b-bg: transparent; --b-sh: none; --b-ink: var(--ink-2); padding: 0 14px; min-height: var(--tap); font-weight: 500; }
/* destructive */
.btn--danger { --b-bg: var(--danger-soft); --b-ink: var(--danger); --b-sh: none; }
.btn--danger-solid { --b-bg: var(--danger); --b-ink: #fff; --b-sh: inset 0 1px 0 rgba(255, 255, 255, .2), 0 8px 18px -8px color-mix(in srgb, var(--danger) 70%, transparent); }
.mat-glass .btn--danger-solid { --b-ink: #2a0d05; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mat-paper .btn--danger-solid { --b-ink: #2a0d05; } }
:root[data-theme="dark"] .mat-paper .btn--danger-solid { --b-ink: #2a0d05; }
/* sizes */
.btn--lg { min-height: var(--h-ctl-lg); font-size: 17px; padding: 0 28px; }
.btn--sm { min-height: 36px; padding: 0 14px; font-size: 14px; font-weight: 500; }
.btn--sm::after { content: ""; position: absolute; inset: -4px -2px; } /* keep the hit area ≥ 44px */
.btn--block { width: 100%; }
/* loading */
.btn.is-busy { color: transparent; pointer-events: none; }
.btn.is-busy::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--b-ink); border-right-color: transparent; animation: kit-spin .7s linear infinite;
}
@keyframes kit-spin { to { transform: rotate(360deg); } }

/* ---------- 6. Segmented control with sliding indicator ---------- */
.seg {
  position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 0; border-radius: var(--r-pill); background: var(--seg-bg); isolation: isolate;
  --ind-inset: 4px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.seg__ind {
  position: absolute; z-index: -1; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: var(--r-pill);
  background: var(--seg-on); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 4px 12px -4px rgba(0, 0, 0, .18);
  transition: transform var(--d-4) var(--spring-soft), width var(--d-4) var(--spring-soft);
}
.seg__opt {
  min-height: 48px; padding: 0 12px; border: 0; border-radius: var(--r-pill); background: none; cursor: pointer;
  font: 500 15px/1 var(--font-sans); color: var(--ink-2); white-space: nowrap;
  transition: color var(--d-2), transform var(--d-3) var(--spring);
}
.seg__opt[aria-checked="true"], .seg__opt[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.mat-glass .seg__opt[aria-checked="true"], .mat-glass .seg__opt[aria-selected="true"] { color: #141413; }
.seg__opt:active { transform: scale(.95); }
.seg__opt:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg__opt:disabled { opacity: .38; cursor: not-allowed; }
.seg--sm .seg__opt { min-height: 44px; font-size: 14px; }

/* ---------- 7. List-row module ---------- */
.rows { display: grid; gap: 8px; }
.row {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 60px; padding: 10px 14px 10px 10px; border: 0; border-radius: var(--r-2);
  background: var(--row-bg); color: var(--ink); text-align: left; text-decoration: none;
  font: 500 16px/1.3 var(--font-sans);
}
.card .row, .panel .row { --row-bg: var(--surface-2); }
.row--plain { padding-left: 16px; }
:is(a, button).row { cursor: pointer; transition: transform var(--d-3) var(--spring), background-color var(--d-2); }
@media (hover: hover) { :is(a, button).row:hover { background: color-mix(in srgb, var(--ink) 3%, var(--row-bg)); } }
:is(a, button).row:active, .row.is-pressed { transform: scale(.98); transition-duration: var(--d-1); }
:is(a, button).row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row__icon {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--tile, var(--surface-3)); color: var(--tile-ink, var(--ink-2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
.row__icon svg { width: 20px; height: 20px; }
.row__icon--accent { --tile: var(--accent); --tile-ink: var(--on-accent); }
.mat-glass .row__icon { --tile: rgba(255, 255, 255, .1); --tile-ink: var(--ink); }
.mat-glass .row__icon--accent { --tile: var(--accent); --tile-ink: var(--on-accent); }
.row__icon .t-num, .row__icon b { font: 600 15px/1 var(--font-sans); }
.row__main { flex: 1; min-width: 0; }
.row__label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__sub { display: block; margin-top: 3px; font: 400 13px/1.35 var(--font-sans); color: var(--ink-3); }
.row__value { flex: none; text-align: right; font: 600 16px/1.2 var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink); }
.row__value small { display: block; margin-top: 3px; font: 400 12px/1.2 var(--font-sans); color: var(--ink-3); }
.row__value--text { font-family: var(--font-sans); font-weight: 500; font-size: 15px; color: var(--ink-2); }
.row__chev { flex: none; width: 16px; height: 16px; color: var(--ink-3); margin-right: -4px; }

/* ---------- 8. Stat / hero number ---------- */
.stat { display: grid; gap: 4px; }
.stat__label { font: 500 var(--fs-sm)/1.3 var(--font-sans); color: var(--ink-3); }
.stat__num { font: 700 64px/.95 var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -.045em; color: var(--ink); }
.stat__num--xl { font-size: 88px; }
.stat__num--md { font-size: 32px; letter-spacing: -.03em; }
.stat__unit { font-size: .42em; font-weight: 600; letter-spacing: 0; margin-left: .06em; color: var(--ink-2); vertical-align: .9em; }
.stat__delta { font: 600 var(--fs-sm)/1.2 var(--font-num); font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats > .inset { padding: 12px 14px; }
.stats .stat__num { font-size: 24px; letter-spacing: -.02em; }

/* ---------- 9. Chip / badge ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 12px; border-radius: var(--r-pill);
  background: var(--press); color: var(--ink-2); font: 500 13px/1 var(--font-sans); white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; }
.chip--accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: color-mix(in srgb, var(--accent) 80%, var(--ink)); }
.mat-glass .chip--accent { color: var(--accent); }
.chip--danger { background: var(--danger-soft); color: var(--danger); }
.chip__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
button.chip { border: 0; cursor: pointer; min-height: 36px; padding: 0 14px; position: relative; transition: transform var(--d-3) var(--spring); }
button.chip::after { content: ""; position: absolute; inset: -4px 0; }
button.chip:active { transform: scale(.95); }
button.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.mat-glass button.chip[aria-pressed="true"] { background: var(--ink); color: #141413; }
button.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--on-accent); font: 600 12px/1 var(--font-num); font-variant-numeric: tabular-nums;
}
.badge--quiet { background: var(--surface-3); color: var(--ink-2); }

/* ---------- 10. Fields: input, textarea, picker, stepper ---------- */
.field { display: grid; gap: 8px; }
.field__label { display: flex; justify-content: space-between; align-items: baseline; font: 500 var(--fs-sm)/1.3 var(--font-sans); color: var(--ink-2); }
.field__label small { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.field__hint { font: 400 13px/1.45 var(--font-sans); color: var(--ink-3); }
.field__error { display: flex; gap: 6px; align-items: center; font: 500 13px/1.45 var(--font-sans); color: var(--danger); }
.field__error:empty { display: none; }
.field__error svg { width: 14px; height: 14px; flex: none; }

.input, .textarea, .picker {
  width: 100%; min-height: 52px; padding: 0 16px; border: 0; border-radius: var(--r-2);
  background: var(--surface-2); color: var(--ink);
  font: 400 17px/1.3 var(--font-sans);                /* ≥16px: iOS will not zoom */
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow var(--d-2), background-color var(--d-2);
  -webkit-appearance: none; appearance: none;
}
.card .input, .card .textarea, .card .picker, .panel .input, .panel .textarea, .panel .picker, .sheet .input, .sheet .textarea, .sheet .picker { background-color: var(--surface-2); }
.mat-paper .sheet :is(.input, .textarea, .picker) { background-color: var(--bg); }
.input--num { font-family: var(--font-num); font-weight: 500; font-variant-numeric: tabular-nums; font-size: 18px; letter-spacing: -.01em; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 1; }
.textarea { min-height: 96px; padding: 14px 16px; line-height: 1.55; resize: none; display: block; }
.input:hover, .textarea:hover, .picker:hover { box-shadow: inset 0 0 0 1px var(--line-2); }
.input:focus, .textarea:focus, .picker:focus, .input.is-focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { box-shadow: inset 0 0 0 1.5px var(--danger), 0 0 0 4px var(--danger-soft); }
.input:disabled, .textarea:disabled, .picker:disabled { opacity: .45; cursor: not-allowed; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 52px; }
.input-wrap__suffix { position: absolute; right: 16px; font: 500 15px/1 var(--font-sans); color: var(--ink-3); pointer-events: none; }
.input-wrap__prefix { position: absolute; left: 16px; font: 500 15px/1 var(--font-sans); color: var(--ink-3); pointer-events: none; }
.input-wrap__prefix + .input { padding-left: 44px; }
/* select-like picker: native <select> (best phone picker), restyled */
.picker {
  padding-right: 44px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 20px;
}
.picker option { color: #141413; background: #fff; }
/* stepper */
.stepper {
  display: grid; grid-template-columns: 52px 1fr 52px; align-items: center; min-height: 52px;
  border-radius: var(--r-2); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow var(--d-2);
}
.mat-paper .sheet .stepper { background: var(--bg); }
.stepper:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.stepper__btn {
  display: grid; place-items: center; height: 52px; border: 0; background: none; cursor: pointer; color: var(--ink-2);
  border-radius: var(--r-2); transition: transform var(--d-3) var(--spring), color var(--d-2);
}
.stepper__btn svg { width: 20px; height: 20px; }
.stepper__btn:active { transform: scale(.85); color: var(--ink); }
.stepper__btn:disabled { opacity: .3; cursor: not-allowed; transform: none; }
.stepper__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.stepper input {
  width: 100%; min-width: 0; height: 52px; border: 0; background: none; text-align: center; color: var(--ink);
  font: 600 20px/1 var(--font-num); font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.stepper input:focus { outline: none; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- 11. Switch ---------- */
.switch {
  position: relative; flex: none; width: 52px; height: 32px; margin: 6px 0; border-radius: var(--r-pill);
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color var(--d-2) var(--ease-out);
}
.switch::before { content: ""; position: absolute; inset: -6px -2px; } /* 44px target */
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 3px 8px -2px rgba(0, 0, 0, .25);
  transition: transform var(--d-3) var(--spring-soft), width var(--d-2) var(--ease-out);
}
.switch:active::after { width: 32px; }
.switch:checked { background: var(--accent); box-shadow: none; }
.switch:checked::after { transform: translateX(20px); }
.switch:checked:active::after { transform: translateX(14px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.switch:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 12. Bottom tab bar (floating, safe-area aware) ---------- */
.tabbar {
  position: fixed; z-index: 40; left: 50%; bottom: calc(var(--safe-b) + 10px); transform: translateX(-50%);
  width: calc(min(100vw, var(--col)) - 2 * var(--gutter));
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 6px; border-radius: 30px;
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 var(--hi), 0 12px 32px -12px rgba(20, 16, 10, .3);
}
.mat-glass .tabbar { box-shadow: inset 0 0 0 1px var(--rim), inset 0 1px 0 var(--rim-top), 0 16px 40px -12px rgba(0, 0, 0, .6); }
.tabbar__item {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 52px;
  border: 0; border-radius: 24px; background: none; color: var(--ink-3); cursor: pointer; text-decoration: none;
  font: 500 11px/1 var(--font-sans); letter-spacing: .04em;
  transition: color var(--d-2), transform var(--d-3) var(--spring);
}
.tabbar__item svg { width: 24px; height: 24px; transition: transform var(--d-3) var(--spring); }
.tabbar__item[aria-current="page"] { color: var(--ink); }
.mat-paper .tabbar__item[aria-current="page"] { color: var(--accent); }
.tabbar__item:active { transform: scale(.92); }
.tabbar__item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tabbar__pill { /* the selected background slides like the segmented indicator */
  position: absolute; z-index: -1; top: 6px; bottom: 6px; left: 0; border-radius: 24px; background: var(--press);
  transition: transform var(--d-4) var(--spring-soft), width var(--d-4) var(--spring-soft);
}
.mat-glass .tabbar__pill { background: rgba(255, 255, 255, .1); }
.tabbar { isolation: isolate; }
.tabbar__dot { position: absolute; top: 9px; left: calc(50% + 9px); width: 7px; height: 7px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--bar-bg); }

/* ---------- 13. Bottom sheet ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 80; background: var(--scrim); opacity: 0; pointer-events: none;
  transition: opacity var(--d-3) var(--ease-out);
}
.scrim.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 90; left: 50%; bottom: 0; width: min(100vw, var(--col));
  max-height: calc(100dvh - var(--safe-t) - 40px);
  display: flex; flex-direction: column;
  border-radius: 28px 28px 0 0; background: var(--sheet-bg); color: var(--ink);
  box-shadow: inset 0 1px 0 var(--hi), 0 -20px 60px -20px rgba(0, 0, 0, .35);
  transform: translate(-50%, 105%); visibility: hidden;
  transition: transform var(--d-3) var(--ease-in), visibility 0s linear var(--d-3);
}
.mat-glass .sheet {
  -webkit-backdrop-filter: blur(40px) saturate(1.6); backdrop-filter: blur(40px) saturate(1.6);
  box-shadow: inset 0 0 0 1px var(--rim), inset 0 1px 0 var(--rim-top), 0 -20px 60px -20px rgba(0, 0, 0, .6);
}
@media (min-width: 640px) { .sheet { bottom: 16px; border-radius: 28px; max-height: calc(100dvh - 64px); } }
.sheet.is-open { transform: translate(-50%, 0); visibility: visible; transition: transform var(--d-4) var(--spring-soft), visibility 0s; }
.sheet.is-dragging { transition: none; }
.sheet:focus { outline: none; }
.sheet__grab { flex: none; display: grid; place-items: center; height: 24px; cursor: grab; touch-action: none; }
.sheet__grab::before { content: ""; width: 36px; height: 5px; border-radius: 3px; background: var(--line-2); }
.sheet__head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 16px 8px 24px; touch-action: none; }
.sheet__title { font: 600 20px/1.3 var(--font-sans); }
.sheet__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 24px 20px; -webkit-overflow-scrolling: touch; }
.sheet__actions {
  flex: none; display: flex; gap: 10px; padding: 12px 20px calc(var(--safe-b) + 16px);
  border-top: 1px solid var(--line); background: inherit; border-radius: 0 0 inherit inherit;
}
.sheet__actions > .btn { flex: 1; }
@media (min-width: 640px) { .sheet__actions { padding-bottom: 16px; } }

/* ---------- 14. Toast ---------- */
.toast-region { position: fixed; z-index: 120; left: 50%; bottom: calc(var(--safe-b) + 92px); transform: translateX(-50%); width: min(calc(100vw - 32px), 400px); display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 100%; min-height: 48px; padding: 12px 18px 12px 14px; border-radius: var(--r-pill);
  background: rgba(24, 24, 22, .92); color: #f5f3ee; font: 500 15px/1.35 var(--font-sans);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1), 0 16px 40px -12px rgba(0, 0, 0, .45);
  animation: kit-toast-in var(--d-4) var(--spring-soft) both;
}
.toast.is-leaving { animation: kit-toast-out var(--d-2) var(--ease-in) both; }
.toast__icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ok); color: #0d1a12; flex: none; }
.toast--error .toast__icon { background: var(--danger); color: #fff; }
.toast__icon svg { width: 14px; height: 14px; }
.mat-paper .toast__icon { background: #6fbf8f; }
@keyframes kit-toast-in { from { opacity: 0; transform: translateY(16px) scale(.94); } }
@keyframes kit-toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------- 15. Progress bar (with optional cap mark) and arc gauge ---------- */
.meter { --v: 0; --cap: 100; position: relative; height: 10px; border-radius: var(--r-pill); background: var(--track); }
.meter__fill {
  position: absolute; inset: 0 auto 0 0; width: calc(var(--v) * 1%); border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0 calc(var(--cap) / var(--v) * 100%), var(--danger) 0);
  transition: width .9s var(--ease-out);
}
.meter__cap { position: absolute; top: -5px; bottom: -5px; left: calc(var(--cap) * 1%); width: 2px; margin-left: -1px; border-radius: 1px; background: var(--ink); box-shadow: 0 0 0 2px var(--bg); }
.card .meter__cap, .panel .meter__cap { box-shadow: 0 0 0 2px var(--surface); }
.mat-glass .meter__cap { box-shadow: none; }
.meter__legend { position: relative; display: flex; justify-content: space-between; margin-top: 10px; font: 500 12px/1 var(--font-sans); color: var(--ink-3); }
.meter--thin { height: 6px; }
.meter__legend .at-cap { position: absolute; left: calc(var(--cap) * 1%); transform: translateX(-50%); }

.gauge { position: relative; width: 100%; max-width: 300px; margin: 0 auto; aspect-ratio: 260 / 196; }
.gauge svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.gauge__track { stroke: var(--track); }
.gauge__fill { stroke: var(--accent); }
.gauge__over { stroke: var(--danger); }
.gauge__cap { stroke: var(--ink); }
.gauge__center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding-top: 6%; }
.gauge__label { font: 500 13px/1.3 var(--font-sans); color: var(--ink-3); }
.gauge__caplabel { font: 600 11px/1 var(--font-sans); fill: var(--ink-2); letter-spacing: .02em; }

.spark { display: block; width: 100%; height: 56px; overflow: visible; }
.spark__line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark__dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.mat-glass .spark__dot { stroke: #0e1310; }

/* ---------- 16. Skeleton, empty, error ---------- */
.skel { position: relative; overflow: hidden; border-radius: 8px; background: var(--surface-3); min-height: 14px; }
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--hi) 80%, transparent), transparent);
  animation: kit-shimmer 1.4s var(--ease-out) infinite;
}
.mat-glass .skel { background: rgba(255, 255, 255, .08); }
.skel--line { height: 14px; } .skel--title { height: 22px; width: 60%; } .skel--num { height: 56px; width: 50%; border-radius: 12px; }
.skel--row { height: 60px; border-radius: var(--r-2); }
@keyframes kit-shimmer { to { transform: translateX(100%); } }

.state { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 28px 12px 8px; }
.state__icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--surface-2); color: var(--ink-3); margin-bottom: 6px; }
.state__icon svg { width: 26px; height: 26px; }
.state--error .state__icon { background: var(--danger-soft); color: var(--danger); }
.state__title { font: 600 17px/1.35 var(--font-sans); }
.state__text { font: 400 14px/1.6 var(--font-sans); color: var(--ink-3); max-width: 26em; }
.state .btn { margin-top: 10px; }

/* ---------- 17. Auto-height + page transitions ---------- */
.autoh { overflow: visible; transition: height var(--d-3) var(--ease-out); }
.autoh.is-animating { overflow: hidden; }
.autoh.is-measuring { transition: none; }
.page[hidden] { display: none; }
.fade-in { animation: kit-fade-in var(--d-3) var(--ease-out) both; }
@keyframes kit-fade-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- 18. Small table (compact history etc.) ---------- */
.mini-table { width: 100%; border-collapse: collapse; font: 400 14px/1.3 var(--font-sans); }
.mini-table th { text-align: right; font: 500 12px/1.2 var(--font-sans); color: var(--ink-3); padding: 0 0 8px; }
.mini-table th:first-child, .mini-table td:first-child { text-align: left; }
.mini-table td { text-align: right; padding: 10px 0; border-top: 1px solid var(--line); font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.mini-table td:first-child { color: var(--ink-2); }

/* ---------- 19. Compact header (title and date on one line) ---------- */
.head--inline { align-items: center; padding: 2px 0 10px; }
.head--inline > div:first-child { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.head--inline .head__eyebrow { margin: 0; white-space: nowrap; }

/* ---------- 20. Stacked bar + legend (parts of a whole) ---------- */
/* <div class="stackbar"><i style="--w:69"></i><i class="stackbar__seg--2" style="--w:20"></i>…</div> */
.stackbar { display: flex; gap: 3px; height: 14px; border-radius: var(--r-pill); overflow: hidden; }
.stackbar > i { flex: var(--w) 1 0; min-width: 6px; background: var(--c, var(--accent)); transform-origin: left; animation: kit-grow .9s var(--ease-out) both; }
.stackbar > i:first-child { border-radius: var(--r-pill) 3px 3px var(--r-pill); }
.stackbar > i:last-child { border-radius: 3px var(--r-pill) var(--r-pill) 3px; }
.stackbar__seg--2 { --c: color-mix(in srgb, var(--accent) 45%, #fff); }
.stackbar__seg--3 { --c: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); }
@keyframes kit-grow { from { transform: scaleX(0); } }
.legend { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.legend__item { display: grid; gap: 4px; min-width: 0; }
.legend__name { display: flex; align-items: center; gap: 6px; font: 500 13px/1.2 var(--font-sans); color: var(--ink-2); }
.legend__key { flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--accent)); }
.legend__key.stackbar__seg--3 { box-shadow: inset 0 0 0 1px var(--line-2); }
.legend__val { font: 600 17px/1.1 var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.legend__val small { display: block; margin-top: 3px; font: 400 12px/1.2 var(--font-num); color: var(--ink-3); letter-spacing: 0; }

/* ---------- 21. Table with a highlighted current row ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font: 400 15px/1.3 var(--font-sans); }
.table th { text-align: left; font: 500 12px/1.2 var(--font-sans); color: var(--ink-3); padding: 0 12px 8px; }
.table th:last-child, .table td:last-child { text-align: right; }
.table td { padding: 13px 12px; border-top: 1px solid var(--line); color: var(--ink-2); }
.table td.num, .table td:last-child { font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.table tr.is-current td { background: color-mix(in srgb, var(--accent) 11%, transparent); color: var(--ink); font-weight: 600; border-top-color: transparent; }
.table tr.is-current + tr td { border-top-color: transparent; }
.table tr.is-current td:first-child { border-radius: 12px 0 0 12px; }
.table tr.is-current td:last-child { border-radius: 0 12px 12px 0; color: var(--accent); }
.table__tag { display: inline-block; margin-left: 8px; padding: 3px 7px; border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent); font: 600 11px/1 var(--font-sans); vertical-align: 1px; }

/* ---------- 22. Info button (ⓘ) → explanation sheet ---------- */
/* <button class="info-btn" data-info="#tpl" aria-label="…是什么"> ; <template id="tpl" data-title="…"> */
.info-btn {
  position: relative; flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin: 0 -2px 0 0; padding: 0;
  border: 0; border-radius: 50%; background: var(--press); color: var(--ink-3); cursor: pointer;
  transition: transform var(--d-3) var(--spring), background-color var(--d-2), color var(--d-2);
}
.info-btn::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; } /* 44px target */
.info-btn svg { width: 16px; height: 16px; }
@media (hover: hover) { .info-btn:hover { background: var(--press-2); color: var(--ink); } }
.info-btn:active { transform: scale(.88); }
.info-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.info { display: grid; gap: 14px; }
.info__lead { font: 400 17px/1.8 var(--font-serif); color: var(--ink); letter-spacing: .02em; }
.info__how { border-radius: var(--r-2); background: var(--surface-2); padding: 14px 16px; font: 400 14px/1.65 var(--font-sans); color: var(--ink-2); }
.info__how b { display: block; margin-bottom: 4px; font: 600 12px/1.2 var(--font-sans); letter-spacing: .06em; color: var(--ink-3); }

/* ---------- 23. Check list (pass / fail) ---------- */
.checks { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 13px 0; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; padding-top: 4px; }
.check__mark { flex: none; display: grid; place-items: center; width: 26px; height: 26px; margin-top: 1px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.check__mark svg { width: 15px; height: 15px; stroke-width: 2.4; }
.check.is-fail .check__mark { background: var(--danger-soft); color: var(--danger); }
.check__label { font: 500 16px/1.4 var(--font-sans); color: var(--ink); }
.check__sub { margin-top: 2px; font: 400 13px/1.5 var(--font-sans); color: var(--ink-3); }
.check__state { margin-left: auto; padding-left: 8px; flex: none; font: 600 13px/26px var(--font-sans); color: var(--accent); }
.check.is-fail .check__state { color: var(--danger); }

/* ---------- 24. Log entries (date · action · reason · condition) ---------- */
.log { display: grid; margin: 0; padding: 0; list-style: none; }
.log__item { position: relative; padding: 14px 0 14px 22px; border-top: 1px solid var(--line); }
.log__item:first-child { border-top: 0; padding-top: 2px; }
.log__item::before { content: ""; position: absolute; left: 3px; top: 21px; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.log__item:first-child::before { top: 9px; }
.log__item.is-skip::before { background: transparent; box-shadow: inset 0 0 0 2px var(--ink-3); }
.log__item.is-exec::before { background: var(--accent); }
.log__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.log__title { font: 600 16px/1.35 var(--font-sans); color: var(--ink); }
.log__date { flex: none; font: 500 12px/1.2 var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink-3); }
.log__reason { margin-top: 6px; font: 400 15px/1.7 var(--font-serif); color: var(--ink-2); letter-spacing: .02em; }
.log__cond { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 5px 10px; border-radius: var(--r-pill); background: var(--surface-2); font: 500 12px/1.2 var(--font-sans); color: var(--ink-2); }
.log__cond svg { width: 13px; height: 13px; color: var(--ink-3); }

/* ---------- 25. Rule lines on a price range (stop · cost · now · target) ---------- */
/* <div class="range" style="--lo:16.5;--hi:24"><i class="range__mark range__mark--stop" style="--at:16.5" data-label="止损 16.50"></i>…</div> */
.range { --span: calc(var(--hi) - var(--lo)); position: relative; height: 92px; margin: 0 6px; }
.range::before { content: ""; position: absolute; left: 0; right: 0; top: 45px; height: 4px; border-radius: 2px; background: var(--track); }
.range__fill { position: absolute; top: 45px; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 55%, transparent);
  left: calc((var(--from) - var(--lo)) / var(--span) * 100%); width: calc((var(--to) - var(--from)) / var(--span) * 100%); }
.range__mark { position: absolute; top: 37px; left: calc((var(--at) - var(--lo)) / var(--span) * 100%); width: 2px; height: 20px; margin-left: -1px; border-radius: 1px; background: var(--ink-2); }
.range__mark::after {
  content: attr(data-label); position: absolute; left: 50%; top: 28px; transform: translateX(var(--tx, -50%));
  white-space: nowrap; font: 500 12px/1.2 var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink-2);
}
.range__mark--up::after { top: auto; bottom: 28px; }
.range__mark--start::after { --tx: -8px; } .range__mark--end::after { --tx: calc(-100% + 8px); }
.range__mark--stop { background: var(--danger); } .range__mark--stop::after { color: var(--danger); font-weight: 600; }
.range__mark--now { top: 40px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--surface-solid, var(--bg)); }
.range__mark--now::after { color: var(--accent); font-weight: 600; top: 25px; }
.range__mark--now.range__mark--up::after { top: auto; bottom: 25px; }

/* ---------- 26. Floating action next to the tab bar (e.g. 「问」) ---------- */
/* Sits beside the bar at the same height, so it never covers page content. */
.has-fab .tabbar { width: calc(min(100vw, var(--col)) - 2 * var(--gutter) - 64px); transform: translateX(calc(-50% - 32px)); }
.fab {
  position: fixed; z-index: 41; bottom: calc(var(--safe-b) + 14px); left: calc(50% + min(100vw, var(--col)) / 2 - var(--gutter) - 56px);
  display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--bar-bg); color: var(--accent); font: 600 19px/1 var(--font-sans);
  -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 var(--hi), 0 12px 32px -12px rgba(20, 16, 10, .3);
  transition: transform var(--d-3) var(--spring);
}
.fab:active { transform: scale(.92); transition-duration: var(--d-1); }
.fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- 27. Frost material: slabs, controls, bars, sheets ---------- */
.mat-frost .card, .mat-frost .panel, .mat-frost .rows {
  background-color: var(--glass);
  background-image: linear-gradient(165deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 42%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4); backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  box-shadow: inset 0 0 0 1px var(--rim), inset 0 1px 0 var(--rim-top), 0 0 0 .5px var(--edge), var(--sh-frost);
}
.mat-frost .card { --row-bg: transparent; }
/* list rows group into one slab with hairlines, like a single object */
.mat-frost .rows { gap: 0; border-radius: var(--r-3); overflow: hidden; }
.mat-frost .rows > .row { border-radius: 0; background: transparent; }
.mat-frost .rows > .row:not([hidden]) ~ .row:not([hidden])::before { content: ""; position: absolute; top: 0; left: 64px; right: 0; height: 1px; background: var(--line); }
.mat-frost .rows > .row--plain:not([hidden]) ~ .row--plain:not([hidden])::before { left: 16px; }
.mat-frost :is(a, button).row:active, .mat-frost .row.is-pressed { transform: none; background: var(--press-2); }
@media (hover: hover) { .mat-frost .rows > :is(a, button).row:hover { background: var(--press); } }
.mat-frost :is(a, button).row:focus-visible { outline-offset: -3px; border-radius: 14px; }
.mat-frost .rows--quiet { background-color: var(--glass-2); }
.mat-frost :is(.card, .panel, .sheet) .rows { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(255, 255, 255, .55); background-image: none; box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--r-2); }
.mat-frost .row__icon { --tile: rgba(80, 70, 40, .07); --tile-ink: var(--ink-2); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7); }
.mat-frost .row__icon--accent { --tile: var(--accent); --tile-ink: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 6px 14px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.mat-frost .inset { box-shadow: inset 0 1px 1px rgba(80, 70, 40, .04); }
.mat-frost .btn--secondary, .mat-frost .btn--icon {
  --b-bg: rgba(255, 255, 255, .66);
  --b-sh: inset 0 0 0 1px var(--rim), inset 0 1px 0 var(--rim-top), 0 0 0 .5px var(--edge), 0 2px 6px -2px rgba(70, 60, 30, .16);
}
.mat-frost :is(.card, .panel, .sheet) .btn--secondary { --b-bg: rgba(255, 255, 255, .78); }
@media (hover: hover) { .mat-frost .btn--secondary:hover, .mat-frost .btn--icon:hover { background: #fff; } }
.mat-frost .btn--icon { -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.mat-frost .btn--primary { background-image: linear-gradient(180deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0)); }
.mat-frost .seg { box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 2px rgba(80, 70, 40, .05); }
.mat-frost .seg__ind { box-shadow: 0 0 0 .5px var(--edge), 0 1px 2px rgba(70, 60, 30, .10), 0 6px 14px -6px rgba(70, 60, 30, .28); }
.mat-frost .tabbar, .mat-frost .fab {
  -webkit-backdrop-filter: blur(28px) saturate(1.6); backdrop-filter: blur(28px) saturate(1.6);
  box-shadow: inset 0 0 0 1px var(--rim), inset 0 1px 0 var(--rim-top), 0 0 0 .5px var(--edge), 0 14px 34px -14px rgba(70, 60, 30, .38);
}
.mat-frost .tabbar__item[aria-current="page"] { color: var(--accent); }
.mat-frost .tabbar__pill { background: color-mix(in srgb, var(--accent) 11%, rgba(255, 255, 255, .5)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8); }
.mat-frost .sheet {
  -webkit-backdrop-filter: blur(40px) saturate(1.5); backdrop-filter: blur(40px) saturate(1.5);
  box-shadow: inset 0 0 0 1px var(--rim), inset 0 1px 0 var(--rim-top), 0 0 0 .5px var(--edge), 0 -20px 60px -20px rgba(60, 50, 30, .3);
}
.mat-frost .sheet__actions { background: transparent; }
.mat-frost .sheet :is(.input, .textarea, .picker), .mat-frost .sheet .stepper { background-color: rgba(255, 255, 255, .8); }
.mat-frost .meter__cap { box-shadow: 0 0 0 2px rgba(255, 255, 255, .8); }
.mat-frost .toast__icon { background: #8fd0a8; }
.mat-frost .head__title { font-weight: 700; }
/* No backdrop-filter: the same slabs, solid */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .mat-frost { --glass: #f8f7f3; --glass-2: #f3f1ec; --bar-bg: #fbfaf7; --sheet-bg: #f8f7f3; }
}
.mat-frost.no-blur { --glass: #f8f7f3; --glass-2: #f3f1ec; --bar-bg: #fbfaf7; --sheet-bg: #f8f7f3; } /* test hook for the fallback */
.mat-frost.no-blur * { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }

/* ---------- 28. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .mat-glass::before, .mat-frost::before { animation: none; }
  .stackbar > i { animation: none; }
  .skel::after { display: none; }
}
