/* Baozang. Tokens and the rules behind them live in DESIGN.md. A literal colour below the token
   blocks is a bug; the only exceptions are Bao's own fixed colours inside the SVG markup. */

:root {
  --page: #FFF8EC;
  --card: #FFFFFF;
  --raised: #FBF1E0;
  --line: #EADCC7;
  --line-strong: #D5C4AA;
  --ink: #1F1A2E;
  --ink-2: #4A4458;
  --muted: #6E6878;
  --brand: #3E5BF2;
  --on-brand: #FFFFFF;
  --hero: #3E5BF2;
  --on-hero: #FFFFFF;
  --hero-soft: #F2F4FF;
  --sun: #FFD23F;
  --pick: #F5A23C;
  --on-pick: #1F1A2E;
  --fixed-ink: #1F1A2E;
  --fixed-paper: #FFF8EC;
  --live: #17A773;
  --steady: #E89A0C;
  --quiet: #BDB3A5;
  --code-bg: #1F1A2E;
  --code-raised: #2E2842;
  --code-line: #3A3350;
  --code-ink: #FFF8EC;
  --code-muted: #A59EB5;
  --scrim: rgb(31 26 46 / 0.45);
  --shadow-float: 0 24px 60px -18px rgb(31 26 46 / 0.5);

  --r-sm: 8px;
  --r-md: 20px;
  --r-lg: 32px;
  --r-full: 9999px;

  --max: 1320px;
  --gutter: 20px;
  --top-h: 72px;

  --display: 'Unbounded', 'Arial Black', system-ui, sans-serif;
  --body: 'Figtree', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --cjk: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --kl: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #15121F;
    --card: #1F1A2E;
    --raised: #29233A;
    --line: #352E48;
    --line-strong: #4A4260;
    --ink: #FFF8EC;
    --ink-2: #D6CFE0;
    --muted: #A39CB2;
    --brand: #7B8FFF;
    --on-brand: #15121F;
    --live: #3DDC97;
    --steady: #FFC24D;
    --quiet: #5E566E;
    --code-bg: #110E19;
    --code-raised: #221D31;
    --code-line: #352E48;
    --scrim: rgb(0 0 0 / 0.6);
    --shadow-float: 0 24px 60px -18px rgb(0 0 0 / 0.8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --page: #15121F;
  --card: #1F1A2E;
  --raised: #29233A;
  --line: #352E48;
  --line-strong: #4A4260;
  --ink: #FFF8EC;
  --ink-2: #D6CFE0;
  --muted: #A39CB2;
  --brand: #7B8FFF;
  --on-brand: #15121F;
  --live: #3DDC97;
  --steady: #FFC24D;
  --quiet: #5E566E;
  --code-bg: #110E19;
  --code-raised: #221D31;
  --code-line: #352E48;
  --scrim: rgb(0 0 0 / 0.6);
  --shadow-float: 0 24px 60px -18px rgb(0 0 0 / 0.8);
  color-scheme: dark;
}

/* ── base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 15px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a, button, summary, label, select, input { touch-action: manipulation; }
.sheet-open body { overflow: hidden; }
img, svg { max-width: 100%; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 0.9em; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.wrap {
  max-width: var(--max); margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.kl { font-family: var(--kl); font-weight: 400; letter-spacing: 0; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: 12px; z-index: 100; padding: 10px 16px; border-radius: var(--r-full); background: var(--ink); color: var(--page); }

/* Hidden until motion.js starts the intro (see the inline script in index.html). */
.intro .hero-copy, .intro .stage { visibility: hidden; }

/* ── buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; padding: 0 26px;
  border: 2.5px solid transparent; border-radius: var(--r-full);
  font: 700 16px/1 var(--body); text-decoration: none; white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn-sm { height: 42px; padding: 0 18px; font-size: 14px; border-width: 2px; }
.btn-hero { background: var(--on-hero); color: var(--hero); }
.btn-hero:hover { background: var(--sun); color: var(--fixed-ink); }
.btn-hero-ghost { background: transparent; border-color: var(--on-hero); color: var(--on-hero); }
.btn-hero-ghost:hover { background: var(--on-hero); color: var(--hero); }
.btn-ink { background: var(--ink); color: var(--page); }
.btn-ink:hover { background: var(--brand); color: var(--on-brand); }
.btn-line { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn-line:hover { background: var(--ink); color: var(--page); }
.icon-btn {
  flex: none; width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 2px solid var(--line-strong); border-radius: var(--r-full);
  background: transparent; color: var(--ink); cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn-sm { width: 34px; height: 34px; }
.link-btn {
  padding: 0; border: 0; background: none; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--ink);
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: var(--line-strong);
}
.link-btn:hover { text-decoration-color: var(--ink); }

/* ── top bar ──────────────────────────────────────────────────────────── */
.top { position: sticky; top: 0; z-index: 30; background: var(--page); }
.top-row { height: var(--top-h); display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 50px; height: auto; }
.brand-word { font: 900 25px/1 var(--display); letter-spacing: -0.05em; }
.top-nav { display: flex; gap: 4px; margin-left: 10px; }
.top-nav a {
  padding: 10px 15px; border-radius: var(--r-full);
  font-size: 14px; font-weight: 700; color: var(--ink-2); text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.top-nav a:hover { background: var(--raised); color: var(--ink); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.btn-stack { height: 46px; padding: 0 6px 0 18px; background: var(--ink); color: var(--page); font-size: 15px; }
.btn-stack:hover { background: var(--brand); color: var(--on-brand); }
.btn-stack .count {
  display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 9px;
  border-radius: var(--r-full); background: var(--pick); color: var(--on-pick);
  font: 600 13px/1 var(--mono);
}

/* ── hero ─────────────────────────────────────────────────────────────── */
.hero {
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 12px;
  min-height: 690px; padding: 60px 56px 0;
  background: var(--hero); color: var(--on-hero);
  border-radius: var(--r-lg); overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: radial-gradient(color-mix(in srgb, var(--on-hero) 16%, transparent) 1.6px, transparent 1.9px);
  background-size: 26px 26px;
  -webkit-mask-image: linear-gradient(to bottom, black 20%, transparent 90%);
  mask-image: linear-gradient(to bottom, black 20%, transparent 90%);
}
.hero-copy { align-self: center; padding-bottom: 60px; }
.eyebrow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 22px; font-size: 16px; font-weight: 600; }
.eyebrow .kl { font-size: 28px; color: var(--sun); }
.hero-title { margin: 0; font: 900 clamp(46px, 5.8vw, 86px)/0.94 var(--display); letter-spacing: -0.05em; }
.hero-title .line { display: block; overflow: hidden; padding-bottom: 0.09em; margin-bottom: -0.09em; }
.hero-title .line > span { display: inline-block; }
.hero-title .hl { color: var(--sun); font-size: 1.06em; }
.lede { margin: 26px 0 0; max-width: 42ch; font-size: 19px; line-height: 1.5; color: var(--on-hero); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.stats { display: flex; flex-wrap: wrap; gap: 14px 34px; margin: 42px 0 0; }
.stats dt { font: 600 11px/1.2 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--hero-soft); }
.stats dd { margin: 7px 0 0; font: 800 30px/1 var(--display); letter-spacing: -0.04em; }
.stats dd.stat-date { font: 600 15px/2 var(--mono); letter-spacing: 0; }

.stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 34px; }
.bao-float { position: relative; z-index: 2; margin-bottom: -20px; }
.bao-btn { display: block; padding: 0; border: 0; background: none; cursor: pointer; line-height: 0; border-radius: var(--r-md); }
.bao-btn:focus-visible { outline: 4px solid var(--sun); outline-offset: 6px; }
.bao { width: 260px; height: auto; overflow: visible; filter: drop-shadow(0 10px 0 color-mix(in srgb, var(--fixed-ink) 24%, transparent)); }
.pile { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pile-row { display: flex; gap: 8px; }
.crate {
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
  width: 106px; height: 96px; padding: 9px 11px 10px;
  background: var(--c); color: var(--fixed-ink);
  border: 3px solid var(--fixed-ink); border-radius: var(--r-md);
  box-shadow: 0 6px 0 var(--fixed-ink);
  text-align: left; cursor: pointer;
  transform: rotate(var(--rot, 0deg));
}
.crate-glyph { display: inline-block; font-size: 42px; line-height: 1; }
.crate-name { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font: 700 14px/1 var(--body); }
.crate-count { font: 600 11px/1 var(--mono); opacity: 0.75; }
.crate.is-active, .crate:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; }
.tagnote {
  position: absolute; z-index: 3; top: 24px; left: 0;
  max-width: 158px; margin: 0; padding: 11px 13px 12px;
  background: var(--fixed-paper); color: var(--fixed-ink);
  border: 2.5px solid var(--fixed-ink); border-radius: var(--r-sm);
  box-shadow: 0 5px 0 var(--fixed-ink);
  transform: rotate(-4deg);
  font: 500 12.5px/1.4 var(--body);
}
.tagnote b { display: block; margin-bottom: 4px; font: 800 16px/1.15 var(--body); }
.tagnote .kl { font-size: 1.12em; }
.feed-gem, .fly-gem {
  position: absolute; left: 0; top: 0; z-index: 4;
  width: 30px; height: 30px;
  background: var(--c); border: 3px solid var(--fixed-ink); border-radius: var(--r-sm);
  pointer-events: none; will-change: transform;
}
.fly-gem { position: fixed; z-index: 70; width: 24px; height: 24px; border-width: 2.5px; }

/* ── stash ────────────────────────────────────────────────────────────── */
.stash { padding-block: 84px 90px; scroll-margin-top: var(--top-h); }
.stash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 18px; }
.h-xl { margin: 0; font: 900 clamp(34px, 4.2vw, 58px)/1 var(--display); letter-spacing: -0.05em; }
.stash-sub { margin: 12px 0 0; max-width: 58ch; font-size: 16px; color: var(--ink-2); }
.result-count { margin: 0; font-weight: 700; color: var(--muted); }
.result-count .mono { color: var(--ink); }

.toolbar {
  position: sticky; top: var(--top-h); z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding-block: 12px; margin-bottom: 22px;
  background: var(--page);
}
.search { position: relative; flex: 1 1 320px; display: flex; align-items: center; }
.search svg { position: absolute; left: 18px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 52px; padding: 0 48px 0 46px;
  background: var(--card); border: 2px solid var(--line-strong); border-radius: var(--r-full);
  font-size: 15px; font-weight: 500; outline: none;
  transition: border-color 0.15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--brand); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search kbd {
  position: absolute; right: 16px;
  padding: 4px 8px; border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
  font: 600 11px/1 var(--mono); color: var(--muted);
}
.search input:not(:placeholder-shown) + kbd { display: none; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  height: 42px; padding: 0 15px;
  border: 2px solid var(--line-strong); border-radius: var(--r-full); background: var(--card);
  font: 700 13px/1 var(--body); color: var(--ink-2); white-space: nowrap; cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip .mono { font-size: 11px; font-weight: 600; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--page); }
.chip[aria-pressed="true"] .mono { color: var(--page); opacity: 0.7; }

.sort { position: relative; flex: none; display: flex; align-items: center; }
.sort select {
  appearance: none; -webkit-appearance: none;
  height: 52px; padding: 0 42px 0 20px;
  background: var(--card); border: 2px solid var(--line-strong); border-radius: var(--r-full);
  font: 700 14px/1 var(--body); cursor: pointer;
}
.sort svg { position: absolute; right: 18px; color: var(--muted); pointer-events: none; }

.cat-body { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 30px; align-items: start; }
.rail { position: sticky; top: calc(var(--top-h) + 96px); max-height: calc(100vh - var(--top-h) - 112px); overflow-y: auto; scrollbar-width: thin; }
.rail summary { display: none; }
.rail fieldset { margin: 0 0 24px; padding: 0; border: 0; min-width: 0; }
.rail legend { padding: 0; margin-bottom: 8px; font: 600 11px/1.2 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.check {
  position: relative; display: flex; align-items: center; gap: 10px;
  margin-inline: -10px; padding: 7px 10px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 700; cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s;
}
.check:hover { background: var(--raised); }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  flex: none; width: 20px; height: 20px;
  display: grid; place-items: center;
  background: var(--card); border: 2px solid var(--line-strong); border-radius: var(--r-sm);
  transition: background-color 0.15s, border-color 0.15s;
}
.check-box::after {
  content: ""; width: 9px; height: 5px;
  border-left: 2.5px solid var(--on-brand); border-bottom: 2.5px solid var(--on-brand);
  transform: translateY(-1px) rotate(-45deg); opacity: 0;
}
.check input:checked + .check-box, .toggle input:checked + .check-box { background: var(--brand); border-color: var(--brand); }
.check input:checked + .check-box::after, .toggle input:checked + .check-box::after { opacity: 1; }
.check input:focus-visible + .check-box, .toggle input:focus-visible + .check-box { outline: 3px solid var(--brand); outline-offset: 2px; }
.check-label { display: flex; flex-direction: column; min-width: 0; }
.check-hint { font-size: 12px; font-weight: 500; color: var(--muted); }
.check-count { margin-left: auto; font: 600 11px/1 var(--mono); color: var(--muted); }
.check.is-empty { opacity: 0.45; }
.cap-dot {
  flex: none; width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: var(--r-sm); background: var(--c); color: var(--fixed-ink);
  font: 700 13px/1 var(--cjk);
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

/* ── card ─────────────────────────────────────────────────────────────── */
.card {
  position: relative;
  display: flex; flex-direction: column;
  padding: 18px 18px 16px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 0 0 var(--c);
  transition: box-shadow 0.22s var(--ease-out), border-color 0.22s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .card:hover { border-color: var(--ink); box-shadow: 6px 6px 0 var(--c); }
}
.card:has(.card-open:focus-visible) { outline: 3px solid var(--brand); outline-offset: 3px; }
.card.in-stack { border-color: var(--ink); box-shadow: 6px 6px 0 var(--pick); }
.tag { display: flex; align-items: center; gap: 8px; min-height: 30px; margin-bottom: 14px; }
.glyph-tile {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--c); color: var(--fixed-ink); border-radius: var(--r-sm);
  font: 700 15px/1 var(--cjk);
}
.tag-cap { font-size: 13px; font-weight: 800; }
.part-no { font: 600 11px/1 var(--mono); color: var(--muted); }
.pins { margin-left: auto; display: flex; gap: 4px; }
.pin {
  display: inline-block; padding: 5px 7px;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
  font: 600 10px/1 var(--mono); letter-spacing: 0.04em; color: var(--ink-2); white-space: nowrap;
}
.pin-solid { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.pin-inline { vertical-align: 2px; }
.card-title { margin: 0; font: 800 21px/1.15 var(--body); letter-spacing: -0.015em; }
.card-open { padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.card-open:focus-visible { outline: none; }
.card-open::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-md); }
.owner { display: flex; align-items: center; gap: 7px; min-width: 0; margin: 6px 0 0; font: 500 12px/1.2 var(--mono); color: var(--muted); }
.owner img { flex: none; width: 18px; height: 18px; border-radius: var(--r-sm); background: var(--line); }
.zh { font-family: var(--cjk); color: var(--ink-2); }
.gem {
  margin: 12px 0 0; font-size: 14.5px; line-height: 1.5; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.like { display: flex; align-items: center; gap: 8px; margin: 12px 0 16px; font-size: 13px; font-weight: 700; }
.like-mark {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px;
  border-radius: var(--r-full); background: var(--c); color: var(--fixed-ink);
  font: 600 13px/1 var(--mono);
}
.card-foot { margin-top: auto; padding-top: 14px; border-top: 2px dashed var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.spec { display: flex; flex-direction: column; gap: 6px; min-width: 0; font: 500 12px/1.2 var(--mono); color: var(--ink-2); }
.spec-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.spec-sub { color: var(--muted); }
.lic-custom, .lic-noncommercial { padding: 2px 6px; border-radius: var(--r-sm); }
.lic-custom { border: 1.5px dashed var(--line-strong); }
.lic-noncommercial { background: var(--ink); color: var(--page); }
.lamp { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: var(--r-full); background: var(--quiet); }
.lamp-live { background: var(--live); }
.lamp-steady { background: var(--steady); }
.stack-toggle {
  position: relative; z-index: 1; flex: none;
  height: 38px; padding: 0 15px;
  border: 2px solid var(--ink); border-radius: var(--r-full); background: var(--card); color: var(--ink);
  font: 700 13px/1 var(--body); white-space: nowrap; cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.stack-toggle:hover { background: var(--ink); color: var(--page); }
.stack-toggle[aria-pressed="true"] { background: var(--pick); border-color: var(--fixed-ink); color: var(--on-pick); }
.stack-toggle-lg { height: 50px; padding: 0 22px; font-size: 15px; }

.empty { grid-column: 1 / -1; padding: 44px 20px; text-align: center; border: 2px dashed var(--line-strong); border-radius: var(--r-md); }
.empty svg { width: 110px; }
.empty h3 { margin: 12px 0 6px; font: 800 22px/1.2 var(--display); letter-spacing: -0.04em; }
.empty p { margin: 0 auto 18px; max-width: 44ch; color: var(--ink-2); }

/* ── how Bao picks + footer ───────────────────────────────────────────── */
.how { padding-block: 0 90px; }
.how-card {
  display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 48px;
  padding: 52px; background: var(--card); border: 2px solid var(--line); border-radius: var(--r-lg);
}
.how-side { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; }
.how-bao { width: 140px; height: auto; }
.how-text p { margin: 0 0 18px; font-size: 17px; line-height: 1.65; color: var(--ink-2); }
.how-text p:last-child { margin-bottom: 0; }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-block: 0 120px; font-size: 13px; font-weight: 600; color: var(--muted); }
.foot p { margin: 0; }

/* ── floating layers ──────────────────────────────────────────────────── */
.stack-pill {
  position: fixed; right: var(--gutter); bottom: var(--gutter); z-index: 35;
  display: flex; align-items: center; gap: 10px;
  height: 60px; padding: 0 9px 0 10px;
  border: 0; border-radius: var(--r-full);
  background: var(--ink); color: var(--page); box-shadow: var(--shadow-float);
  font: 700 15px/1 var(--body); cursor: pointer;
  visibility: hidden;
}
.pill-bao { width: 46px; height: auto; overflow: visible; }
.pill-count {
  display: grid; place-items: center; min-width: 42px; height: 42px; padding: 0 10px;
  border-radius: var(--r-full); background: var(--pick); color: var(--on-pick);
  font: 600 15px/1 var(--mono);
}

.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.scrim.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; top: 10px; right: 10px; bottom: 10px; z-index: 50;
  width: min(580px, calc(100vw - 20px));
  display: flex; flex-direction: column;
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
  overflow: hidden; visibility: hidden;
}
.sheet-head { display: flex; align-items: center; gap: 10px; min-height: 70px; padding: 14px 16px 14px 22px; border-bottom: 2px solid var(--line); }
.sheet-head .icon-btn { margin-left: auto; }
.sheet-title { margin: 0; font: 900 24px/1 var(--display); letter-spacing: -0.045em; }
.sheet-title .mono { margin-left: 8px; font-size: 14px; font-weight: 600; letter-spacing: 0; color: var(--muted); }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 24px 22px 40px; }

.detail-title { margin: 0; font: 900 clamp(30px, 3.4vw, 42px)/1.02 var(--display); letter-spacing: -0.05em; overflow-wrap: anywhere; }
.detail-title .zh { margin-left: 10px; font: 500 20px/1 var(--cjk); letter-spacing: 0; color: var(--muted); }
.detail-like { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-weight: 700; }
.detail-gem { margin: 12px 0 0; font-size: 17px; line-height: 1.55; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 22px 0 0; background: var(--raised); border-radius: var(--r-md); overflow: hidden; }
.facts div { min-width: 0; padding: 12px 14px; border-right: 2px solid var(--card); border-bottom: 2px solid var(--card); }
.facts div:nth-child(4n) { border-right: 0; }
.facts div:nth-last-child(-n + 4) { border-bottom: 0; }
.facts dt { font: 600 10px/1.2 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 6px 0 0; font: 600 13px/1.3 var(--mono); overflow-wrap: anywhere; }

.orig { margin-top: 14px; padding: 14px 16px; border: 2px dashed var(--line-strong); border-radius: var(--r-md); }
.orig-label { margin: 0 0 6px; font: 600 10px/1.2 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.orig-label span { font-family: var(--cjk); letter-spacing: 0; }
.orig p:last-child { margin: 0; font-size: 14px; color: var(--ink-2); }
.orig [lang="zh"] { font-family: var(--cjk); }

.caveats { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.caveats li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 12px 14px; background: var(--raised); border-radius: var(--r-md); font-size: 14px; line-height: 1.5; }
.caveats b { font: 600 10px/2 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; }

.section-label { margin: 34px 0 4px; font: 800 20px/1 var(--display); letter-spacing: -0.04em; }
.path { padding: 16px 0 20px; border-bottom: 2px dashed var(--line); }
.path:last-child { border-bottom: 0; }
.path-head { display: flex; align-items: center; gap: 10px; }
.path-head h4 { margin: 0; font-size: 16px; font-weight: 800; }
.via { margin: 8px 0 0; font: 500 12px/1.4 var(--mono); color: var(--muted); }
.via a { color: var(--ink-2); }
.note { margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.source { margin: 8px 0 0; font: 500 11.5px/1.4 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.source a { color: var(--muted); }
.source a:hover { color: var(--ink); }

/* Code blocks stay dark in both themes. */
.code { margin-top: 12px; background: var(--code-bg); color: var(--code-ink); border-radius: var(--r-md); overflow: hidden; }
.code-bar { display: flex; align-items: center; gap: 2px; min-height: 46px; padding: 7px 7px 7px 9px; border-bottom: 1.5px solid var(--code-line); overflow-x: auto; scrollbar-width: none; }
.code-lang { padding-left: 8px; font: 600 10.5px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--code-muted); }
.tab { flex: none; height: 32px; padding: 0 12px; border: 0; border-radius: var(--r-full); background: transparent; color: var(--code-muted); font: 600 12px/1 var(--mono); white-space: nowrap; cursor: pointer; transition: color 0.15s, background-color 0.15s; }
.tab:hover { color: var(--code-ink); }
.tab[aria-selected="true"] { background: var(--code-raised); color: var(--code-ink); }
.tab:focus-visible, .copy:focus-visible { outline: 2px solid var(--code-ink); outline-offset: -2px; }
.copy { flex: none; margin-left: auto; height: 32px; padding: 0 15px; border: 1.5px solid var(--code-line); border-radius: var(--r-full); background: transparent; color: var(--code-ink); font: 700 12px/1 var(--body); cursor: pointer; }
.copy:hover { border-color: var(--code-muted); }
.copy-primary { background: var(--pick); border-color: var(--pick); color: var(--on-pick); }
.copy-primary:hover { border-color: var(--code-ink); }
.code pre { margin: 0; padding: 14px 16px 16px; overflow-x: auto; font: 500 12.5px/1.65 var(--mono); white-space: pre; tab-size: 2; }
.code .c { color: var(--code-muted); }

.stack-list { list-style: none; margin: -8px 0 0; padding: 0; }
.stack-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 2px dashed var(--line); }
.stack-name { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.stack-name .link-btn { text-align: left; font-size: 15px; font-weight: 800; text-decoration: none; }
.stack-name .link-btn:hover { text-decoration: underline; }
.stack-name .mono { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-note { margin: 16px 0 0; font-size: 14px; color: var(--ink-2); }
.toggle { position: relative; display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed; left: 0; right: 0; bottom: 100px; z-index: 60;
  width: max-content; max-width: calc(100vw - 32px); margin-inline: auto;
  padding: 12px 20px; border-radius: var(--r-full);
  background: var(--ink); color: var(--page); box-shadow: var(--shadow-float);
  font-size: 14px; font-weight: 700;
  opacity: 0; pointer-events: none;
}

/* Without GSAP (script blocked or failed), layers still open and close. */
html:not(.gsap-on) .sheet { transform: translateX(110%); transition: transform 0.3s var(--ease-out), visibility 0s linear 0.3s; }
html:not(.gsap-on) .sheet.is-open { transform: none; visibility: visible; transition: transform 0.3s var(--ease-out); }
html:not(.gsap-on) .stack-pill { transform: translateY(150%); transition: transform 0.3s var(--ease-out), visibility 0s linear 0.3s; }
html:not(.gsap-on) .stack-pill.is-visible { transform: none; visibility: visible; transition: transform 0.3s var(--ease-out); }
html:not(.gsap-on) .toast { transition: opacity 0.2s; }
html:not(.gsap-on) .toast.is-on { opacity: 1; }

/* ── responsive ───────────────────────────────────────────────────────── */
/* Below 1240px the stage is too narrow for the note to sit clear of Bao's ear, so stack the hero. */
@media (max-width: 1240px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 52px 44px 0; }
  .hero-copy { padding-bottom: 20px; }
  .stage { min-height: 560px; }
  .tagnote { left: 2%; }
}
@media (max-width: 900px) {
  .toolbar { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  .chips {
    flex: 1 1 0; min-width: 0;
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
  }
  .cat-body { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .rail { position: static; max-height: none; overflow: visible; background: var(--card); border: 2px solid var(--line); border-radius: var(--r-md); }
  .rail summary { display: flex; align-items: center; gap: 8px; padding: 14px 16px; font-size: 15px; font-weight: 800; cursor: pointer; list-style: none; }
  .rail summary::-webkit-details-marker { display: none; }
  .rail summary::after { content: "+"; margin-left: auto; font: 600 18px/1 var(--mono); color: var(--muted); }
  .rail[open] summary::after { content: "−"; }
  .rail-count { font-size: 12px; color: var(--muted); }
  .rail-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 24px; padding: 4px 16px 16px; }
  .rail-inner .link-btn { justify-self: start; }
  .how-card { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 36px; }
}
@media (max-width: 700px) {
  :root { --gutter: 14px; --top-h: 64px; }
  /* Touch targets: 44px minimum on anything you tap. */
  .chip { height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn-sm { width: 40px; height: 40px; }
  .stack-toggle { height: 44px; padding: 0 16px; }
  .check { padding-block: 11px; }
  .stack-name .link-btn { padding-block: 8px; }
  /* Avatars are decoration; app.js leaves them out here so a phone makes no avatar requests. */
  .owner img { display: none; }
  .top { position: static; }
  .toolbar { top: 0; }
  .top-nav { display: none; }
  .brand-mark { width: 42px; }
  .brand-word { font-size: 21px; }
  .btn-stack { height: 42px; font-size: 14px; }
  .btn-stack .count { min-width: 30px; height: 30px; }
  .hero { padding: 34px 20px 0; border-radius: var(--r-md); min-height: 0; }
  .eyebrow { font-size: 14px; }
  .lede { font-size: 17px; }
  .btn { height: 50px; padding: 0 20px; font-size: 15px; }
  .stats { gap: 12px 24px; }
  .stats dd { font-size: 24px; }
  .stage { min-height: 0; padding-top: 110px; padding-bottom: 24px; }
  .bao { width: 190px; }
  .bao-float { margin-bottom: -14px; }
  .pile, .pile-row { gap: 6px; }
  .crate { width: 72px; height: 70px; padding: 7px 8px; border-width: 2.5px; border-radius: var(--r-sm); box-shadow: 0 4px 0 var(--fixed-ink); }
  .crate-glyph { font-size: 28px; }
  .crate-name { font-size: 10.5px; }
  .crate-count { display: none; }
  .tagnote { top: 14px; left: 0; max-width: 176px; padding: 9px 11px 10px; font-size: 11.5px; }
  .tagnote b { font-size: 15px; }
  .stash { padding-block: 60px 70px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .how-card { padding: 28px 22px; }
  .how-text p { font-size: 16px; }
  .sheet { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 90vh; max-height: 90dvh; }
  .detail-title .zh { display: block; margin: 8px 0 0; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts div:nth-child(4n) { border-right: 2px solid var(--card); }
  .facts div:nth-child(2n) { border-right: 0; }
  .facts div:nth-last-child(-n + 4) { border-bottom: 2px solid var(--card); }
  .facts div:nth-last-child(-n + 2) { border-bottom: 0; }
  .caveats li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .stack-pill { left: var(--gutter); justify-content: space-between; bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); }
  .sheet { bottom: calc(8px + env(safe-area-inset-bottom)); }
  .sheet-body { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
  .foot { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
}

/* GSAP checks prefers-reduced-motion itself; this covers CSS keyframes and smooth scrolling. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
  html:not(.gsap-on) .sheet, html:not(.gsap-on) .stack-pill { transition: none !important; }
}
