:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --text: #22201c;
  --muted: #7a756c;
  --line: #e7e2d8;
  --accent: #2f6f5e;
  --accent-soft: #e3f0eb;
  --mark: #fff1c2;
  --mark-line: #e0b84a;
  --active: #f0ebe0;
  --shadow: 0 6px 24px rgba(0, 0, 0, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #211f1c;
    --text: #ece8e1;
    --muted: #9c968c;
    --line: #34312c;
    --accent: #7cc3ac;
    --accent-soft: #1f3a32;
    --mark: #4a3d16;
    --mark-line: #b8923a;
    --active: #2a2723;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
button, select, input { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; margin: 0; line-height: 1.3; }
.topbar .titles p { margin: 0; font-size: 13px; }
.back { font-size: 28px; line-height: 1; text-decoration: none; color: var(--accent); padding: 0 6px; }

/* 單集清單 */
.episode-list { list-style: none; margin: 16px 0; padding: 0; display: grid; gap: 10px; }
.episode-list a {
  display: grid; gap: 2px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  color: inherit; text-decoration: none;
}
.episode-list a:hover { border-color: var(--accent); }
.ep-title { font-weight: 600; }
.ep-title-zh, .ep-meta { color: var(--muted); font-size: 14px; }

/* 播放頁 */
.episode-page { padding-bottom: 140px; }
.media-mount audio { display: none; }
.yt-box { position: relative; aspect-ratio: 16 / 9; margin-top: 12px; border-radius: 10px; overflow: hidden; background: #000; }
.yt-box iframe { position: absolute; inset: 0; width: 100%; height: 100%; }

.tabs { display: flex; gap: 4px; margin: 12px 0 4px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: none; padding: 8px 12px; cursor: pointer;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected=true] { color: var(--text); border-color: var(--accent); font-weight: 600; }

.seg {
  display: grid; grid-template-columns: 48px 1fr; gap: 6px; align-items: start;
  padding: 10px 8px; margin: 2px -8px; border-radius: 10px; cursor: pointer;
  transition: background .15s;
}
.seg:hover { background: var(--active); }
.seg.active { background: var(--accent-soft); }
.seg-time {
  border: 0; background: none; padding: 3px 0 0; cursor: pointer;
  color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: left;
}
.seg.active .seg-time { color: var(--accent); font-weight: 600; }
.seg-body p { margin: 0; }
.en { font-size: 18px; }
.zh { color: var(--muted); font-size: 15px; margin-top: 2px !important; }
.hide-zh .zh { display: none; }
.speaker { font-weight: 600; color: var(--accent); }

.vocab {
  background: linear-gradient(transparent 60%, var(--mark) 60%);
  border-bottom: 1.5px dotted var(--mark-line);
  cursor: pointer; border-radius: 2px;
}
.vocab:hover, .vocab:focus { background: var(--mark); outline: none; }

.vocab-list { display: grid; gap: 8px; padding: 12px 0; }
.vocab-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.vi-head { font-weight: 600; }
.vi-zh { grid-column: 1 / -1; color: var(--muted); font-size: 15px; }
.tag {
  display: inline-block; margin: 0; padding: 1px 8px; border-radius: 99px;
  font-size: 12px; background: var(--accent-soft); color: var(--accent); align-self: start; width: fit-content;
}

/* 控制列 */
.controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
}
.progress-row, .button-row { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.progress-row input { flex: 1; accent-color: var(--accent); }
.time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 36px; }
.button-row { justify-content: space-between; margin-top: 4px; }
.button-row button {
  border: 0; background: none; cursor: pointer; font-size: 20px;
  width: 44px; height: 44px; border-radius: 50%;
}
.button-row button:hover { background: var(--active); }
.button-row .play { background: var(--accent); color: var(--bg); width: 52px; height: 52px; font-size: 18px; }
.button-row .play:hover { background: var(--accent); filter: brightness(1.1); }
.button-row .small { font-size: 15px; color: var(--muted); }
.button-row .small[aria-pressed=true] { color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.button-row select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 4px; font-size: 14px;
}

/* 單字解釋卡（手機底部抽屜，電腦置中） */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .25); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-card {
  position: relative; width: 100%; max-width: 560px;
  background: var(--surface); border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@media (min-width: 720px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: 16px; }
}
@keyframes up { from { transform: translateY(20px); opacity: 0; } }
.sheet-card h2 { margin: 6px 0 2px; font-size: 22px; }
.sheet-card p { margin: 6px 0; }
.zh-big { font-size: 18px; color: var(--accent); font-weight: 600; }
.example { font-style: italic; color: var(--muted); }
.note { font-size: 14px; background: var(--active); padding: 8px 10px; border-radius: 8px; }
.sheet-close { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted); }
.pill { margin-top: 8px; border: 1px solid var(--accent); color: var(--accent); background: none; padding: 6px 14px; border-radius: 99px; cursor: pointer; }
