:root {
  --bg: #f4efe4;          /* rice paper */
  --card: #fffdf8;
  --ink: #221d18;
  --muted: #7a6e62;
  --line: #e5dccd;
  --accent: #a8321e;      /* seal vermilion */
  --accent-soft: #f5e3dc;
  --good: #2f7a4b;
  --good-soft: #e2f0e6;
  --bad: #b23b35;
  --bad-soft: #f8e3e1;
  --gold: #a87a2a;
  --lv0: #d6ccbf;
  --lv1: #d28a2e;
  --lv2: #5f95b3;
  --lv3: #2f7a4b;
  --link-cheng: #5a6f8c;
  --link-fan: #a8321e;
  --link-bu: #2f7a5f;
  --link-shi: #a87a2a;
  --serif-zh: 'Noto Serif TC', 'Songti TC', 'PMingLiU', serif;
  --serif: 'Noto Serif', 'Iowan Old Style', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', 'PingFang TC', 'Noto Sans TC', sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 4px 14px rgba(60, 40, 20, 0.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --card: #211c17;
    --ink: #eee5d6;
    --muted: #a39686;
    --line: #3a3129;
    --accent: #e2876a;
    --accent-soft: #3b241b;
    --good: #6cc08b;
    --good-soft: #1d3325;
    --bad: #ef7d74;
    --bad-soft: #3d201e;
    --gold: #d9a441;
    --lv0: #4a4038;
    --link-cheng: #93a9c8;
    --link-fan: #e2876a;
    --link-bu: #6cc0a0;
    --link-shi: #d9a441;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  padding-bottom: calc(66px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--serif-zh); font-weight: 600; line-height: 1.3; }
h1 small, h2 small, h3 small { font-family: var(--sans); font-weight: 400; font-size: 0.6em; color: var(--muted); margin-left: 0.4em; }
p { margin: 0.4em 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
small { font-size: 0.78em; }
.boot { display: grid; place-items: center; height: 80vh; font-size: 64px; color: var(--accent); }

/* ---------- top bar & tabs ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
header.top .logo { font-size: 26px; line-height: 1; color: var(--accent); }
header.top .back { border: 0; background: none; font-size: 30px; line-height: 1; padding: 0 6px 0 0; color: var(--accent); }
header.top .title { font-family: var(--serif-zh); font-weight: 600; font-size: 1.05rem; }
header.top .title small { font-family: var(--sans); font-weight: 400; color: var(--muted); margin-left: 6px; }

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
nav.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: 11px; line-height: 1.25; padding: 2px 0; }
nav.tabs a svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 2px; }
nav.tabs a .tz { font-size: 12px; font-weight: 600; }
nav.tabs a .te { font-size: 9.5px; opacity: 0.85; }
nav.tabs a.on { color: var(--accent); }

main { max-width: 760px; margin: 0 auto; }
.page { padding: 12px 16px 24px; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 12px 0;
}
.card h1 { font-size: 1.5rem; margin: 0 0 8px; }
.card h2 { font-size: 1.1rem; margin: 18px 0 8px; color: var(--accent); }
.card h2:first-child { margin-top: 0; }
h3.sub, h2.sub { font-size: 1rem; margin: 18px 0 6px; color: var(--muted); }
.section-title { font-size: 1.15rem; margin: 26px 4px 8px; }

/* ---------- hexagram svg ---------- */
svg.hex { display: block; flex: none; }
svg.hex .bar { fill: var(--ink); }
svg.hex .bar.empty { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 3; }
svg.hex .bar.focus { fill: var(--accent); }
svg.hex .bar.wrong { fill: var(--bad); }
svg.hex .chg { fill: var(--card); stroke: var(--accent); stroke-width: 3; }
svg.hex path.chg { fill: none; stroke-width: 3.2; stroke-linecap: round; }
svg.yao-mini .bar { fill: var(--line); }
svg.yao-mini .bar.focus { fill: var(--accent); }
svg.tri { display: inline-block; vertical-align: -3px; }

/* ---------- text ---------- */
.bi .zh { font-family: var(--serif-zh); line-height: 1.85; }
.bi .en { font-family: var(--serif); color: var(--muted); font-size: 0.95rem; line-height: 1.6; }
.classic { font-family: var(--serif-zh); line-height: 1.95; font-size: 1.05rem; letter-spacing: 0.02em; }
.classic.big { font-size: 1.2rem; }
.classic.xiang { color: var(--muted); font-size: 0.97rem; }
blockquote.classic { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.en-inline { color: var(--muted); font-weight: 400; font-family: var(--sans); }
.lbl small { font-size: 0.75em; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 0.78rem; border: 1px solid currentColor; white-space: nowrap; }
.chip small { opacity: 0.8; }
.chip.rel { color: var(--muted); }
.link-承 { color: var(--link-cheng); }
.link-反 { color: var(--link-fan); }
.link-補 { color: var(--link-bu); }
.link-始 { color: var(--link-shi); }

button.link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
button.primary, button.ghost, label.ghost {
  border-radius: 99px; padding: 10px 22px; font-weight: 600; border: 1px solid var(--accent);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button.primary { background: var(--accent); color: #fff; }
button.primary:disabled { opacity: 0.4; cursor: default; }
button.primary.big { padding: 14px 32px; font-size: 1.05rem; }
button.ghost, label.ghost { background: transparent; color: var(--accent); cursor: pointer; }
.danger { border-color: var(--bad) !important; color: var(--bad) !important; }
.q-actions { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.q-actions.left { justify-content: flex-start; }
.q-actions.bottom { margin-bottom: 12px; }

input.text, textarea.text {
  width: 100%; font: inherit; font-size: 1.05rem; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
input.text:focus, textarea.text:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.text.num { max-width: 140px; }

.seg { display: flex; background: var(--line); border-radius: 99px; padding: 3px; margin: 10px 0; }
.seg button { flex: 1; border: 0; background: none; border-radius: 99px; padding: 7px 8px; font-size: 0.9rem; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- home ---------- */
.hero { text-align: center; padding: 18px 0 6px; }
.hero h1 { font-size: 2rem; margin: 10px 0 2px; letter-spacing: 0.08em; }
.hero-sub { color: var(--muted); margin: 0; }
.hero-figs { display: flex; justify-content: center; gap: 16px; }
.modes { display: grid; gap: 10px; margin-top: 12px; }
.mode { display: flex; align-items: center; gap: 14px; margin: 0; color: var(--ink); }
.mode-title { font-family: var(--serif-zh); font-weight: 600; font-size: 1.1rem; }
.mode-title small { color: var(--muted); font-family: var(--sans); font-weight: 400; }
.mode-desc { font-size: 0.88rem; color: var(--muted); line-height: 1.45; }
.mode-desc .en { font-size: 0.82rem; opacity: 0.85; }
.mode .chev { margin-left: auto; font-size: 1.6rem; color: var(--muted); }
.random-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.random-body { display: flex; gap: 14px; align-items: center; color: var(--ink); margin-top: 8px; }
.random-name { font-family: var(--serif-zh); font-size: 1.1rem; }
.summary { display: block; color: var(--ink); }
.summary-row { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; margin: 6px 0; }
.bar-stack { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--lv0); margin: 8px 0; }
.bar-stack span { display: block; }
.seg-0 { background: var(--lv0); }
.seg-1 { background: var(--lv1); }
.seg-2 { background: var(--lv2); }
.seg-3 { background: var(--lv3); }

/* ---------- browse ---------- */
.searchbar { display: flex; gap: 8px; position: sticky; top: calc(49px + env(safe-area-inset-top)); z-index: 5; background: var(--bg); padding: 6px 0; }
.searchbar input { flex: 1; min-width: 0; font: inherit; padding: 10px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.finder-btn { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 0 12px; font-size: 0.85rem; white-space: nowrap; }
.finder-btn.on { border-color: var(--accent); color: var(--accent); }
.finder-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; font-size: 0.9rem; }
.finder-body { display: flex; align-items: center; gap: 24px; justify-content: center; margin-top: 10px; }
.finder-count { font-size: 2rem; font-family: var(--serif-zh); color: var(--accent); text-align: center; line-height: 1.1; }
.finder-count small { display: block; font-size: 0.8rem; color: var(--muted); }
h3.canon { font-size: 1rem; margin: 16px 4px 8px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 7px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px 6px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--ink);
}
.tile:hover { border-color: var(--accent); }
.tile-num { font-size: 0.7rem; color: var(--muted); line-height: 1; }
.tile-name { font-family: var(--serif-zh); font-size: 0.95rem; line-height: 1.2; white-space: nowrap; }
.lv { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; }
.lv-0 { display: none; }
.lv-1 { background: var(--lv1); }
.lv-2 { background: var(--lv2); }
.lv-3 { background: var(--lv3); }

.pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.pair { display: flex; align-items: center; justify-content: space-between; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.pair a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink); min-width: 56px; }
.pair-rel { display: flex; flex-direction: column; align-items: center; font-family: var(--serif-zh); color: var(--muted); font-size: 0.95rem; }
.pair-rel small { font-family: var(--sans); font-size: 0.65rem; }
.pair.rel-cuo { border-color: var(--gold); }
.pair.rel-cuo .pair-rel { color: var(--gold); }
.pair.rel-both .pair-rel { color: var(--accent); }

.matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.matrix { border-collapse: separate; border-spacing: 3px; margin: 0 auto; width: 100%; max-width: 620px; table-layout: fixed; }
.matrix thead th:first-child, .matrix tbody th { width: 40px; }
.matrix th { font-weight: 400; font-size: 0.72rem; color: var(--muted); padding: 2px; }
.matrix th span { display: block; font-family: var(--serif-zh); white-space: nowrap; }
.matrix th svg { margin: 0 auto 2px; display: block; }
.matrix td a { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 46px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.matrix td a b { font-size: 0.65rem; color: var(--muted); font-weight: 400; line-height: 1; }
.matrix td a span { font-family: var(--serif-zh); font-size: 0.74rem; line-height: 1.3; white-space: nowrap; }
.matrix th svg.tri { width: 20px; height: auto; }
.matrix .corner span { font-size: 0.7rem; }

/* ---------- line editor ---------- */
.line-editor { display: flex; flex-direction: column; gap: 6px; width: 180px; }
.le-row { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.le-pos { width: 1.4em; font-family: var(--serif-zh); font-size: 0.8rem; color: var(--muted); }
.le-bar { flex: 1; height: 20px; display: flex; gap: 24%; }
.le-bar i { flex: 1; border-radius: 3px; }
.le-yang i { background: var(--ink); }
.le-yang { gap: 0; }
.le-yin i { background: var(--ink); }
.le-empty i { border: 1.5px dashed var(--muted); }
.le-empty { gap: 0; }
.le-empty i + i { display: none; }
.le-row.wrong .le-bar i { background: var(--bad); }
.le-row:disabled { cursor: default; }

/* ---------- detail ---------- */
.hex-header { display: flex; gap: 18px; align-items: center; }
.hh-num { font-size: 0.85rem; color: var(--muted); font-family: var(--serif-zh); }
.hh-num small { font-family: var(--sans); }
.hh-name { font-size: 2.3rem; margin: 0; letter-spacing: 0.05em; line-height: 1.15; }
.hh-pinyin { font-family: var(--serif); font-size: 1rem; font-weight: 400; color: var(--muted); margin-left: 10px; letter-spacing: 0; font-style: italic; }
.hh-full { font-family: var(--serif-zh); font-size: 1.05rem; }
.hh-en { font-family: var(--serif); color: var(--muted); font-size: 0.9rem; }
.hh-tri { display: flex; gap: 2px 14px; flex-wrap: wrap; margin-top: 6px; line-height: 1.5; font-size: 0.85rem; font-family: var(--serif-zh); }
.hh-tri small { font-family: var(--sans); color: var(--muted); }
.gist { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.relations { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; font-size: 0.9rem; }
.rel-link { display: inline-flex; align-items: center; gap: 4px; font-family: var(--serif-zh); padding: 2px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.stage-link { display: block; margin-top: 10px; font-size: 0.9rem; color: var(--ink); }
.stage-link small { color: var(--muted); }

.xg { margin: 6px 0 4px; }
.xg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-family: var(--serif-zh); }
.xg-head a { display: inline-flex; align-items: center; gap: 5px; color: var(--ink); }
.xg-to { font-weight: 600; }
.arrow { color: var(--muted); }
.arrow.big { font-size: 1.6rem; }
.xg-en .en { font-style: italic; }
.modern { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.modern-label { font-size: 0.78rem; font-weight: 600; color: var(--accent); letter-spacing: 0.05em; }
.modern .bi + .bi { margin-top: 8px; }
.more { display: inline-block; margin-top: 10px; font-size: 0.9rem; }

ol.yao { list-style: none; padding: 0; margin: 0; }
ol.yao li { padding: 10px 0; border-bottom: 1px dashed var(--line); }
ol.yao li:last-child { border-bottom: 0; }
.yao-line { display: flex; gap: 10px; align-items: flex-start; }
.yao-line svg { margin-top: 8px; }
.yao-use { width: 20px; text-align: center; font-family: var(--serif-zh); color: var(--accent); margin-top: 4px; }
ol.yao .xiang { margin-left: 30px; }
.pager { display: flex; justify-content: space-between; margin: 8px 4px; font-family: var(--serif-zh); }

/* ---------- order ---------- */
.order .intro h1 small { display: block; margin: 2px 0 0; }
.link-counts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
details.card summary { cursor: pointer; font-family: var(--serif-zh); font-weight: 600; font-size: 1.05rem; list-style: none; display: flex; flex-direction: column; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary small { font-family: var(--sans); font-weight: 400; color: var(--muted); font-size: 0.82rem; }
details.card summary::after { content: '+'; position: absolute; right: 16px; color: var(--muted); }
details.card { position: relative; }
details.card[open] summary::after { content: '−'; }
details.card[open] summary { margin-bottom: 10px; }
details.essay .bi .zh, details.essay .bi .en { margin: 0.6em 0; }
.song-lines { columns: 2; column-gap: 24px; }
.song-lines p { margin: 0; break-inside: avoid; }
.canon-tag { font-size: 0.75rem; color: var(--accent); font-weight: 600; letter-spacing: 0.08em; margin-bottom: 6px; }
.stage-head { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 0; text-align: left; }
.stage-range { font-size: 0.75rem; color: var(--muted); min-width: 40px; }
.stage-title { font-family: var(--serif-zh); font-weight: 600; font-size: 1.05rem; display: flex; flex-direction: column; line-height: 1.3; flex: 1; }
.stage-title small { font-family: var(--sans); font-weight: 400; color: var(--muted); font-size: 0.78rem; }
.stage-figs { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; max-width: 45%; }
.caret { color: var(--muted); font-size: 1.2rem; width: 16px; text-align: center; }
.stage-sum { margin-top: 6px; font-size: 0.93rem; }
.stage-sum .zh { line-height: 1.7; }
ol.chain { list-style: none; padding: 0; margin: 12px 0 0; border-left: 2px solid var(--line); padding-left: 14px; }
.chain-item { position: relative; padding: 6px 0 10px; }
.chain-item::before { content: ''; position: absolute; left: -20px; top: 16px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.chain-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.chain-hex { display: inline-flex; align-items: center; gap: 8px; font-family: var(--serif-zh); font-size: 1.1rem; color: var(--ink); }
.chain-hex b { font-family: var(--sans); font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.chain-item blockquote { cursor: pointer; }

/* ---------- quiz ---------- */
.quiz-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.quiz-head h2 { margin: 6px 0 0; font-size: 1.4rem; }
.score { font-size: 0.9rem; color: var(--muted); }
.score b { color: var(--good); }
.quiz-controls { margin-top: 6px; }
.chips-row { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.chip-btn { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 5px 12px; font-size: 0.85rem; white-space: nowrap; color: var(--muted); }
.chip-btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chip-btn small { font-size: 0.75em; }
.question .q-figure { display: flex; justify-content: center; padding: 10px 0 14px; }
.q-name { text-align: center; font-family: var(--serif-zh); font-size: 3rem; font-weight: 700; letter-spacing: 0.1em; padding: 6px 0 12px; }
.q-name .hh-pinyin { display: block; font-size: 1rem; letter-spacing: 0; margin: 0; }
.part { padding: 12px 0; border-top: 1px solid var(--line); }
.part-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; font-size: 0.95rem; margin-bottom: 8px; }
.part .mark { font-weight: 600; }
.part.ok .mark { color: var(--good); }
.part.no .mark { color: var(--bad); }
.part .answer { font-family: var(--serif-zh); }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.choice { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 11px 6px; font-family: var(--serif-zh); font-size: 1.15rem; touch-action: manipulation; }
.choice.picked { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.choice.right { border-color: var(--good); background: var(--good-soft); color: var(--good); font-weight: 600; }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.choice:disabled { cursor: default; }
.verdict { font-weight: 600; width: 100%; text-align: center; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.draw-area { display: flex; align-items: center; justify-content: center; gap: 28px; }
.draw-answer { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.neighbours { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 14px 0 4px; }
.nb { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--ink); min-width: 64px; padding: 6px; border-radius: 10px; }
.nb b { font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.nb span { font-family: var(--serif-zh); }
.nb.cur { background: var(--accent-soft); }
.nb.cur span { font-weight: 600; color: var(--accent); }
.nb.none { color: var(--muted); }

/* ---------- divination ---------- */
.journal-link { margin-top: 8px; font-size: 0.9rem; }
.cast-body { display: flex; align-items: center; justify-content: space-around; gap: 16px; margin: 16px 0 6px; flex-wrap: wrap; }
.coins { display: flex; gap: 10px; cursor: pointer; perspective: 400px; }
.coin { width: 58px; height: 58px; }
.coin svg { width: 100%; height: 100%; }
.coin-rim { fill: #b8862f; }
.coin-face { fill: #d6a64a; stroke: #9b6d20; stroke-width: 2; }
.coin.back .coin-face { fill: #c99a3f; }
.coin-hole { fill: var(--card); stroke: #9b6d20; stroke-width: 2; }
.coin-ch { font-family: var(--serif-zh); font-size: 19px; font-weight: 700; fill: #6b4a12; text-anchor: middle; dominant-baseline: middle; }
.coin.spin { animation: spin 0.65s ease-in-out; }
@keyframes spin {
  0% { transform: rotateY(0) translateY(0); }
  50% { transform: rotateY(540deg) translateY(-26px); }
  100% { transform: rotateY(1080deg) translateY(0); }
}
.toss-result { font-family: var(--serif-zh); }
.question-text { font-family: var(--serif-zh); text-align: center; color: var(--muted); }
.reading-figs { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.rf { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink); font-family: var(--serif-zh); }
.rf-label { font-size: 0.8rem; color: var(--muted); }
.values { display: flex; justify-content: center; gap: 10px; margin: 10px 0; font-size: 0.85rem; color: var(--muted); font-family: var(--serif-zh); flex-wrap: wrap; }
.values .chg { color: var(--accent); font-weight: 600; }
.plan { padding: 10px 12px; background: var(--accent-soft); border-radius: 10px; margin: 10px 0; }
.reading-texts .rt { padding: 8px 12px; border-left: 3px solid var(--line); margin: 8px 0; }
.reading-texts .rt.focus { border-left-color: var(--accent); }
.reading-texts .rt.main { background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.rt-label { font-family: var(--serif-zh); font-weight: 600; font-size: 0.9rem; display: flex; gap: 8px; align-items: center; }
.rt-label small { font-family: var(--sans); color: var(--muted); font-weight: 400; }
.badge { font-size: 0.7rem; background: var(--accent); color: #fff; border-radius: 99px; padding: 1px 8px; font-family: var(--sans); }
.journal-item { display: flex; gap: 14px; align-items: center; color: var(--ink); }

/* ---------- progress ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.82rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.legend small { color: var(--muted); }
.toggle { display: flex; align-items: center; gap: 10px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.file-btn { cursor: pointer; }

/* ---------- audiobook ---------- */
.listen-link { display: inline-block; margin-top: 10px; font-family: var(--serif-zh); font-weight: 600; }
.listen-link small { font-family: var(--sans); font-weight: 400; color: var(--muted); }
.listen-from { display: inline-flex; align-items: center; gap: 6px; margin: 10px 0 0 14px; border: 1px solid var(--accent); background: none; color: var(--accent); border-radius: 99px; padding: 4px 12px 4px 8px; font-size: 0.85rem; }
.listen-from svg { width: 16px; height: 16px; fill: currentColor; }
.now-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.now-num { font-size: 0.85rem; color: var(--muted); }
.now-name { font-family: var(--serif-zh); font-size: 1.5rem; font-weight: 700; color: var(--ink); }
.transcript { border-top: 1px solid var(--line); padding-top: 6px; }
.tb { margin: 10px 0; }
.tb .en { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.transcript p { font-family: var(--serif-zh); line-height: 1.95; margin: 0; }
.t-head, .t-next { font-weight: 600; }
.t-next { color: var(--accent); }
.t-canon { color: var(--gold); font-weight: 600; }
.cue { cursor: pointer; border-radius: 4px; padding: 1px 0; transition: background-color 0.2s, color 0.2s; }
.cue.on { background: color-mix(in srgb, var(--gold) 26%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 26%, transparent); }
.player-bar { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 5; padding: 10px 14px 6px; }
.scrub { width: 100%; accent-color: var(--accent); margin: 0; }
.times { display: flex; justify-content: space-between; gap: 8px; font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.times .muted { min-width: 0; font-family: var(--serif-zh); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.controls { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.controls button { border: 0; background: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); touch-action: manipulation; }
.controls svg { width: 26px; height: 26px; fill: currentColor; }
.controls button.main { width: 56px; height: 56px; background: var(--accent); color: #fff; }
.controls button.main svg { width: 30px; height: 30px; }
.controls button.main.busy { opacity: 0.6; }
.pause-row { display: flex; align-items: center; gap: 8px; margin-top: 2px; min-width: 0; }
.pause-row .chips-row { min-width: 0; flex-wrap: wrap; overflow: visible; }
.pause-row > .muted { white-space: nowrap; }
.range-row, .offline-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.range-row select { font: inherit; font-family: var(--serif-zh); font-size: 0.9rem; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); max-width: 7.5em; }
.offline-row progress { flex: 1; max-width: 220px; accent-color: var(--accent); }
.offline-row .ok { color: var(--good); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.controls .repeat svg { width: 22px; height: 22px; }
.controls .repeat.on { color: var(--accent); background: var(--accent-soft); }
.controls .speed, .controls .repeat { width: 48px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.skip-icon .ring { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.skip-icon text { font: 700 7px var(--sans); text-anchor: middle; fill: currentColor; }
.ch-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.ch-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid transparent; background: none; border-radius: 8px; padding: 4px 0; color: var(--ink); min-width: 0; }
.ch-tile .tile-num { font-size: 0.65rem; color: var(--muted); line-height: 1; }
.ch-tile .tile-name { font-family: var(--serif-zh); font-size: 0.8rem; line-height: 1.2; white-space: nowrap; }
.ch-tile.in-range { background: var(--accent-soft); }
.ch-tile.on { border-color: var(--accent); background: var(--accent-soft); }
.ch-intro { grid-column: 1 / -1; font-family: var(--serif-zh); font-size: 0.9rem; padding: 6px; }
.mini-player {
  position: fixed; left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 9;
  display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}
.mini-info { flex: 1; display: flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--serif-zh); min-width: 0; }
.mini-info span { display: flex; flex-direction: column; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-info small { font-family: var(--sans); color: var(--muted); font-size: 0.7rem; }
.mini-player button { border: 0; background: none; width: 40px; height: 40px; display: grid; place-items: center; color: var(--accent); }
.mini-player svg { width: 24px; height: 24px; fill: currentColor; }
main:has(+ .mini-player) { padding-bottom: 56px; }
.bad { color: var(--bad); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow);
}
.toast button { border: 0; background: var(--accent); color: #fff; border-radius: 99px; padding: 4px 12px; }
.toast button.x { background: none; color: var(--bg); font-size: 1.2rem; padding: 0 4px; }

/* ---------- larger screens ---------- */
@media (min-width: 720px) {
  .page { padding: 16px 20px 32px; }
  .modes { grid-template-columns: 1fr 1fr; }
  .grid { grid-template-columns: repeat(8, 1fr); }
  .choices { grid-template-columns: repeat(4, 1fr); }
  .matrix td a { height: 56px; }
  .matrix td a span { font-size: 0.95rem; }
}
@media (max-width: 380px) {
  .hh-name { font-size: 1.9rem; }
  .hex-header { gap: 12px; }
  .song-lines { columns: 1; }
}
