:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --line: #e2ddd1;
  --text: #1d2433;
  --muted: #5f6878;
  --faint: #8c93a0;
  --brand: #1f3a68;
  --brand-ink: #ffffff;
  --brand-soft: #e3e9f4;
  --gold: #b8860b;
  --gold-soft: #f6ecd2;
  --ok: #1d7a55;
  --ok-soft: #dff2e8;
  --bad: #b3372f;
  --bad-soft: #f8e1de;
  --link: #1f6fb2;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .06);
  --radius: 14px;
  --font: 'Plus Jakarta Sans', 'Noto Sans TC', system-ui, sans-serif;
  --ipa: 'Noto Sans', 'Lucida Sans Unicode', 'Arial Unicode MS', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141d;
    --surface: #171e2a;
    --surface-2: #1f2836;
    --line: #2a3445;
    --text: #e8ecf3;
    --muted: #a3adbd;
    --faint: #7a8496;
    --brand: #8fb2ea;
    --brand-ink: #0f141d;
    --brand-soft: #1e2c45;
    --gold: #e0b44c;
    --gold-soft: #3a2f14;
    --ok: #5fcf9c;
    --ok-soft: #15372a;
    --bad: #f08a80;
    --bad-soft: #3d1c1a;
    --link: #8cc4f5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f141d;
  --surface: #171e2a;
  --surface-2: #1f2836;
  --line: #2a3445;
  --text: #e8ecf3;
  --muted: #a3adbd;
  --faint: #7a8496;
  --brand: #8fb2ea;
  --brand-ink: #0f141d;
  --brand-soft: #1e2c45;
  --gold: #e0b44c;
  --gold-soft: #3a2f14;
  --ok: #5fcf9c;
  --ok-soft: #15372a;
  --bad: #f08a80;
  --bad-soft: #3d1c1a;
  --link: #8cc4f5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
p { margin: 0; }
.ipa { font-family: var(--ipa); }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.hidden { display: none !important; }

/* ── header ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 880px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.brand > div:last-child { min-width: 0; }
.brand h1 { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) {
  .topbar-inner { padding: 8px 12px; gap: 8px; }
  .brand-mark { width: 30px; height: 30px; font-size: 12px; }
  .brand h1 { font-size: 14px; }
  .brand p { display: none; }
  .seg button { padding: 3px 5px; }
  .icon-btn { width: 28px; }
}
@media (max-width: 370px) {
  .brand h1 { display: none; }
}
.brand p { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls { display: flex; gap: 6px; align-items: center; flex: none; }
.seg {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 2px;
}
.seg button {
  border: 0; background: transparent; padding: 3px 7px; border-radius: 7px;
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px;
  width: 32px; height: 30px; font-size: 14px;
}

/* ── nav ── */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { max-width: 880px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.nav-ico { position: relative; }
.badge {
  position: absolute; top: -4px; right: -12px; font-style: normal; font-size: 10px; font-weight: 800;
  background: var(--bad); color: #fff; border-radius: 999px; padding: 0 5px; line-height: 15px; min-width: 15px; text-align: center;
}
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 2px 9px; text-decoration: none; color: var(--faint); font-size: 11px; font-weight: 600;
}
.nav a .nav-ico { font-size: 18px; line-height: 1.2; }
.nav a[aria-current="page"] { color: var(--brand); }

@media (min-width: 760px) {
  body { padding-bottom: 32px; }
  .nav { position: sticky; top: 55px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); background: var(--bg); }
  .nav-inner { display: flex; gap: 4px; padding: 6px 16px; }
  .nav a { flex-direction: row; gap: 6px; font-size: 14px; padding: 7px 12px; border-radius: 9px; }
  .nav a .nav-ico { font-size: 15px; }
  .nav a[aria-current="page"] { background: var(--brand-soft); }
}

/* ── layout ── */
main { max-width: 880px; margin: 0 auto; padding: 16px; }
.page-head { margin: 4px 0 14px; }
.page-head h2 { font-size: 20px; font-weight: 800; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card h3 { font-size: 15px; font-weight: 800; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head p { color: var(--muted); font-size: 13px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  padding: 7px 12px; border-radius: 10px; font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 4px 9px; font-size: 12px; border-radius: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); background: var(--surface-2);
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted);
}
button.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--gold-soft); color: var(--gold); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips > * { flex: none; }

.search {
  width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-size: 15px; outline: none;
}
.search:focus { border-color: var(--brand); }

/* ── word list ── */
.word-list { display: grid; gap: 8px; margin-top: 12px; }
@media (min-width: 640px) { .word-list { grid-template-columns: 1fr 1fr; } }
.word-row {
  text-align: left; width: 100%;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}
.word-row:hover { border-color: var(--brand); }
.word-row .w { font-weight: 800; font-size: 16px; }
.word-row .ipa { color: var(--muted); font-size: 13px; }
.word-row .zh { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.due-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); display: inline-block; margin-left: 6px; vertical-align: middle; }

/* ── morpheme parts ── */
.parts { display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; }
.part {
  display: flex; flex-direction: column; align-items: center;
  border-radius: 10px; padding: 6px 10px; min-width: 56px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.part b { font-size: 15px; }
.part span { font-size: 11px; color: var(--muted); }
.part.root { background: var(--brand-soft); border-color: var(--brand); }
.part.root b { color: var(--brand); }
.plus { align-self: center; color: var(--faint); font-weight: 700; }

/* ── modal ── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(10, 15, 25, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .2);
}
@media (min-width: 760px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; max-height: 86vh; }
}
.sheet-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-word { font-size: 28px; font-weight: 800; line-height: 1.1; }
.sheet-meta { color: var(--muted); font-size: 14px; margin-top: 4px; }
.label { font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .02em; margin-bottom: 6px; display: block; }
.say {
  border: 0; background: none; padding: 0; text-align: left; color: var(--link);
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px;
}
.list-plain { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.src-note { font-size: 11px; color: var(--faint); }

/* ── drum ── */
.drum { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; }
.beat {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px;
  padding: 8px 10px; min-width: 52px; text-align: center; transition: transform .12s, box-shadow .12s;
}
.beat .ipa { display: block; font-size: 14px; }
.beat small { display: block; font-size: 10px; color: var(--faint); font-weight: 700; }
.beat.s2 { background: var(--gold-soft); border-color: var(--gold); padding: 14px 14px; }
.beat.s2 .ipa { font-size: 18px; font-weight: 800; color: var(--gold); }
.beat.s1 { padding: 11px 12px; }
.beat.hit { transform: scale(1.08); box-shadow: 0 0 0 3px var(--gold); }

/* ── review ── */
.flash { text-align: center; padding: 28px 16px; }
.flash .w { font-size: 34px; font-weight: 800; }
.flash-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }

/* ── roots ── */
.root-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.root-card {
  text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.root-card b { font-size: 17px; color: var(--brand); display: block; }
.root-card span { font-size: 13px; }
.root-card small { display: block; color: var(--faint); font-size: 11px; margin-top: 2px; }
.root-card[aria-expanded="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }

/* ── lesson ── */
.lesson-card { text-align: left; width: 100%; display: block; }
.mouths { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mouth {
  border-radius: 12px; padding: 10px; text-align: center; border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.mouth.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.mouth.good { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.mouth .verdict { font-size: 12px; font-weight: 800; }
.mouth.bad .verdict { color: var(--bad); }
.mouth.good .verdict { color: var(--ok); }
.mouth svg { width: 110px; height: 72px; }
.mouth .tip { font-size: 12px; color: var(--muted); }
.link-row {
  width: 100%; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 12px;
}
.link-row[aria-expanded="true"] { border-color: var(--link); }
.link-row b { color: var(--link); font-size: 15px; }
.link-detail { border-left: 3px solid var(--link); padding: 6px 0 6px 12px; margin: 6px 0 4px 4px; }
.passage { font-size: 17px; line-height: 2.1; }
.tok {
  border: 0; background: none; padding: 1px 2px; border-radius: 5px; font-size: inherit; line-height: inherit;
}
.tok.known { color: var(--brand); font-weight: 700; border-bottom: 2px solid var(--brand-soft); }
.tok:hover, .tok.on { background: var(--brand-soft); }
.gloss { background: var(--surface-2); border-radius: 12px; padding: 12px; margin-top: 10px; }
.timeline { position: relative; display: flex; justify-content: space-between; padding: 8px 4px 0; }
.timeline::before {
  content: ''; position: absolute; left: 24px; right: 24px; top: 26px; height: 3px; background: var(--line);
}
.tnode { position: relative; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 33%; }
.tnode i {
  font-style: normal; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; background: var(--surface-2); border: 2px solid var(--line);
}
.tnode[aria-pressed="true"] i { background: var(--gold); border-color: var(--gold); color: #fff; }
.tnode span { font-size: 12px; font-weight: 700; text-align: center; }
.tnode small { font-size: 11px; color: var(--faint); }
.score-words { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { padding: 2px 8px; border-radius: 7px; font-size: 14px; border: 1px solid transparent; }
.sw.ok { background: var(--ok-soft); color: var(--ok); }
.sw.miss { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); font-weight: 700; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e5484d; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.notice { font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--gold-soft); color: var(--text); }

/* ── import ── */
textarea {
  width: 100%; min-height: 160px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); padding: 10px 12px; font-family: ui-monospace, Menlo, monospace; font-size: 12px;
}
pre.prompt {
  white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border-radius: 10px;
  padding: 10px 12px; font-size: 12px; max-height: 220px; overflow: auto; margin: 0;
}
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 13px; z-index: 60;
}

/* ═════════ v3：卡片、樂高、音節鼓、舌位 ═════════ */
:root { --prefix: #2f6db5; --prefix-soft: #e2ecf8; --rootc: #b8860b; --rootc-soft: #f8edd0; --suffix: #6b7280; --suffix-soft: #eceef1; --tongue: #e58a96; --skin: #8a6f62; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --prefix: #8cb8ef; --prefix-soft: #1c2c44; --rootc: #e8bd55; --rootc-soft: #3a2f14; --suffix: #a3adbd; --suffix-soft: #252e3c; --tongue: #d9737f; --skin: #c3a594; } }
:root[data-theme="dark"] { --prefix: #8cb8ef; --prefix-soft: #1c2c44; --rootc: #e8bd55; --rootc-soft: #3a2f14; --suffix: #a3adbd; --suffix-soft: #252e3c; --tongue: #d9737f; --skin: #c3a594; }

.grow { flex: 1; }
.center { text-align: center; }
.row.tight { gap: 6px; }
.stack-s > * + * { margin-top: 6px; }
.strong { font-weight: 800; font-size: 16px; }
.card.flat { box-shadow: none; background: var(--surface-2); }
.card.warn { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.lesson-card { display: block; text-decoration: none; color: inherit; }
.btn.danger-on { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 9px 10px; font-size: 14px; max-width: 46%;
}
.filter-row { display: flex; gap: 8px; }
.filter-row .search { flex: 1; min-width: 0; }

.subtabs { display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs a {
  flex: none; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 700;
  padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
.subtabs a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* 卡片牌組：左右滑 */
.deck-bar { display: flex; align-items: center; gap: 8px; margin: 12px 0 8px; }
.counter { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 64px; text-align: center; }
.toggle { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.deck {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 0; outline: none;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; align-items: flex-start;
  margin: 0 -16px; padding: 0;
}
.deck::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: center; padding: 2px 16px 8px; }

.wcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  padding: 18px 16px; max-width: 640px; margin: 0 auto;
}
.sheet .wcard { box-shadow: none; border: 0; padding: 0; background: transparent; }
.wcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.wcard-word { font-size: 32px; font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.wcard-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); margin-top: 4px; font-size: 15px; }
.wcard-meta .ipa { color: var(--text); }
.tags { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.tag.root { background: var(--rootc-soft); color: var(--rootc); }
.play-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); font-size: 17px;
}
.blk { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.story { margin-top: 10px; font-weight: 600; }
.pic { margin-top: 6px; color: var(--muted); font-style: italic; }
.wcard-actions { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }

/* 音節鼓 */
.syl-wrap > * + * { margin-top: 8px; }
.syl-row { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; }
.syl {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px;
  padding: 6px 10px 5px; min-width: 50px; transition: transform .12s, box-shadow .12s;
}
.syl b { font-size: 17px; font-weight: 700; }
.syl .ipa { font-size: 12px; color: var(--muted); }
.syl.s2 { background: var(--rootc-soft); border: 2px solid var(--rootc); padding: 11px 14px 8px; }
.syl.s2 b { font-size: 22px; font-weight: 800; color: var(--rootc); text-transform: uppercase; }
.syl.s1 { padding: 8px 11px 6px; }
.syl.s1 b { font-weight: 800; }
.syl.s0 b { color: var(--muted); }
.syl.hit { transform: translateY(-3px) scale(1.08); box-shadow: 0 0 0 3px var(--rootc); }

/* 樂高零件 */
.lego { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 7px; }
.brick {
  position: relative; display: flex; flex-direction: column; align-items: center;
  border-radius: 8px; padding: 8px 12px 6px; min-width: 64px; border: 2px solid;
}
.brick::before {
  content: ''; position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 6px; border-radius: 4px 4px 0 0; border: 2px solid; border-bottom: 0;
  background: inherit; border-color: inherit;
}
.brick b { font-size: 17px; font-weight: 800; }
.brick span { font-size: 12px; font-weight: 700; }
.brick i { font-size: 11px; opacity: .75; }
.brick.prefix { background: var(--prefix-soft); border-color: var(--prefix); color: var(--prefix); }
.brick.root { background: var(--rootc-soft); border-color: var(--rootc); color: var(--rootc); }
.brick.suffix { background: var(--suffix-soft); border-color: var(--suffix); color: var(--suffix); }
.lego.small { gap: 3px; padding-top: 5px; }
.lego.small .brick { padding: 3px 7px 2px; min-width: 0; border-width: 1.5px; border-radius: 6px; }
.lego.small .brick::before { width: 12px; height: 4px; top: -5px; border-width: 1.5px; }
.lego.small .brick b { font-size: 13px; }
.lego.small .brick span { font-size: 10px; }

/* 音素、規則、連音 */
.ph-chip, .rule-chip {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px; padding: 3px 9px;
  font-family: var(--ipa); font-size: 15px;
}
.ph-chip.v { border-color: color-mix(in srgb, var(--prefix) 45%, var(--line)); }
.ph-chip.hard { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); font-weight: 700; }
.rule-chip { font-family: var(--font); font-size: 12px; font-weight: 700; background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.phrase {
  border: 0; background: var(--surface-2); border-radius: 10px; padding: 7px 11px; text-align: left; font-size: 15px;
  display: block; width: 100%; line-height: 1.7;
}
.phrase:hover { background: var(--brand-soft); }
.link-mark { color: var(--link); font-weight: 800; padding: 0 1px; }
.link-mark.big { font-size: 20px; }
.link-ex {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface-2); border-radius: 10px; padding: 8px 10px;
}
.family { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.fam { text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 8px 10px; }
.fam b { font-size: 15px; }
.fam > span { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* 總覽 */
.brick-list { display: grid; gap: 10px; margin-top: 12px; }
@media (min-width: 760px) { .brick-list { grid-template-columns: 1fr 1fr; } }
.brick-row { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.brick-row-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.brick-row-body { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.brick-row .syl { padding: 3px 7px; min-width: 0; }
.brick-row .syl b { font-size: 13px; }
.brick-row .syl.s2 b { font-size: 15px; }
.brick-row .syl .ipa { font-size: 10px; }
.rule-word { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* 音標表與舌位圖 */
.sound-layout { display: grid; gap: 12px; }
@media (min-width: 860px) { .sound-layout { grid-template-columns: 1fr 1.1fr; align-items: start; } .sound-layout > .card { position: sticky; top: 112px; } }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.ph-key {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center;
}
.ph-key b { font-size: 19px; }
.ph-key small { font-size: 10px; color: var(--faint); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ph-key[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.ph-key[aria-pressed="true"] small { color: var(--brand-ink); opacity: .8; }
.big-ipa { font-size: 40px; font-weight: 700; line-height: 1.1; }
.figure { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; }
.figure.compact { grid-template-columns: 1fr 1.5fr; gap: 4px; }
.fig-cell { background: var(--surface-2); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.fig-cell small { font-size: 10px; color: var(--faint); }
.front-mouth { width: 100%; max-width: 120px; height: auto; }
.front-mouth .lip { fill: none; stroke: var(--tongue); stroke-width: 5; }
.front-mouth .mouth-in { fill: #3b1f24; }
.front-mouth .teeth { fill: #fbfbf7; }
.side-view { width: 100%; height: auto; }
.side-view .anat { fill: none; stroke: var(--skin); stroke-width: 2.4; stroke-linecap: round; }
.side-view .faint-line { stroke-dasharray: 3 4; opacity: .5; }
.side-view .skin { fill: none; stroke: var(--skin); stroke-width: 2.4; stroke-linecap: round; }
.side-view .palate { stroke-width: 3; }
.side-view .velum { stroke-width: 4; }
.side-view .tooth { fill: #fbfbf7; stroke: var(--skin); stroke-width: 1; }
.side-view .face { fill: color-mix(in srgb, var(--skin) 22%, var(--surface)); }
.side-view .nasal { fill: color-mix(in srgb, var(--skin) 10%, var(--surface)); stroke: var(--skin); stroke-width: 1; stroke-dasharray: 3 3; }
.side-view .cavity { fill: color-mix(in srgb, #5a1e2a 22%, var(--surface)); }
.side-view .lip-side { fill: var(--tongue); fill-opacity: .55; stroke: var(--skin); stroke-width: 1.6; }
.side-view .tongue { fill: var(--tongue); fill-opacity: .85; stroke: color-mix(in srgb, var(--tongue) 70%, #000); stroke-width: 1.5; }
.side-view .contact { fill: #e5484d; stroke: #fff; stroke-width: 1.5; }
.side-view .air { fill: none; stroke: var(--link); stroke-width: 2; stroke-dasharray: 4 3; }
.side-view .arrow-head { fill: var(--link); }
.side-view .voice { fill: none; stroke: var(--ok); stroke-width: 2; }
.mouth .figure { width: 100%; }

.voice-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: var(--surface-2); }
.flash-word { font-size: 34px; font-weight: 800; margin: 6px 0 10px; }
.flash .syl-row { justify-content: center; }
.flash .row.tight { justify-content: center; }
.shadow-target .phrase { font-size: 17px; font-weight: 600; }
/* 手機：嘴型比較改上下排，圖不撐破版面 */
.mouth, .fig-cell, .figure > * { min-width: 0; }
@media (max-width: 640px) { .mouths { grid-template-columns: 1fr; } }
.voice-row { min-width: 0; flex-wrap: wrap; }
.sheet { overflow-x: hidden; }
.mistake-chips { margin-top: 8px; }
html, body { overflow-x: hidden; }

/* ═════════ v6：練習區、對比、無障礙 ═════════ */
:root { --faint: #636b78; --gold: #8a6408; --rootc: #8a6408; --suffix: #575d69; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --faint: #8f99aa; --gold: #e0b44c; --rootc: #e8bd55; --suffix: #b4bccb; } }
:root[data-theme="dark"] { --faint: #8f99aa; --gold: #e0b44c; --rootc: #e8bd55; --suffix: #b4bccb; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; border-radius: 6px; }
@media (pointer: coarse) {
  .btn, .btn.small, .chip, .ph-chip, .rule-chip, .seg button, .subtabs a, .icon-btn, .say, .tok, .ext, .phrase, .syl { min-height: 44px; }
  .chip, .ph-chip, .rule-chip { display: inline-flex; align-items: center; }
  .seg button { min-width: 40px; }
  .icon-btn { width: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.ext-links { margin-top: 10px; }
.ext { font-size: 13px; font-weight: 700; color: var(--link); text-decoration: none; border: 1px solid var(--line); border-radius: 9px; padding: 5px 10px; display: inline-flex; align-items: center; }
.wcard-actions > * + * { margin-top: 0; }
.seg-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; flex-wrap: wrap; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.drill-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .drill-grid { grid-template-columns: 1fr 1fr; } }
.drill-card {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.drill-card:hover { border-color: var(--brand); }
.drill-ico { grid-row: 1 / 3; font-size: 28px; }
.drill-card b { font-size: 16px; }
.drill-card .muted { font-size: 13px; }
.drill-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.progress i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .25s; }
.drill-stage > * + * { margin-top: 12px; }
.q-word { text-align: center; font-size: 22px; font-weight: 800; }
.center-row { justify-content: center; }
.syl.pickable b { color: var(--text); }
.syl.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big-choice { justify-content: center; font-size: 20px; padding: 16px; }
.big-choice.is-right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.big-choice.is-wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.feedback { border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback.ok > b { color: var(--ok); }
.feedback.bad > b { color: var(--bad); }
.build-slot { min-height: 56px; justify-content: center; border: 2px dashed var(--line); border-radius: 12px; padding: 12px 8px 6px; }
.brick-btn { border: 2px solid var(--prefix); background: var(--prefix-soft); color: var(--prefix); font-weight: 800; border-radius: 8px; padding: 8px 14px; font-size: 16px; min-height: 44px; }
.brick-btn:disabled { opacity: .3; }

/* ═════════ v6 偵測器修正：去巢狀卡片、去米色、字級下限、對比 ═════════ */
:root {
  --bg: #f4f5f7; --surface-2: #eceef2; --line: #dde1e7;
  --muted: #555d6b; --link: #1a5f99; --prefix: #285f9e;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --prefix: #8cb8ef; --link: #8cc4f5; --muted: #a3adbd; } }
:root[data-theme="dark"] { --prefix: #8cb8ef; --link: #8cc4f5; --muted: #a3adbd; }
/* 單字卡本身不當卡片：用留白和分隔線分區，積木才是唯一的方塊 */
.wcard { background: transparent; border: 0; box-shadow: none; border-radius: 0; padding: 4px 2px 8px; }
.family { display: flex; flex-direction: column; gap: 0; }
.fam { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 8px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.fam:last-child { border-bottom: 0; }
.note { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; }
.note.warn { border-left-color: var(--bad); }
.fig-cell { background: transparent; border-radius: 0; padding: 2px; }
/* 字級下限 11px */
.ph-key small, .fig-cell small, .lego.small .brick span, .brick-row .syl .ipa, .beat small { font-size: 11px; }
.page-title { font-size: 18px; font-weight: 800; margin: 0 0 6px; }
.brick i { opacity: 1; }
.brick-row { background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px 2px; }
.brick-list { gap: 0 24px; }
.mouth { background: transparent !important; border: 0 !important; border-top: 3px solid var(--line) !important; border-radius: 0; padding: 10px 2px 4px; }
.mouth.bad { border-top-color: var(--bad) !important; }
.mouth.good { border-top-color: var(--ok) !important; }

/* ═════════════════════════════════════════════════════════════
   風格 E：積木遊戲（Neubrutalism，Merle 2026-10-28 選定）
   粗黑外框＋實心偏移陰影；字首藍、字根黃、字尾灰；Fredoka 標題、Nunito 內文
   ═════════════════════════════════════════════════════════════ */
:root {
  --font: 'Nunito', 'Noto Sans TC', system-ui, sans-serif;
  --display: 'Fredoka', 'Noto Sans TC', system-ui, sans-serif;
  --ink: #111111;          /* 外框與陰影 */
  --on-fill: #111111;      /* 彩色塊上的字 */
  --bg: #FFF8E1; --surface: #FFFFFF; --surface-2: #FFF3C4; --line: #E6DCBC;
  --text: #111111; --muted: #3F3F46; --faint: #52525B;
  --brand: #111111; --brand-ink: #FFFFFF; --brand-soft: #FFF3C4;
  --y: #FFD43B; --b: #4DABF7; --g: #51CF66; --r: #FF8787; --gray: #E9ECEF;
  --gold: #111111; --gold-soft: #FFD43B;
  --rootc: #111111; --rootc-soft: #FFD43B;
  --prefix: #111111; --prefix-soft: #4DABF7;
  --suffix: #111111; --suffix-soft: #E9ECEF;
  --ok: #2B8A3E; --ok-soft: #D3F9D8; --bad: #C92A2A; --bad-soft: #FFE3E3;
  --link: #1864AB;
  --radius: 14px;
  --shadow: 4px 4px 0 var(--ink);
  --press: 0 4px 0 var(--ink);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --ink: #F1EAD2; --bg: #1B1913; --surface: #26231B; --surface-2: #332E21; --line: #4A4330;
  --text: #FAF6E8; --muted: #D6CFBA; --faint: #B8B09A; --brand: #FAF6E8; --brand-ink: #1B1913; --brand-soft: #332E21;
  --ok: #8CE99A; --ok-soft: #1F3A24; --bad: #FFA8A8; --bad-soft: #43201F; --link: #74C0FC; color-scheme: dark;
} }
:root[data-theme="dark"] {
  --ink: #F1EAD2; --bg: #1B1913; --surface: #26231B; --surface-2: #332E21; --line: #4A4330;
  --text: #FAF6E8; --muted: #D6CFBA; --faint: #B8B09A; --brand: #FAF6E8; --brand-ink: #1B1913; --brand-soft: #332E21;
  --ok: #8CE99A; --ok-soft: #1F3A24; --bad: #FFA8A8; --bad-soft: #43201F; --link: #74C0FC; color-scheme: dark;
}

body { font-family: var(--font); font-weight: 600; }
h1, h2, h3, .page-title, .wcard-word, .flash-word, .q-word, .big-ipa, .story, .drill-card b, .brand h1, .root-card b, .counter, .stat b { font-family: var(--display); }
.ipa, .big-ipa { font-family: var(--ipa); }
:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; }

/* 頂部、底部導覽 */
.topbar { background: var(--bg); border-bottom: 2.5px solid var(--ink); backdrop-filter: none; -webkit-backdrop-filter: none; }
.brand-mark { background: var(--y); color: var(--on-fill); border: 2.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); font-family: var(--display); }
.seg { background: var(--surface); border: 2px solid var(--ink); border-radius: 10px; }
.seg button { color: var(--text); font-weight: 800; }
.seg button[aria-pressed="true"] { background: var(--y); color: var(--on-fill); box-shadow: none; }
.icon-btn { background: var(--surface); border: 2px solid var(--ink); border-radius: 10px; box-shadow: 2px 2px 0 var(--ink); color: var(--text); }
.nav { background: var(--surface); border-top: 2.5px solid var(--ink); }
.nav a { color: var(--muted); font-weight: 800; }
.nav a[aria-current="page"] { color: var(--link); }
@media (min-width: 760px) {
  .nav { background: var(--bg); border-top: 0; border-bottom: 2.5px solid var(--ink); }
  .nav a[aria-current="page"] { background: var(--y); color: var(--on-fill); border: 2px solid var(--ink); }
}
.badge { border: 1.5px solid var(--ink); }

/* 分頁、篩選 */
.subtabs a { background: var(--surface); color: var(--text); border: 2px solid var(--ink); border-radius: 10px; box-shadow: 2px 2px 0 var(--ink); font-weight: 800; }
.subtabs a[aria-current="page"] { background: var(--y); color: var(--on-fill); border-color: var(--ink); }
.search, .select, textarea { background: var(--surface); border: 2px solid var(--ink); border-radius: 12px; font-weight: 700; }
.search:focus { border-color: var(--link); }
.chip { background: var(--surface); color: var(--text); border: 2px solid var(--ink); border-radius: 10px; font-weight: 800; }
button.chip[aria-pressed="true"] { background: var(--y); color: var(--on-fill); border-color: var(--ink); }
.tag, .tag.root { background: var(--y); color: var(--on-fill); border: 1.5px solid var(--ink); border-radius: 8px; }

/* 按鈕：底下有厚邊，按下去會沉 */
.btn { background: var(--surface); color: var(--text); border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: var(--press); font-weight: 900; transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--g); color: var(--on-fill); border-color: var(--ink); }
.btn.gold { background: var(--y); color: var(--on-fill); border-color: var(--ink); }
.btn.ghost { background: var(--surface); }
.btn.danger { color: var(--bad); }
.btn.danger-on { background: var(--r); color: var(--on-fill); border-color: var(--ink); }
.play-btn { background: var(--y); color: var(--on-fill); border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }
.ext { border: 2px solid var(--ink); border-radius: 10px; color: var(--text); background: var(--surface); box-shadow: 2px 2px 0 var(--ink); }

/* 卡片類：粗框＋偏移陰影 */
.card, .drill-card, .root-card, .stat, .link-row { background: var(--surface); border: 2.5px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.drill-card:hover, .root-card:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.root-card b { color: var(--text); }
.root-card[aria-expanded="true"] { background: var(--y); box-shadow: var(--shadow); }
.root-card[aria-expanded="true"] b, .root-card[aria-expanded="true"] span, .root-card[aria-expanded="true"] small { color: var(--on-fill); }
.sheet { background: var(--bg); border: 2.5px solid var(--ink); }
.sheet-backdrop { background: rgba(17, 17, 17, .5); }

/* 單字卡：卡片本身攤平在底色上，積木和鼓才是主角（避免卡片套卡片） */
.wcard-word { font-weight: 700; font-size: 34px; letter-spacing: 0; }
.blk { border-top: 2px dashed var(--line); }
.label { color: var(--text); font-weight: 900; }
.story { font-weight: 600; font-size: 16px; }
.pic { font-weight: 600; }

/* 音節鼓 */
.syl { background: var(--surface); border: 2px solid var(--ink); border-radius: 10px; box-shadow: 0 3px 0 var(--ink); color: var(--text); }
.syl b { font-weight: 800; }
.syl.s0 b { color: var(--text); }
.syl .ipa { color: var(--muted); }
.syl.s2 { background: var(--y); border: 2.5px solid var(--ink); }
.syl.s2 b, .syl.s2 .ipa { color: var(--on-fill); }
.syl.s1 { background: var(--surface-2); }
.syl.hit { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.syl.wrong { background: var(--r); }
.syl.wrong b { color: var(--on-fill); }

/* 樂高積木：實心色塊＋黑框＋凸點 */
.lego { gap: 6px; padding-top: 9px; }
.brick { border: 2.5px solid var(--ink); border-radius: 10px; box-shadow: 0 4px 0 var(--ink); color: var(--on-fill); }
.brick::before { border: 2.5px solid var(--ink); border-bottom: 0; top: -9px; height: 7px; border-radius: 5px 5px 0 0; }
.brick.prefix { background: var(--b); color: var(--on-fill); }
.brick.root { background: var(--y); color: var(--on-fill); }
.brick.suffix { background: var(--gray); color: var(--on-fill); }
.brick b, .brick span, .brick i { color: var(--on-fill); }
.lego.small .brick { border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
.lego.small .brick::before { border-width: 2px; top: -6px; height: 5px; }
.brick-btn { background: var(--b); color: var(--on-fill); border: 2.5px solid var(--ink); border-radius: 10px; box-shadow: 0 3px 0 var(--ink); }
.build-slot { border: 2.5px dashed var(--ink); }

/* 音素、規則、連音 */
.ph-chip { background: var(--surface); color: var(--text); border: 2px solid var(--ink); border-radius: 8px; font-weight: 700; }
.ph-chip.v { border-color: var(--ink); }
.ph-chip.hard { background: var(--r); color: var(--on-fill); border-color: var(--ink); }
.rule-chip { background: #D0EBFF; color: var(--on-fill); border: 2px solid var(--ink); border-radius: 8px; }
.phrase { background: var(--surface); border: 2px solid var(--ink); border-radius: 10px; font-weight: 700; }
.phrase:hover { background: var(--surface-2); }
.link-mark { color: var(--bad); }
.link-ex { background: var(--surface); border: 2px solid var(--ink); border-radius: 10px; }
.ph-key { background: var(--surface); border: 2px solid var(--ink); border-radius: 10px; box-shadow: 0 3px 0 var(--ink); color: var(--text); }
.ph-key small { color: var(--muted); }
.ph-key[aria-pressed="true"] { background: var(--y); color: var(--on-fill); border-color: var(--ink); }
.ph-key[aria-pressed="true"] small { color: var(--on-fill); }
.note { border-left: 4px solid var(--ink); }
.note.warn { border-left-color: var(--bad); }

/* 練習區 */
.progress { height: 14px; background: var(--surface); border: 2px solid var(--ink); }
.progress i { background: var(--g); }
.feedback { border: 2.5px solid var(--ink); }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.big-choice.is-right { background: var(--g); color: var(--on-fill); border-color: var(--ink); }
.big-choice.is-wrong { background: var(--r); color: var(--on-fill); border-color: var(--ink); }
.sw.ok { border: 2px solid var(--ink); }
.sw.miss { border: 2px solid var(--ink); }
.tok.known { color: var(--link); border-bottom: 3px solid var(--y); }
.tok:hover, .tok.on { background: var(--y); color: var(--on-fill); }
.tnode i { border: 2.5px solid var(--ink); background: var(--surface); }
.tnode[aria-pressed="true"] i { background: var(--y); border-color: var(--ink); color: var(--on-fill); }
.timeline::before { background: var(--ink); height: 3px; }
.notice { background: var(--y); color: var(--on-fill); border: 2px solid var(--ink); }
.toast { background: var(--ink); color: var(--bg); border-radius: 10px; }
.voice-row { background: var(--surface); border: 2px solid var(--ink); }
pre.prompt { background: var(--surface-2); border: 2px solid var(--ink); }
.say { color: var(--link); }
.mouth.bad { border-top-color: var(--bad) !important; }
.mouth.good { border-top-color: var(--ok) !important; }
@media (prefers-reduced-motion: reduce) { .btn:active, .syl.hit { transform: none; } }
/* E：卡片裡的列表攤平，用分隔線，不再加框（避免卡片套卡片） */
.link-ex { background: transparent; border: 0; border-bottom: 2px dashed var(--line); border-radius: 0; padding: 8px 0; }
.link-ex:last-child { border-bottom: 0; }
.card .notice { background: transparent; border: 0; border-left: 5px solid var(--y); border-radius: 0; padding: 4px 0 4px 12px; color: var(--text); }
.gloss { background: transparent; border-top: 2px dashed var(--line); border-radius: 0; padding: 12px 0 0; }
:root { --ok: #237032; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ok: #8CE99A; } }
:root[data-theme="dark"] { --ok: #8CE99A; }
h1, h2, h3 { text-wrap: balance; }

/* 學習範圍、等級、熟練度、延伸補充 */
.scope { margin: 0 0 12px; }
.scope-toggle {
  width: 100%; display: flex; align-items: center; gap: 4px; text-align: left; font-weight: 800; font-size: 14px;
  background: var(--surface); color: var(--text); border: 2.5px solid var(--ink); border-radius: 12px; padding: 10px 12px; box-shadow: var(--press); min-height: 44px;
}
.scope-toggle .caret { margin-left: auto; transition: transform .15s; }
.scope-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }
.scope-body { border: 2.5px solid var(--ink); border-top: 0; border-radius: 0 0 12px 12px; background: var(--surface); padding: 12px; margin-top: -4px; }
.level-checks { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.level-check { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; cursor: pointer; }
.level-check input, .toggle input { width: 18px; height: 18px; accent-color: #2B8A3E; }
.tag.lv { font-family: var(--display); letter-spacing: .02em; }
.tag.lv-A1, .tag.lv-A2 { background: #D3F9D8; }
.tag.lv-B1 { background: #D0EBFF; }
.tag.lv-B2 { background: #A5D8FF; }
.tag.lv-C1 { background: #FFD8A8; }
.tag.lv-C2 { background: #FFC9C9; }
.tag.lv-未分級 { background: var(--gray); }
.tag.mastery { background: var(--g); }
.tag.lv, .tag.mastery { color: #111; }
.lego-wrap > * + * { margin-top: 6px; }
.brick[role="button"] { cursor: pointer; transition: transform .08s, box-shadow .08s; }
.brick[role="button"]:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.brick[aria-expanded="true"] { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); outline: 3px solid var(--link); outline-offset: 2px; }
.tap-hint { font-size: 12px; }
.part-note { border-left: 5px solid var(--y); padding: 6px 0 6px 12px; }
.part-note > * + * { margin-top: 6px; }
.part-title { font-family: var(--display); font-size: 17px; }
.hook { font-weight: 800; }
.credits { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.credits li + li { margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { .brick[role="button"]:hover { transform: none; } }
#settings-btn { position: relative; }
.sync-dot { position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); background: var(--gray); }
.sync-dot.ok { background: var(--g); }
.sync-dot.bad { background: var(--r); }
.coach > * + * { margin-top: 10px; }
.coach-list { margin: 0; padding-left: 22px; }
.coach-list li + li { margin-top: 8px; }
.drill-item { border-top: 2px dashed var(--line); padding-top: 10px; }
.drill-item > * + * { margin-top: 6px; }
.drill-prompt { font-weight: 700; font-size: 16px; }
.coach-answer { border-left: 5px solid var(--g); padding-left: 10px; }

/* 頁尾：作者與更多作品 */
.site-foot { max-width: 880px; margin: 0 auto; padding: 8px 16px 24px; text-align: center; font-size: 13px; color: var(--muted); }
.site-foot a { display: inline-block; padding: 10px 6px; color: var(--link); font-weight: 800; text-underline-offset: 3px; }
