/* ════════════════════════════════════════════
   StreamVault — Main CSS
   Premium Dark Cinema design system
   (Netflix / Apple TV+ tier · v2)
   Tokens + class names preserved; visuals upgraded.
════════════════════════════════════════════ */

:root {
  /* ── Surfaces (deep charcoal, faint cool cast) ── */
  --bg:        #08080d;
  --bg2:       #0d0d15;
  --bg3:       #16161f;
  --bg4:       #20202c;
  --border:    rgba(255,255,255,0.08);
  --border2:   rgba(255,255,255,0.14);

  /* ── Accent ── */
  --red:       #e6394d;
  --red2:      #ff5a6b;
  --amber:     #f4a261;
  --teal:      #2ec4b6;
  --green:     #4ade80;

  /* ── Text (raised contrast for a11y) ── */
  --text:      #f4f4fa;
  --text2:     #a2a2bd;
  --text3:     #6b6b85;

  --card:      #101019;
  --card-h:    #1a1a26;

  /* ── Radii ── */
  --radius:    14px;
  --radsm:     9px;
  --radlg:     22px;

  --font-h:    'Archivo Black', sans-serif;
  --font-b:    'Syne', sans-serif;
  --font-m:    'JetBrains Mono', monospace;

  /* ── Elevation scale ── */
  --e1:        0 1px 2px rgba(0,0,0,0.4);
  --e2:        0 6px 18px rgba(0,0,0,0.45);
  --e3:        0 14px 40px rgba(0,0,0,0.55);
  --e4:        0 24px 70px rgba(0,0,0,0.65);
  --sh:        var(--e3);
  --glow:      0 0 28px rgba(230,57,77,0.35);

  /* ── Motion ── */
  --ease:      cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in:   cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast:    0.15s;
  --t:         0.25s;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(230,57,77,0.07), transparent 60%),
    radial-gradient(1000px 500px at 0% 0%, rgba(46,196,182,0.05), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-b);
  font-weight: 400;
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

/* ── Accessibility: visible focus (skill: focus-states) ── */
:focus-visible {
  outline: 2px solid var(--red2);
  outline-offset: 2px;
  border-radius: 4px;
}
button, a, .chip, .lib-item, .sb-item, .view-btn { -webkit-tap-highlight-color: transparent; }

/* ── Scrollbar ─────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--red); }

/* ════════════════════════════════════════════
   NAV
════════════════════════════════════════════ */
.nav {
  position: sticky;
  top: 0; z-index: 200;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.75rem;
  height: 60px;
  background: linear-gradient(to bottom, rgba(8,8,13,0.92), rgba(8,8,13,0.72));
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--red), #b8202f);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255,255,255,0.25);
}

.nav-name {
  font-family: var(--font-h);
  font-size: 1.2rem;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #fff, #c9c9d8);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-search {
  flex: 1;
  max-width: 440px;
  position: relative;
}

.nav-search input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.5rem 1.1rem;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}

.nav-search input::placeholder { color: var(--text3); }
.nav-search input:focus {
  border-color: var(--red);
  background: var(--bg2);
  box-shadow: 0 0 0 4px rgba(230,57,77,0.14);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: rgba(20,20,28,0.96);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
  display: none;
  z-index: 500;
  box-shadow: var(--e4);
}

.search-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  transition: background var(--t-fast);
  cursor: pointer;
}

.search-item:hover { background: var(--bg4); }

.search-thumb {
  width: 38px; height: 56px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  box-shadow: var(--e1);
}

.search-no-thumb {
  width: 38px; height: 56px;
  background: var(--bg4);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.search-title { font-size: 0.88rem; font-weight: 600; }
.search-meta  { font-size: 0.72rem; color: var(--text2); margin-top: 0.1rem; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.nav-link {
  font-size: 0.82rem;
  color: var(--text2);
  padding: 0.35rem 0.7rem;
  border-radius: 100px;
  transition: color var(--t-fast), background var(--t-fast);
}

.nav-link:hover { color: var(--text); background: var(--bg3); }

.btn-sm {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 100px;
  padding: 0.4rem 0.95rem;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  transition: all var(--t) var(--ease);
  white-space: nowrap;
}

.btn-sm:hover, .btn-sm.btn-active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: var(--glow);
}

/* ════════════════════════════════════════════
   HERO
════════════════════════════════════════════ */
.hero {
  position: relative;
  height: clamp(420px, 58vh, 640px);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: -5%;
  background-size: cover;
  background-position: center 18%;
  filter: blur(2px) saturate(115%);
  transform: scale(1.08);
}

.hero-grain {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.4;
  pointer-events: none;
}

.hero-grad {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, var(--bg) 2%, rgba(8,8,13,0.85) 28%, rgba(8,8,13,0.35) 62%, rgba(8,8,13,0.12) 100%),
    linear-gradient(to right, rgba(8,8,13,0.7) 0%, transparent 55%);
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 0 3.5rem 3.25rem;
  max-width: 820px;
  animation: heroIn 0.7s var(--ease) both;
}
@keyframes heroIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }

.hero-eyebrow {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.pill {
  background: rgba(255,255,255,0.09);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 100px;
  padding: 0.22rem 0.75rem;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  font-family: var(--font-m);
  color: var(--text);
}

.hero-title {
  font-family: var(--font-h);
  font-size: clamp(2.3rem, 5.5vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: -0.5px;
  margin-bottom: 0.9rem;
  text-shadow: 0 4px 30px rgba(0,0,0,0.8);
}

.hero-synopsis {
  font-size: 0.95rem;
  color: var(--text2);
  margin-bottom: 1.6rem;
  max-width: 560px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-btns { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--red);
  color: #fff;
  padding: 0.7rem 1.9rem;
  min-height: 44px;
  border-radius: var(--radsm);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: transform var(--t) var(--ease), background var(--t), box-shadow var(--t);
  box-shadow: var(--glow);
  text-decoration: none;
}

.btn-primary:hover { background: var(--red2); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(230,57,77,0.45); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,255,255,0.1);
  color: #fff;
  padding: 0.7rem 1.6rem;
  min-height: 44px;
  border-radius: var(--radsm);
  font-size: 0.9rem;
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background var(--t), transform var(--t) var(--ease);
  text-decoration: none;
}

.btn-ghost:hover { background: rgba(255,255,255,0.18); transform: translateY(-2px); }
.btn-ghost:active { transform: translateY(0); }

.btn-icon { font-size: 0.85em; }

/* ── Hero carousel (Netflix-style auto-sliding, admin-curated) ────────────── */
.hero-carousel { align-items: stretch; }

.hero-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s ease;
  pointer-events: none;
}
.hero-slide.active {
  position: relative;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.hero-logo {
  max-width: min(420px, 60vw);
  max-height: 140px;
  object-fit: contain;
  object-position: left bottom;
  margin-bottom: 0.9rem;
  filter: drop-shadow(0 4px 20px rgba(0,0,0,0.6));
}

.hero-dots {
  position: absolute;
  right: 3rem;
  bottom: 1.5rem;
  z-index: 3;
  display: flex;
  gap: 0.5rem;
}
.hero-dot {
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.3);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background var(--t);
}
.hero-dot.active { background: var(--red); }
.hero-dot:hover { background: rgba(255,255,255,0.6); }

@media (max-width: 900px) {
  .hero { height: clamp(360px, 52vh, 520px); }
  .hero-content { padding: 0 1.5rem 2.25rem; max-width: 100%; }
  .hero-dots { right: 1.5rem; bottom: 1rem; }
  .hero-logo { max-height: 100px; }
}

@media (max-width: 560px) {
  .hero { height: clamp(320px, 48vh, 440px); }
  .hero-bg { background-position: center 22%; }
  .hero-synopsis { -webkit-line-clamp: 2; font-size: 0.85rem; }
  .hero-btns .btn-primary, .hero-btns .btn-ghost { padding: 0.6rem 1.2rem; font-size: 0.85rem; }
  .hero-dots { display: none; } /* swipe is the primary control on mobile */
}

/* ════════════════════════════════════════════
   FILTERS / STATS
════════════════════════════════════════════ */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.filters-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text3);
  font-weight: 600;
  white-space: nowrap;
}

.chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1;
}

.chip {
  padding: 0.32rem 0.85rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.78rem;
  color: var(--text2);
  cursor: pointer;
  transition: all var(--t) var(--ease);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.chip:hover { border-color: var(--border2); color: var(--text); transform: translateY(-1px); }
.chip.active { background: var(--red); border-color: var(--red); color: #fff; box-shadow: var(--glow); }

.chip-count {
  background: rgba(255,255,255,0.15);
  border-radius: 100px;
  padding: 0 0.35rem;
  font-size: 0.68rem;
  font-family: var(--font-m);
}

.chip.active .chip-count { background: rgba(0,0,0,0.2); }

.view-toggle { display: flex; gap: 0.25rem; }

.view-btn {
  width: 32px; height: 32px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radsm);
  color: var(--text2);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t);
}

.view-btn.active { background: var(--bg4); color: var(--text); border-color: var(--border2); }

.stats-bar {
  padding: 0.45rem 2rem;
  font-size: 0.72rem;
  color: var(--text3);
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-m);
}

.stats-bar strong { color: var(--text2); }

/* ════════════════════════════════════════════
   MOVIE GRID
════════════════════════════════════════════ */
.library { padding: 1.75rem 2rem 3rem; }

.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 1.4rem 1.25rem;
}

.movie-card {
  animation: fadeUp 0.4s var(--ease) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-link { display: block; }

.card-thumb {
  position: relative;
  aspect-ratio: 2/3;
  background: var(--bg3);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t);
  will-change: transform;
}

.movie-card:hover .card-thumb {
  border-color: rgba(230,57,77,0.5);
  transform: translateY(-6px) scale(1.03);
  box-shadow: var(--e3), 0 0 0 1px rgba(230,57,77,0.25);
  z-index: 5;
}

.card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s var(--ease);
}

.movie-card:hover .card-thumb img { transform: scale(1.08); }

.card-no-thumb {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-h);
  font-size: 3.5rem;
  color: var(--bg4);
  background: linear-gradient(135deg, var(--bg3), var(--bg4));
}

.card-hover {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.25) 55%, rgba(0,0,0,0.5) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  opacity: 0;
  transition: opacity var(--t);
}

.movie-card:hover .card-hover { opacity: 1; }

.card-play-btn {
  width: 56px; height: 56px;
  background: var(--red);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  transition: transform var(--t) var(--ease), background var(--t);
  box-shadow: var(--glow);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-play-btn:hover { transform: scale(1.12); background: var(--red2); }

.card-hover-actions {
  display: flex;
  gap: 0.5rem;
}

.card-action-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  backdrop-filter: blur(4px);
  transition: background var(--t-fast), transform var(--t-fast);
}

.card-action-btn:hover { background: rgba(255,255,255,0.28); transform: scale(1.08); }

.card-runtime {
  position: absolute;
  bottom: 0.45rem;
  right: 0.45rem;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(4px);
  font-family: var(--font-m);
  font-size: 0.68rem;
  padding: 0.14rem 0.42rem;
  border-radius: 5px;
  color: #fff;
}

.card-rating {
  position: absolute;
  top: 0.45rem; left: 0.45rem;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(4px);
  color: #f5c518;
  font-family: var(--font-m);
  font-weight: 600;
  font-size: 0.68rem;
  padding: 0.14rem 0.42rem;
  border-radius: 5px;
  border: 1px solid rgba(245,197,24,0.3);
}

.card-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--red);
  width: 0;
  border-radius: 0 100px 100px 0;
  box-shadow: var(--glow);
  transition: width 0.3s;
}

.card-body { padding: 0.7rem 0.15rem; }

.card-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.card-meta {
  font-family: var(--font-m);
  font-size: 0.68rem;
  color: var(--text3);
  display: flex;
  gap: 0.4rem;
}

/* List view */
.movie-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.movie-list .movie-card { animation: none; }
.movie-list .card-link { display: flex; align-items: center; gap: 1rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem; transition: border-color var(--t), background var(--t), transform var(--t) var(--ease); }
.movie-list .card-link:hover { border-color: rgba(230,57,77,0.5); background: var(--card-h); transform: translateX(4px); }
.movie-list .card-thumb { aspect-ratio: 2/3; width: 54px; flex-shrink: 0; border-radius: 7px; }
.movie-list .movie-card:hover .card-thumb { transform: none; box-shadow: none; }
.movie-list .card-hover, .movie-list .card-runtime { display: none; }
.movie-list .card-body { flex: 1; padding: 0; }
.movie-list .card-title { -webkit-line-clamp: 1; }

/* ════════════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════════ */
.empty {
  text-align: center;
  padding: 6rem 2rem;
}

.empty-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.85; }
.empty h2 { font-family: var(--font-h); font-size: 2rem; margin-bottom: 0.5rem; }
.empty p { color: var(--text2); }
.empty code { background: var(--bg3); padding: 0.1rem 0.4rem; border-radius: 4px; font-family: var(--font-m); font-size: 0.85em; color: var(--amber); }

/* ════════════════════════════════════════════
   MODAL
════════════════════════════════════════════ */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-bg[hidden] { display: none !important; }

.modal-box {
  background: linear-gradient(180deg, var(--bg3), var(--bg2));
  border: 1px solid var(--border2);
  border-radius: var(--radlg);
  padding: 2rem;
  width: 440px;
  max-width: 95vw;
  position: relative;
  box-shadow: var(--e4);
  animation: modalIn 0.28s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }

.modal-box h2 { font-family: var(--font-h); font-size: 1.5rem; margin-bottom: 0.5rem; }
.modal-box p  { color: var(--text2); font-size: 0.9rem; }

.modal-box label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 0.85rem;
}

.modal-box input, .modal-box textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radsm);
  padding: 0.6rem 0.85rem;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
  width: 100%;
}

.modal-box input:focus, .modal-box textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(230,57,77,0.14); }

.modal-x {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 30px; height: 30px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text2);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}

.modal-x:hover { background: var(--red); color: #fff; border-color: var(--red); transform: rotate(90deg); }

/* Auth pages */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 50% 25%, rgba(230,57,77,0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(46,196,182,0.08) 0%, transparent 50%),
    var(--bg);
}

.auth-box {
  width: 380px;
  max-width: 95vw;
  background: linear-gradient(180deg, rgba(22,22,31,0.9), rgba(13,13,21,0.9));
  backdrop-filter: blur(20px);
  border: 1px solid var(--border2);
  border-radius: var(--radlg);
  padding: 2.5rem;
  box-shadow: var(--e4);
}

.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo .nav-logo { width: 52px; height: 52px; font-size: 1.5rem; margin: 0 auto 0.75rem; display: flex; align-items: center; justify-content: center; border-radius: 14px; box-shadow: var(--glow); }
.auth-logo h1 { font-family: var(--font-h); font-size: 1.55rem; letter-spacing: 2px; }

.auth-box label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.85rem;
}

.auth-box input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radsm);
  padding: 0.7rem 1rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
  width: 100%;
}

.auth-box input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(230,57,77,0.14); }

.auth-error {
  background: rgba(230,57,77,0.12);
  border: 1px solid rgba(230,57,77,0.28);
  color: var(--red2);
  padding: 0.55rem 0.8rem;
  border-radius: var(--radsm);
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
  .nav { padding: 0 1rem; gap: 0.75rem; }
  .hero-content { padding: 0 1.5rem 2rem; }
  .hero-title { font-size: 2rem; }
  .library { padding: 1rem; }
  .movie-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 1rem 0.8rem; }
  .filters-bar { padding: 0.75rem 1rem; }
  .stats-bar { padding: 0.3rem 1rem; }
  .movie-card:hover .card-thumb { transform: none; } /* no hover-lift on touch */
}

/* ── Library Sidebar ─────────────────────── */
.app-layout { display: flex; min-height: calc(100vh - 60px); }

.lib-sidebar {
  width: 210px; min-width: 200px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky; top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto; flex-shrink: 0;
}

.lib-sidebar-title {
  font-size: 0.65rem; text-transform: uppercase;
  letter-spacing: 3px; color: var(--text3);
  font-weight: 600; padding: 0 1rem 0.75rem;
}

.lib-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1rem; color: var(--text2);
  font-size: 0.875rem; cursor: pointer;
  transition: all var(--t-fast); border-left: 3px solid transparent;
  text-decoration: none;
}
.lib-item:hover { background: var(--bg3); color: var(--text); }
.lib-item.active { background: linear-gradient(to right, rgba(230,57,77,0.12), transparent); color: var(--text); border-left-color: var(--red); }
.lib-icon { font-size: 1rem; flex-shrink: 0; }
.lib-count { margin-left: auto; font-size: 0.7rem; color: var(--text3); background: var(--bg4); padding: 0.1rem 0.4rem; border-radius: 100px; font-family: var(--font-m); }
.lib-add-btn { width: calc(100% - 2rem); margin: 0.75rem 1rem 0; background: var(--bg3); border: 1px dashed var(--border2); border-radius: var(--radsm); padding: 0.5rem; color: var(--text3); font-size: 0.8rem; cursor: pointer; transition: all var(--t); }
.lib-add-btn:hover { border-color: var(--red); color: var(--red); }
.lib-content { flex: 1; min-width: 0; }

.lib-header { display: flex; align-items: center; gap: 1rem; padding: 1.5rem 2rem 0.5rem; }
.lib-header-icon { font-size: 2.5rem; }
.lib-header-title { font-family: var(--font-h); font-size: 1.8rem; line-height: 1; }
.lib-header-meta { font-size: 0.8rem; color: var(--text3); margin-top: 0.2rem; font-family: var(--font-m); }
.lib-header-actions { margin-left: auto; display: flex; gap: 0.4rem; flex-wrap: wrap; }

.modal-box select, .modal-box textarea {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radsm); padding: 0.6rem 0.85rem;
  color: var(--text); font-size: 0.9rem; outline: none;
  transition: border-color var(--t); width: 100%;
}
.modal-box select:focus, .modal-box textarea:focus { border-color: var(--red); }
.modal-box textarea { resize: vertical; font-family: var(--font-m); }

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .lib-sidebar { width: 100%; height: auto; position: static; display: flex; flex-wrap: wrap; padding: 0.5rem; gap: 0.3rem; border-right: none; border-bottom: 1px solid var(--border); }
  .lib-sidebar-title { display: none; }
  .lib-item { border-left: none; border-radius: 100px; padding: 0.35rem 0.8rem; border: 1px solid var(--border); }
  .lib-item.active { border-color: var(--red); background: var(--red); color: #fff; }
  .lib-add-btn { width: auto; margin: 0; }
}

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


/* ── App Sidebar ─────────────────────────── */
.app-layout { display: flex; min-height: calc(100vh - 60px); }
.app-main   { flex: 1; min-width: 0; }

.app-sidebar {
  width: 220px; min-width: 200px; flex-shrink: 0;
  background: var(--bg2); border-right: 1px solid var(--border);
  position: sticky; top: 60px;
  height: calc(100vh - 60px); overflow-y: auto;
  transition: transform 0.3s var(--ease);
}

.sidebar-overlay { display: none; }
.sidebar-close-btn { display: none; }

.nav-menu-btn {
  display: none; background: none; border: none;
  color: var(--text); font-size: 1.2rem; cursor: pointer;
  padding: 0.3rem 0.5rem; border-radius: var(--radsm);
}
.nav-menu-btn:hover { background: var(--bg3); }

.sb-section { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.sb-section:last-child { border: none; }
.sb-section-title {
  font-size: 0.6rem; text-transform: uppercase;
  letter-spacing: 3px; color: var(--text3);
  font-weight: 600; padding: 0 1rem 0.5rem;
}
.sb-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 1rem; color: var(--text2);
  font-size: 0.85rem; cursor: pointer;
  transition: all var(--t-fast); border-left: 3px solid transparent;
  text-decoration: none; white-space: nowrap; overflow: hidden;
}
.sb-item span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.sb-item:hover { background: var(--bg3); color: var(--text); }
.sb-item.active { background: linear-gradient(to right, rgba(230,57,77,0.12), transparent); color: var(--text); border-left-color: var(--red); }
.sb-icon  { font-size: 0.95rem; flex-shrink: 0; }
.sb-count {
  margin-left: auto; font-size: 0.65rem; color: var(--text3);
  background: var(--bg4); padding: 0.1rem 0.35rem;
  border-radius: 100px; font-family: var(--font-m); flex-shrink: 0;
}
.sb-add-btn {
  width: calc(100% - 2rem); margin: 0.5rem 1rem 0;
  background: var(--bg3); border: 1px dashed var(--border2);
  border-radius: var(--radsm); padding: 0.45rem; color: var(--text3);
  font-size: 0.78rem; cursor: pointer; transition: all var(--t); display: block;
}
.sb-add-btn:hover { border-color: var(--red); color: var(--red); }

.page-header { display: flex; align-items: center; gap: 1rem; padding: 1.5rem 1.5rem 0.5rem; flex-wrap: wrap; }
.page-header-icon  { font-size: 2rem; }
.page-header-title { font-family: var(--font-h); font-size: 1.6rem; line-height: 1; }
.page-header-meta  { font-size: 0.75rem; color: var(--text3); font-family: var(--font-m); margin-top: 0.2rem; }
.page-header-actions { margin-left: auto; display: flex; gap: 0.35rem; flex-wrap: wrap; }

.nav-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--red), #b8202f);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 0.85rem; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}
.nav-link-desktop { display: flex; }

/* Mobile */
@media (max-width: 768px) {
  .nav-menu-btn { display: flex; align-items: center; }
  .nav-name { display: none; }
  .nav-link-desktop { display: none; }

  .app-sidebar {
    position: fixed; top: 0; left: 0;
    height: 100vh; z-index: 300;
    transform: translateX(-100%);
    width: 260px; padding-top: 3rem;
    box-shadow: none;
  }
  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
  }
  .sidebar-overlay {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); z-index: 299;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
  }
  .sidebar-overlay.open { opacity: 1; pointer-events: all; }
  .sidebar-close-btn {
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: 0.75rem; right: 0.75rem;
    width: 32px; height: 32px; background: var(--bg3);
    border: 1px solid var(--border); border-radius: 50%;
    cursor: pointer; color: var(--text2); font-size: 0.8rem;
  }
}

/* ── Reduced motion (skill: reduced-motion) ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .movie-card:hover .card-thumb { transform: none; }
}

/* ── Global navigation loader ─────────────────────────────────
   Slim top bar shown while a click is committing to a new page.
   Driven by /js/loader.js; see that file for what does and does
   not count as "loading" (custom schemes like the VLC hand-off
   are deliberately excluded). */
.sv-loadbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: transparent;
}
.sv-loadbar.on { opacity: 1; }
.sv-loadbar-fill {
  position: relative;   /* anchors the ::after leading edge */
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--red), var(--red2));
  box-shadow: 0 0 10px rgba(230, 57, 77, 0.7), 0 0 4px rgba(230, 57, 77, 0.9);
  transition: width 0.2s ease;
  border-radius: 0 2px 2px 0;
}
/* A soft leading edge reads as motion even when width is easing slowly. */
.sv-loadbar-fill::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 90px; height: 100%;
  background: linear-gradient(90deg, transparent, var(--red2));
  opacity: 0.85;
}
@media (prefers-reduced-motion: reduce) {
  .sv-loadbar-fill { transition: none; }
  .sv-loadbar-fill::after { display: none; }
}

/* ── TV performance overrides ─────────────────────────────────
   Only applied when tv-mode.js has confirmed a real TV device and
   added .tv-mode to <body>. Phones and desktops are untouched.

   Every backdrop-filter is a live blur of whatever sits behind the
   element, recomputed each frame. There are eleven of them in this
   file, including blur(22px) on the permanently-visible nav and a
   full-frame blur on .hero-bg. A TV SoC cannot composite that while
   also moving a focus ring, which is what made D-pad navigation
   crawl. Each one is replaced with a solid surface of roughly the
   same tone, which is indistinguishable at viewing distance. */
body.tv-mode .nav,
body.tv-mode .search-results,
body.tv-mode .pill,
body.tv-mode .btn-ghost,
body.tv-mode .card-action-btn,
body.tv-mode .card-runtime,
body.tv-mode .card-rating,
body.tv-mode .modal-bg,
body.tv-mode .auth-box,
body.tv-mode .hero-bg {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
/* Restore opacity lost with the blur, so translucent panels stay readable. */
body.tv-mode .nav            { background: #0a0a12 !important; }
body.tv-mode .search-results { background: #0d0d15 !important; }
body.tv-mode .modal-bg       { background: rgba(4,4,8,0.92) !important; }
body.tv-mode .auth-box       { background: #0d0d15 !important; }
body.tv-mode .card-runtime,
body.tv-mode .card-rating,
body.tv-mode .card-action-btn { background: rgba(0,0,0,0.75) !important; }
body.tv-mode .pill           { background: #14141f !important; }

/* .hero-bg carried filter: blur(2px) saturate(115%) across a full-screen
   image - the single most expensive rule on the page. */
body.tv-mode .hero-bg { filter: none !important; }

/* Entry animations fire for every card on a page full of them. Harmless on a
   phone, a stutter on a TV. */
body.tv-mode .movie-card,
body.tv-mode .lib-row-card,
body.tv-mode .cw-card,
body.tv-mode .show-card { animation: none !important; }

/* Hover transforms fight the D-pad focus scale when a remote reports as a
   pointer (air-mouse remotes do). Focus styling wins. */
body.tv-mode .movie-card:hover .card-thumb,
body.tv-mode .btn-primary:hover { transform: none !important; box-shadow: none !important; }

/* A TV should never see the desktop hero carousel. /tv-home has none, but a
   TV can still reach '/' via an older app build, a bookmark, or a redirect -
   and the hero is both wrong for a 10-foot UI and the single most expensive
   thing on the page (full-bleed image, blur, autoplaying slide timer). */
body.tv-mode .hero,
body.tv-mode .hero-bg,
body.tv-mode .hero-grain,
body.tv-mode .hero-grad,
body.tv-mode .hero-content,
body.tv-mode .hero-dots { display: none !important; }
