/* In-car look, light by day and dark at night like the car itself (follows the
   system setting). Flat panels, one blue accent. The player is always dark. */
:root {
  color-scheme: light;
  --bg: #f2f2f3;
  --panel: #ffffff;
  --panel-2: #e9e9ec;
  --panel-3: #dcdce0;
  --line: rgba(0, 0, 0, 0.08);
  --text: #171a20;
  --muted: #5c5e62;
  --accent: #3e6ae1;
  --accent-soft: rgba(62, 106, 225, 0.12);
  --danger: #e82127;
  --topbar: rgba(242, 242, 243, 0.92);
  --seg-track: #e4e4e7;
  --seg-on: #ffffff;
  --dialog: rgba(255, 255, 255, 0.97);
  --shadow: rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-lg: 18px;
  --font: Inter, "SF Pro Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Dark: automatically with the system (the car switches at night), or forced
   from the theme button (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0a0b;
    --panel: #18181a;
    --panel-2: #222225;
    --panel-3: #2e2e32;
    --line: rgba(255, 255, 255, 0.08);
    --text: #f4f4f5;
    --muted: #8d8d93;
    --accent-soft: rgba(62, 106, 225, 0.18);
    --topbar: rgba(10, 10, 11, 0.92);
    --seg-track: #18181a;
    --seg-on: #2e2e32;
    --dialog: rgba(24, 24, 26, 0.94);
    --shadow: rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #18181a;
  --panel-2: #222225;
  --panel-3: #2e2e32;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f4f5;
  --muted: #8d8d93;
  --accent-soft: rgba(62, 106, 225, 0.18);
  --topbar: rgba(10, 10, 11, 0.92);
  --seg-track: #18181a;
  --seg-on: #2e2e32;
  --dialog: rgba(24, 24, 26, 0.94);
  --shadow: rgba(0, 0, 0, 0.4);
}

/* The player stays dark in both modes, like video apps in the car. */
.player {
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #18181a;
  --panel-2: #222225;
  --panel-3: #2e2e32;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f4f5;
  --muted: #8d8d93;
  --accent-soft: rgba(62, 106, 225, 0.18);
  --seg-track: #222225;
  --seg-on: #3a3a3e;
  --dialog: rgba(24, 24, 26, 0.94);
  --shadow: rgba(0, 0, 0, 0.4);
  color: var(--text);
}

* { box-sizing: border-box; }

/* Author display rules (e.g. .grid) would otherwise override the hidden attribute. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 19px/1.35 var(--font);
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; letter-spacing: inherit; }

button {
  min-height: 56px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--panel-2);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}
button:active { transform: scale(0.97); background: var(--panel-3); }
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.primary:active { background: #345bc4; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon .fill, symbol .fill { fill: currentColor; stroke: none; }
symbol text { fill: currentColor; stroke: none; font: 600 6.4px var(--font); }

.icon-button {
  width: 56px;
  min-width: 56px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: transparent;
}
.icon-button:active { background: var(--panel-3); }

/* Segmented control: grey track, the active option is a lighter raised pill. */
.segmented {
  display: inline-flex;
  flex: none;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--seg-track);
  white-space: nowrap;
}
.segmented button {
  min-height: 48px;
  min-width: 0;
  padding: 0 20px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}
.segmented button[aria-pressed="true"] {
  background: var(--seg-on);
  color: var(--text);
  box-shadow: 0 1px 3px var(--shadow);
}
.segmented.small button { min-height: 40px; padding: 0 16px; font-size: 16px; }

/* Toggle switch (passenger mode). */
.switch {
  display: inline-flex;
  gap: 14px;
  align-items: center;
  flex: none;
  padding: 0 14px 0 20px;
  background: var(--panel);
  white-space: nowrap;
}
.switch .track {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: 15px;
  background: var(--panel-3);
  transition: background-color 0.2s;
}
.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.switch[aria-pressed="true"] .track { background: var(--accent); }
.switch[aria-pressed="true"] .knob { transform: translateX(22px); }

/* ---------- Login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login form {
  width: min(460px, 100%);
  display: grid;
  gap: 18px;
  padding: 40px 36px;
  background: var(--panel);
  border-radius: var(--radius-lg);
}
.login h1 { margin: 0 0 6px; font-size: 30px; font-weight: 600; letter-spacing: -0.02em; }
.login input {
  min-height: 64px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 22px;
}
.login input:focus { outline: none; border-color: var(--accent); }
.login .error { margin: 0; color: var(--danger); }
.login button { min-height: 64px; }

/* ---------- Library ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 24px;
  background: var(--topbar);
  backdrop-filter: blur(12px);
}
.search {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 56px;
  padding: 0 18px;
  border-radius: 14px;
  background: var(--panel);
  color: var(--muted);
}
.search input {
  flex: 1;
  min-width: 0;
  height: 54px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 20px;
}
.search input:focus { outline: none; }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent); }
/* Keeps the right-hand controls in place when the search box is hidden (show view). */
.topbar .push-right { margin-left: auto; }

h2 { font-weight: 600; letter-spacing: -0.015em; }

.continue { padding: 18px 24px 0; }
.continue h2, .tools h2 { margin: 0 0 14px; font-size: 22px; }
.continue .row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 176px;
  align-items: start;
  gap: 20px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
}
.continue .row::-webkit-scrollbar { display: none; }

.tools {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 4px;
}
.tools h2 { margin: 0; }

.status { padding: 48px 24px; color: var(--muted); text-align: center; }

/* Genre and collection chips, one scrollable row. */
.chips {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 14px 24px 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 22px;
  background: var(--panel);
  color: var(--muted);
  font-size: 16px;
}
.chip.collection { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 26px 20px;
  padding: 14px 24px 48px;
}

.card {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  background: none;
  text-align: left;
  font-weight: 400;
  /* Buttons centre their content vertically; keep posters top-aligned in a row. */
  align-self: start;
}
.card:active { background: none; transform: scale(0.97); }
.card .poster {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 17px;
  text-align: center;
}
.card .poster.text { padding: 12px; }
.card .poster img { width: 100%; height: 100%; object-fit: cover; }
.card .title {
  margin-top: 10px;
  font-size: 17px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card .meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Watch state: a blue bar for a started item, a tick for a watched one. */
.progress {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.3);
}
.progress span { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.watched {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

/* ---------- TV show ---------- */

.show { padding: 10px 24px 48px; }
.show-head { display: flex; gap: 8px; align-items: center; margin-left: -12px; }
.show-head h2 {
  margin: 0;
  font-size: 28px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.show .seasons { flex-wrap: wrap; }
.episodes {
  display: grid;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--panel);
}
.episode {
  display: flex;
  align-items: center;
  padding-right: 12px;
}
.episode + .episode { border-top: 1px solid var(--line); }
.episode.next { background: var(--accent-soft); }
.episode-main {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 18px;
  align-items: center;
  min-height: 0;
  padding: 12px 10px 12px 12px;
  border-radius: 0;
  background: transparent;
  text-align: left;
  font-weight: 400;
}
.episode-main:active { transform: none; background: var(--panel-2); }
.episode .still {
  position: relative;
  flex: none;
  width: 176px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
}
.episode .still img { width: 100%; height: 100%; object-fit: cover; display: block; }
.episode .still .progress { left: 6px; right: 6px; bottom: 6px; }
.episode .still .watched { top: 6px; right: 6px; width: 24px; height: 24px; font-size: 13px; }
.episode .number { min-width: 34px; color: var(--muted); font-variant-numeric: tabular-nums; }
.episode .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.episode .length { color: var(--muted); white-space: nowrap; font-size: 16px; }
.episode .poster-still { width: 72px; aspect-ratio: 2 / 3; }

/* Download button: arrow, percentage while downloading, tick when done. */
.download-state .when-done, .download-state .when-active { display: none; }
.download-state[data-state="done"] .when-none, .download-state[data-state="active"] .when-none { display: none; }
.download-state[data-state="done"] { background: var(--accent); color: #fff; }
.download-state[data-state="done"] .when-done { display: block; }
.download-state[data-state="active"] .when-active { display: block; font-size: 14px; font-weight: 600; color: var(--accent); }

.downloads { padding: 18px 24px 48px; }
.downloads h2 { font-size: 22px; }
.downloads .hint { margin: 0 0 16px; color: var(--muted); font-size: 16px; }

/* Storage: one quiet line with a thin bar, next to the heading. */
.downloads-head { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.downloads-head h2 { margin: 0; }
.storage { display: grid; gap: 6px; justify-items: end; color: var(--muted); font-size: 14px; }
.storage-bar {
  display: flex;
  width: 220px;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--panel-3);
}
.storage-bar .part { height: 100%; transition: width 0.4s; }
.storage-bar .part-downloads { background: var(--accent); }
.storage-bar .part-other { background: var(--muted); opacity: 0.5; }

.season-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 16px 0 20px; }
.season-row .seasons { margin: 0; }
.season-download[data-state="active"] { color: var(--accent); }

/* ---------- Player ---------- */

.player {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: #000;
}
.player video,
.player .stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #000;
}
.player .stage { display: grid; place-items: center; }
.player .stage canvas { max-width: 100%; max-height: 100%; background: #000; }

.player .controls {
  /* Above the loading backdrop. */
  position: relative;
  z-index: 1;
  padding: 10px 20px 14px;
  background: var(--panel);
}

.player .seek {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 0 6px;
}
.player .seek .time {
  min-width: 150px;
  color: var(--muted);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.player .seek .resolution {
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--panel-3);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
/* Fixed width, so the seek bar keeps its length whatever the label says (or before it has one). */
.player .seek .resolution { min-width: 112px; text-align: center; }
.player .seek .resolution:empty { visibility: hidden; }
.player .seek .resolution:empty::before { content: '\00a0'; }

/* Thin track with a white fill and a large touch thumb. --fill is set from app.js. */
.player .seek input {
  flex: 1;
  min-width: 0;
  height: 44px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  --fill: 0%;
}
.player .seek input::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #fff var(--fill), rgba(255, 255, 255, 0.22) var(--fill));
}
.player .seek input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.player .seek input::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.22); }
.player .seek input::-moz-range-progress { height: 6px; border-radius: 3px; background: #fff; }
.player .seek input::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: #fff; }

.player .bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin-top: 4px;
}
.player .side { display: flex; gap: 8px; align-items: center; min-width: 0; }
.player .side.end { justify-content: flex-end; }
.player .now {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.player .transport { display: flex; gap: 22px; align-items: center; }
.player .transport .icon-button .icon { width: 32px; height: 32px; }
.play-button {
  width: 68px;
  height: 68px;
  min-width: 68px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #000;
}
.play-button:active { background: #d9d9de; }
.play-button .icon { width: 30px; height: 30px; }
.play-button[data-state="playing"] .when-paused,
.play-button[data-state="paused"] .when-playing,
#fullscreen[data-state="off"] .when-on,
#fullscreen[data-state="on"] .when-off { display: none; }

.pill {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 0 18px 0 14px;
  border-radius: 24px;
  background: var(--panel-2);
  white-space: nowrap;
}
.pill[aria-pressed="true"] { background: var(--accent); color: #fff; }
.topbar .pill { min-height: 56px; border-radius: 14px; background: var(--seg-track); }
.topbar .pill[aria-pressed="true"] { background: var(--accent); }
/* Timer: just the icon until a timer runs, then icon + time left. */
.pill.quiet { padding: 0 14px; background: transparent; }
.pill.quiet[aria-pressed="true"] { padding: 0 18px 0 14px; background: var(--accent); }
.player.locked .controls { display: none; }

/* Floating actions over the picture: skip intro, next episode. */
.float-action {
  position: absolute;
  right: 28px;
  bottom: 190px;
  z-index: 3;
  min-height: 56px;
  padding: 0 26px;
  border-radius: 28px;
  background: rgba(244, 244, 245, 0.95);
  color: #000;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.float-action:active { background: #d9d9de; }
.player.controls-hidden .float-action, .player.locked .float-action { bottom: 40px; }
.next-up {
  position: absolute;
  right: 28px;
  bottom: 190px;
  z-index: 3;
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: min(620px, 90%);
  padding: 12px 12px 12px 22px;
  border-radius: 20px;
  background: rgba(24, 24, 26, 0.96);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.5);
}
.player.controls-hidden .next-up, .player.locked .next-up { bottom: 40px; }
.next-up-text { display: grid; min-width: 0; margin-right: 8px; }
.next-up-label { color: var(--muted); font-size: 15px; }
.next-up-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.next-up .play-now {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  background: #fff;
  color: #000;
  font-weight: 600;
}
.next-up .play-now .icon { width: 22px; height: 22px; }

/* Touch lock: a layer that swallows touches, with a card that explains how to unlock. */
.lock-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  touch-action: none;
}
.lock-card, .dialog {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(420px, 90%);
  padding: 28px 28px 26px;
  border-radius: 24px;
  background: var(--dialog);
  box-shadow: 0 20px 60px var(--shadow);
  backdrop-filter: blur(16px);
  text-align: center;
  animation: pop-in 0.18s ease-out;
}
.lock-card strong, .dialog strong { font-size: 22px; font-weight: 600; }
.lock-card span, .dialog span { color: var(--muted); }
.lock-icon, .dialog-icon { width: 34px; height: 34px; margin-bottom: 4px; color: var(--accent); }
.hold {
  position: relative;
  width: 88px;
  height: 88px;
  margin-top: 14px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-3);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.08);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.hold:active { transform: none; }
.hold .icon { width: 32px; height: 32px; }
.hold .ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 289;
  stroke-dashoffset: 289;
}
.hold.holding .ring { stroke-dashoffset: 0; transition: stroke-dashoffset 1.5s linear; }
.hold.holding { background: var(--accent-soft); }
@keyframes pop-in { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }

.dialog-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
}
.dialog-actions { display: flex; gap: 12px; margin-top: 16px; }
button.danger { background: var(--danger); color: #fff; font-weight: 600; }
body > .dialog-layer { position: fixed; z-index: 20; }
.dialog-actions button { min-width: 140px; }
.sheet.narrow { width: min(460px, 92%); }
.sheet .hint { color: var(--muted); font-size: 15px; }

/* Full screen: the controls overlay the picture on a gradient and hide after a while (see app.js). */
.player.fullscreen .controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  padding-top: 60px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 30%, rgba(0, 0, 0, 0));
}
.player.fullscreen .controls { transition: opacity 0.3s, transform 0.3s; }
.player.controls-hidden .controls { opacity: 0; transform: translateY(16px); pointer-events: none; }

/* Subtitles float above the controls; in full screen with hidden controls, near the bottom. */
.player .subtitle {
  position: absolute;
  left: 50%;
  bottom: 170px;
  z-index: 2;
  transform: translateX(-50%);
  max-width: 88%;
  margin: 0;
  padding: 4px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  white-space: pre-line;
  pointer-events: none;
}
.player.controls-hidden .subtitle { bottom: 40px; }

.player .notice {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 3;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 6px 6px 6px 20px;
  border-radius: 16px;
  background: rgba(24, 24, 26, 0.94);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
.player .notice button { min-height: 48px; background: var(--panel-3); }

.player .error {
  position: absolute;
  top: 20px;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  margin: 0;
  padding: 12px 22px;
  border-radius: 14px;
  background: var(--danger);
  font-weight: 500;
}

/* Audio, subtitles and quality: a sheet over the picture. */
.player .tracks {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
}
.sheet {
  width: min(900px, 94%);
  max-height: 92%;
  display: flex;
  flex-direction: column;
  padding: 22px 24px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.sheet h3 { margin: 0 0 10px 4px; color: var(--muted); font-size: 15px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.sheet-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  min-height: 0;
  overflow-y: auto;
}
.sheet .options {
  display: grid;
  overflow: hidden;
  border-radius: 14px;
  background: var(--panel-2);
}
.sheet .options p { margin: 0; padding: 16px 18px; color: var(--muted); }
.sheet .options button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 54px;
  padding: 0 16px 0 18px;
  border-radius: 0;
  background: transparent;
  text-align: left;
  font-weight: 400;
}
.sheet .options button + button { border-top: 1px solid var(--line); }
.sheet .options button:active { transform: none; background: var(--panel-3); }
.sheet .options button .icon { width: 22px; height: 22px; color: var(--accent); stroke-width: 2.4; visibility: hidden; }
.sheet .options button[aria-pressed="true"] { font-weight: 500; }
.sheet .options button[aria-pressed="true"] .icon { visibility: visible; }
.sheet-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-top: 20px;
}
.sheet-footer .primary { min-width: 160px; }

.storage-test { padding: 32px 24px; }
.storage-test a { color: var(--accent); }

/* ---------- Narrower browser (split screen next to the car controls) ---------- */

@media (max-width: 1000px) {
  html, body { font-size: 17px; }
  .topbar { gap: 10px; padding: 10px 16px; }
  .topbar .top-quality { display: none; }
  .topbar .pill .label, .player #switchMode .label { display: none; }
  .topbar .pill { padding: 0 14px; }
  .segmented button { padding: 0 14px; min-height: 44px; }
  .search { min-height: 52px; padding: 0 14px; }
  .search input { height: 50px; font-size: 17px; }

  .continue, .tools, .chips, .downloads, .show { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 18px 12px; padding: 12px 16px 40px; }
  .continue .row { grid-auto-columns: 118px; gap: 12px; }
  .card .title { font-size: 15px; margin-top: 8px; }
  .card .meta { font-size: 13px; }
  .continue h2, .tools h2, .downloads h2 { font-size: 19px; }
  .watched { width: 24px; height: 24px; font-size: 13px; top: 6px; right: 6px; }

  .episode .still { width: 120px; }
  .episode .poster-still { width: 56px; }
  .episode-main { gap: 12px; }
  .episode .number { min-width: 26px; }
  .show-head h2 { font-size: 22px; }

  .player .controls { padding: 8px 12px 10px; }
  .player .seek { gap: 10px; padding: 0; }
  .player .seek .time { min-width: 0; font-size: 14px; }
  .player .bar { display: flex; justify-content: space-between; gap: 6px; }
  .player .now { display: none; }
  .player .side { gap: 2px; }
  .player .transport { gap: 6px; }
  .player .icon-button { width: 46px; min-width: 46px; min-height: 46px; height: 46px; }
  .player .transport .icon-button .icon { width: 28px; height: 28px; }
  .play-button { width: 58px; height: 58px; min-width: 58px; }
  .player .pill { min-height: 46px; padding: 0 12px; }
  .player .pill.quiet[aria-pressed="true"] { padding: 0 12px 0 10px; }
  .player .subtitle { font-size: 24px; bottom: 140px; }
  .float-action, .next-up { right: 14px; bottom: 150px; }
  .sheet-columns { grid-template-columns: 1fr; }
  .sheet-footer { flex-wrap: wrap; }
}

@media (max-width: 720px) {
  .player .seek .resolution { display: none; }
  .tools { flex-wrap: wrap; }
}

/* ---------- Loading look ---------- */

/* Blurred picture of the film with a spinner until the first frame. */
.player .backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: none;
  overflow: hidden;
  background: #000;
  pointer-events: none;
}
.player .backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(28px) brightness(0.55);
  transform: scale(1.12);
}
.player.loading .backdrop { display: block; }
.player video, .player .stage { position: relative; z-index: 0; }
.player.loading video, .player.loading .stage { opacity: 0; }
.player .spinner {
  position: absolute;
  top: calc(50% - 60px);
  left: calc(50% - 28px);
  z-index: 1;
  display: none;
  width: 56px;
  height: 56px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  pointer-events: none;
}
.player.loading .spinner, .player.buffering .spinner { display: block; }
.player.paused .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeletons: grey outlines with a soft moving sheen. */
.skeleton .poster, .skeleton .line, .skeleton .still, .chip.skeleton {
  background: linear-gradient(100deg, var(--panel-2) 30%, var(--panel-3) 50%, var(--panel-2) 70%);
  background-size: 300% 100%;
  animation: sheen 1.4s ease-in-out infinite;
}
.skeleton .line { height: 14px; margin-top: 10px; border-radius: 7px; }
.skeleton .line.short { width: 55%; margin-top: 6px; }
.episode.skeleton .line { flex: 1; max-width: 260px; margin: 0; }
.chip.skeleton { display: inline-block; width: 96px; height: 44px; }
@keyframes sheen { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Pictures fade in once loaded. */
.poster img, .still img, .backdrop img { opacity: 0; transition: opacity 0.35s ease; }
.poster img.loaded, .still img.loaded, .backdrop img.loaded { opacity: 1; }

/* ---------- Motion ---------- */

.topbar { transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
.topbar.topbar-hidden { transform: translateY(-100%); }

@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } }
@keyframes sheet-up { from { opacity: 0; transform: translateY(48px); } }
@keyframes slide-in-right { from { opacity: 0; transform: translateX(32px); } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-16px); } }

.grid > .card:not(.skeleton), .continue .row > .card, .episodes > .episode:not(.skeleton), #downloadList > .episode {
  animation: fade-up 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.show, .downloads, .continue { animation: fade-in 0.25s ease both; }
.player { animation: fade-in 0.22s ease both; }
.player .tracks, .dialog-layer { animation: fade-in 0.2s ease both; }
.player .tracks .sheet { animation: sheet-up 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.float-action, .next-up { animation: slide-in-right 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.player .notice, .player .error { animation: slide-down 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.player .error { animation-name: fade-in; }
.chip, .segmented button, .pill, .icon-button, .card .poster { transition: background-color 0.2s, color 0.2s, transform 0.12s, box-shadow 0.2s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
