:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1e2328;
  --muted: #6b7280;
  --line: #e5e2d9;
  --accent: #c2410c;
  --accent-soft: #fff1e8;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --rt: #9a3412;
  --active: #fff7d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1d2026;
    --text: #e8e6e1;
    --muted: #9aa0aa;
    --line: #2d3139;
    --accent: #fb923c;
    --accent-soft: #2b2018;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
    --rt: #fdba74;
    --active: #332c10;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 "Noto Sans TC", "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Microsoft JhengHei", system-ui, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px 80px; }
header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 0 8px; flex-wrap: wrap;
}
header.top h1 { font-size: 20px; margin: 0; }
header.top nav { display: flex; gap: 14px; font-size: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; margin: 14px 0;
}
.card h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
textarea, input[type=text], input[type=password], select {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
textarea { min-height: 110px; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; }
select { width: auto; }
button, .btn {
  font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none; display: inline-block;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--err); }
button:disabled { opacity: .5; cursor: default; }
.badge {
  display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.done { color: var(--ok); border-color: var(--ok); }
.badge.run { color: var(--warn); border-color: var(--warn); }
.badge.error { color: var(--err); border-color: var(--err); }
.list { display: flex; flex-direction: column; }
.list .item {
  display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.list .item:first-child { border-top: 0; }
.list .item .meta { flex: 1 1 260px; min-width: 0; }
.list .item .name { font-weight: 600; overflow-wrap: anywhere; }
.err-text { color: var(--err); font-size: 14px; white-space: pre-wrap; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .4s; }

/* ---------- 導讀頁 ---------- */
.player {
  position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 8px 0 6px;
  border-bottom: 1px solid var(--line);
}
.player audio { width: 100%; height: 40px; }
.toggles { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; margin-top: 4px; color: var(--muted); }
.toggles label { cursor: pointer; white-space: nowrap; }
.overview p { margin: .4em 0; }
.overview ul, .overview ol { margin: .3em 0; padding-left: 1.4em; }
.timeline { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 15px; }
.tlink { color: var(--accent); cursor: pointer; font-variant-numeric: tabular-nums; text-decoration: none; }
.tlink:hover { text-decoration: underline; }

.seg { padding: 0; overflow: hidden; }
.seg > .seg-head {
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  padding: 12px 18px; background: var(--accent-soft); border-bottom: 1px solid var(--line);
}
.seg-head .topic { font-weight: 700; }
.seg-body { padding: 10px 18px 16px; }
.seg-summary { margin: 4px 0 10px; }
.lines { display: flex; flex-direction: column; }
.line {
  display: grid; grid-template-columns: 52px 1fr; gap: 2px 10px; padding: 7px 6px;
  border-bottom: 1px dashed var(--line); border-radius: 6px;
}
.line.active { background: var(--active); }
.line .t { font-size: 12px; padding-top: 6px; }
.line .ja { font-size: 19px; line-height: 2.1; }
.line .speaker { font-size: 12px; color: var(--accent); margin-right: 6px; font-weight: 600; }
.line .zh { color: var(--muted); font-size: 15px; }
.line .note { font-size: 13px; color: var(--warn); }
ruby rt { font-size: .55em; color: var(--rt); letter-spacing: 0; }
body.hide-ruby rt { display: none; }
body.hide-zh .line .zh, body.hide-zh .zh-inline { display: none; }
body.hide-note .line .note { display: none; }
body.hide-vocab .blk-vocab, body.hide-grammar .blk-grammar, body.hide-colloquial .blk-colloquial,
body.hide-keys .blk-keys, body.hide-names .blk-names, body.hide-lines .lines { display: none; }

.blk { margin-top: 14px; }
.blk > h3 { font-size: 14px; margin: 0 0 6px; color: var(--accent); }
.entry { padding: 6px 0; border-top: 1px solid var(--line); font-size: 15px; }
.entry:first-of-type { border-top: 0; }
.entry .w { font-size: 18px; font-weight: 700; }
.entry .r { color: var(--rt); margin-left: 6px; }
.entry .tag { font-size: 12px; color: var(--muted); margin-left: 6px; }
.entry .ex { color: var(--muted); font-size: 14px; margin-top: 2px; }
.entry .ex .ja { color: var(--text); }
.vocab-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.vocab-table th, .vocab-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.vocab-table th { font-size: 13px; color: var(--muted); }
.disclaimer { font-size: 13px; color: var(--muted); border-left: 3px solid var(--warn); padding: 4px 10px; margin: 10px 0; }
.center { max-width: 360px; margin: 18vh auto 0; }
@media (max-width: 560px) {
  .line { grid-template-columns: 1fr; }
  .line .t { padding-top: 0; }
  .line .ja { font-size: 18px; }
}
