:root {
  --bg: #111318;
  --panel: #1a1d24;
  --panel2: #232733;
  --line: #2e3340;
  --text: #e8eaf0;
  --muted: #8b92a3;
  --accent: #ff7a59;
  --accent-ink: #1b0f0b;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
body { padding-bottom: env(safe-area-inset-bottom); }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg .fill, svg path.fill { fill: currentColor; stroke: none; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); background: rgba(17,19,24,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; flex: 1; }
.icon-btn { background: none; border: 0; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: var(--text); }
.icon-btn:active { background: var(--panel2); }

.player { max-width: 520px; margin: 0 auto; padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.art { width: min(100%, 300px); height: auto; aspect-ratio: 1; align-self: center; border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.45); background: var(--panel); }

.meta { text-align: center; }
.kicker { color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.title { margin: 4px 0 0; font-size: 20px; line-height: 1.25; font-weight: 650; text-wrap: balance; }
.note { margin-top: 8px; color: var(--muted); font-size: 13px; }

input[type=range] { width: 100%; height: 28px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; accent-color: var(--accent); }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--text); border: 0; }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--text); border: 0; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.transport { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.tbtn { position: relative; background: none; border: 0; color: var(--text); width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; }
.tbtn svg { width: 28px; height: 28px; }
.tbtn span { position: absolute; font-size: 9px; font-weight: 700; top: 50%; left: 50%; transform: translate(-50%, -38%); }
.tbtn:active { background: var(--panel2); }
.tbtn.play { width: 76px; height: 76px; background: var(--accent); color: var(--accent-ink); }
.tbtn.play svg { width: 34px; height: 34px; }
.tbtn.play:active { filter: brightness(.9); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-weight: 600; }
.row-head output { font-variant-numeric: tabular-nums; color: var(--accent); }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.link { background: none; border: 0; color: var(--accent); padding: 4px 0; font-weight: 500; }

.speed { display: flex; align-items: center; gap: 10px; }
.step { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); font-size: 20px; line-height: 1; }
.chips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 10px; }
.chips button { min-width: 0; padding: 0; height: 34px; border-radius: 17px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px; font-variant-numeric: tabular-nums; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--panel2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { height: 36px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-weight: 550; }
.seg button[aria-checked=true] { background: var(--text); color: var(--bg); }
.saved { margin-top: 10px; color: var(--muted); font-size: 13px; }
.saved:empty { display: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--line); }
.item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 0; }
.item-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.item-title { display: block; margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item:active .item-title { color: var(--accent); }
.item-meta .played { color: var(--accent); }
#playedCount { margin: -4px 0 2px; }

.show-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.show-row + .show-row { border-top: 1px solid var(--line); }
.show-row > span { display: flex; flex-direction: column; min-width: 0; }
.show-name { font-weight: 550; }
.switch { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 50px; height: 30px; margin: 0; border-radius: 15px; background: var(--panel2); border: 1px solid var(--line); cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(20px); background: #fff; }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet-panel { width: 100%; max-width: 560px; max-height: 85vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 17px; }
.sheet-panel input[type=search] { width: 100%; height: 44px; padding: 0 12px; margin: 4px 0 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; }
.sheet-panel .list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-sub { color: var(--muted); padding: 8px 0; }
.sheet-foot { display: flex; flex-direction: column; gap: 8px; }
.sheet-foot:empty { display: none; }
.sheet-foot:not(:empty) { margin-top: 8px; }

.btn { height: 46px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); font-weight: 550; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar, 0px) + 72px); transform: translateX(-50%); z-index: 30; max-width: calc(100% - 32px); background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.4); }

/* login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login img { width: 120px; height: 120px; align-self: center; border-radius: 22px; }
.login h1 { margin: 0; font-size: 22px; }
.login input { height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 16px; }
.login .err { color: #ff8a82; min-height: 1.4em; margin: 0; }

/* share clip */
.clip { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 6px; }
.clip-row { display: grid; grid-template-columns: 44px 40px 1fr 40px auto; align-items: center; gap: 8px; }
.clip-row > span { color: var(--muted); font-size: 13px; }
.clip-row output { text-align: center; font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 600; }
.clip-row .btn.sm { height: 40px; padding: 0 12px; }
.clip-len { color: var(--muted); font-size: 13px; text-align: center; }
.clip-len.bad { color: #ff8a82; }
.clip-status { text-align: center; font-weight: 550; }
/* Square, so sized by screen height too: the whole video and the buttons fit without scrolling. */
.clip video { width: min(100%, 36vh); aspect-ratio: 1; align-self: center; border-radius: 12px; background: #000; }
a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; color: inherit; }

/* ---- tabs and screens ---- */
.brand-icon { width: 26px; height: 26px; margin-right: 8px; }
/* Room at the bottom for the tab bar (and the mini-player above it, on the other tabs). */
body { --tabbar: calc(56px + env(safe-area-inset-bottom)); padding-bottom: 0; }
.screen { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar) + 24px); }
body:not([data-tab=now]) .screen { padding-bottom: calc(var(--tabbar) + 88px); }
.player.screen { padding-bottom: calc(var(--tabbar) + 24px); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr); height: var(--tabbar); padding-bottom: env(safe-area-inset-bottom); background: rgba(17,19,24,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 550; }
.tabbar a[aria-current=true] { color: var(--accent); }
.tab-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; line-height: 18px; text-align: center; }

.mini { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabbar) + 8px); z-index: 9; max-width: 544px; margin: 0 auto; display: flex; align-items: center; gap: 4px; padding: 6px 4px 6px 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.45); }
.mini-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.mini img { width: 44px; height: 44px; border-radius: 8px; flex: none; background: var(--panel); }
.mini-text { min-width: 0; display: flex; flex-direction: column; }
.mini-kicker { color: var(--accent); font-size: 12px; font-weight: 600; }
.mini-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }

/* ---- lists with artwork ---- */
.item.with-art { display: flex; gap: 12px; align-items: flex-start; }
.thumb { width: 48px; height: 48px; border-radius: 8px; flex: none; background: var(--panel2); }
.item-body { flex: 1; min-width: 0; display: block; }
.item-meta .new, .item-meta .now { color: var(--accent); }
progress.bar { display: block; width: 100%; height: 3px; margin-top: 6px; border: 0; border-radius: 2px; overflow: hidden; background: var(--line); -webkit-appearance: none; appearance: none; }
progress.bar::-webkit-progress-bar { background: var(--line); }
progress.bar::-webkit-progress-value { background: var(--accent); }
progress.bar::-moz-progress-bar { background: var(--accent); }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.then { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; padding-top: 10px; border-top: 1px solid var(--line); }
#queueList:empty + .then { margin-top: 0; padding-top: 0; border-top: 0; }
select { min-width: 0; height: 36px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; font-size: 14px; }
.then select { flex: 1; }

/* ---- Library ---- */
.search { width: 100%; height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-size: 16px; }
#libSearch { margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 12px; }
@media (min-width: 480px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tile { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tile-link { display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; min-width: 0; }
.tile-art { position: relative; display: block; margin-bottom: 6px; }
.tile-art img { display: block; width: 100%; aspect-ratio: 1; border-radius: 12px; background: var(--panel); }
.badge { position: absolute; top: 6px; right: 6px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; line-height: 24px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.tile-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-switch { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.switch.sm { width: 40px; height: 24px; border-radius: 12px; }
.switch.sm::after { width: 18px; height: 18px; }
.switch.sm:checked::after { transform: translateX(16px); }

/* ---- a show's page ---- */
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); text-decoration: none; font-weight: 550; margin: -4px 0 12px -6px; padding: 4px 0; }
.show-head { display: flex; gap: 14px; align-items: center; }
.show-head img { width: 112px; height: 112px; border-radius: 12px; flex: none; background: var(--panel); }
.show-head h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.2; }
.show-desc { color: var(--muted); font-size: 14px; margin: 12px 0 0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.show-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; }
#tab-show .card { margin-bottom: 16px; }
.list-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.seg.two { grid-template-columns: repeat(2, 1fr); flex: none; width: 170px; }
.list-tools .search { flex: 1; min-width: 0; height: 42px; }
.btn.wide { width: 100%; margin-top: 12px; }

/* ---- Inbox ---- */
.screen-head { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.screen-head .muted { flex: 1; }

/* ---- adding podcasts and downloads ---- */
.warn { background: #3a2a12; border: 1px solid #6b4a17; color: #ffd08a; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.lib-tools { display: flex; gap: 8px; margin-bottom: 16px; }
.lib-tools .search { flex: 1; min-width: 0; }
#libSearch { margin-bottom: 0; }
.add-btn { flex: none; width: 44px; height: 44px; padding: 0; color: var(--accent); }
.tile-add { color: var(--muted); text-decoration: none; gap: 2px; }
.add-art { display: grid; place-items: center; aspect-ratio: 1; border-radius: 12px; border: 2px dashed var(--line); margin-bottom: 6px; }
.add-art svg { width: 40px; height: 40px; }
.tile .busy { color: var(--accent); }
.add-form { margin-bottom: 8px; }
.add-hint { margin: 4px 0 12px; }
.sub-status { margin-top: 10px; }
.sub-status:empty { display: none; }
.sub-actions { display: flex; justify-content: space-between; margin-top: 8px; }
.link.danger, .btn.danger { color: #ff8a82; }
.btn.danger { border-color: #6b2b27; }
.preview { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 8px; }
.preview-head { display: flex; gap: 12px; align-items: center; }
.preview-head img { width: 88px; height: 88px; border-radius: 10px; flex: none; background: var(--panel2); object-fit: cover; }
.preview-desc { margin: 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.choice { display: grid; gap: 8px; }
.choice button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; text-align: left; border-radius: 12px; background: var(--panel2); border: 2px solid var(--line); }
.choice button span { color: var(--muted); font-size: 13px; }
.choice button[aria-checked=true] { border-color: var(--accent); }
.sheet-panel .search { margin: 4px 0; }
#subMode { width: 100%; }
.preview .warn { margin: 0; }

/* ---- chapters, notes, sleep timer ---- */
.chapter { display: flex; align-items: center; gap: 4px; margin-top: -4px; }
.chapter-title { flex: 1; min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 10px; font-size: 14px; }
.extras { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; font-weight: 550; }
.pill svg { width: 18px; height: 18px; }
.pill.on { color: var(--accent); border-color: var(--accent); }
.notes { padding: 4px 0 8px; line-height: 1.5; overflow-wrap: anywhere; }
.notes a { color: var(--accent); }
.notes p { margin: 0 0 10px; }
.notes ul, .notes ol { padding-left: 20px; margin: 0 0 10px; }
.chapters .item-meta { font-variant-numeric: tabular-nums; }
.chapters .item.on .item-title { color: var(--accent); }
