:root {
  --bg: #101216;
  --panel: #181b21;
  --line: #2a2e36;
  --text: #f4f5f7;
  --muted: #9aa1ad;
  --faint: #6b7280;
  --accent: #5aa9ff;
  --accent-text: #08111d;
  --live: #3ccf73;
  --wait: #f2b84b;
  --scale: 1;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fbfbfa;
    --panel: #ffffff;
    --line: #e4e4e0;
    --text: #15171a;
    --muted: #5d636d;
    --faint: #8a8f98;
    --accent: #0a62c9;
    --accent-text: #ffffff;
    --live: #16a34a;
    --wait: #c47f00;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------ captions page */

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar-title { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); flex: none; }
.dot[data-state="live"] { background: var(--live); box-shadow: 0 0 0 4px color-mix(in srgb, var(--live) 25%, transparent); }
.dot[data-state="connecting"] { background: var(--wait); }
.lang-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 16px;
  font-weight: 600;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed {
  padding: 16px 16px 120px;
  max-width: 760px;
  margin: 0 auto;
  min-height: 60vh;
}
.empty { color: var(--muted); font-size: 17px; margin-top: 30vh; text-align: center; }
.line { margin: 0 0 18px; }
.line .main {
  margin: 0;
  font-size: calc(24px * var(--scale));
  line-height: 1.38;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.line .main.pending { color: var(--muted); font-style: italic; font-weight: 400; }
.line .sub {
  margin: 4px 0 0;
  font-size: calc(15px * var(--scale));
  color: var(--muted);
}
.partial {
  margin: 0;
  min-height: 1em;
  font-size: calc(20px * var(--scale));
  color: var(--muted);
  font-style: italic;
}
.partial.dots { letter-spacing: 3px; font-style: normal; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .partial.dots { animation: none; } }

.notice {
  position: fixed;
  left: 16px;
  right: 16px;
  top: calc(64px + env(safe-area-inset-top));
  z-index: 6;
  max-width: 728px;
  margin: 0 auto;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.jump {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 5;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.tools {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tool {
  min-width: 48px;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  font-weight: 700;
}
.toggle { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.toggle[hidden] { display: none; }

/* ------------------------------------------------------------ language sheet */

.lang-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: min(78vh, 720px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  overflow: hidden;
}
.lang-dialog[open] { display: flex; flex-direction: column; }
.lang-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.lang-head { padding: 18px 16px 12px; border-bottom: 1px solid var(--line); }
.lang-head h2 { margin: 0 0 12px; font-size: 20px; }
.lang-search {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 16px;
}
.lang-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.lang-item {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: start;
}
.lang-item:hover, .lang-item:focus-visible { background: var(--bg); }
.lang-item[aria-current="true"] { background: var(--bg); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.lang-item .native { font-size: 19px; font-weight: 600; }
.lang-item .english { font-size: 14px; color: var(--muted); white-space: nowrap; }

/* ------------------------------------------------------------ home page */

.home {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.home-card { width: min(420px, 100%); text-align: center; }
.home-card h1 { font-size: 30px; margin: 0 0 8px; }
.home-card p { color: var(--muted); margin: 0 0 22px; }
.code-form { display: flex; gap: 10px; }
.code-input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-size: 24px;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
}
.code-go {
  border: 0;
  border-radius: 12px;
  padding: 0 22px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 18px;
}
.home-error { color: #ff7a7a; min-height: 1.4em; margin-top: 12px !important; }
