/* ==========================================================================
   五分聽 FiveListen — 溫潤宣紙 × 松煙墨 × 青碧聲波 設計系統
   支援三種高對比視覺主題：paper (日間宣紙) / dark (夜間護眼) / eink (電子紙)
   ========================================================================== */

:root,
[data-theme="paper"] {
  --bg: #f9f7f2;
  --bg-subtle: #f1ede3;
  --surface: #ffffff;
  --surface-raised: #fffdf9;
  --border: #e3ddd0;
  --border-strong: #c8bfb0;

  --ink: #1a232b;
  --ink-secondary: #485664;
  --ink-muted: #5a6774;

  --accent: #0f6b6e;
  --accent-hover: #0b5558;
  --accent-soft: #e4f2f2;
  --accent-ink: #ffffff;

  --warm: #b55a1c;
  --warm-soft: #fbede2;

  --ok: #1e7a4c;
  --ok-soft: #e5f5ec;
  --danger: #b8332a;
  --danger-soft: #fceae8;

  --shadow-sm: 0 1px 2px rgba(26, 35, 43, 0.05);
  --shadow-md: 0 8px 24px rgba(26, 35, 43, 0.07);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --nav-height: 68px;
  --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  --font-en: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #11161a;
  --bg-subtle: #192127;
  --surface: #1b232a;
  --surface-raised: #222c35;
  --border: #2c3843;
  --border-strong: #415160;

  --ink: #f3efe7;
  --ink-secondary: #c4ced6;
  --ink-muted: #9eb0be;

  --accent: #3eb8b5;
  --accent-hover: #53cac7;
  --accent-soft: rgba(62, 184, 181, 0.16);
  --accent-ink: #081819;

  --warm: #e69d53;
  --warm-soft: rgba(230, 157, 83, 0.16);

  --ok: #46c982;
  --ok-soft: rgba(70, 201, 130, 0.16);
  --danger: #f06e65;
  --danger-soft: rgba(240, 110, 101, 0.17);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.36);
}

[data-theme="eink"] {
  --bg: #ffffff;
  --bg-subtle: #f4f4f4;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #111111;
  --border-strong: #000000;

  --ink: #000000;
  --ink-secondary: #111111;
  --ink-muted: #222222;

  --accent: #000000;
  --accent-hover: #222222;
  --accent-soft: #eaeaea;
  --accent-ink: #ffffff;

  --warm: #000000;
  --warm-soft: #ededed;

  --ok: #000000;
  --ok-soft: #e6e6e6;
  --danger: #000000;
  --danger-soft: #e0e0e0;

  --shadow-sm: none;
  --shadow-md: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 18px);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 頂部導覽列 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

[data-theme="eink"] .topbar {
  background: #ffffff;
  backdrop-filter: none;
  border-bottom-width: 1.5px;
}

.topbar-inner {
  max-width: 780px;
  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-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

.brand-sub {
  font-family: var(--font-en);
  font-size: 0.72rem;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ctrl-pill {
  height: 36px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ctrl-pill:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

/* ---------- 主內容容器 ---------- */
.app-main {
  max-width: 780px;
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.view-panel {
  display: none;
  animation: fadeSlide 0.2s ease;
}

.view-panel.active {
  display: block;
}

[data-theme="eink"] .view-panel {
  animation: none;
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- 基礎卡片與區塊 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.card + .card,
.stack > * + * {
  margin-top: 14px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.section-meta {
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* ---------- 首頁 Hero 行動卡 ---------- */
.hero-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  box-shadow: var(--shadow-md);
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-greeting {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 4px;
}

.hero-heading {
  font-size: 1.48rem;
  font-weight: 800;
  line-height: 1.28;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.hero-desc {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-secondary);
}

.streak-badge {
  background: var(--warm-soft);
  color: var(--warm);
  border: 1px solid color-mix(in srgb, var(--warm) 28%, transparent);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-align: center;
  min-width: 84px;
}

.streak-num {
  display: block;
  font-family: var(--font-en);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
}

.streak-lbl {
  font-size: 0.74rem;
  font-weight: 600;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.kpi-box {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
  border: 1px solid var(--border);
}

.kpi-val {
  font-family: var(--font-en);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.15;
}

.kpi-lbl {
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin-top: 3px;
}

.goal-bar-wrap {
  margin-bottom: 18px;
}

.goal-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.progress-track {
  height: 9px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ---------- 範圍切換與模式按鈕 ---------- */
.scope-strip {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.scope-strip::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.chip:hover {
  border-color: var(--border-strong);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 520px) {
  .mode-grid {
    grid-template-columns: 1fr;
  }
}

.mode-btn {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 74px;
  transition: transform 0.14s ease, border-color 0.15s ease, background 0.15s ease;
}

.mode-btn:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

.mode-btn:active {
  transform: scale(0.985);
}

.mode-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.mode-btn.primary:hover {
  background: var(--accent-hover);
}

.mode-btn.primary .mode-sub {
  color: color-mix(in srgb, var(--accent-ink) 86%, transparent);
}

.mode-ico {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.mode-btn.primary .mode-ico {
  background: rgba(255, 255, 255, 0.18);
  color: var(--accent-ink);
}

.mode-name {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
}

.mode-sub {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* ---------- 六級進度條 ---------- */
.level-list {
  display: grid;
  gap: 10px;
}

.level-row {
  display: grid;
  grid-template-columns: 78px 1fr 78px;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.level-row:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

.level-tag {
  font-weight: 700;
  font-size: 0.88rem;
}

.level-badge-core {
  display: inline-block;
  font-size: 0.68rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 999px;
  margin-top: 2px;
}

.level-nums {
  text-align: right;
  font-family: var(--font-en);
  font-size: 0.8rem;
  color: var(--ink-secondary);
  font-weight: 600;
}

/* ---------- 通用按鈕 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  transition: background 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-warm {
  background: var(--warm-soft);
  border-color: color-mix(in srgb, var(--warm) 35%, transparent);
  color: var(--warm);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

/* ---------- 練習階段（盲聽四選一 & 短句語境） ---------- */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.quiz-progress-text {
  font-family: var(--font-en);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

.audio-stage {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 18px 20px;
  text-align: center;
  margin: 14px 0 16px;
  box-shadow: var(--shadow-sm);
}

.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.stage-pill.warn {
  color: var(--warm);
  background: var(--warm-soft);
}

.play-orb {
  width: 86px;
  height: 86px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto 12px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 32%, transparent);
  transition: transform 0.15s ease, background 0.15s ease;
}

.play-orb:hover {
  background: var(--accent-hover);
  transform: scale(1.04);
}

.play-orb:active {
  transform: scale(0.95);
}

[data-theme="eink"] .play-orb {
  box-shadow: none;
}

.wave-bars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
}

.wave-bars span {
  width: 4px;
  height: 10px;
  border-radius: 99px;
  background: currentColor;
  transition: height 0.15s ease;
}

.play-orb.playing .wave-bars span {
  animation: soundPulse 0.75s ease-in-out infinite;
}

.play-orb.playing .wave-bars span:nth-child(2) {
  animation-delay: 0.12s;
}
.play-orb.playing .wave-bars span:nth-child(3) {
  animation-delay: 0.24s;
}
.play-orb.playing .wave-bars span:nth-child(4) {
  animation-delay: 0.36s;
}
.play-orb.playing .wave-bars span:nth-child(5) {
  animation-delay: 0.48s;
}

@keyframes soundPulse {
  0%, 100% { height: 8px; }
  50% { height: 28px; }
}

[data-theme="eink"] .play-orb.playing .wave-bars span,
@media (prefers-reduced-motion: reduce) {
  .play-orb.playing .wave-bars span {
    animation: none;
  }
}

.audio-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.context-sentence {
  font-family: var(--font-en);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.65;
  color: var(--ink);
  margin: 14px auto 6px;
  max-width: 560px;
}

.cloze-blank {
  display: inline-block;
  min-width: 78px;
  border-bottom: 2.5px solid var(--accent);
  color: var(--accent);
  font-weight: 800;
  padding: 0 6px;
}

.cloze-reveal {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 7px;
  border-radius: 6px;
  font-weight: 800;
}

.choices-grid {
  display: grid;
  gap: 10px;
}

.choice-btn {
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.1s ease;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

.choice-btn:active:not(:disabled) {
  transform: scale(0.99);
}

.choice-key {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-family: var(--font-en);
  font-size: 0.82rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--ink-secondary);
}

.choice-text {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.35;
}

.choice-text.en {
  font-family: var(--font-en);
  font-size: 1.05rem;
}

.choice-pos {
  font-family: var(--font-en);
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-left: auto;
  flex-shrink: 0;
}

.choice-btn.correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.choice-btn.correct .choice-key {
  background: var(--ok);
  border-color: var(--ok);
  color: #ffffff;
}

.choice-btn.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.choice-btn.wrong .choice-key {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

[data-theme="eink"] .choice-btn.correct {
  border-width: 3px;
}

[data-theme="eink"] .choice-btn.wrong {
  border-style: dashed;
  border-width: 2px;
}

/* ---------- 揭曉卡片 ---------- */
.reveal-card {
  margin-top: 14px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  animation: fadeSlide 0.18s ease;
}

.reveal-word-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.reveal-word {
  font-family: var(--font-en);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--ink);
}

.reveal-ipa {
  font-family: var(--font-en);
  font-size: 0.92rem;
  color: var(--ink-muted);
}

.reveal-pos {
  font-family: var(--font-en);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.reveal-zh {
  margin: 8px 0 0;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
}

.reveal-zh-full {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: var(--ink-secondary);
}

.stress-tip {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--warm-soft);
  color: var(--warm);
  font-size: 0.82rem;
  font-weight: 600;
}

.example-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.example-en {
  font-family: var(--font-en);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 4px;
}

.example-zh {
  font-size: 0.86rem;
  color: var(--ink-secondary);
  margin: 0;
}

.reveal-footer {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- 通勤磨耳朵播放器 ---------- */
.commute-stage {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 20px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.commute-phase {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.commute-word {
  font-family: var(--font-en);
  font-size: 2rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
}

.commute-ipa {
  font-family: var(--font-en);
  color: var(--ink-muted);
  font-size: 0.98rem;
  margin: 4px 0 8px;
}

.commute-zh {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 12px;
  min-height: 1.6em;
}

.commute-ex {
  font-family: var(--font-en);
  font-size: 0.94rem;
  color: var(--ink-secondary);
  margin: 0 auto 6px;
  max-width: 520px;
}

.commute-ex-zh {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin: 0;
}

.commute-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 22px;
}

.commute-round-btn {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
}

.commute-round-btn.main {
  width: 68px;
  height: 68px;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-size: 1.45rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 520px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-secondary);
  margin-bottom: 5px;
}

.field select,
.field input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}

/* ---------- 詞庫列表與搜尋 ---------- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-bar input {
  flex: 1;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.96rem;
}

.word-list {
  display: grid;
  gap: 8px;
}

.word-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

.word-play-mini {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.word-body {
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.word-line-1 {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}

.word-en {
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 1rem;
}

.word-meta-tag {
  font-family: var(--font-en);
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.word-zh-preview {
  font-size: 0.86rem;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.state-dot {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.state-dot.mastered {
  background: var(--ok-soft);
  color: var(--ok);
}

.state-dot.mistake {
  background: var(--danger-soft);
  color: var(--danger);
}

.state-dot.learning {
  background: var(--accent-soft);
  color: var(--accent);
}

.state-dot.new {
  background: var(--bg-subtle);
  color: var(--ink-muted);
}

/* ---------- 附錄折疊卡 ---------- */
.appendix-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 14px;
}

.appendix-group + .appendix-group {
  margin-top: 8px;
}

.appendix-group summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.appendix-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.appendix-pill {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-family: var(--font-en);
  font-size: 0.82rem;
}

.appendix-pill:hover {
  border-color: var(--accent);
}

/* ---------- 底部手機固定導覽列 ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="eink"] .bottom-nav {
  background: #ffffff;
  backdrop-filter: none;
  border-top-width: 1.5px;
}

.bottom-nav-inner {
  max-width: 780px;
  margin: 0 auto;
  height: var(--nav-height);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 600;
  position: relative;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item.active {
  color: var(--accent);
  font-weight: 800;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 28px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--accent);
}

/* ---------- 頁內彈窗與 Toast（嚴禁使用原生 alert/confirm） ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 22, 28, 0.56);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
}

.modal-backdrop.open {
  display: flex;
}

@media (min-width: 600px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 84dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%) translateY(16px);
  z-index: 70;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.attribution-box {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  line-height: 1.65;
}

.attribution-box p {
  margin: 4px 0;
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--ink-secondary);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
