:root {
  --bg: #111418; --fg: #eef1f4; --muted: #8b949e; --line: #262c33; --card: #1a1f25;
  --accent: #4ea1ff; --danger: #ff6b6b; --warn: #f2b84b;
  --zh-size: 30px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #fafafa; --fg: #15191e; --muted: #67707a; --line: #dde1e5; --card: #fff; color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font-family: -apple-system, "PingFang TC", "Noto Sans Thai", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
#app { height: 100%; display: flex; flex-direction: column; }
button { font: inherit; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button.big { font-size: 20px; padding: 14px 28px; min-width: 160px; }
input, select { font: inherit; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.muted { color: var(--muted); }
.banner { margin: 8px 16px; padding: 12px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.warn { border-color: var(--warn); }

/* 首頁 */
main.home, main.detail { max-width: 860px; width: 100%; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 20px 40px; overflow-y: auto; }
.start-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 20px 0; }
.start-box input { flex: 1; min-width: 220px; }
.sessions { list-style: none; padding: 0; margin: 0; }
.sessions a { display: flex; justify-content: space-between; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.sessions .meta, .detail .meta { color: var(--muted); font-size: 14px; }
.settings { margin-top: 24px; }

/* 即時字幕 */
.live-top { display: flex; align-items: center; gap: 12px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line); }
.live-top .title { font-weight: 600; }
.rec-dot { color: var(--danger); }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); }
.stats { color: var(--muted); font-size: 14px; }
.stats.warn { color: var(--warn); }
.spacer { flex: 1; }
#captions { flex: 1; overflow-y: auto; padding: 12px 20px 40px; scroll-behavior: auto; }
.row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.row .zh { font-size: var(--zh-size); line-height: 1.35; }
.row .src { font-size: calc(var(--zh-size) * 0.55); color: var(--muted); margin-top: 4px; }
.row .tag { display: inline-block; font-size: 12px; border: 1px solid var(--muted); border-radius: 4px; padding: 0 5px; margin-right: 6px; vertical-align: 2px; }
.row .late { font-size: 12px; color: var(--warn); margin-left: 8px; }
.row .ts { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .empty-note { font-size: 14px; color: var(--muted); opacity: .7; }
.row.empty { padding: 4px 0; }
.jump { position: fixed; right: 24px; bottom: 110px; background: var(--accent); color: #fff; border: 0; }
.live-bottom { display: flex; justify-content: center; gap: 20px; padding: 14px 16px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }

/* 詳情 */
.detail .back { color: var(--accent); text-decoration: none; }
.detail .actions { display: flex; gap: 12px; margin: 16px 0; }
.detail #transcript .row { cursor: pointer; --zh-size: 20px; }
#audio-parts audio { width: 100%; margin: 6px 0; }
#summary { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px 12px; margin: 12px 0; }

/* 覆蓋層與提示 */
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 10; }
#overlay[hidden] { display: none; }
.pin-card { background: var(--card); padding: 24px; border-radius: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 300px; }
.pin-msg { color: var(--danger); min-height: 1.2em; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 100px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast { background: var(--card); border: 1px solid var(--warn); border-radius: 10px; padding: 10px 16px; max-width: 80vw; }
#version { position: fixed; right: 8px; bottom: 4px; font-size: 11px; color: var(--muted); opacity: .6; pointer-events: none; }
