/* ============================================================
   UQ.Rocks — Studio Dark
   True-black surfaces, Geist sans throughout, Geist Mono for
   numbers, six-theme picker (lime / magenta / cyan / amber /
   violet / paper). Default accent: electric lime #c8ff00.
   ============================================================ */

:root {
  --bg:           #0a0a0a;
  --bg-2:         #111111;
  --surface:      #161616;
  --surface-2:    #1d1d1d;
  --surface-3:    #262626;
  --border:       rgba(255, 255, 255, 0.06);
  --border-hi:    rgba(255, 255, 255, 0.10);
  --text:         #f5f5f5;
  --text-2:       #d4d4d4;
  --muted:        rgba(245, 245, 245, 0.58);
  --muted-soft:   rgba(245, 245, 245, 0.32);
  --muted-faint:  rgba(245, 245, 245, 0.18);

  --accent:       #c8ff00;
  --accent-2:     #d9ff4a;
  --accent-soft:  rgba(200, 255, 0, 0.12);
  --accent-glow:  rgba(200, 255, 0, 0.35);
  --danger:       #ff4d6d;
  --danger-soft:  rgba(255, 77, 109, 0.12);

  --font-sans:    'Geist', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Legacy aliases — old class names point at new tokens */
  --font-display: var(--font-sans);
  --font-body:    var(--font-sans);
  --primary:      var(--accent);
  --primary-hover: var(--accent-2);
  --primary-soft: var(--accent-soft);

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* ============================================================
   Theme presets — applied via [data-theme] on <html>
   ============================================================ */
:root[data-theme="magenta"] {
  --bg:        #160a13;
  --bg-2:      #1d1019;
  --surface:   #211420;
  --surface-2: #2a1a28;
  --surface-3: #352230;
  --accent: #ff3aa1;
  --accent-2: #ff5eb5;
  --accent-soft: rgba(255, 58, 161, 0.13);
  --accent-glow: rgba(255, 58, 161, 0.42);
}
:root[data-theme="cyan"] {
  --bg:        #06121a;
  --bg-2:      #0c1a26;
  --surface:   #11212e;
  --surface-2: #172a3a;
  --surface-3: #203247;
  --accent: #3decec;
  --accent-2: #6ff3f3;
  --accent-soft: rgba(61, 236, 236, 0.13);
  --accent-glow: rgba(61, 236, 236, 0.4);
}
:root[data-theme="amber"] {
  --bg:        #161008;
  --bg-2:      #1d160c;
  --surface:   #221a10;
  --surface-2: #2a2014;
  --surface-3: #34291a;
  --accent: #ffaa00;
  --accent-2: #ffbe3d;
  --accent-soft: rgba(255, 170, 0, 0.16);
  --accent-glow: rgba(255, 170, 0, 0.45);
}
:root[data-theme="violet"] {
  --bg:        #0e0a1a;
  --bg-2:      #150f24;
  --surface:   #19132c;
  --surface-2: #211a38;
  --surface-3: #2a2348;
  --accent: #a78bfa;
  --accent-2: #c4adff;
  --accent-soft: rgba(167, 139, 250, 0.16);
  --accent-glow: rgba(167, 139, 250, 0.42);
}
/* Light "paper" theme — flips surfaces. Player frame stays dark
   so videos look right against the light page. */
:root[data-theme="paper"] {
  --bg:           #f6f4ee;
  --bg-2:         #ebe7dc;
  --surface:      #ffffff;
  --surface-2:    #f1ede1;
  --surface-3:    #e6e0d0;
  --border:       rgba(20, 18, 14, 0.08);
  --border-hi:    rgba(20, 18, 14, 0.14);
  --text:         #14120e;
  --text-2:       #3a3631;
  --muted:        rgba(20, 18, 14, 0.62);
  --muted-soft:   rgba(20, 18, 14, 0.42);
  --muted-faint:  rgba(20, 18, 14, 0.22);
  --accent:       #ff3a2d;
  --accent-2:     #ff5440;
  --accent-soft:  rgba(255, 58, 45, 0.10);
  --accent-glow:  rgba(255, 58, 45, 0.32);
  --danger:       #d12a44;
  --danger-soft:  rgba(209, 42, 68, 0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); }

body {
  font-family: var(--font-sans);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  background-image:
    radial-gradient(ellipse 1200px 700px at 70% -10%, var(--accent-soft) 0%, transparent 55%),
    radial-gradient(ellipse 800px 600px at 0% 100%, rgba(255, 255, 255, 0.02) 0%, transparent 60%);
}
:root[data-theme="paper"] body {
  background-image:
    radial-gradient(ellipse 1200px 700px at 70% -10%, rgba(255, 58, 45, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse 800px 600px at 0% 100%, rgba(0, 0, 0, 0.025) 0%, transparent 60%);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

h1, h2, h3, .display {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--text);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ============================================================
   Backdrop layer (kept for app.js compatibility — disabled visually)
   ============================================================ */
#backdrop { display: none; }

/* ============================================================
   Header
   ============================================================ */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0.95rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}
:root[data-theme="paper"] header {
  background: rgba(246, 244, 238, 0.78);
}

.logo-container {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
}
.logo-container a {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

/* Wordmark glyph (replaces logo image) */
.brand-glyph {
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}

/* If logo img is still in markup, hide it (we use text wordmark) */
header img { display: none; }

header h1 {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand-accent { color: var(--accent); }

.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.nav-links {
  display: flex;
  gap: 0.15rem;
  align-items: center;
}
.nav-links a {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  transition: color 0.16s ease, background 0.16s ease;
}
.nav-links a:hover { color: var(--text); background: var(--surface); }
.nav-links a.is-active { color: var(--text); background: var(--surface-2); }

/* ============================================================
   Theme picker
   ============================================================ */
.theme-picker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.theme-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-hi);
  cursor: pointer;
  position: relative;
  padding: 0;
  transition: transform 0.18s ease;
}
.theme-swatch:hover { transform: scale(1.18); }
.theme-swatch.is-active::after {
  content: '';
  position: absolute;
  inset: -5px;
  border: 1.5px solid var(--text);
  border-radius: 50%;
  pointer-events: none;
}
.theme-swatch[data-theme="lime"]    { background: #c8ff00; }
.theme-swatch[data-theme="magenta"] { background: #ff3aa1; }
.theme-swatch[data-theme="cyan"]    { background: #3decec; }
.theme-swatch[data-theme="amber"]   { background: #ffaa00; }
.theme-swatch[data-theme="violet"]  { background: #a78bfa; }
.theme-swatch[data-theme="paper"]   { background: linear-gradient(135deg, #f6f4ee 50%, #14120e 50%); }

@media (max-width: 720px) {
  .theme-picker { display: none; }
}

/* ============================================================
   Layout
   ============================================================ */
main {
  max-width: 1340px;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
}

.app-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}
@media (min-width: 1100px) {
  .app-container { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 2rem; }
}

.video-section,
.queue-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.queue-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-self: start;
  position: sticky;
  top: 5.5rem;
  max-height: calc(100vh - 7rem);
  overflow: hidden;
}

/* ============================================================
   Search input + add button
   ============================================================ */
#video-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  position: relative;
}

input[type="text"] {
  flex: 1;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.16s ease, background 0.16s ease;
  letter-spacing: -0.005em;
}
input[type="text"]::placeholder { color: var(--muted-soft); }
input[type="text"]:focus {
  border-color: var(--accent);
  background: var(--surface-2);
}

.btn {
  height: 42px;
  padding: 0 1.1rem;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.1s ease, box-shadow 0.16s ease;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.btn:active { transform: translateY(1px); }
.btn i[data-lucide] { width: 16px; height: 16px; stroke-width: 2; }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover { background: var(--accent-2); }

.btn-accent {
  background: var(--accent);
  color: var(--bg);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-hi);
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(255, 77, 109, 0.3);
}
.btn-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

/* ============================================================
   Video player
   ============================================================ */
.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: #000;
  border: 1px solid var(--border);
}
.video-container iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* ============================================================
   Transport
   ============================================================ */
.transport {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.tp-btn {
  width: 38px; height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 8px;
  display: grid;
  place-items: center;
  transition: background 0.16s ease, color 0.16s ease, transform 0.1s ease;
}
.tp-btn:hover { background: var(--surface-2); color: var(--text); }
.tp-btn:active { transform: translateY(1px); }
.tp-btn i[data-lucide] { width: 16px; height: 16px; stroke-width: 2; }

.tp-btn.tp-btn--play {
  width: 46px; height: 46px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 50%;
  margin: 0 0.25rem;
  box-shadow: 0 0 0 0 var(--accent-glow);
  transition: background 0.16s ease, box-shadow 0.2s ease, transform 0.1s ease;
}
.tp-btn.tp-btn--play:hover {
  background: var(--accent-2);
  box-shadow: 0 0 24px 0 var(--accent-glow);
}
.tp-btn.tp-btn--play i[data-lucide] { width: 18px; height: 18px; }

.tp-btn[data-state="one"],
.tp-btn[data-state="all"],
.tp-btn[data-state="on"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.tp-btn--danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.transport__divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 0.35rem;
}
.transport__spacer { flex: 1; }

/* ============================================================
   "Popular Today" pill
   ============================================================ */
.popular-today {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: -0.005em;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.popular-today:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================================
   Queue list — currently-playing list (active queue)
   ============================================================ */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 0.75rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
  counter-reset: track;
}

.queue-card {
  counter-increment: track;
  display: grid;
  grid-template-columns: 28px 64px 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0.6rem 0.5rem 0.5rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.queue-card::before {
  content: counter(track, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted-soft);
  text-align: center;
  font-feature-settings: 'tnum' 1;
  width: 28px;
}
.queue-card:hover {
  background: var(--surface);
  border-color: var(--border);
}
.queue-card:hover::before { color: var(--accent); }
.queue-card:hover .queue-card__title { color: var(--accent); }

.queue-card__thumb {
  width: 64px;
  height: 36px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
  cursor: grab;
  background: var(--surface-2);
}
.queue-card__thumb:active { cursor: grabbing; }

.queue-card__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.queue-card__title {
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease;
}

.queue-card__channel {
  font-size: 0.76rem;
  color: var(--muted-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-card__remove {
  background: transparent;
  color: var(--muted-soft);
  border: 0;
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.queue-card__remove:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.queue-card.dragging { opacity: 0.4; }

/* Now-playing variant */
.queue-card.is-playing {
  background: var(--accent-soft);
  border-color: rgba(255, 255, 255, 0.04);
}
.queue-card.is-playing::before {
  content: '►';
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
}
.queue-card.is-playing .queue-card__title {
  color: var(--accent);
  font-weight: 600;
}
:root[data-theme="paper"] .queue-card.is-playing {
  border-color: rgba(0, 0, 0, 0.06);
}

/* ============================================================
   Saved queues panel
   ============================================================ */
.qm-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.qm-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.qm-save {
  display: flex;
  gap: 0.5rem;
}
.qm-save input { padding: 0.7rem 0.85rem; font-size: 0.88rem; }
.qm-save .btn { height: 38px; padding: 0 0.95rem; font-size: 0.85rem; }

.qm-toolbar {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.qm-toolbar input[type="text"] { padding: 0.6rem 0.8rem; font-size: 0.85rem; }
.qm-toolbar .btn {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--bg-2);
  border-color: var(--border);
  color: var(--muted);
}
.qm-toolbar .btn:hover { color: var(--accent); border-color: var(--accent); background: var(--surface-2); }

#queue-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
}

.queue-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}
.queue-item:hover {
  background: var(--surface-2);
  border-color: var(--border-hi);
  transform: translateY(-1px);
}

.queue-item__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.queue-item__name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: -0.015em;
  word-break: break-word;
}

.queue-item__meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted-soft);
  white-space: nowrap;
  flex-shrink: 0;
  font-feature-settings: 'tnum' 1;
}

.queue-item__actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.queue-item__actions .btn {
  padding: 0 0.7rem;
  height: 28px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ============================================================
   Scrollbars
   ============================================================ */
.queue-list::-webkit-scrollbar,
#queue-list::-webkit-scrollbar { width: 6px; }
.queue-list::-webkit-scrollbar-track,
#queue-list::-webkit-scrollbar-track { background: transparent; }
.queue-list::-webkit-scrollbar-thumb,
#queue-list::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 3px;
}
.queue-list::-webkit-scrollbar-thumb:hover,
#queue-list::-webkit-scrollbar-thumb:hover {
  background: var(--muted-soft);
}

/* ============================================================
   Combobox (autocomplete)
   ============================================================ */
.combobox-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  max-height: 320px;
  overflow-y: auto;
  z-index: 10000;
}
.combobox-item {
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.3;
  letter-spacing: -0.005em;
}
.combobox-item:hover,
.combobox-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ============================================================
   Toasts
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  z-index: 10000;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 360px;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-hi);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  transform: translateX(calc(100% + 32px));
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.toast--visible { transform: translateX(0); opacity: 1; }
.toast--success { border-left: 3px solid var(--accent); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--info    { border-left: 3px solid var(--accent); }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.modal-overlay--visible { opacity: 1; }

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 14px;
  padding: 1.5rem;
  max-width: 420px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.modal-message {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 1.25rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.modal-btn {
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.16s ease;
}
.modal-btn--cancel {
  background: transparent;
  color: var(--muted);
  border-color: var(--border-hi);
}
.modal-btn--cancel:hover {
  background: var(--surface-2);
  color: var(--text);
}
.modal-btn--confirm {
  background: var(--accent);
  color: var(--bg);
}
.modal-btn--confirm:hover { background: var(--accent-2); }

/* ============================================================
   Custom fullscreen button — overlays the video at bottom-right,
   directly covering YouTube's native fullscreen button location.
   We set fs:0 to hide YouTube's button, but keeping ours on top
   guarantees clicks land on our handler even if fs:0 fails.
   ============================================================ */
.uq-fs-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 10;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.18s ease, background 0.15s ease, color 0.15s ease, transform 0.12s ease;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.video-container:hover .uq-fs-btn,
.uq-fs-btn:focus-visible { opacity: 1; }
.uq-fs-btn:hover {
  background: var(--accent);
  color: var(--bg);
  transform: scale(1.06);
}
.uq-fs-btn:active { transform: scale(0.96); }
.uq-fs-btn i[data-lucide] {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

/* ============================================================
   Theater mode (body.is-fullscreen) — opened via ?fullscreen=1.
   Hides every chrome, fills the viewport with just the video.
   ============================================================ */
body.is-fullscreen header,
body.is-fullscreen footer,
body.is-fullscreen .nav-links,
body.is-fullscreen .theme-picker,
body.is-fullscreen .queue-section,
body.is-fullscreen .transport,
body.is-fullscreen .popular-today,
body.is-fullscreen #video-form,
body.is-fullscreen .toast-container { display: none !important; }

body.is-fullscreen { background: #000; }
body.is-fullscreen main {
  margin: 0;
  padding: 0;
  max-width: none;
}
body.is-fullscreen .app-container {
  display: block;
  gap: 0;
}
body.is-fullscreen .video-section {
  background: #000;
  border: 0;
  border-radius: 0;
  padding: 0;
  position: fixed;
  inset: 0;
}
body.is-fullscreen .video-container {
  position: absolute;
  inset: 0;
  padding: 0;
  height: 100%;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}
body.is-fullscreen .video-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
}
/* Keep the custom fs button in theater mode so users can exit via Esc hint
   (we also bind Escape in app.js to close the window). */
body.is-fullscreen .uq-fs-btn {
  display: none;
}

/* ============================================================
   Sleep timer
   ============================================================ */
.tp-btn[data-countdown]::after {
  content: attr(data-countdown);
  position: absolute;
  bottom: -3px;
  right: -2px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  line-height: 1;
  pointer-events: none;
  font-feature-settings: 'tnum' 1;
}
#tp-sleep {
  position: relative;
}
#tp-sleep.is-on {
  color: var(--accent);
  background: var(--accent-soft);
}

.sleep-popover {
  position: absolute;
  bottom: calc(100% + 0.6rem);
  right: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  padding: 0.4rem;
  min-width: 200px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sleep-popover[hidden] { display: none; }
.sleep-popover__head {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-soft);
  padding: 0.5rem 0.7rem 0.4rem;
}
.sleep-opt {
  background: transparent;
  border: 0;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.sleep-opt:hover { background: var(--surface-2); color: var(--text); }
.sleep-opt.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Fade-to-black overlay when the sleep timer fires. */
.sleep-fade {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 3.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.sleep-fade.is-on {
  opacity: 1;
  pointer-events: auto;
}
.sleep-fade__msg {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.32);
  text-transform: uppercase;
  opacity: 0;
  /* Message fades in slightly after the page has darkened. */
  transition: opacity 0.9s ease 1.8s;
}
.sleep-fade.is-on .sleep-fade__msg { opacity: 1; }

/* ============================================================
   Responsive
   ============================================================ */
@media screen and (max-width: 768px) {
  header { padding: 0.75rem 1rem; gap: 0.75rem; }
  main { padding: 1.5rem 1rem 4rem; }
  .video-section, .queue-section { padding: 1rem; }
  #video-form { flex-direction: column; }
  #video-form .btn { width: 100%; }
  .queue-section {
    position: static;
    max-height: none;
  }
  .transport { flex-wrap: wrap; }
  .nav-links a { font-size: 0.8rem; padding: 0.35rem 0.7rem; }
}
