:root {
  --bg: #14161c; --surface: #1c1f27; --surface-2: #252935; --border: #2f3442;
  --text: #eceef3; --muted: #9aa1b2; --accent: #e8a33d; --accent-ink: #1a1306;
  --ok: #57c48a; --danger: #e06363; --radius: 14px;
  --player-h: 184px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f4ef; --surface: #ffffff; --surface-2: #efece4; --border: #e0dbd0;
    --text: #1d1f24; --muted: #6a6f7b; --accent: #b86e0b; --accent-ink: #fff;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(var(--player-h) + env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg path[d^="M8 5v14"], #icoPause path { fill: currentColor; stroke: none; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 650; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.container { max-width: 820px; margin: 0 auto; padding: 16px; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); padding: 10px 14px; border-radius: 999px; font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-primary svg { width: 18px; height: 18px; }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: transparent; color: var(--text); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); }
.badge { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--danger); color: #fff; }

.summary { display: flex; gap: 16px; align-items: center; justify-content: space-between; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.summary > div { flex: 1; min-width: 0; }
.summary-line { margin-bottom: 8px; }

.progress-track { display: block; height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress-track.big { height: 8px; }
.progress-fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .3s; }

.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin: 16px 0 8px; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: 999px; font: inherit; font-size: .9rem; cursor: pointer; }
.segmented button.active { background: var(--surface-2); color: var(--text); }
.jump input { width: 120px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }

.chapter-list { list-style: none; margin: 0; padding: 0; }
.chapter { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border); }
.chapter.current { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 10px; }
.ch-main { flex: 1; display: flex; gap: 12px; align-items: center; text-align: left; background: none; border: 0; color: inherit;
  padding: 12px 8px; font: inherit; cursor: pointer; min-width: 0; }
.ch-main:disabled { cursor: default; opacity: .45; }
.ch-num { width: 44px; flex: none; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.chapter.done .ch-num { color: var(--ok); }
.ch-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter.done .ch-title { color: var(--muted); }
.ch-dl.cached { color: var(--ok); }
.ch-dl.loading { color: var(--accent); }

.player { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 6px; box-shadow: 0 -8px 24px #0004; }
.player > * { max-width: 820px; width: 100%; margin: 0 auto; }
.player-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seek { display: flex; align-items: center; gap: 10px; }
.seek input { flex: 1; accent-color: var(--accent); }
.time { font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--muted); min-width: 44px; text-align: center; }
.controls { display: flex; justify-content: center; align-items: center; gap: 10px; }
.play-btn { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; cursor: pointer; }
.play-btn svg { width: 26px; height: 26px; }
.player-extra { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 6px 10px; font: inherit; font-size: .85rem; }

dialog.sheet { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  width: min(560px, calc(100% - 32px)); padding: 0; }
dialog.sheet.tall { width: min(760px, calc(100% - 32px)); max-height: 85vh; }
dialog::backdrop { background: #0008; }
.sheet-inner { padding: 20px; display: grid; gap: 14px; }
.sheet h2 { margin: 0; font-size: 1.15rem; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.gap { gap: 10px; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; flex-wrap: nowrap; }
.reader { font-size: 1.05rem; line-height: 1.7; overflow-y: auto; max-height: 68vh; padding-right: 6px; }
.reader p { margin: 0 0 1em; }

.center-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px; text-align: center;
  display: grid; gap: 12px; justify-items: center; max-width: 380px; width: 100%; }
.login-card h1 { margin: 4px 0 0; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #dadce0; font-weight: 600; }
.btn-google svg { stroke: none; }

@media (max-width: 520px) {
  :root { --player-h: 200px; }
  .ch-num { width: 34px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .jump input { width: 100%; }
}
