:root {
  color-scheme: dark;
  --bg: #0d1116;
  --panel: #151b22;
  --line: #2a323c;
  --text: #edf2f7;
  --muted: #8d98a6;
  --accent: #6ee7b7;
  --accent2: #60a5fa;
  --danger: #f87171;
  --warn: #fbbf24;
  --caption-size: 30px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Noto Sans TC", "PingFang TC", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) clamp(14px, 4vw, 40px) 12px;
  background: rgba(13, 17, 22, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
h1 { margin: 0; font-size: clamp(18px, 2.4vw, 26px); }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.status {
  display: grid;
  justify-items: end;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  min-width: 120px;
}
.status strong { font-size: 14px; color: var(--muted); }
.status span { font-size: 11px; color: var(--muted); }
.status.live { border-color: var(--accent); }
.status.live strong { color: var(--accent); }
.status.error { border-color: var(--danger); }
.status.error strong { color: var(--danger); }
main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px clamp(12px, 3vw, 32px) 32px;
  display: grid;
  gap: 14px;
}
.settings {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
}
.settings summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.settings-body { display: grid; gap: 12px; padding-top: 14px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea, button {
  font: inherit;
  color: var(--text);
  background: #0a0e12;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent2); outline-offset: 1px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; }
.hidden { display: none; }
.preview { margin: 0; color: #5e6b7a; font-size: 11px; max-height: 2.8em; overflow: hidden; }
.live {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary { background: var(--accent); color: #06261a; border-color: var(--accent); font-weight: 800; }
.meter { flex: 1 1 120px; height: 8px; min-width: 80px; background: #0a0e12; border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .1s; }
.stat { display: grid; justify-items: end; min-width: 58px; }
.stat span { color: var(--muted); font-size: 10px; }
.stat strong { font-size: 14px; }
.caption-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.caption-actions button { padding: 6px 10px; font-size: 12px; }
.font { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.captions {
  min-height: 50vh;
  max-height: 62vh;
  overflow: auto;
  padding: 16px clamp(14px, 3vw, 28px) 30px;
  scroll-behavior: smooth;
}
.empty { color: var(--muted); font-size: 15px; }
.segment { margin: 0 0 22px; }
.source {
  margin: 0;
  font-size: var(--caption-size);
  line-height: 1.65;
  color: var(--text);
}
.translation {
  margin: 8px 0 0;
  font-size: calc(var(--caption-size) * .62);
  line-height: 1.65;
  color: var(--accent);
}
.pending { color: var(--muted); }
.partial {
  margin: 0;
  font-size: var(--caption-size);
  line-height: 1.65;
  color: var(--muted);
}
footer {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 clamp(14px, 3vw, 32px) 28px;
  color: #5e6b7a;
  font-size: 12px;
}
footer p { margin: 4px 0; }
@media (max-width: 600px) {
  .topbar { align-items: flex-start; }
  .status { min-width: 0; }
  .stat:nth-of-type(3) { display: none; }
  .captions { max-height: 58vh; }
}
.inline-control { display: flex; gap: 8px; }
.inline-control select { flex: 1; min-width: 0; }
.inline-control button { white-space: nowrap; padding: 0 12px; }
.notice {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  background: rgba(251, 191, 36, .1);
  color: var(--warn);
}
.notice.error { background: rgba(248, 113, 113, .12); color: var(--danger); }
.notice.ok { background: rgba(110, 231, 183, .1); color: var(--accent); }
.diag {
  margin: 0;
  padding: 10px 14px;
  max-height: 180px;
  overflow: auto;
  border-bottom: 1px solid var(--line);
  background: #0a0e12;
  color: var(--muted);
  font: 11px/1.5 ui-monospace, monospace;
  white-space: pre-wrap;
}
