:root {
  --bg: #f6f4ef; --card: #fff; --ink: #1f1d1a; --sub: #6b665e; --line: #e4dfd5;
  --accent: #c2410c; --accent-soft: #fde7d9; --stage: #111; --rec: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17161a; --card: #222126; --ink: #eeeae2; --sub: #a39d92; --line: #34323a;
    --accent: #fb923c; --accent-soft: #3a2a20; --stage: #000;
  }
}
:root[data-theme="dark"] {
  --bg: #17161a; --card: #222126; --ink: #eeeae2; --sub: #a39d92; --line: #34323a;
  --accent: #fb923c; --accent-soft: #3a2a20; --stage: #000;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); line-height: 1.5;
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.top {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  max-width: 1200px; margin: 0 auto; padding: 12px 16px;
}
.top h1 { font-size: 20px; margin: 0; white-space: nowrap; }
.urlbar { flex: 1; display: flex; gap: 6px; max-width: 520px; }
.urlbar input { flex: 1; min-width: 0; font: inherit; font-size: 15px; min-height: 40px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.choice { max-width: 1200px; margin: 0 auto 10px; padding: 12px 16px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 14px; width: calc(100% - 32px); }
.choice p { margin: 4px 0; }
.choice .sub { color: var(--sub); font-size: 13px; }
.prog { height: 10px; background: var(--card); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.prog div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.ytwrap { width: 100%; aspect-ratio: 16 / 9; max-height: 70vh; }
.ytwrap iframe, .ytwrap > div { width: 100%; height: 100%; display: block; border: 0; }
.ytwrap.mirror { transform: scaleX(-1); }
main { max-width: 1200px; margin: 0 auto; padding: 0 16px 32px; }

.btn {
  font: inherit; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 40px; padding: 6px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; user-select: none;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.primary-soft { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.btn.icon { min-width: 48px; }
.btn.lg { font-size: 18px; min-height: 52px; padding: 10px 28px; }
.btn.toggle.on { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 700; }
.btn.rec { color: var(--rec); border-color: var(--rec); font-weight: 700; }
.btn.rec.on { background: var(--rec); color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.empty { text-align: center; padding: 56px 16px; background: var(--card); border: 1px dashed var(--line); border-radius: 16px; margin-top: 8px; }
.empty .big { font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.empty .sub { color: var(--sub); font-size: 14px; }

.stage { display: grid; grid-template-columns: 1fr; gap: 8px; }
.stage.side { grid-template-columns: 1fr 1fr; }
.stage.over { position: relative; }
.pane { position: relative; background: var(--stage); border-radius: 12px; overflow: hidden; min-height: 120px; }
.pane video { width: 100%; height: 100%; max-height: 70vh; display: block; object-fit: contain; background: var(--stage); }
.pane.cam video { object-fit: cover; }
.stage.side .pane video { aspect-ratio: 16 / 9; height: auto; }
.stage.over .pane.cam { position: absolute; inset: 0; background: transparent; pointer-events: none; opacity: var(--op, .5); }
.stage.over .pane.cam video { object-fit: contain; background: transparent; max-height: none; }
video.mirror { transform: scaleX(-1); }
.cnt {
  position: absolute; top: 10px; left: 10px; background: rgba(0, 0, 0, .62); color: #fff; border-radius: 12px;
  padding: 4px 14px; display: flex; align-items: baseline; gap: 10px; pointer-events: none; font-variant-numeric: tabular-nums;
}
.cnt .e { font-size: 15px; }
.cnt .b { font-size: 40px; font-weight: 800; color: #fde047; min-width: 1ch; line-height: 1.1; }
.cnt.pre .b { color: #93c5fd; }
.flash { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 0 #fde047; transition: box-shadow .12s; }
.flash.on { box-shadow: inset 0 0 0 6px #fde047; transition: none; }
.tag { position: absolute; top: 10px; left: 10px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; padding: 2px 10px; border-radius: 8px; }
.recdot { position: absolute; top: 10px; right: 10px; background: var(--rec); color: #fff; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 8px; }

.seek { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.seek .t { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--sub); min-width: 52px; }
.seek .t:last-child { text-align: right; }
.bar { position: relative; flex: 1; height: 32px; display: flex; align-items: center; }
.bar input { width: 100%; margin: 0; accent-color: var(--accent); position: relative; z-index: 1; background: transparent; }
.ab { position: absolute; top: 9px; height: 14px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 4px; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.row.sub { padding-left: 56px; }
.transport { justify-content: center; margin: 6px 0 10px; }
.play { min-width: 120px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px; }
.lbl { font-weight: 700; font-size: 14px; min-width: 48px; }
.info { font-size: 14px; color: var(--sub); }
.num { font-variant-numeric: tabular-nums; min-width: 72px; text-align: center; color: var(--ink); font-weight: 600; }
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; font-size: 14px; min-height: 38px; min-width: 50px; padding: 4px 10px; border: 0; border-right: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-variant-numeric: tabular-nums; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 700; }
.foot { color: var(--sub); font-size: 13px; margin-top: 12px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(20, 20, 20, .9); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); z-index: 10; }
.toast.on { opacity: 1; }
.drop { position: fixed; inset: 0; background: rgba(194, 65, 12, .85); color: #fff; font-size: 24px; font-weight: 700; display: flex; align-items: center; justify-content: center; z-index: 20; }

@media (max-width: 700px) {
  .stage.side { grid-template-columns: 1fr; }
  .row.sub { padding-left: 0; }
  .pane video { max-height: 45vh; }
  .seg button { min-width: 44px; padding: 4px 8px; }
  .top h1 { font-size: 18px; }
  .top { flex-wrap: wrap; }
  .urlbar { order: 3; flex-basis: 100%; max-width: none; }
}

/* 段落清單 */
.txt { font: inherit; font-size: 15px; min-height: 40px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-width: 0; flex: 1; max-width: 320px; }
.seglist { list-style: none; margin: 4px 0 8px; padding: 0 0 0 56px; display: grid; gap: 6px; }
.seglist li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px 4px 4px; background: var(--bg); }
.seglist li.on { border-color: var(--accent); background: var(--accent-soft); }
.seglist .go { flex: 1; min-width: 0; text-align: left; justify-content: flex-start; border: 0; background: transparent; font-weight: 700; white-space: normal; }
.seglist .go .tm { font-weight: 400; color: var(--sub); font-size: 13px; margin-left: 8px; }
.seglist li.on .go::before { content: "▶"; color: var(--accent); margin-right: 4px; font-size: 12px; }
@media (max-width: 700px) { .seglist { padding-left: 0; } .txt { max-width: none; } }
