:root {
  color-scheme: light dark;
  --bg: #f6f6f8;
  --card: #fff;
  --text: #16161a;
  --muted: #6b6b76;
  --line: #e4e4ea;
  --accent: #4f46e5;
  --ad: #f59e0b;
  font-family: system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111114; --card: #1c1c21; --text: #ececf1; --muted: #9a9aa6; --line: #2c2c33; --accent: #818cf8; }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); padding-bottom: 190px; }
button, select, input { font: inherit; color: inherit; }
button, select {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; white-space: nowrap;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .5; }

nav {
  position: sticky; top: 0; z-index: 1; display: flex; background: var(--card);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top);
}
nav a { flex: 1; text-align: center; padding: 14px 0; color: var(--muted); text-decoration: none; font-weight: 600; }
nav a.active { color: var(--accent); box-shadow: inset 0 -2px var(--accent); }

#offline { padding: 8px 16px; text-align: center; font-size: .85rem; background: var(--ad); color: #000; }
#signin { max-width: 760px; margin: 12px auto 0; padding: 0 16px; }
#signin[hidden] { display: none; }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px; }
h2 { font-size: 1.2rem; margin: 8px 0 12px; }
h3 { font-size: 1rem; margin: 18px 0 8px; }
#queue-rules { margin-bottom: 12px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
#queue-rules ol { margin: 8px 0; padding-left: 20px; }
#queue-rules li { margin: 4px 0; }
#queue-rules b { color: var(--text); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.row input[type=text], .row input[type=url], .row input[type=password] { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.order { display: flex; gap: 12px; } /* a show's group and day order on the Shows tab */
.row input[type=number], .order input { width: 70px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.empty, .sub { color: var(--muted); font-size: .85rem; }

ul { list-style: none; margin: 0; padding: 0; }
li.item {
  display: grid; grid-template-columns: 56px 1fr; gap: 4px 12px; padding: 12px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
li.item img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; grid-row: span 2; background: var(--line); }
/* Episodes with a YouTube video, and shows with a YouTube source: a badge in the top right corner. */
li.item.has-video { position: relative; }
li.item.has-video .title { padding-right: 60px; }
.video-badge { position: absolute; top: 10px; right: 10px; padding: 2px 6px; border-radius: 6px; background: #c4302b; color: #fff; font-size: .7rem; font-weight: 700; letter-spacing: .04em; }
.audio-only li.has-video:not(.audio-ok) { opacity: .5; } /* skipped while Audio only is on */
li.item.played .title { color: var(--muted); }
li.item.playing { border-color: var(--accent); }
li.in-queue { user-select: none; -webkit-touch-callout: none; } /* a long press drags instead of selecting */
li.in-queue img { pointer-events: none; } /* no native image drag */
li.item.dragging { border-color: var(--accent); box-shadow: 0 8px 24px rgb(0 0 0 / .35); transform: scale(1.02); }
body.dragging { overflow-anchor: none; } /* anchoring would scroll against the moving card */
.title { font-weight: 600; overflow-wrap: anywhere; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button { padding: 4px 8px; font-size: .85rem; }
details { grid-column: 1 / -1; font-size: .9rem; color: var(--muted); }
summary { cursor: pointer; }
.sessions { font-size: .85rem; margin-top: 2px; } /* History tab: one line per listening session */
.bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 4px; }
.bar div { height: 100%; background: var(--accent); border-radius: 2px; }
.bar.dl div { background: var(--muted); } /* download progress, apart from listening progress */
a.show { color: inherit; text-decoration: none; min-width: 0; }
.sub a { color: inherit; }
.latest { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* The video fills the window: the largest 16:9 box that leaves room for the tabs and the row under it. */
#watch { width: min(100% - 32px, (100vh - 110px) * 16 / 9); margin: 8px auto 0; }
#yt { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border: 0; border-radius: 12px; background: #000; }
#watch .row { margin: 8px 0 0; }
#watch-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#player {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
#player > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.now { display: flex; gap: 12px; align-items: center; }
.now img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.now .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now > div { min-width: 0; }
#seek { display: block; width: 100%; margin-top: 8px; accent-color: var(--accent); }
/* The ads the player skips, under the seek bar. */
#ad-marks { height: 3px; margin-top: 2px; margin-bottom: 2px; border-radius: 2px; } /* side margins center it like the seek bar */
#ad-note { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
#ad-note[hidden] { display: none; }
#ad-note button { padding: 2px 10px; }
.times { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.controls { display: flex; justify-content: center; gap: 10px; margin-top: 4px; }
.controls button { min-width: 64px; padding: 8px 12px; }
