:root {
  color-scheme: dark;
  --bg: #101820;
  --panel: #17242f;
  --panel-2: #1f3140;
  --text: #f5f7f8;
  --muted: #aebbc4;
  --line: rgba(255,255,255,.12);
  --accent: #f5c84b;
  --accent-2: #37c8a6;
  --danger: #ff7676;
  --reader-size: 38px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input { font: inherit; }
button { border: 0; cursor: pointer; }
.is-hidden { display: none !important; }

.lock-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #0b1118 0%, #132231 100%);
}

.lock-panel {
  width: min(520px, 100%);
  padding: 28px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brand, .eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.lock-panel h1 { margin: 12px 0 8px; font-size: 30px; }
.lock-panel p { margin: 0 0 22px; color: var(--muted); line-height: 1.6; }
.password-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.password-form input {
  min-width: 0;
  height: 50px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: #0d151d;
  color: var(--text);
}
.password-form button, .primary-button, .play-button {
  height: 50px;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: #1b1b12;
  font-weight: 800;
}
.password-error { min-height: 24px; margin-top: 12px; color: var(--danger); }

.app { min-height: 100vh; padding: 18px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto 16px;
}
.topbar h1 { margin: 4px 0 0; font-size: 28px; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.icon-button, .ghost-button, .controls button, .secondary-controls button, .script-header button {
  min-height: 44px;
  border-radius: 6px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
}

.player-shell {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
}

.episode-list, .now-card, .reader, .script-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.episode-list { max-height: calc(100vh - 106px); overflow: hidden; display: flex; flex-direction: column; }
.list-header { display: flex; justify-content: space-between; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); color: var(--muted); }
.episode-items { overflow-y: auto; padding: 8px; }
.episode-item {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 10px;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
}
.episode-item:hover, .episode-item.is-active { background: rgba(255,255,255,.08); }
.episode-item.is-active { outline: 2px solid rgba(245,200,75,.35); }
.episode-index { color: var(--accent); font-weight: 800; font-size: 13px; }
.episode-name { font-size: 15px; line-height: 1.35; }
.episode-progress { color: var(--muted); font-size: 12px; white-space: nowrap; }

.stage { min-width: 0; display: grid; gap: 16px; }
.now-card { padding: 18px; }
.episode-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }
.now-card h2 { margin: 8px 0; font-size: 28px; line-height: 1.25; }
.now-card p { color: var(--muted); line-height: 1.6; margin: 0 0 16px; }
.time-row { display: flex; justify-content: space-between; color: var(--muted); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
#seekBar { width: 100%; accent-color: var(--accent); }
.controls, .secondary-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.controls button { flex: 1; min-width: 140px; }
.play-button { color: #16130a !important; background: var(--accent) !important; border: 0 !important; font-size: 18px; }

.reader {
  min-height: 44vh;
  padding: clamp(18px, 4vw, 44px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.segment-kind {
  color: var(--accent-2);
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 16px;
}
.current-segment {
  font-size: var(--reader-size);
  line-height: 1.45;
  font-weight: 750;
  word-break: break-word;
}
.reader.is-pause .current-segment { color: var(--accent); }
.next-label { margin-top: 26px; color: var(--muted); font-size: 14px; }
.next-segment { margin-top: 8px; color: var(--muted); font-size: 20px; line-height: 1.45; }

.script-panel { padding: 0; overflow: hidden; }
.script-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--muted); }
.script-timeline { max-height: 42vh; overflow-y: auto; padding: 10px; }
.timeline-item {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  padding: 11px 10px;
  border-radius: 6px;
  color: var(--muted);
  line-height: 1.55;
}
.timeline-item.is-current { color: var(--text); background: rgba(245,200,75,.12); outline: 1px solid rgba(245,200,75,.32); }
.timeline-time { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 800; }
.timeline-item.pause .timeline-text { color: var(--accent); }

:fullscreen .app, .app.fullscreen-like {
  padding: 0;
  background: #080d12;
}
:fullscreen .topbar, :fullscreen .episode-list, :fullscreen .script-panel,
.app.fullscreen-like .topbar, .app.fullscreen-like .episode-list, .app.fullscreen-like .script-panel {
  display: none;
}
:fullscreen .player-shell, .app.fullscreen-like .player-shell {
  max-width: none;
  min-height: 100vh;
  grid-template-columns: 1fr;
  gap: 0;
}
:fullscreen .stage, .app.fullscreen-like .stage { min-height: 100vh; grid-template-rows: auto 1fr; gap: 0; }
:fullscreen .now-card, .app.fullscreen-like .now-card {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: #101820;
}
:fullscreen .reader, .app.fullscreen-like .reader {
  border: 0;
  border-radius: 0;
  min-height: 0;
  background: #080d12;
}
:fullscreen .current-segment, .app.fullscreen-like .current-segment { font-size: clamp(40px, 8vw, 86px); }
:fullscreen .next-segment, .app.fullscreen-like .next-segment { font-size: clamp(22px, 3.2vw, 36px); }

@media (max-width: 900px) {
  .app { padding: 10px; }
  .topbar { align-items: flex-start; }
  .player-shell { grid-template-columns: 1fr; }
  .episode-list { max-height: 32vh; }
  .current-segment { font-size: calc(var(--reader-size) * .82); }
  .now-card h2 { font-size: 22px; }
}

@media (max-width: 560px) {
  .password-form { grid-template-columns: 1fr; }
  .topbar { display: grid; }
  .top-actions { justify-content: stretch; }
  .top-actions button { flex: 1; }
  .controls button, .secondary-controls button { min-width: calc(50% - 5px); flex: 1; }
  .reader { min-height: 50vh; }
  .current-segment { font-size: clamp(28px, 9vw, 44px); }
  .timeline-item { grid-template-columns: 64px 1fr; }
}
