/* ============================================================
   Divine Revelations VIDEO Player (VPlayer) — player.css
   Cinematic dark-mode, fully responsive, no frameworks.
   Compatible: Chrome 70+, Firefox 65+, Safari 12+, Edge 79+
   ============================================================ */

/* ── Google Font ─────────────────────────────────────────── */
/* Inter is loaded by the <link> in index.php (loading it again from here would block rendering). */

/* ── CSS Custom Properties ───────────────────────────────── */
:root {
  /* Core palette */
  --bg-base:          #0d0d0f;
  --bg-panel:         #15151a;
  --bg-panel-hover:   #1e1e26;
  --bg-glass:         rgba(21, 21, 26, 0.85);
  --bg-overlay:       rgba(0, 0, 0, 0.55);

  /* Accent — overridable via JS: document.documentElement.style.setProperty */
  --accent:           #f0a500;
  --accent-dim:       rgba(240, 165, 0, 0.18);
  --accent-glow:      rgba(240, 165, 0, 0.35);

  /* Text */
  --text-primary:     #f0f0f5;
  --text-secondary:   #9090a0;
  --text-muted:       #8080a0;

  /* Borders */
  --border:           rgba(255, 255, 255, 0.07);
  --border-accent:    rgba(240, 165, 0, 0.4);

  /* Sizes */
  --radius-sm:        6px;
  --radius-md:        12px;
  --radius-lg:        20px;
  --radius-xl:        28px;

  /* Timing */
  --ease-out:         cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-in-out:      cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast:           0.15s;
  --t-med:            0.28s;
  --t-slow:           0.45s;

  /* Touch targets — Apple asks for 44px, Google/Material for 48px */
  --tap-min:          48px;
  --skip-size:        60px;
  --play-size:        76px;

  /* Layout */
  --controls-height:  104px;
  --ctl-clear:        0px;   /* height of a controls bar floating over the picture (set by player.js) */
  --panel-width:      320px;
  --z-video:          1;
  --z-controls:       10;
  --z-panel:          20;
  --z-modal:          30;
  --z-tooltip:        40;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  overflow: hidden; /* Player owns the whole viewport */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;          /* no iOS long-press callout on the picture */
  -webkit-tap-highlight-color: transparent;
}

/* The HTML `hidden` attribute must always win over component display rules below */
[hidden] { display: none !important; }

/* Rapid taps on controls must never zoom the page (iOS double-tap-to-zoom) */
button, a, select, input[type="range"], .chip, .chip-btn, #media-video {
  touch-action: manipulation;
}
/* Dragging the scrubber must never pan / pull-to-refresh the page */
#scrubber-wrap { touch-action: none; }

/* ── Focus styles (accessibility) ───────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* ── Player Shell ────────────────────────────────────────── */
#player-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  overflow: hidden;
}

/* ── Ambient Background Art ──────────────────────────────── */
#ambient-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(40px) brightness(0.3) saturate(1.4);
  transform: scale(1.08); /* Prevent blur edges */
  transition: background-image var(--t-slow) var(--ease-out),
              opacity var(--t-slow) var(--ease-out);
  opacity: 0;
}
#ambient-bg.has-art { opacity: 1; }

/* ── Main Content Area ───────────────────────────────────── */
#content-area {
  position: relative;
  z-index: var(--z-video);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0 12px 12px;
  transition: padding var(--t-med) var(--ease-out);
}

/* ── Video Element ───────────────────────────────────────── */
/* The video fills the content area; the fit mode is controlled by object-fit
   so ?fit= / Z can switch between contain (fit), cover (fill), fill (stretch). */
#media-video {
  width: 100%;
  height: 100%;
  object-fit: contain;              /* default = "fit" */
  border-radius: var(--radius-md);
  background: #000;
  display: block;
  cursor: pointer;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  transition: border-radius var(--t-med) var(--ease-out);
}
body.fit-fill    #media-video { object-fit: cover; }
body.fit-stretch #media-video { object-fit: fill; }

/* Fullscreen — no rounding */
:fullscreen #media-video,
:-webkit-full-screen #media-video {
  border-radius: 0;
}

/* ── Subtitle cue styling (matches the site) ─────────────── */
#media-video::cue {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  white-space: pre-line;
}

/* ── Title / Info Bar ────────────────────────────────────── */
#info-bar {
  position: relative;
  z-index: var(--z-controls);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 6px;
  flex-shrink: 0;
}
#media-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  letter-spacing: 0.01em;
}
#playlist-position {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Controls Bar ────────────────────────────────────────── */
#controls-bar {
  position: relative;
  z-index: var(--z-controls);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
  flex-shrink: 0;
  order: -1;
  transition: opacity var(--t-med) var(--ease-out),
              transform var(--t-med) var(--ease-out);
}

/* Auto-hide in video mode — slides up since bar is at top */
body.video-mode.controls-hidden #controls-bar,
body.video-mode.controls-hidden #info-bar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}
body.video-mode.controls-visible #controls-bar,
body.video-mode.controls-visible #info-bar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ── Progress / Scrubber Row ─────────────────────────────── */
#scrubber-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

#scrubber-wrap {
  flex: 1;
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

#progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  overflow: visible;
  transition: height var(--t-fast) var(--ease-out);
}
#scrubber-wrap:hover #progress-track { height: 6px; }

#progress-buffered {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
  transition: width 0.5s linear;
  pointer-events: none;
}
#progress-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
  transition: none; /* Updated via JS, no transition */
}

/* ── Chapter tick marks (inside the progress track) ──────── */
#chapter-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.chapter-tick {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 1px;
  pointer-events: none;
}

#progress-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  pointer-events: none;
  transition: transform var(--t-fast) var(--ease-out);
  left: 0%;
}
#scrubber-wrap:hover #progress-thumb { transform: translate(-50%, -50%) scale(1); }
#scrubber-wrap.dragging #progress-thumb { transform: translate(-50%, -50%) scale(1.25); }

/* Hover time tooltip — shows below scrubber since bar is at top */
#scrubber-tooltip {
  position: absolute;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
  z-index: var(--z-tooltip);
  backdrop-filter: blur(8px);
}
#scrubber-wrap:hover #scrubber-tooltip { opacity: 1; }

/* A/B loop region overlay */
#ab-region {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(240, 165, 0, 0.25);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  pointer-events: none;
  display: none;
}
#ab-region.visible { display: block; }

/* Time display */
.time-display {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 88px;
  text-align: right;
}

/* ── Main Controls Row ───────────────────────────────────── */
#controls-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

#controls-left, #controls-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
#controls-right { justify-content: flex-end; }

#controls-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Icon Buttons ────────────────────────────────────────── */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.07);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.active {
  color: var(--accent);
}
.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}
.icon-btn svg { display: block; }

/* Play/Pause — larger */
#btn-play {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  box-shadow: 0 4px 20px var(--accent-glow);
  transition: background var(--t-fast), transform var(--t-fast),
              box-shadow var(--t-fast);
}
#btn-play:hover {
  background: #ffc107;
  transform: scale(1.07);
  box-shadow: 0 6px 28px var(--accent-glow);
}
#btn-play:active { transform: scale(0.95); }

/* Frame-step buttons — only visible while paused */
#btn-frame-back, #btn-frame-fwd { display: none; }
body.paused #btn-frame-back,
body.paused #btn-frame-fwd { display: flex; }

/* CC button active (subtitles showing) */
#btn-cc.active { color: var(--accent); }

/* ── Volume Control ──────────────────────────────────────── */
#volume-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
#volume-slider-wrap {
  width: 80px;
  overflow: hidden;
  transition: width var(--t-med) var(--ease-out),
              opacity var(--t-med) var(--ease-out);
}
.vol-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
@media (max-width: 480px) {
  #volume-slider-wrap { width: 56px; }
}
@media (max-width: 360px) {
  #volume-slider-wrap { width: 0; opacity: 0; }
  .vol-label { display: none; }
}

/* ── Range Input (shared) ────────────────────────────────── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
  height: 20px;
  padding: 0;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -5px;
  box-shadow: 0 0 6px var(--accent-glow);
  transition: transform var(--t-fast);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: 0 0 6px var(--accent-glow);
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.2); }
input[type="range"]:hover::-moz-range-thumb    { transform: scale(1.2); }
input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Gradient fill trick for volume */
#volume-slider {
  --pct: 100%;
  background: linear-gradient(to right,
    var(--accent) 0%,
    var(--accent) var(--pct),
    rgba(255,255,255,0.15) var(--pct),
    rgba(255,255,255,0.15) 100%) no-repeat center / 100% 4px;
  border-radius: 2px;
}
#volume-slider::-webkit-slider-runnable-track { background: transparent; }
#volume-slider::-moz-range-track             { background: transparent; }

/* ── Speed Selector ──────────────────────────────────────── */
#speed-select {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
  min-width: 52px;
  text-align: center;
}
#speed-select:hover  { border-color: var(--border-accent); background: var(--bg-panel-hover); }
#speed-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Slide-in Panels (shared) ────────────────────────────── */
.side-panel {
  position: fixed;
  top: var(--controls-height);
  bottom: 0;
  width: var(--panel-width);
  max-width: 90vw;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  transition: transform var(--t-slow) var(--ease-out),
              opacity var(--t-slow) var(--ease-out),
              visibility 0s linear var(--t-slow);
  overflow: hidden;
  /* A closed panel must not be reachable by Tab / screen readers. visibility flips AFTER the
     slide-out finishes (delay above) and BEFORE the slide-in starts (.open resets the delay). */
  visibility: hidden;
}
.side-panel.open { visibility: visible; transition-delay: 0s; }
.side-panel.panel-right {
  right: 0;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  transform: translateX(100%);
  border-right: none;
}
.side-panel.panel-left {
  left: 0;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  transform: translateX(-100%);
  border-left: none;
}
.side-panel.open { transform: translateX(0); }

/* Scrim backdrop — starts below the controls bar */
#panel-scrim {
  position: fixed;
  top: var(--controls-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: calc(var(--z-panel) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out);
}
#panel-scrim.visible {
  opacity: 1;
  pointer-events: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.panel-body::-webkit-scrollbar { width: 6px; }
.panel-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Settings Panel ──────────────────────────────────────── */
#settings-panel { right: 0; }

.setting-section {
  margin-bottom: 24px;
}
.setting-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: block;
}
.setting-note {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}
.setting-row label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.12);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--t-fast), background var(--t-fast);
}
.toggle-switch input:checked + .toggle-track {
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(20px);
  background: var(--accent);
}
.toggle-switch input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Slider row in settings */
.setting-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.setting-slider-row input[type="range"] { flex: 1; }
.setting-slider-value {
  font-size: 0.78rem;
  color: var(--accent);
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Loop mode button group + Fit mode button group (shared look) */
#loop-group, #fit-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.loop-btn, .fit-btn {
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--t-fast);
}
.loop-btn.active, .fit-btn.active {
  background: var(--accent-dim);
  border-color: var(--border-accent);
  color: var(--accent);
}
.loop-btn:hover:not(.active),
.fit-btn:hover:not(.active) { border-color: rgba(255,255,255,0.2); color: var(--text-primary); }

/* Picture adjustment sliders */
.picture-slider-row {
  display: grid;
  grid-template-columns: 78px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.picture-slider-row label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
#btn-reset-picture { margin-top: 8px; }

/* Frame tools row (settings, mobile-reachable fallback) */
#frame-tools-row {
  display: flex;
  gap: 6px;
}
.frame-tool-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.frame-tool-btn:hover { border-color: var(--border-accent); color: var(--accent); }
.frame-tool-btn svg { display: block; }

/* A/B Loop controls */
#ab-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#ab-status {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  padding: 6px 10px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
#ab-btn-row {
  display: flex;
  gap: 6px;
}
.ab-btn {
  flex: 1;
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--t-fast);
}
.ab-btn:hover { border-color: var(--border-accent); color: var(--accent); }
.ab-btn.set   { border-color: var(--border-accent); color: var(--accent); background: var(--accent-dim); }

/* Download button */
#btn-download-full {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  color: var(--accent);
  text-decoration: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
}
#btn-download-full:hover {
  background: rgba(240, 165, 0, 0.28);
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* ── Settings Panel: Volume Row ─────────────────────────── */
#settings-volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
#settings-volume-row input[type="range"] {
  flex: 1;
  --pct: 100%;
  background: linear-gradient(to right,
    var(--accent) 0%,
    var(--accent) var(--pct),
    rgba(255,255,255,0.15) var(--pct),
    rgba(255,255,255,0.15) 100%) no-repeat center / 100% 4px;
  border-radius: 2px;
}
#settings-volume-row input[type="range"]::-webkit-slider-runnable-track { background: transparent; }
#settings-volume-row input[type="range"]::-moz-range-track             { background: transparent; }
#settings-volume-value {
  font-size: 0.78rem;
  color: var(--accent);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Settings Panel: Action Buttons ─────────────────────── */
#settings-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: all var(--t-fast);
}
.settings-action-btn:hover {
  border-color: var(--border-accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.settings-action-btn svg { flex-shrink: 0; }

/* ── Queue / Playlist Panel ──────────────────────────────── */
#queue-panel { right: 0; }

.queue-header-actions {
  display: flex;
  gap: 6px;
}

/* Chapter list (top of queue panel) */
#chapter-list { margin-bottom: 20px; }
#chapter-list-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}
.chapter-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.chapter-row:hover { background: var(--bg-panel-hover); }
.chapter-row.active {
  background: var(--accent-dim);
  border-color: var(--border-accent);
}
.chapter-row.active .chapter-row-title { color: var(--accent); }
.chapter-row-time {
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 48px;
}
.chapter-row.active .chapter-row-time { color: var(--accent); }
.chapter-row-title {
  font-size: 0.82rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#queue-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast);
  position: relative;
}
.queue-item:hover  { background: var(--bg-panel-hover); border-color: var(--border); }
.queue-item.active { background: var(--accent-dim); border-color: var(--border-accent); }
.queue-item.active .qi-title { color: var(--accent); }

.qi-num {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.queue-item.active .qi-num {
  color: var(--accent);
  font-weight: 700;
}
.qi-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-panel-hover);
  flex-shrink: 0;
}
.qi-thumb-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.qi-info {
  flex: 1;
  min-width: 0;
}
.qi-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qi-ext {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.queue-item.active .qi-ext { color: #b0b0c2; }   /* contrast on the accent-tinted row (WCAG AA, measured >= 4.5:1) */
.qi-drag {
  color: var(--text-muted);
  cursor: grab;
  padding: 4px;
  flex-shrink: 0;
  opacity: 0.5;
}
.queue-item.dragging { opacity: 0.4; background: var(--accent-dim); }
.queue-item.drag-over { border-top: 2px solid var(--accent); }

/* Shuffle active indicator */
#btn-shuffle.active { color: var(--accent); }

/* ── Keyboard Shortcut Help Panel ────────────────────────── */
#shortcuts-panel {
  left: 0;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  table-layout: fixed;          /* columns can't be pushed wider than the panel by long URLs */
}
.shortcut-table tr + tr { border-top: 1px solid var(--border); }
.shortcut-table td { padding: 7px 4px; vertical-align: middle; overflow-wrap: anywhere; }
.shortcut-table td:first-child { width: 40%; }

.shortcut-group-header {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 14px 4px 4px;
}
kbd {
  display: inline-block;
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Inter', monospace;
  font-size: 0.72rem;
  color: var(--text-primary);
  white-space: nowrap;
}

/* iframe-mode notice */
#iframe-notice {
  display: none;
  padding: 12px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 12px;
  line-height: 1.5;
}
body.in-iframe #iframe-notice { display: block; }
body.in-iframe .shortcut-table { opacity: 0.45; }

/* ── URL Params section in Shortcuts panel ───────────────── */
.url-params-section {
  margin-top: 20px;
}
.url-params-section code,
.shortcut-table code {
  font-family: 'Inter', monospace;
  font-size: 0.72rem;
  background: var(--bg-panel-hover);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  white-space: normal;          /* was nowrap: a long ?file=… example overflowed the panel */
  overflow-wrap: anywhere;
}

/* ── Panel navigation footer ─────────────────────────────── */
.panel-nav {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  background: var(--bg-panel);
}
.panel-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border: 1px solid var(--border-accent);
  border-radius: 20px;
  background: transparent;
  color: var(--accent);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.panel-nav-btn:hover {
  background: var(--accent-dim);
}
.panel-nav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Resume prompt (non-modal, bottom-left of the video) ─── */
#resume-prompt {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 0.85rem;
  color: var(--text-primary);
  max-width: calc(100% - 32px);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--t-med) var(--ease-out),
              transform var(--t-med) var(--ease-out);
}
#resume-prompt.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}
#resume-time { color: var(--accent); }
#resume-btns { display: flex; gap: 8px; flex-shrink: 0; }
#resume-btns button {
  font-family: inherit;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1px solid var(--border);
  background: var(--bg-panel-hover);
  color: var(--text-secondary);
}
#resume-yes {
  background: var(--accent) !important;
  color: #000 !important;
  border-color: var(--accent) !important;
  font-weight: 600;
}
#resume-btns button:hover { border-color: var(--border-accent); color: var(--accent); }
#resume-yes:hover { background: #ffc107 !important; color: #000 !important; }

/* ── Up Next countdown card ──────────────────────────────── */
#upnext-card {
  position: absolute;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#upnext-card.visible { display: flex; }
#upnext-thumb {
  width: 200px;
  height: 112px;
  border-radius: var(--radius-md);
  background: var(--bg-panel-hover) center/cover no-repeat;
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
#upnext-info { max-width: 340px; }
#upnext-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 6px;
}
#upnext-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 8px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
#upnext-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
#upnext-count strong { color: var(--accent); font-variant-numeric: tabular-nums; }
#upnext-btns { display: flex; gap: 10px; }
#upnext-btns button {
  font-family: inherit;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1px solid var(--border);
  background: var(--bg-panel-hover);
  color: var(--text-secondary);
}
#upnext-cancel:hover { border-color: var(--border-accent); color: var(--accent); }
#upnext-play {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}
#upnext-play:hover { background: #ffc107; }

/* ── Replay overlay button ───────────────────────────────── */
#btn-replay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 28px var(--accent-glow);
  transition: background var(--t-fast), transform var(--t-fast);
}
#btn-replay.visible { display: flex; }
#btn-replay:hover { background: #ffc107; transform: translate(-50%, -50%) scale(1.07); }
#btn-replay svg { display: block; }

/* ── Error / No-File State ───────────────────────────────── */
#error-screen {
  position: absolute;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  gap: 16px;
  padding: 32px;
  padding-top: max(48px, 8vh);
  background: var(--bg-base);
  text-align: center;
}
#error-screen.visible { display: flex; }
#error-params {
  text-align: left;
  max-width: 580px;
  width: 100%;
  margin-top: 8px;
  padding-bottom: 24px;
}
#error-icon { color: rgba(240,165,0,0.5); }
#error-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}
#error-message {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 380px;
  line-height: 1.6;
}

/* ── Loading Spinner ─────────────────────────────────────── */
#loading-overlay {
  position: absolute;
  inset: 0;
  z-index: calc(var(--z-controls) + 1);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-med);
}
/* The spinner is purely visual and must NEVER intercept touches: after every seek the video fires `waiting`,
   and a click-catching overlay would swallow taps on the skip buttons (and the resume prompt) until the
   buffer filled — breaking press-and-hold skipping on a phone connection. */
#loading-overlay.visible { opacity: 1; }
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Live region for screen-reader announcements ─────────── */
#sr-announce {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Toast notifications ─────────────────────────────────── */
#toast-container {
  position: fixed;
  top: calc(var(--controls-height) + 8px);
  right: 16px;
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--text-primary);
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity var(--t-med) var(--ease-out),
              transform var(--t-med) var(--ease-out);
  max-width: 280px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.toast.show {
  opacity: 1;
  transform: translateX(0);
}
.toast.toast-accent {
  border-color: var(--border-accent);
  color: var(--accent);
}

/* ── PiP button state ────────────────────────────────────── */
#btn-pip.active { color: var(--accent); }

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive tweaks ───────────────────────────────────── */
@media (max-width: 600px) {
  :root { --panel-width: 90vw; }
  #controls-row { gap: 2px; }
  /* NOTE: Rewind / Forward / Speed / Prev / Next used to be hidden here, which left phones with no
     way to skip. The phone layout (see "PHONE & TABLET LAYOUT" below) now shows them, large. */
  .time-display { min-width: 70px; font-size: 0.7rem; }

  /* Up Next card: stack thumb + info vertically */
  #upnext-card { flex-direction: column; gap: 14px; text-align: center; }
  #upnext-thumb { width: 160px; height: 90px; }
  #upnext-btns { justify-content: center; }

  /* Settings panel: larger text on small screens */
  .setting-label         { font-size: 0.8rem; }
  .setting-row label     { font-size: 0.92rem; }
  .settings-action-btn   { font-size: 0.92rem; }
  .vol-label             { font-size: 0.78rem; }

  /* Queue panel: larger text on small screens */
  .qi-title  { font-size: 0.88rem; }
  .qi-ext    { font-size: 0.76rem; }
  .qi-num    { font-size: 0.76rem; }

  /* Shortcuts panel: larger text on small screens */
  .shortcut-table        { font-size: 0.88rem; }
  .shortcut-group-header { font-size: 0.78rem; }
  kbd                    { font-size: 0.78rem; }

  /* Panel title and nav */
  .panel-title   { font-size: 0.95rem; }
  .panel-nav-btn { font-size: 0.82rem; }
}

/* ============================================================
   v2.0 — MOBILE-FIRST CONTROLS
   Everything below adds the skip buttons, chips, sheets and the
   phone/tablet layout. Desktop keeps the original top bar.
   ============================================================ */

/* ── Skip buttons (back / forward N seconds) ─────────────── */
.skip-btn { padding: 6px; }

/* ── Time display: elapsed / total — the total toggles to "-remaining" ── */
.time-dur {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  border-radius: 4px;
}
.time-dur:hover { color: var(--text-primary); }
.time-display.show-remaining .time-dur { color: var(--accent); }
/* Hit area >= 24 px (WCAG 2.5.8) without changing the layout: padding grown, margin pulled back by the same amount */
.time-dur { padding: 4px 6px; margin: -4px -6px; }
/* Name of the current chapter: phones only (touch has no hover tooltip) */
.chapter-now { display: none; }

/* ── Chips (speed / sleep-timer pickers) ─────────────────── */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
/* Fixed-column grids keep the rows tidy: 10 speeds = 5 x 2, 6 sleep options = 3 x 2 */
#speed-chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
#sleep-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
#speed-chips .chip, #sleep-chips .chip { padding: 0 4px; font-size: 0.85rem; white-space: nowrap; }
.chip {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  background: var(--bg-panel-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.chip:hover:not(.active) { border-color: rgba(255,255,255,0.22); color: var(--text-primary); }
.chip:active { transform: scale(0.96); }
.chip.active {
  background: var(--accent-dim);
  border-color: var(--border-accent);
  color: var(--accent);
}
#sleep-status {
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  margin-left: 6px;
}

/* ── Quick row (phone/tablet only — hidden on desktop) ───── */
#quick-row { display: none; }
/* Icon above a short label (+ optional small state, e.g. "1.5x"). Stacked, like a bottom tab bar, so
   it still fits when a video playlist shows four chips on a 320px-wide phone. */
.chip-btn {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.chip-btn:active { transform: scale(0.96); background: rgba(255,255,255,0.14); }
.chip-btn.active {
  color: var(--accent);
  border-color: var(--border-accent);
  background: var(--accent-dim);
}
.chip-btn svg { display: block; }
.chip-ico   { display: flex; flex-shrink: 0; }
.chip-text  { display: flex; flex-direction: row; align-items: baseline; justify-content: center; gap: 5px; max-width: 100%; min-width: 0; line-height: 1.15; }
.chip-label { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-state { font-size: 0.72rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.chip-btn:not(.active) .chip-state { color: var(--text-secondary); }
.chip-state:empty { display: none; }

/* ── Skip feedback bubbles ("+15 s") ─────────────────────── */
.skip-flash {
  position: absolute;
  top: 50%;
  z-index: calc(var(--z-controls) + 2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 96px;
  padding: 14px 18px;
  border-radius: 28px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.85);
  transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out);
}
.skip-flash-left  { left: 6%; }
.skip-flash-right { right: 6%; }
.skip-flash.show  { opacity: 1; transform: translateY(-50%) scale(1); }
.skip-flash .sf-ico { display: flex; color: var(--accent); }

/* ── Settings: Advanced fold-out + action grid ───────────── */
.advanced-settings { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 4px; }
.advanced-settings > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}
.advanced-settings > summary::-webkit-details-marker { display: none; }
.advanced-settings > summary::after {
  content: '▾';
  margin-left: auto;
  transition: transform var(--t-fast);
}
.advanced-settings[open] > summary { margin-bottom: 12px; }
.advanced-settings[open] > summary::after { transform: rotate(180deg); }
#settings-actions-help .settings-action-btn { width: 100%; }

/* ── Device-dependent visibility ─────────────────────────── */
body.no-volume-control #volume-slider-wrap,
body.no-volume-control .vol-label,
body.no-volume-control #settings-volume-row input[type="range"],
body.no-volume-control #settings-volume-value { display: none; }  /* iOS ignores page-set volume */

/* ── Panel handle (only drawn on phones) ─────────────────── */
.panel-header { position: relative; }

/* ── Touch devices: no sticky :hover after a tap ─────────── */
@media (hover: none) {
  .icon-btn:hover:not(.active):not(#btn-play) { background: none; color: var(--text-secondary); }
  #btn-play:hover { background: var(--accent); transform: none; box-shadow: 0 4px 20px var(--accent-glow); }
  .chip:hover:not(.active)     { border-color: var(--border); color: var(--text-secondary); }
  .time-dur:hover              { color: inherit; }
  #scrubber-wrap:hover #scrubber-tooltip { opacity: 0; }
  #scrubber-wrap.dragging #scrubber-tooltip { opacity: 1; }
  #resume-btns button:hover, #upnext-cancel:hover { border-color: var(--border); color: var(--text-secondary); }
  #resume-yes:hover { background: var(--accent) !important; }
  #upnext-play:hover, #btn-replay:hover { background: var(--accent); transform: none; }
  #btn-replay:hover { transform: translate(-50%, -50%); }
  .frame-tool-btn:hover, .ab-btn:hover:not(.set), .settings-action-btn:hover {
    border-color: var(--border); color: var(--text-secondary); background: var(--bg-panel-hover);
  }
}
/* Drag-and-drop reordering needs a mouse; hide the useless handle on touch screens */
@media (hover: none) and (pointer: coarse) {
  .qi-drag { display: none; }
}

/* ============================================================
   PHONE & TABLET LAYOUT
   Applies to narrow windows AND to any touch-first device.
   Controls move to the bottom (thumb zone) under the picture;
   panels become bottom sheets; everything tappable is >= 44px
   (48px for the transport row). In landscape and fullscreen the
   controls float over the picture instead (body.controls-overlay,
   set by player.js) and auto-hide.
   ============================================================ */
@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  :root { --panel-width: 100vw; }

  /* Order: info bar (top) → picture → controls (bottom) */
  #info-bar {
    order: 0;
    padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 4px max(16px, env(safe-area-inset-left));
  }
  #content-area { order: 1; padding: 0 12px 8px; }
  #controls-bar {
    order: 2;
    padding: 6px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    border-bottom: 0;
    border-top: 1px solid var(--border);
    border-radius: 24px 24px 0 0;
  }
  body.video-mode.controls-hidden #controls-bar,
  body.video-mode.controls-hidden #info-bar { transform: translateY(0); }

  /* Scrubber: tall touch area, always-visible knob, time bubble above the finger */
  #scrubber-row { flex-direction: column; align-items: stretch; gap: 0; margin-bottom: 4px; }
  /* flex: 0 0 auto — the base rule's `flex: 1` would otherwise collapse the HEIGHT in a column layout */
  #scrubber-wrap { flex: 0 0 auto; height: 44px; }
  #progress-track,
  #scrubber-wrap:hover #progress-track { height: 6px; border-radius: 3px; }
  #progress-fill, #progress-buffered { border-radius: 3px; }
  /* Chapter ticks stay visible on the thicker track */
  .chapter-tick { top: -2px; bottom: -2px; }
  #progress-thumb,
  #scrubber-wrap:hover #progress-thumb { width: 20px; height: 20px; transform: translate(-50%, -50%) scale(1); }
  #scrubber-wrap.dragging #progress-thumb { transform: translate(-50%, -50%) scale(1.35); }
  #scrubber-tooltip {
    top: auto;
    bottom: calc(100% - 2px);
    padding: 6px 12px;
    font-size: 0.95rem;
    font-weight: 700;
    max-width: 80vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #scrubber-wrap.dragging #scrubber-tooltip { opacity: 1; }
  .time-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    margin-top: -8px;
    padding: 0 2px;
    font-size: 0.85rem;
    text-align: left;
  }
  .time-sep { display: none; }
  /* Current chapter between elapsed and total time (long sermons) */
  .chapter-now {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
    color: var(--text-primary);
    opacity: 0.85;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Generous hit area for the "remaining time" toggle without changing the row height */
  .time-dur { padding: 12px 0 12px 28px; margin: -12px 0; }

  /* Transport row: |<  <15  PLAY  15>  >|   (frame-step lives in More > Advanced > Frame Tools) */
  #controls-row { flex-direction: column; align-items: stretch; gap: 10px; }
  #controls-left, #controls-right { display: none; }
  body.paused #btn-frame-back, body.paused #btn-frame-fwd,
  #btn-frame-back, #btn-frame-fwd { display: none; }
  #controls-center {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    justify-content: space-between;
    gap: 0;
  }
  #btn-prev, #btn-next {
    width: var(--tap-min); height: var(--tap-min);
    border-radius: 50%; padding: 0;
  }
  #btn-rew, #btn-fwd {
    width: var(--skip-size); height: var(--skip-size);
    border-radius: 50%; padding: 0;
    color: var(--text-primary);
  }
  #btn-play { width: var(--play-size); height: var(--play-size); }
  #btn-prev:disabled, #btn-next:disabled { visibility: hidden; }   /* single video: keep ▶ centred */

  /* Quick row: CC · Chapters/Queue · Full · More (each only when it applies) */
  #quick-row { display: flex; gap: 10px; }

  /* Settings / queue / shortcuts → bottom sheets */
  .side-panel,
  .side-panel.panel-right,
  .side-panel.panel-left,
  #settings-panel, #queue-panel, #shortcuts-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: 86vh;
    max-height: 86dvh;
    border-radius: 24px 24px 0 0;
    border: 1px solid var(--border);
    border-bottom: 0;
    transform: translateY(100%);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -12px 40px rgba(0,0,0,0.55);
  }
  /* The ID selectors above (needed to beat #shortcuts-panel's own corner radius) also win over a plain
     `.side-panel.open`, which would leave the sheet parked below the screen — so spell out the open state. */
  .side-panel.open,
  #settings-panel.open, #queue-panel.open, #shortcuts-panel.open { transform: translateY(0); }
  #panel-scrim { top: 0; }
  .panel-header { padding: 22px 12px 10px 20px; }
  .panel-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    width: 44px;
    height: 5px;
    margin-left: -22px;
    border-radius: 3px;
    background: rgba(255,255,255,0.22);
  }
  .panel-close { width: var(--tap-min); height: var(--tap-min); }
  .queue-header-actions .icon-btn { width: var(--tap-min); height: var(--tap-min); }
  .panel-body { padding: 14px 16px 20px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .panel-nav { display: none; }

  /* Settings content sized for fingers */
  .setting-section { margin-bottom: 22px; }
  .chip { min-height: 46px; }
  .loop-btn, .fit-btn { flex: 1; min-height: 46px; font-size: 0.9rem; }
  .ab-btn { min-height: 46px; font-size: 0.9rem; }
  .frame-tool-btn { min-height: 48px; }
  .setting-row { min-height: 48px; }
  .settings-action-btn { min-height: 54px; font-size: 0.92rem; }
  #settings-volume-row input[type="range"], .picture-slider-row input[type="range"] { height: 44px; }
  .picture-slider-row { grid-template-columns: 84px 1fr 48px; }
  .queue-item { min-height: 60px; padding: 10px; }
  .qi-thumb, .qi-thumb-placeholder { width: 44px; height: 44px; }
  .chapter-row { min-height: 48px; align-items: center; padding: 8px 10px; }

  /* Toasts: top-centre, clear of the thumb */
  #toast-container {
    top: max(52px, calc(env(safe-area-inset-top) + 44px));
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
    width: max-content;
    max-width: calc(100vw - 32px);
  }
  .toast { transform: translateY(-12px); }
  .toast.show { transform: translateY(0); }

  /* Resume prompt: thumb-sized buttons, in the picture area ABOVE the bottom bar */
  #resume-prompt { left: 12px; right: 12px; max-width: none; justify-content: space-between; padding: 12px 14px; }
  #resume-btns button { min-height: 48px; padding: 0 18px; font-size: 0.95rem; }
  /* Up Next buttons: thumb-sized too */
  #upnext-btns button { min-height: 48px; padding: 0 20px; font-size: 0.95rem; }
}

/* ── Compact: landscape phones and short embeds (iframe) ──
   One transport row, icon-only chips: CC · |< <15 PLAY 15> >| · Chapters · Full · More      */
@media (max-height: 460px) and (max-width: 820px),
       (max-height: 460px) and (hover: none) and (pointer: coarse) {
  #info-bar { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 2px; }
  #controls-bar { border-radius: 0; padding-top: 4px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  #scrubber-row { flex-direction: row; align-items: center; gap: 10px; margin-bottom: 2px; }
  #scrubber-wrap { flex: 1 1 auto; height: 36px; }
  .time-display { width: auto; min-width: 96px; margin-top: 0; justify-content: flex-end; font-size: 0.8rem; }
  .chapter-now { display: none; }
  .time-sep { display: inline; padding: 0 0.35em; }   /* flex items drop the spaces around the "/" */
  .time-dur { padding: 13px 0; margin: -13px 0 -13px -16px; min-width: 44px; text-align: right; }   /* 44 px hit area, row layout unchanged */

  #controls-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 6px; }
  #controls-center, #quick-row { display: contents; }     /* flatten so every button is one flex item */
  #btn-cc-quick     { order: 1; }
  #btn-prev         { order: 2; }
  #btn-rew          { order: 3; }
  #btn-play         { order: 4; }
  #btn-fwd          { order: 5; }
  #btn-next         { order: 6; }
  #btn-queue-quick  { order: 7; }
  #btn-fs-quick     { order: 8; }
  #btn-more         { order: 9; }
  #btn-prev, #btn-next { width: 44px; height: 44px; }
  #btn-rew, #btn-fwd   { width: 48px; height: 48px; }
  #btn-play            { width: 56px; height: 56px; }
  .chip-btn { flex: 0 0 auto; min-width: 48px; min-height: 48px; padding: 0; border-radius: 14px; }
  .chip-text { display: none; }
}
/* Narrow AND short (small embeds, e.g. 360x200): tighter row so a single video's controls fit on ONE line
   (they float over a very small picture); a playlist's extra Prev/Next may still wrap to a second line. */
@media (max-height: 460px) and (max-width: 520px) {
  #controls-row { flex-wrap: wrap; justify-content: center; gap: 4px; }
  #controls-bar { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  #btn-prev:disabled, #btn-next:disabled { display: none; }   /* single video: no width for invisible buttons */
  #btn-prev, #btn-next, #btn-rew, #btn-fwd { width: 44px; height: 44px; }
  #btn-play { width: 52px; height: 52px; }
  .chip-btn { min-width: 44px; min-height: 44px; }
}

/* ── Controls floating over the picture ───────────────────────
   body.controls-overlay is set by player.js whenever the controls cannot sit below the picture:
   a landscape phone / tablet / short embed, and any fullscreen. They sit on a gradient and
   auto-hide while playing. (Desktop's own fullscreen rules further down give the same result.) */
body.controls-overlay #content-area { position: absolute; inset: 0; padding: 0; }
body.controls-overlay #media-video { border-radius: 0; }
body.controls-overlay #info-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent);
}
body.controls-overlay #controls-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  order: unset;
  background: linear-gradient(to top, rgba(0,0,0,0.88), rgba(0,0,0,0));
  border: none;
  border-radius: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
body.video-mode.controls-overlay.controls-hidden #controls-bar { opacity: 0; pointer-events: none; transform: translateY(8px); }
body.video-mode.controls-overlay.controls-hidden #info-bar     { opacity: 0; pointer-events: none; transform: translateY(-8px); }

/* Overlays inside the picture stay clear of a floating controls bar (--ctl-clear = its height, from player.js) */
#resume-prompt { bottom: calc(16px + var(--ctl-clear, 0px)); }
#upnext-card   { padding-bottom: calc(24px + var(--ctl-clear, 0px)); }

/* Short frames (landscape phones, 360x200 embeds): the Up Next card becomes ONE row - text left, buttons right - so both
   buttons stay clear of the floating controls (the 160x90 thumbnail and the label would not fit). */
@media (max-height: 460px) and (max-width: 820px),
       (max-height: 460px) and (hover: none) and (pointer: coarse) {
  #upnext-card  { flex-direction: row; justify-content: center; align-items: center; text-align: left;
                  padding: 8px 12px calc(6px + var(--ctl-clear, 0px)); }
  #upnext-thumb, #upnext-label { display: none; }
  #upnext-info  { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: center;
                  width: 100%; max-width: none; }
  #upnext-title { grid-column: 1; grid-row: 1; font-size: 0.9rem; line-height: 1.25; margin-bottom: 2px; }
  #upnext-count { grid-column: 1; grid-row: 2; font-size: 0.78rem; margin-bottom: 0; }
  #upnext-btns  { grid-column: 2; grid-row: 1 / span 2; justify-content: flex-end; gap: 8px; }
  #upnext-btns button { min-height: 48px; padding: 0 14px; }
  /* With so little height the card cannot share the picture with the floating controls: they step aside while it is up */
  body.upnext-open.controls-overlay #controls-bar { opacity: 0; pointer-events: none; }
  body.upnext-open #upnext-card { padding-bottom: 8px; }
}

/* ── Fullscreen adjustments ──────────────────────────────── */
:fullscreen #player-shell,
:-webkit-full-screen #player-shell {
  background: #000;
}
:fullscreen #content-area,
:-webkit-full-screen #content-area {
  padding: 0;
}
:fullscreen #controls-bar,
:-webkit-full-screen #controls-bar {
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  border: none;
  position: absolute;
  bottom: 0; left: 0; right: 0;
  order: unset;
}
:fullscreen #info-bar,
:-webkit-full-screen #info-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent);
  padding-top: 16px;
}
