/* TV Series subtitle reader */
:root {
  --tv-ink: #0f172a;
  --tv-muted: #64748b;
  --tv-teal: #0f766e;
  --tv-teal-soft: #ccfbf1;
  --tv-line: #e2e8f0;
  --tv-bg: #f8fafc;
  --tv-card: #ffffff;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #ccfbf1 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #e0f2fe 0%, transparent 50%),
    var(--tv-bg);
  color: var(--tv-ink);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

.tv-app { min-height: 100vh; max-width: 820px; margin: 0 auto; padding-bottom: 80px; }
.hidden { display: none !important; }

.tv-auth-gate {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.tv-auth-card {
  background: var(--tv-card); border: 1px solid var(--tv-line);
  border-radius: 16px; padding: 28px 24px; max-width: 420px; text-align: center;
}
.tv-auth-eyebrow { color: var(--tv-teal); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.75rem; }
.tv-auth-card h1 { margin: 8px 0 12px; font-size: 1.6rem; }
.tv-auth-lead { color: var(--tv-muted); line-height: 1.5; }
.tv-auth-btn {
  display: inline-block; margin-top: 16px; background: var(--tv-teal); color: #fff;
  text-decoration: none; padding: 10px 18px; border-radius: 10px; font-weight: 600;
}

.tv-top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(248, 250, 252, 0.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--tv-line); padding: 10px 14px 12px;
}
.tv-top-row { display: flex; align-items: center; gap: 8px; }
.tv-home, .tv-icon {
  border: 0; background: transparent; font-size: 1.15rem; cursor: pointer;
  text-decoration: none; color: inherit; padding: 4px 6px; border-radius: 8px;
}
.tv-home:hover, .tv-icon:hover { background: var(--tv-teal-soft); }
.tv-titles { flex: 1; min-width: 0; }
.tv-show-title { display: block; font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-ep-title { display: block; color: var(--tv-muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tv-chip {
  border: 1px solid var(--tv-line); background: #fff; border-radius: 999px;
  padding: 5px 11px; font-size: 0.8rem; font-weight: 600; cursor: pointer; color: var(--tv-ink);
}
.tv-chip.is-on { background: var(--tv-teal); border-color: var(--tv-teal); color: #fff; }

.tv-audio-bar {
  background: #042f2e; color: #ecfdf5; padding: 10px 14px;
  border-bottom: 1px solid #115e59;
}
.tv-shadow-main { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tv-sh-btn {
  border: 0; background: #134e4a; color: #fff; border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer; font-size: 0.95rem;
}
.tv-sh-play { background: var(--tv-teal); width: 44px; }
.tv-sh-status { flex: 1; font-size: 0.85rem; font-weight: 600; }
.tv-shadow-opts {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px;
  font-size: 0.78rem; align-items: center;
}
.tv-shadow-opts select {
  margin-left: 4px; border-radius: 6px; border: 0; padding: 2px 4px;
}
.tv-sh-check { display: inline-flex; align-items: center; gap: 4px; }

.tv-library { padding: 20px 16px; }
.tv-library-title { margin: 0 0 16px; font-size: 1.25rem; }
.tv-library-list { display: grid; gap: 12px; }
.tv-show-card {
  display: block; text-align: left; width: 100%;
  background: var(--tv-card); border: 1px solid var(--tv-line);
  border-radius: 14px; padding: 16px 18px; cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.tv-show-card:hover { border-color: var(--tv-teal); transform: translateY(-1px); }
.tv-show-card h3 { margin: 0 0 4px; font-size: 1.1rem; }
.tv-show-card .zh { color: var(--tv-teal); font-weight: 600; font-size: 0.9rem; }
.tv-show-card p { margin: 8px 0 0; color: var(--tv-muted); font-size: 0.88rem; line-height: 1.45; }
.tv-show-meta { margin-top: 10px; font-size: 0.8rem; color: var(--tv-muted); }

.tv-reader-wrap { padding: 8px 0 24px; }
.tv-reader { padding: 8px 14px 24px; }
.tv-loading { color: var(--tv-muted); padding: 24px; text-align: center; }

.tv-line {
  position: relative;
  padding: 12px 12px 12px 14px;
  border-left: 3px solid transparent;
  border-radius: 0 10px 10px 0;
  margin: 0 0 4px;
}
.tv-line:hover { background: rgba(15, 118, 110, 0.04); }
.tv-line.is-active {
  background: var(--tv-teal-soft);
  border-left-color: var(--tv-teal);
}
.tv-line.is-sfx { opacity: 0.65; }
.tv-line-meta {
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
  font-size: 0.75rem; color: var(--tv-muted); margin-bottom: 4px;
}
.tv-line-meta .speaker { font-weight: 700; color: var(--tv-teal); }
body.hide-ts .tv-line-meta .ts { display: none; }
.tv-line-en {
  font-size: 1.05rem; line-height: 1.45; font-weight: 550;
}
.tv-line-en .w {
  cursor: pointer; border-radius: 4px; transition: background 0.12s;
}
.tv-line-en .w:hover { background: rgba(15, 118, 110, 0.14); }
.tv-line-en .w.is-active { background: var(--tv-teal); color: #fff; }
.tv-line-zh {
  display: none; margin-top: 4px; color: #334155; font-size: 0.92rem; line-height: 1.4;
}
.tv-reader.show-zh .tv-line-zh { display: block; }
.tv-line.zh-force-on .tv-line-zh { display: block !important; }
.tv-line.zh-force-off .tv-line-zh { display: none !important; }
.tv-line-actions {
  display: flex; gap: 6px; margin-top: 6px;
}
.tv-act {
  border: 1px solid var(--tv-line); background: #fff; border-radius: 8px;
  padding: 2px 8px; font-size: 0.75rem; font-weight: 700; cursor: pointer; color: var(--tv-ink);
}
.tv-act:hover { border-color: var(--tv-teal); color: var(--tv-teal); }

.tv-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 16px; border-top: 1px solid var(--tv-line);
}
.tv-nav-btn {
  border: 1px solid var(--tv-line); background: #fff; border-radius: 10px;
  padding: 8px 12px; font-weight: 600; cursor: pointer;
}
.tv-nav-pos { color: var(--tv-muted); font-size: 0.85rem; }

.tv-toc {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw);
  background: #fff; z-index: 40; box-shadow: -8px 0 30px rgba(0,0,0,0.12);
  display: flex; flex-direction: column;
}
.tv-toc-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--tv-line); font-weight: 700;
}
.tv-toc-list { list-style: none; margin: 0; padding: 8px; overflow: auto; flex: 1; }
.tv-toc-list li button {
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: 0.92rem;
}
.tv-toc-list li button:hover,
.tv-toc-list li button.is-current { background: var(--tv-teal-soft); }
.tv-toc-list .badge {
  display: inline-block; margin-left: 6px; font-size: 0.7rem;
  background: #e2e8f0; border-radius: 6px; padding: 1px 5px; color: var(--tv-muted);
}
.tv-backdrop, .tv-pop-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35); z-index: 30;
}
.tv-pop-backdrop { z-index: 50; }

.tv-pop {
  position: fixed; left: 50%; top: 10vh; transform: translateX(-50%);
  width: min(520px, 94vw); max-height: 78vh; overflow: auto;
  background: #fff; border-radius: 16px; z-index: 60;
  box-shadow: 0 20px 50px rgba(0,0,0,0.22);
}
.tv-pop-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--tv-line);
  position: sticky; top: 0; background: #fff;
}
.tv-explain-title { font-weight: 800; }
.tv-pop-actions { display: flex; gap: 4px; }
.tv-pop-body { padding: 14px 16px 20px; }
.tv-ex-sentence { font-size: 1.05rem; font-weight: 650; margin: 0 0 12px; line-height: 1.4; }
.tv-ex-section { margin-top: 14px; }
.tv-ex-h {
  font-size: 0.8rem; font-weight: 800; letter-spacing: 0.02em;
  color: var(--tv-teal); margin-bottom: 8px;
}
.tv-ex-meanings {
  margin: 0; padding: 0 0 0 1.15em; line-height: 1.65;
}
.tv-ex-meanings li { margin: 0 0 2px; }
.tv-ex-lesson {
  margin: 0;
  line-height: 1.7;
  font-size: 0.98rem;
  white-space: pre-wrap;
}
.tv-ex-zh { margin: 0 0 4px; line-height: 1.65; white-space: normal; }
.tv-ex-en { margin: 8px 0 0; color: var(--tv-muted); font-size: 0.9rem; line-height: 1.45; }
.tv-ex-point {
  border: 1px solid var(--tv-line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px;
}
.tv-ex-term { font-weight: 700; }
.tv-ex-type {
  display: inline-block; margin-left: 6px; font-size: 0.68rem; font-weight: 700;
  background: var(--tv-teal-soft); color: var(--tv-teal); border-radius: 999px; padding: 1px 7px;
  text-transform: uppercase;
}
.tv-ex-empty { color: var(--tv-muted); font-size: 0.9rem; }

.tv-word-head { font-size: 1.3rem; font-weight: 800; }
.tv-word-phon { color: var(--tv-muted); margin-left: 8px; font-size: 0.9rem; }
.tv-word-note { margin: 0 0 10px; font-size: 0.85rem; color: var(--tv-muted); }
.tv-sense { padding: 8px 0; border-top: 1px solid var(--tv-line); }
.tv-sense:first-of-type { border-top: none; }
.tv-sense.is-best {
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 6px 0;
}
.tv-sense-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 800;
  color: var(--tv-teal); background: var(--tv-teal-soft);
  border-radius: 999px; padding: 1px 8px; margin: 0 6px 4px 0;
}
.tv-sense-badge.muted { color: var(--tv-muted); background: #f1f5f9; font-weight: 600; }
.tv-pos {
  display: inline-block; font-size: 0.75rem; font-weight: 700;
  color: var(--tv-teal); margin-right: 6px;
}
.tv-def { line-height: 1.5; }
.tv-word-ex { margin-top: 6px; font-size: 0.88rem; color: var(--tv-muted); }
.tv-word-ex .en { display: block; color: var(--tv-ink); }
.tv-word-ex .zh { display: block; }

@media (max-width: 560px) {
  .tv-line-en { font-size: 1rem; }
  .tv-pop { top: 6vh; max-height: 86vh; }
}
