/* ============================================================================
 * YT Player — "Cinematic Control Deck"
 * Warm near-black editorial dark theme · single vermilion accent ·
 * Bricolage Grotesque (display) / Hanken Grotesk (UI) / JetBrains Mono (data)
 * ========================================================================== */

:root {
  /* Warm, layered near-blacks */
  --bg: #0a0a0c;
  --bg-1: #101013;
  --bg-2: #16161b;
  --bg-3: #1d1d24;
  --line: #26262f;
  --line-soft: #1c1c23;

  /* Type */
  --text: #f5f3f0;
  --text-2: #b6b5bf;
  --text-dim: #76757f;

  /* Signature accent — vermilion with a warm halo */
  --accent: #ff4b32;
  --accent-bright: #ff6a52;
  --accent-deep: #d4321d;
  --accent-glow: rgba(255, 75, 50, 0.45);

  --display: "Bricolage Grotesque", Georgia, serif;
  --ui: "Hanken Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.7);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Ambient warm light bleed from top-left + film grain over everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 600px at 18% -10%, rgba(255, 75, 50, 0.10), transparent 60%),
    radial-gradient(700px 500px at 100% 110%, rgba(90, 120, 255, 0.05), transparent 55%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #34343f; background-clip: content-box; }

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 264px 1fr;
  height: 100vh;
}

/* ===================== Sidebar ===================== */
.sidebar {
  background: linear-gradient(180deg, var(--bg-1), var(--bg));
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  overflow-y: auto;
  overflow-x: hidden;
}
/* The whole sidebar scrolls as a single unit; keep its sections at their
   natural height so the playlists are always reachable on short screens
   instead of collapsing competing inner scroll regions. */
.sidebar > * { flex-shrink: 0; }

.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 10px 22px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent-bright), var(--accent-deep));
  box-shadow: 0 6px 18px -4px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.25);
}

.nav { display: flex; flex-direction: column; gap: 3px; margin-bottom: 20px; }
.nav-item {
  position: relative;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color 0.18s, background 0.18s;
}
.nav-item::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 3px; height: 0;
  border-radius: 3px;
  background: var(--accent);
  transform: translateY(-50%);
  transition: height 0.22s var(--ease);
}
.nav-item:hover { color: var(--text); background: var(--bg-2); }
.nav-item.active { color: var(--text); background: var(--bg-2); font-weight: 600; }
.nav-item.active::before { height: 18px; box-shadow: 0 0 12px var(--accent-glow); }

.pl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  border-radius: 8px;
  width: 26px; height: 26px;
  transition: all 0.18s var(--ease);
}
.icon-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; transform: rotate(90deg); }

.playlist-list { flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px; padding-right: 2px; }
.playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  transition: background 0.16s, color 0.16s;
}
.playlist-item::before {
  content: "▸";
  color: var(--text-dim);
  font-size: 10px;
  transition: color 0.16s, transform 0.16s;
}
.playlist-item:hover { background: var(--bg-2); color: var(--text); }
.playlist-item:hover::before { color: var(--accent); transform: translateX(2px); }
.playlist-item.active { background: var(--bg-2); color: var(--text); }
.playlist-item.active::before { color: var(--accent); }
.playlist-item .pl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-weight: 500; }
.playlist-item .pl-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-3);
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer { border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: auto; flex-shrink: 0; }
.switch {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-2); cursor: pointer; padding: 8px 10px;
  border-radius: var(--radius-sm); font-size: 13px;
  transition: background 0.16s;
}
.switch:hover { background: var(--bg-2); }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ===================== Main ===================== */
.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(16,16,19,0.7), transparent);
  backdrop-filter: blur(8px);
}
.search-form { flex: 1; display: flex; gap: 10px; max-width: 760px; }

/* Hamburger toggle — hidden on desktop, revealed in the mobile breakpoint */
.sidebar-toggle {
  display: none;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.sidebar-toggle:hover { background: var(--bg-3); border-color: var(--accent); }

/* Backdrop behind the off-canvas drawer — only shown when the drawer is open */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}
#searchInput {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--ui);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
#searchInput::placeholder { color: var(--text-dim); }
#searchInput:focus {
  border-color: var(--accent);
  background: var(--bg-1);
  box-shadow: 0 0 0 4px rgba(255, 75, 50, 0.12);
}
.search-btn {
  background: linear-gradient(145deg, var(--accent-bright), var(--accent-deep));
  color: #fff;
  border: none;
  padding: 0 24px;
  border-radius: 11px;
  font-family: var(--ui);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 8px 22px -8px var(--accent-glow);
  transition: transform 0.16s var(--ease), box-shadow 0.16s;
}
.search-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -8px var(--accent-glow); }
.search-btn:active { transform: translateY(0); }

.body { flex: 1; display: flex; overflow: hidden; }

/* ===================== Player pane ===================== */
.player-pane {
  flex: 1.5;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 26px 26px 30px;
  overflow-y: auto;
}
.player-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow), 0 0 0 1px var(--line) inset;
}
/* Cinematic glow ring when something is loaded */
.player-pane:not(.empty) .player-stage {
  box-shadow: var(--shadow), 0 0 60px -20px var(--accent-glow), 0 0 0 1px var(--line) inset;
}
#video { width: 100%; height: 100%; background: #000; display: block; }

.art-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, var(--bg-3), #000); }
.art-fallback img { max-width: 58%; max-height: 78%; border-radius: 14px; box-shadow: var(--shadow); }

.player-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 28px;
  background:
    radial-gradient(680px 420px at 50% 30%, rgba(255, 75, 50, 0.10), transparent 70%),
    radial-gradient(circle at 50% 120%, rgba(90, 120, 255, 0.06), transparent 60%),
    linear-gradient(180deg, var(--bg-1), #000);
}
/* Hero landing */
.hero {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; max-width: 460px;
  animation: heroIn 0.6s var(--ease) both;
}
@keyframes heroIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.ph-logo {
  font-size: 32px;
  width: 88px; height: 88px;
  display: grid; place-items: center;
  border-radius: 26px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent-bright), var(--accent-deep));
  box-shadow: 0 18px 50px -14px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.25);
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.hero-title {
  margin: 6px 0 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 40px;
  letter-spacing: -0.03em;
  line-height: 1;
  background: linear-gradient(180deg, #fff, #c8c6cf);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-tagline {
  margin: 0; max-width: 380px;
  color: var(--text-2); font-size: 14.5px; line-height: 1.5;
}
.hero-pills { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 2px; }
.hero-pill {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--text-2);
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 6px 12px 6px 26px;
  border-radius: 20px;
  position: relative;
}
.hero-pill::before {
  content: "✓";
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--accent); font-size: 10px; font-weight: 800;
}
.hero-suggests {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center;
  margin-top: 10px;
}
.hero-suggests-label {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-dim);
  margin-right: 2px;
}
.chip {
  font-family: var(--ui); font-size: 13px; font-weight: 600;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.chip:hover {
  color: #fff;
  background: linear-gradient(145deg, var(--accent-bright), var(--accent-deep));
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -8px var(--accent-glow);
}

.spinner {
  position: absolute;
  width: 48px; height: 48px;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Control deck ---- */
.controls {
  margin-top: 16px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.seek-row { display: flex; align-items: center; gap: 14px; }
.time {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  min-width: 46px;
  text-align: center;
}

/* Custom range tracks (seek + volume) */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 10px;
  background: var(--bg-3);
  cursor: pointer;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent-bright);
  border: 2px solid #fff;
  box-shadow: 0 0 0 4px rgba(255,75,50,0.18), 0 2px 6px rgba(0,0,0,0.5);
  transition: transform 0.14s var(--ease);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.25); }
.seek { flex: 1; }

.btn-row { display: flex; align-items: center; gap: 9px; margin-top: 15px; flex-wrap: wrap; }
.ctrl {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  min-width: 42px; height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  display: grid; place-items: center;
  transition: all 0.16s var(--ease);
}
.ctrl:hover { border-color: var(--accent); color: var(--accent-bright); transform: translateY(-1px); }
.ctrl:active { transform: translateY(0); }
.ctrl.play {
  width: 52px; height: 44px;
  font-size: 17px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent-bright), var(--accent-deep));
  border-color: transparent;
  box-shadow: 0 8px 20px -8px var(--accent-glow);
}
.ctrl.play:hover { color: #fff; box-shadow: 0 12px 26px -8px var(--accent-glow); }

.vol { display: flex; align-items: center; gap: 8px; }
.vol input { width: 92px; }
.spacer { flex: 1; }

.sel {
  display: flex; align-items: center; gap: 7px;
  color: var(--text-dim); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700;
}
.sel select {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 9px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: border-color 0.16s;
}
.sel select:hover { border-color: var(--accent); }

.now-meta {
  margin-top: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.np-text { min-width: 0; }
.np-actions { display: flex; gap: 8px; flex-shrink: 0; }
.np-btn {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.16s var(--ease);
}
.np-btn:hover { color: var(--text); border-color: var(--accent); background: var(--bg-2); transform: translateY(-1px); }
.np-btn:disabled { opacity: 0.6; cursor: default; transform: none; }
.np-btn.done { color: #7ee0a8; border-color: rgba(126,224,168,0.35); }
.np-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.015em;
  line-height: 1.25;
}
.np-channel {
  color: var(--text-dim);
  margin-top: 6px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.np-channel::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent-glow);
}

.player-pane.empty .controls,
.player-pane.empty .now-meta,
.player-pane.empty .upnext { display: none; }

/* ===================== Up next queue ===================== */
.upnext {
  margin-top: 16px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.upnext-header {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.upnext-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  background: rgba(255,75,50,0.12);
  padding: 0 7px;
  border-radius: 10px;
  line-height: 17px;
}
.upnext-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 200px; overflow-y: auto;
}
.upnext-item {
  display: flex; gap: 10px;
  padding: 6px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.16s;
}
.upnext-item:hover { background: var(--bg-3); }
.upnext-item img {
  width: 80px; aspect-ratio: 16/9;
  border-radius: 6px;
  object-fit: cover;
  background: #000;
  flex-shrink: 0;
}
.upnext-info { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.upnext-title {
  font-size: 12.5px; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.upnext-channel {
  font-size: 11px; color: var(--text-dim);
  margin-top: 3px;
}

/* ===================== List pane ===================== */
.list-pane {
  width: 452px;
  flex-shrink: 0;
  border-left: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-1), var(--bg));
}
.list-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 20px 12px;
  gap: 12px;
}
.list-header h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.list-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.list-actions button {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.16s;
}
.list-actions button:hover { color: var(--text); border-color: var(--accent); background: var(--bg-3); }

.status { padding: 16px 20px; color: var(--text-dim); font-size: 13px; }

/* ===================== Skeleton loading ===================== */
.skeleton-card {
  cursor: default !important;
  pointer-events: none;
  border-color: transparent !important;
  animation: cardIn 0.45s var(--ease) backwards !important;
}
.skeleton-shimmer {
  position: relative;
  overflow: hidden;
  background: var(--bg-3);
  border-radius: 9px;
}
.skeleton-shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255,255,255,0.04) 40%,
    rgba(255,255,255,0.07) 50%,
    rgba(255,255,255,0.04) 60%,
    transparent
  );
  animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.skeleton-card .thumb {
  background: var(--bg-3);
}
.skeleton-line {
  height: 14px;
  width: 100%;
  border-radius: 8px;
}
.skeleton-dot {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  align-self: center;
  flex-shrink: 0;
}

/* ===================== Empty state ===================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 32px 60px;
  gap: 8px;
  animation: heroIn 0.5s var(--ease) both;
}
.empty-icon {
  font-size: 42px;
  width: 80px; height: 80px;
  display: grid; place-items: center;
  border-radius: 24px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  margin-bottom: 10px;
  transition: transform 0.3s var(--ease), box-shadow 0.3s;
}
.empty-state:hover .empty-icon {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px -12px var(--accent-glow);
}
.empty-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
}
.empty-desc {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 300px;
}
.empty-desc strong { color: var(--text-2); font-weight: 600; }
.empty-cta {
  margin-top: 16px;
  background: linear-gradient(145deg, var(--accent-bright), var(--accent-deep));
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 11px;
  font-family: var(--ui);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 8px 22px -8px var(--accent-glow);
  transition: transform 0.16s var(--ease), box-shadow 0.16s;
}
.empty-cta:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -8px var(--accent-glow); }
.empty-cta:active { transform: translateY(0); }

.cards { flex: 1; overflow-y: auto; padding: 6px 14px 28px; display: flex; flex-direction: column; gap: 5px; }

.card {
  display: flex;
  gap: 12px;
  padding: 9px;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
  transition: background 0.16s, border-color 0.16s, transform 0.16s var(--ease);
  animation: cardIn 0.45s var(--ease) backwards;
}
/* staggered reveal */
.card:nth-child(1){animation-delay:.02s}.card:nth-child(2){animation-delay:.05s}
.card:nth-child(3){animation-delay:.08s}.card:nth-child(4){animation-delay:.11s}
.card:nth-child(5){animation-delay:.14s}.card:nth-child(6){animation-delay:.17s}
.card:nth-child(7){animation-delay:.20s}.card:nth-child(8){animation-delay:.23s}
.card:nth-child(9){animation-delay:.26s}.card:nth-child(10){animation-delay:.29s}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card:hover { background: var(--bg-2); border-color: var(--line); }
.card.playing {
  background: var(--bg-2);
  border-color: var(--accent);
  box-shadow: 0 0 26px -12px var(--accent-glow);
}
.card.playing::after {
  content: "▶ NOW PLAYING";
  position: absolute; top: 9px; right: 44px;
  font-family: var(--mono); font-size: 8px; font-weight: 700;
  letter-spacing: 0.1em; color: var(--accent);
}

.thumb {
  position: relative;
  width: 138px;
  flex-shrink: 0;
  aspect-ratio: 16/9;
  border-radius: 9px;
  overflow: hidden;
  background: #000;
}
.thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.4s var(--ease), filter 0.3s;
}
.card:hover .thumb img { transform: scale(1.07); }
.thumb::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(255,75,50,0.0), transparent);
  opacity: 0; transition: opacity 0.25s;
}
.card:hover .thumb::after { opacity: 1; background: radial-gradient(circle at center, rgba(255,75,50,0.18), transparent 70%); }
.thumb .dur {
  position: absolute; right: 5px; bottom: 5px;
  background: rgba(0,0,0,0.82); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  padding: 2px 6px; border-radius: 5px;
  backdrop-filter: blur(2px);
}

.card-info { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.card-title {
  font-size: 13.5px; font-weight: 600; line-height: 1.32;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-channel { font-size: 12px; color: var(--text-dim); margin-top: 5px; }
.card-menu {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 8px;
  width: 32px; height: 32px;
  cursor: pointer;
  align-self: center;
  flex-shrink: 0;
  font-size: 19px;
  line-height: 1;
  transition: all 0.16s;
  opacity: 0.9;
}
.card:hover .card-menu { opacity: 1; }
.card-menu:hover { color: #fff; border-color: var(--accent); background: var(--accent); }

/* Drag-to-reorder */
.card.dragging { opacity: 0.4; }
.card.drag-over { border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent-glow); }

/* Saved-offline badge on cards */
.saved-badge {
  position: absolute; left: 5px; bottom: 5px;
  display: none;
  align-items: center; justify-content: center;
  width: 18px; height: 18px;
  background: rgba(126, 224, 168, 0.92);
  color: #06281a;
  font-size: 10px; font-weight: 700;
  border-radius: 5px;
  backdrop-filter: blur(2px);
}
.card.cached .saved-badge { display: flex; }
.card.downloading .saved-badge {
  display: flex;
  background: rgba(255, 200, 80, 0.92);
  color: #2a1d00;
  animation: pulse 1s ease-in-out infinite;
}
.card.downloading .saved-badge::before { content: "⏳"; }
.card.downloading .saved-badge { font-size: 0; }
.card.downloading .saved-badge::before { font-size: 10px; }

/* Download progress bar on card thumb */
.dl-progress {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(0,0,0,0.5);
  overflow: hidden;
}
.dl-bar {
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent-bright));
  border-radius: 0 2px 2px 0;
  animation: dlSlide 1.2s ease-in-out infinite;
}
@keyframes dlSlide {
  0% { transform: translateX(-100%); width: 30%; }
  50% { width: 45%; }
  100% { transform: translateX(400%); width: 30%; }
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ===================== Settings page ===================== */
.settings { display: flex; flex-direction: column; gap: 18px; padding: 4px 6px 28px; }
.set-group {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.set-group-title {
  font-family: var(--mono);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 14px;
}
.set-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}
.set-group .set-row:first-of-type { border-top: none; }
.set-row > span { display: flex; flex-direction: column; gap: 3px; color: var(--text); font-size: 13.5px; font-weight: 500; }
.set-row small { color: var(--text-dim); font-size: 11.5px; font-weight: 400; line-height: 1.4; max-width: 280px; }
.set-row input[type="range"] { width: 150px; }
.set-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.about-version { color: var(--text-dim); font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; user-select: text; }
.set-select {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 10px; font-family: var(--mono); font-size: 12px; cursor: pointer;
}
.set-select:hover { border-color: var(--accent); }
.set-stat { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.set-actions { padding-top: 14px; }
.cache-list { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.cache-empty { color: var(--text-dim); font-size: 12.5px; padding: 8px 0; }
.cache-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--bg-3);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.cache-item .ci-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.cache-item .ci-size { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.cache-item .ci-del {
  background: transparent; border: 1px solid var(--line);
  color: var(--text-dim); width: 24px; height: 24px;
  border-radius: 6px; cursor: pointer; font-size: 12px; line-height: 1;
  transition: all 0.16s;
}
.cache-item .ci-del:hover { color: #fff; background: var(--accent); border-color: var(--accent); }

/* ===================== Modal ===================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5,5,7,0.7);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  width: 400px;
  max-width: 90vw;
  box-shadow: var(--shadow);
  animation: pop 0.24s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal h3 { margin: 0 0 16px; font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.modal input[type="text"] {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
  color: var(--text);
  font-family: var(--ui);
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.modal input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255,75,50,0.12); }
.modal-list { display: flex; flex-direction: column; gap: 5px; max-height: 280px; overflow-y: auto; margin-top: 2px; }
.modal-list button {
  text-align: left;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 13px;
  border-radius: 9px;
  cursor: pointer;
  font-family: var(--ui);
  font-size: 13.5px;
  transition: border-color 0.16s, background 0.16s, transform 0.12s;
}
.modal-list button:hover { border-color: var(--accent); transform: translateX(3px); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.btn {
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 9px;
  cursor: pointer;
  font-family: var(--ui);
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.16s var(--ease);
}
.btn:hover { border-color: var(--text-dim); }
.btn.primary {
  background: linear-gradient(145deg, var(--accent-bright), var(--accent-deep));
  border-color: transparent; color: #fff;
  box-shadow: 0 8px 20px -8px var(--accent-glow);
}
.btn.primary:hover { transform: translateY(-1px); }
.btn.danger { color: #ff8a7a; border-color: rgba(255,75,50,0.3); }
.btn.danger:hover { background: rgba(255,75,50,0.12); }

/* ===================== Toast ===================== */
.toast-container {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 13px 20px;
  border-radius: 11px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  animation: toastIn 0.3s var(--ease);
  pointer-events: auto;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast-exit {
  animation: toastOut 0.25s var(--ease) forwards;
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}
/* PWA update banner — persistent toast with inline action button */
.toast-update {
  border-color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast-reload-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* ===================== Keyboard shortcut overlay ===================== */
.shortcut-overlay {
  position: fixed; inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.shortcut-panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px;
  min-width: 380px;
  max-width: 480px;
  box-shadow: 0 24px 64px -16px rgba(0,0,0,0.6);
  animation: panelIn 0.2s var(--ease);
}
@keyframes panelIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: none; } }
.shortcut-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.shortcut-header h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.shortcut-close {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text-2);
  width: 32px; height: 32px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 15px;
  display: grid; place-items: center;
  transition: all 0.16s;
}
.shortcut-close:hover { color: var(--text); border-color: var(--accent); background: var(--bg-3); }
.shortcut-grid {
  display: flex; flex-direction: column; gap: 10px;
}
.shortcut-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-row span { color: var(--text-2); font-size: 13px; flex: 1; }
.shortcut-row kbd {
  font-family: var(--mono);
  font-size: 11px; font-weight: 700;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 9px;
  min-width: 28px;
  text-align: center;
  line-height: 1;
}

.hidden { display: none !important; }

/* ============================================================================
 * Bottom Navigation Bar — YouTube-style, portrait PWA mode only
 * Hidden by default; made visible inside the portrait-PWA media query.
 * ========================================================================== */
.bottom-nav {
  display: none; /* hidden on desktop and non-portrait modes */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 310; /* above mini-bar (300) so it's always accessible */
  flex-direction: row;
  align-items: stretch;
  background: linear-gradient(180deg, var(--bg-1), var(--bg));
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
}

.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px 6px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.16s var(--ease);
  min-width: 0;
}

.bottom-nav-btn:active {
  background: var(--bg-2);
}

.bottom-nav-btn.active {
  color: var(--accent-bright);
}

.bottom-nav-btn.active .bottom-nav-icon {
  /* Subtle scale pop on active */
  transform: scale(1.12);
}

.bottom-nav-icon {
  font-size: 20px;
  line-height: 1;
  display: block;
  transition: transform 0.18s var(--ease);
}

.bottom-nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.bottom-nav-badge {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  display: grid;
  place-items: center;
  line-height: 1;
  pointer-events: none;
}

.bottom-nav-badge.hidden { display: none; }

/* ===================== Mini now-playing bar ===================== */
.mini-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 300;
  cursor: pointer;
  animation: miniBarIn 0.25s var(--ease);
}
@keyframes miniBarIn {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.mini-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.mini-btn {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: all 0.16s;
}
.mini-btn:hover { border-color: var(--accent); color: var(--accent-bright); }
.mini-close {
  width: 28px; height: 28px;
  font-size: 12px;
  color: var(--text-dim);
}
.mini-close:hover { color: var(--text); border-color: var(--text-dim); }
.mini-info {
  min-width: 0; flex: 1;
  display: flex; flex-direction: column;
  gap: 2px;
}
.mini-title {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-channel {
  font-size: 11px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  flex-shrink: 0;
}
.mini-progress {
  height: 3px;
  background: var(--bg-3);
}
.mini-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent-bright));
  transition: width 1s linear;
}

@media (max-width: 1080px) {
  .body { flex-direction: column; }
  .list-pane { width: auto; border-left: none; border-top: 1px solid var(--line-soft); }
  /* In the stacked layout both panes must be allowed to shrink below their
     content height (flex min-height defaults to auto), or they overflow the
     hidden .body instead of engaging their own scrollbars — on a landscape
     phone that made "Up next" unreachable. The base .list-pane rule sets
     flex-shrink: 0 (right for the fixed-width side column); here the pane
     must shrink or long views (Settings) get clipped with no scrollbar. */
  .player-pane { min-height: 0; }
  .list-pane { min-height: 0; flex-shrink: 1; }
}

/* ============================================================================
 * Responsive sidebar — off-canvas drawer on small screens
 * Below 860px the fixed 264px grid column is dropped; the sidebar becomes a
 * slide-in drawer toggled by the hamburger button so the playlist and every
 * other sidebar item stay reachable from 320px up to tablet width.
 * ========================================================================== */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }

  .sidebar-toggle { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 300px);
    max-width: 300px;
    z-index: 100;
    border-right: 1px solid var(--line-soft);
    box-shadow: var(--shadow);
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease);
    will-change: transform;
  }

  .app.sidebar-open .sidebar { transform: translateX(0); }

  .app.sidebar-open .sidebar-backdrop { display: block; opacity: 1; }
}

/* Very narrow screens (e.g. 320px) — keep the topbar usable and the drawer
   from ever exceeding the viewport. */
@media (max-width: 420px) {
  .topbar { padding: 12px 14px; }
  .sidebar { width: min(88vw, 280px); }
}

/* ============================================================================
 * Loop / repeat active state
 * ========================================================================== */
.ctrl.active {
  color: #fff;
  background: linear-gradient(145deg, var(--accent-bright), var(--accent-deep));
  border-color: transparent;
  box-shadow: 0 6px 16px -8px var(--accent-glow);
}

/* ============================================================================
 * Sidebar nav badges (queue / downloads counts)
 * ========================================================================== */
.nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  font-family: var(--mono);
  font-size: 10px; font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: 10px;
  vertical-align: middle;
}

/* ============================================================================
 * Clickable channel links
 * ========================================================================== */
.card-channel.link { cursor: pointer; }
.card-channel.link:hover { color: var(--accent); text-decoration: underline; }
.np-channel { cursor: pointer; }
.np-channel:hover { color: var(--text-2); }
.upnext-channel.link { cursor: pointer; }
.upnext-channel.link:hover { color: var(--accent); text-decoration: underline; }
.ri-channel.link { cursor: pointer; }
.ri-channel.link:hover { color: var(--accent); text-decoration: underline; }
.mini-channel.link { cursor: pointer; }
.mini-channel.link:hover { color: var(--accent); text-decoration: underline; }

/* ============================================================================
 * Per-card delete button (playlist / queue / saved)
 * ========================================================================== */
.card-del {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text-dim);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  align-self: center;
  flex-shrink: 0;
  font-size: 13px;
  line-height: 1;
  opacity: 0;
  transition: all 0.16s var(--ease);
}
.card:hover .card-del { opacity: 1; }
.card-del:hover { color: #fff; background: var(--accent); border-color: var(--accent); }
.saved-card .card-del { opacity: 0.85; }

/* ============================================================================
 * Modal divider label
 * ========================================================================== */
.modal-divider {
  font-family: var(--mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 2px 2px;
}

/* ============================================================================
 * Saved / Downloads summary header
 * ========================================================================== */
.saved-summary {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 9px 14px;
}
.saved-total {
  font-family: var(--display);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.saved-sub { color: var(--text-dim); font-size: 13px; }
.saved-size { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }

/* ============================================================================
 * THEMES
 * ========================================================================== */
:root[data-theme="light"] {
  --bg: #f4f2ee;
  --bg-1: #ffffff;
  --bg-2: #efece6;
  --bg-3: #e5e0d8;
  --line: #d8d2c8;
  --line-soft: #e6e1d9;
  --text: #1b1a18;
  --text-2: #4a4843;
  --text-dim: #7c776e;
  --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.25);
}
:root[data-theme="light"] body::after { opacity: 0.02; }
:root[data-theme="light"] .hero-title {
  background: linear-gradient(180deg, #1b1a18, #514d46);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
:root[data-theme="light"] #video,
:root[data-theme="light"] .player-stage { background: #000; }

:root[data-theme="contrast"] {
  --bg: #000000;
  --bg-1: #000000;
  --bg-2: #0a0a0a;
  --bg-3: #161616;
  --line: #ffffff;
  --line-soft: #9a9a9a;
  --text: #ffffff;
  --text-2: #ffffff;
  --text-dim: #d8d8d8;
  --accent: #ff5a3c;
  --accent-bright: #ff8a6c;
  --accent-deep: #ff5a3c;
  --accent-glow: rgba(255, 90, 60, 0.85);
}
:root[data-theme="contrast"] body::after { display: none; }
:root[data-theme="contrast"] body::before { display: none; }
:root[data-theme="contrast"] .hero-title {
  background: none;
  -webkit-text-fill-color: var(--text);
  color: var(--text);
}
:root[data-theme="contrast"] .card { border-color: var(--line-soft); }
:root[data-theme="contrast"] .card-channel,
:root[data-theme="contrast"] .card-title { color: var(--text); }

/* ============================================================================
 * FONT SIZE — scales the whole UI (zoom is supported by WebView2 + WKWebView)
 * ========================================================================== */
:root[data-font="small"] { zoom: 0.9; }
:root[data-font="normal"] { zoom: 1; }
:root[data-font="large"] { zoom: 1.12; }
:root[data-font="xl"] { zoom: 1.26; }

/* ============================================================================
 * LAYOUT DENSITY — compact tightens spacing
 * ========================================================================== */
:root[data-density="compact"] .player-pane { padding: 14px 16px 18px; }
:root[data-density="compact"] .cards { gap: 2px; padding: 4px 10px 20px; }
:root[data-density="compact"] .card { padding: 6px; gap: 9px; }
:root[data-density="compact"] .thumb { width: 104px; }
:root[data-density="compact"] .card-title { font-size: 12.5px; -webkit-line-clamp: 1; }
:root[data-density="compact"] .card-channel { margin-top: 2px; }
:root[data-density="compact"] .nav-item { padding: 8px 12px; }
:root[data-density="compact"] .playlist-item { padding: 7px 12px; }
:root[data-density="compact"] .controls { padding: 12px 14px; margin-top: 12px; }
:root[data-density="compact"] .btn-row { margin-top: 11px; gap: 7px; }
:root[data-density="compact"] .list-header { padding: 16px 16px 10px; }
:root[data-density="compact"] .topbar { padding: 11px 18px; }

/* ============================================================================
 * PERFORMANCE MODE — drop expensive paints (grain, blur, big glows)
 * ========================================================================== */
:root[data-perf="on"] body::before,
:root[data-perf="on"] body::after { display: none; }
:root[data-perf="on"] .topbar { backdrop-filter: none; }
:root[data-perf="on"] .modal-backdrop,
:root[data-perf="on"] .shortcut-overlay,
:root[data-perf="on"] .mini-bar-inner { backdrop-filter: none; }
:root[data-perf="on"] .player-pane:not(.empty) .player-stage {
  box-shadow: 0 0 0 1px var(--line) inset;
}
:root[data-perf="on"] .ph-logo,
:root[data-perf="on"] .skeleton-shimmer::after { animation: none; }
:root[data-perf="on"] .card { animation: none; }

/* ============================================================================
 * REDUCE MOTION — honor explicit toggle and OS preference
 * ========================================================================== */
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================================
 * Seek wrap + A-B markers
 * ========================================================================== */
.seek-wrap { position: relative; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.seek-wrap .seek { width: 100%; flex: none; }
.ab-indicator {
  display: flex; align-items: center; padding: 0 2px;
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
}
.ab-label { color: var(--text-dim); transition: color 0.16s; }
.ab-label.active { color: var(--accent); }
.ab-ctrl { font-family: var(--mono); font-size: 12px; font-weight: 800; min-width: 34px; }
.ab-ctrl.active {
  color: #fff;
  background: linear-gradient(145deg, var(--accent-bright), var(--accent-deep));
  border-color: transparent;
  box-shadow: 0 6px 16px -8px var(--accent-glow);
}

/* ============================================================================
 * Sleep timer status bar
 * ========================================================================== */
.sleep-status {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; margin-top: 10px;
  background: rgba(255,75,50,0.07);
  border: 1px solid rgba(255,75,50,0.22);
  border-radius: var(--radius-sm);
}
.sleep-countdown {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--accent); flex: 1;
}
.sleep-cancel {
  background: transparent; border: 1px solid rgba(255,75,50,0.35);
  color: var(--accent); border-radius: 7px;
  padding: 5px 10px; cursor: pointer; font-size: 12px; font-weight: 600;
  transition: all 0.16s;
}
.sleep-cancel:hover { background: rgba(255,75,50,0.14); }
.ctrl.sleep-active {
  color: #fff;
  background: linear-gradient(145deg, var(--accent-bright), var(--accent-deep));
  border-color: transparent;
}

/* ============================================================================
 * Related videos panel
 * ========================================================================== */
.related-panel {
  margin-top: 16px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.related-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.related-label {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.16em; color: var(--text-dim);
}
.related-toggle-btn {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 16px; cursor: pointer; padding: 0 4px; line-height: 1;
  transition: color 0.16s;
}
.related-toggle-btn:hover { color: var(--text); }
.related-list {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 10px; max-height: 280px; overflow-y: auto;
}
.related-item {
  display: flex; gap: 10px; padding: 6px 8px;
  border-radius: 9px; cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.16s, border-color 0.16s;
}
.related-item:hover { background: var(--bg-3); border-color: var(--line); }
.related-item img { width: 80px; aspect-ratio: 16/9; border-radius: 6px; object-fit: cover; background: #000; flex-shrink: 0; }
.related-item .ri-info { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.related-item .ri-title {
  font-size: 12.5px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.related-item .ri-channel { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

/* ============================================================================
 * Smart / auto playlists in sidebar
 * ========================================================================== */
.smart-pl-header { opacity: 0.75; margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.smart-pl-list { flex: 0 0 auto !important; margin-bottom: 6px; }
.smart-item .pl-name::before { content: "◈ "; color: var(--text-dim); font-size: 9px; }
.smart-item.active .pl-name::before { color: var(--accent); }

/* ============================================================================
 * List filter bar
 * ========================================================================== */
.list-filter-bar { padding: 0 14px 8px; }
.list-filter-bar input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 12px;
  color: var(--text); font-family: var(--ui); font-size: 13px;
  outline: none; transition: border-color 0.16s, box-shadow 0.16s;
}
.list-filter-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,75,50,0.1); }
.list-filter-bar input::placeholder { color: var(--text-dim); }

/* ============================================================================
 * Batch selection bar
 * ========================================================================== */
.batch-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 14px;
  background: rgba(255,75,50,0.07);
  border-bottom: 1px solid rgba(255,75,50,0.18);
}
.batch-count { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--accent); flex: 1; }
.batch-btn {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text-2);
  border-radius: 7px; padding: 6px 11px; cursor: pointer;
  font-family: var(--ui); font-size: 12px; font-weight: 600; transition: all 0.16s;
}
.batch-btn:hover { color: var(--text); border-color: var(--accent); }
.batch-danger { color: #ff8a7a !important; border-color: rgba(255,75,50,0.28) !important; }
.batch-danger:hover { background: rgba(255,75,50,0.12) !important; }

/* Batch checkboxes on cards */
.card .batch-check {
  display: none; position: absolute; left: 8px; top: 8px; z-index: 3;
  width: 20px; height: 20px; border-radius: 6px;
  border: 2px solid var(--line); background: var(--bg-1);
  align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; transition: all 0.14s;
  pointer-events: none;
}
.cards.select-mode .card .batch-check { display: flex; }
.cards.select-mode .card { cursor: pointer; }
.card.selected .batch-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.card.selected .batch-check::after { content: "✓"; }
.card.selected { border-color: var(--accent) !important; background: var(--bg-2); }

/* ============================================================================
 * PORTRAIT PWA — activates only in standalone (installed) mode + portrait
 *
 * Triggers:   @media (display-mode: standalone) and (orientation: portrait)
 * Safe areas: env(safe-area-inset-*) applied to all fixed/sticky containers
 *             so notches and home-indicator bars never obscure UI chrome.
 * Layout:     Full single-column vertical stack; sidebar stays as drawer only.
 * ========================================================================== */
@media (display-mode: standalone) and (orientation: portrait) {

  /* --- Root layout: single-column full-width stack ----------------------- */
  .app {
    grid-template-columns: 1fr;
    /* Stack children: topbar → body → mini-bar (all in .main) */
  }

  /* --- Bottom nav: shown in portrait PWA, hidden everywhere else ---------- */
  .bottom-nav {
    display: flex;
  }

  /* --- Sidebar toggle: visible in portrait for playlist/drawer access ---- */
  /* Primary navigation is now the bottom bar; the hamburger gives access
     to playlists and auto-playlists which are not in the bottom nav. */
  .sidebar-toggle { display: inline-flex; }

  /* --- Sidebar: always off-canvas drawer (never occupies grid column) ---- */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 300px);
    max-width: 300px;
    z-index: 100;
    border-right: 1px solid var(--line-soft);
    box-shadow: var(--shadow);
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease);
    will-change: transform;
    /* Respect notch/home-bar on the left edge */
    padding-top: calc(22px + env(safe-area-inset-top));
    padding-left: calc(14px + env(safe-area-inset-left));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .app.sidebar-open .sidebar { transform: translateX(0); }
  .app.sidebar-open .sidebar-backdrop { display: block; opacity: 1; }

  /* --- Topbar: full-width, padded for status-bar notch ------------------- */
  /* Width 100% ensures the topbar background fills behind the notch/status
     bar area so its colour (the gradient) extends edge-to-edge. */
  .topbar {
    width: 100%;
    /* iOS < 11.2 fallback — constant() was the predecessor to env() */
    padding-top: calc(12px + constant(safe-area-inset-top, 0px));
    padding-left: calc(14px + constant(safe-area-inset-left, 0px));
    padding-right: calc(14px + constant(safe-area-inset-right, 0px));
    padding-bottom: 12px;
    /* Modern browsers: env() overrides the constant() lines above */
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-left: calc(14px + env(safe-area-inset-left, 0px));
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
    position: sticky;
    top: 0;
    z-index: 50;
  }

  /* --- Body: vertical stack (player above list), THE scroll container ---- */
  .body {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    /* The body is the single scroll container in portrait. A playing player
       pane (stage + control deck + meta + up-next + related) is taller than
       the whole viewport, so it must be able to scroll out of the way — with
       overflow:hidden here the list-pane sat unreachable below the fold and
       every sidebar/bottom-nav tap looked dead while a track was playing. */
  }

  /* --- Player pane: full width, compact vertical padding ----------------- */
  .player-pane {
    flex: none;
    width: 100%;
    padding: 14px calc(14px + env(safe-area-inset-right)) 14px
             calc(14px + env(safe-area-inset-left));
    overflow-y: visible;
  }

  /* Player stage: keep 16:9 aspect ratio, fill viewport width */
  .player-stage {
    width: 100%;
    aspect-ratio: 16 / 9;
  }

  /* Controls: wrap btn-row so nothing overflows on narrow screens */
  .btn-row {
    flex-wrap: wrap;
    gap: 7px;
  }

  /* Now-playing meta: stack vertically */
  .now-meta {
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
  }

  .np-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* --- List pane: full width below player, flows in the body scroll ------ */
  .list-pane {
    flex: none;
    /* At least one full body-height so navigating always yields a full-screen
       page; longer content just grows the body scroll. */
    min-height: 100%;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--line-soft);
    overflow-y: visible;
    overflow-x: hidden;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    /* Pad bottom to clear bottom-nav (~56px) + mini-bar (~52px) + safe area */
    padding-bottom: calc(116px + env(safe-area-inset-bottom));
  }

  /* Cards list: unconstrained height — list-pane is now the scroll container */
  .cards {
    max-height: none;
    overflow-y: visible;
    padding-bottom: 0;
  }

  /* Settings panel: ensure full accessibility with bottom clearance */
  .settings {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  /* --- Mini now-playing bar: sit above the bottom-nav -------------------- */
  /* bottom-nav is ~56px tall; mini-bar floats on top of it.
     The bottom-nav's own padding-bottom handles the safe-area-inset, so
     mini-bar only needs to clear the nav height itself (no extra inset). */
  .mini-bar {
    bottom: calc(56px + env(safe-area-inset-bottom));
    padding-bottom: 0;
  }

  .mini-bar-inner {
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }

  /* --- Toast container: clear bottom-nav + mini-bar ---------------------- */
  .toast-container {
    bottom: calc(82px + env(safe-area-inset-bottom));
  }

  /* --- Modal: safe-area aware -------------------------------------------- */
  .modal-backdrop {
    padding: calc(16px + env(safe-area-inset-top))
             calc(16px + env(safe-area-inset-right))
             calc(16px + env(safe-area-inset-bottom))
             calc(16px + env(safe-area-inset-left));
  }

  /* --- Shortcut overlay: safe-area aware --------------------------------- */
  .shortcut-overlay {
    padding: calc(16px + env(safe-area-inset-top))
             calc(16px + env(safe-area-inset-right))
             calc(16px + env(safe-area-inset-bottom))
             calc(16px + env(safe-area-inset-left));
  }

  /* --- Up next list: allow reasonable height on portrait screen ---------- */
  .upnext-list {
    max-height: 160px;
  }

  /* --- Related videos panel: compact on portrait ------------------------- */
  .related-list {
    max-height: 200px;
  }

  /* --- Hero title: slightly smaller on narrow portrait screens ----------- */
  .hero-title { font-size: 30px; }
  .ph-logo { width: 68px; height: 68px; font-size: 26px; }
  .hero-tagline { font-size: 13px; }
}

/* ============================================================================
 * INSTALLED PWA ON TOUCH DEVICES — drop expensive full-screen composites
 *
 * The film-grain overlay (mix-blend-mode over the whole viewport), the fixed
 * gradient wash, and the chrome backdrop-blurs all re-composite over the
 * playing <video> every frame. On iPhones that GPU contention audibly
 * stutters audio — backgrounding the PWA (which stops rendering) made
 * playback smooth, which is how this was diagnosed. Same cuts as
 * data-perf="on", applied automatically where they hurt most; desktop
 * browsers and fine-pointer devices are untouched.
 * ========================================================================== */
@media (display-mode: standalone) and (pointer: coarse) {
  body::before,
  body::after { display: none; }
  .topbar,
  .bottom-nav,
  .mini-bar-inner {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .player-pane:not(.empty) .player-stage {
    box-shadow: 0 0 0 1px var(--line) inset;
  }
}

/* ============================================================================
 * PORTRAIT PWA — mobile app design refresh
 *
 * Same media query as the structural block above; being later in the cascade,
 * these rules win ties. Scope is intentionally identical so desktop, browser
 * tabs, and landscape are never affected. Design goals (mobile-app UI):
 *   • 44px minimum tap targets, thumb-zone transport controls
 *   • music-app control deck: centered shuffle/prev/play/next/repeat row,
 *     secondary tools on a second row; volume slider hidden (hardware keys)
 *   • bottom-sheet modals, floating mini-player card, nav active pill
 *   • 16px input font to stop iOS focus-zoom
 * ========================================================================== */
@media (display-mode: standalone) and (orientation: portrait) {

  /* --- Global touch polish ---------------------------------------------- */
  ::-webkit-scrollbar { width: 0; height: 0; }
  button, .card, .nav-item, .playlist-item { -webkit-tap-highlight-color: transparent; }

  /* --- Topbar: app-bar with pill search --------------------------------- */
  .sidebar-toggle {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }
  .search-form { min-width: 0; } /* flex item: allow shrinking to the viewport */
  #searchInput {
    height: 44px;
    min-width: 0; /* let the pill shrink below intrinsic input width */
    border-radius: 22px;
    padding: 0 18px;
    font-size: 16px; /* ≥16px prevents iOS focus-zoom */
  }
  .search-btn {
    height: 44px;
    border-radius: 22px;
    padding: 0 18px;
  }

  /* --- Player pane ------------------------------------------------------- */
  .player-pane {
    padding: 12px calc(12px + env(safe-area-inset-right)) 12px
             calc(12px + env(safe-area-inset-left));
  }
  .player-stage { border-radius: 16px; }

  /* --- Control deck: two-row music-app transport ------------------------- */
  .controls {
    margin-top: 12px;
    border-radius: 18px;
    padding: 14px 14px 16px;
  }
  .seek-row { gap: 10px; }
  /* Fatter seek track + thumb for touch */
  .seek { height: 6px; }
  .seek::-webkit-slider-thumb { width: 18px; height: 18px; }

  .btn-row {
    justify-content: center;
    gap: 10px 8px;
    margin-top: 14px;
  }
  /* Forced line break between transport row (order ≤ 5) and tool row (≥ 7) */
  .btn-row::before { content: ""; width: 100%; order: 6; height: 0; }

  /* Row A — transport, centered in the thumb zone */
  #shuffleBtn { order: 1; }
  #prevBtn    { order: 2; }
  #playBtn    { order: 3; }
  #nextBtn    { order: 4; }
  #repeatBtn  { order: 5; }

  #prevBtn, #nextBtn, #shuffleBtn, #repeatBtn {
    background: transparent;
    border-color: transparent;
    width: 48px;
    height: 48px;
    border-radius: 50%;
  }
  #prevBtn, #nextBtn { font-size: 20px; }
  #shuffleBtn, #repeatBtn { font-size: 17px; color: var(--text-2); }
  #shuffleBtn.active, #repeatBtn.active {
    color: var(--accent-bright);
    background: rgba(255, 75, 50, 0.16);
    border-color: transparent;
    box-shadow: none;
  }
  #playBtn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    font-size: 24px;
    margin: 0 6px;
  }

  /* Row B — secondary tools, uniform 44px targets (sizes only: colors and
     .active/.sleep-active states keep their class-based styling) */
  #abABtn, #abBBtn, #abClearBtn, #muteBtn, #loopBtn, #sleepTimerBtn, #fsBtn {
    order: 7;
    min-width: 44px;
    height: 44px;
    border-radius: 13px;
  }
  .vol { order: 7; }
  .vol input { display: none; } /* hardware volume keys on mobile */
  .btn-row .spacer { display: none; }
  .btn-row .sel { order: 8; }
  .sel select {
    height: 44px;
    border-radius: 13px;
    padding: 0 10px;
  }

  /* --- Now playing meta: full-width action grid --------------------------- */
  .now-meta { margin-top: 16px; }
  .np-title { font-size: 18px; }
  .np-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
  }
  .np-btn {
    padding: 12px 8px;
    text-align: center;
    border-radius: 13px;
  }

  /* --- Up next / related: comfier touch rows ------------------------------ */
  .upnext { border-radius: 18px; }
  .upnext-item { padding: 8px; border-radius: 12px; }
  .upnext-item img { width: 96px; border-radius: 8px; }
  .related-panel { border-radius: 18px; }
  .related-item { padding: 8px; border-radius: 12px; }
  .related-item img { width: 96px; border-radius: 8px; }

  /* --- List pane: large title, touch-sized rows --------------------------- */
  .list-header { padding: 18px 16px 10px; }
  .list-header h2 { font-size: 24px; letter-spacing: -0.02em; }
  .list-actions button { padding: 9px 13px; border-radius: 10px; }
  .list-filter-bar input {
    padding: 11px 14px;
    border-radius: 13px;
    font-size: 16px;
  }
  .batch-btn { padding: 10px 14px; border-radius: 10px; }

  .cards { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .card { padding: 10px; gap: 12px; border-radius: 16px; }
  .thumb { border-radius: 12px; }
  .card-title { font-size: 14px; }
  .card-channel { margin-top: 6px; }
  /* No hover on touch — keep row actions always visible and finger-sized */
  .card-menu { width: 38px; height: 38px; border-radius: 12px; opacity: 1; }
  .card-del { opacity: 1; width: 36px; height: 36px; border-radius: 11px; }

  /* --- Settings: roomier rows --------------------------------------------- */
  .set-group { border-radius: 18px; }
  .set-row { padding: 14px 0; }
  .set-row input[type="checkbox"] { width: 22px; height: 22px; }
  .set-select { padding: 10px 12px; border-radius: 11px; }

  /* --- Sidebar drawer: rounded sheet edge --------------------------------- */
  .sidebar {
    border-right: none;
    border-radius: 0 22px 22px 0;
  }
  .nav-item { padding: 13px 14px; font-size: 15px; }
  .playlist-item { padding: 12px 14px; }
  .switch { padding: 12px 10px; }

  /* --- Bottom nav: active pill indicator ---------------------------------- */
  .bottom-nav-btn { padding: 8px 4px 10px; gap: 4px; }
  .bottom-nav-icon {
    font-size: 21px;
    padding: 4px 16px;
    border-radius: 16px;
    transition: background 0.2s var(--ease), transform 0.18s var(--ease);
  }
  .bottom-nav-btn.active .bottom-nav-icon {
    background: rgba(255, 75, 50, 0.16);
    transform: none;
  }
  .bottom-nav-badge { top: 4px; margin-left: 10px; }

  /* --- Mini player: floating card above the nav --------------------------- */
  .mini-bar {
    left: 10px;
    right: 10px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    box-shadow: 0 12px 34px -10px rgba(0, 0, 0, 0.65);
  }
  .mini-bar-inner {
    border-top: none;
    padding: 10px 6px 10px 14px;
  }
  .mini-btn { width: 40px; height: 40px; border-radius: 12px; }
  .mini-close { width: 36px; height: 36px; }

  /* List pane clearance for taller nav + floating mini-bar */
  .list-pane { padding-bottom: calc(152px + env(safe-area-inset-bottom)); }

  /* --- Toasts: clear the floating mini-bar -------------------------------- */
  .toast-container { bottom: calc(148px + env(safe-area-inset-bottom)); }
  .toast { white-space: normal; max-width: calc(100vw - 32px); text-align: center; }

  /* --- Modals: bottom sheet ----------------------------------------------- */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
    z-index: 400; /* above mini-bar (300) and bottom-nav (310) */
  }
  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: 22px 22px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
    animation: sheetUp 0.3s var(--ease);
  }
  .modal::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--line);
    margin: 0 auto 16px;
  }
  .modal input[type="text"] { font-size: 16px; padding: 13px 15px; border-radius: 13px; }
  .modal-list button { padding: 14px 15px; border-radius: 13px; }
  .modal-actions { margin-top: 22px; }
  .modal-actions .btn { padding: 13px 20px; border-radius: 13px; }

  /* --- Shortcut overlay: fit narrow screens ------------------------------- */
  .shortcut-panel { min-width: 0; width: 100%; max-width: 480px; }
}

@keyframes sheetUp {
  from { opacity: 0; transform: translateY(40%); }
  to { opacity: 1; transform: none; }
}

/* ============================================================================
 * PORTRAIT PWA — JS-class mirror (.portrait-pwa on .app)
 *
 * The JS layer (setupPortraitPwaWatcher in app.js) adds / removes
 * `.portrait-pwa` on `.app` whenever the media query fires, giving a CSS hook
 * that works inside JS-conditional code paths (e.g. scroll position checks,
 * layout reads) without re-evaluating matchMedia inline.
 *
 * These selectors intentionally duplicate nothing from the @media block above
 * — they only fill gaps that require the JS class (e.g. interaction states
 * that can't be expressed purely with CSS media queries).
 * ========================================================================== */
.portrait-pwa .body {
  /* Body does not scroll in portrait — list-pane handles scrolling.
     Scroll-snap is intentionally omitted since there is no scroll root here. */
}
.portrait-pwa .player-pane {
  /* Player pane is always visible at top; no snap needed. */
}

/* ============================================================================
 * LANDSCAPE PWA — activates in standalone (installed) mode + landscape
 *
 * In landscape, the notch (if present) sits on one of the horizontal edges.
 * We apply safe-area-inset-* to the topbar so its content never slides under
 * the notch or the status-bar area, and ensure the topbar background spans
 * the full screen width so the theme colour fills the notch region.
 * ========================================================================== */
@media (display-mode: standalone) and (orientation: landscape) {
  /* Topbar: full width + safe-area padding on all sides.
     constant() for iOS < 11.2; env() for all modern browsers (overrides above). */
  .topbar {
    width: 100%;
    /* iOS < 11.2 fallback */
    padding-top: calc(8px + constant(safe-area-inset-top, 0px));
    padding-left: calc(14px + constant(safe-area-inset-left, 0px));
    padding-right: calc(14px + constant(safe-area-inset-right, 0px));
    padding-bottom: 8px;
    /* Modern browsers */
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    padding-left: calc(14px + env(safe-area-inset-left, 0px));
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
  }
}
