/* ============ AnyWatch — Netflix-style UI ============ */

:root {
  --bg: #0b0b0f;
  --bg-elev: #16161d;
  --bg-card: #1c1c24;
  --text: #f4f4f5;
  --text-dim: #a1a1aa;
  --text-faint: #63636b;
  --accent: #e50914;
  --accent-hot: #ff2b35;
  --accent-glow: rgba(229,9,20,.4);
  --radius: 10px;
  --nav-h: 64px;
  --pad: clamp(16px, 4vw, 56px);
  --card-w: clamp(118px, 15vw, 200px);
  --shadow: 0 10px 30px rgba(0,0,0,.55);
  --shadow-lg: 0 25px 60px rgba(0,0,0,.6);
  --glass: rgba(255,255,255,.06);
  --glass-border: rgba(255,255,255,.1);
  --grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--accent-hot); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(229,9,20,.55); }

/* subtle ambient glow at the very top */
body::before {
  content: "";
  position: fixed; inset: -40% -20% auto -20%; height: 70vh;
  background:
    radial-gradient(ellipse at 25% 0%, rgba(229,9,20,.08), transparent 55%),
    radial-gradient(ellipse at 75% 5%, rgba(255,106,61,.05), transparent 50%),
    radial-gradient(ellipse at 50% -10%, rgba(120,40,200,.03), transparent 45%);
  pointer-events: none; z-index: 0;
  animation: ambientPulse 8s ease infinite alternate;
}
@keyframes ambientPulse {
  0% { opacity: .75; }
  100% { opacity: 1; }
}
/* film grain overlay */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 9999;
  pointer-events: none;
  opacity: .022;
  background-image: var(--grain);
  mix-blend-mode: overlay;
}

/* ============ Navigation ============ */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding-top: env(safe-area-inset-top);
  transition: background .35s ease, backdrop-filter .35s ease;
  background: linear-gradient(to bottom, rgba(5,5,8,.85), transparent);
}
.nav.solid {
  background: rgba(11,11,15,.82);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 6px 30px rgba(0,0,0,.35), 0 0 100px rgba(229,9,20,.015);
}
.nav-inner {
  height: var(--nav-h);
  display: flex; align-items: center; gap: 28px;
  padding: 0 var(--pad);
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 21px; font-weight: 500; letter-spacing: -.02em;
  color: var(--text); text-decoration: none; flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand b { color: var(--accent-hot); font-weight: 800; }
.brand-mark { width: 26px; height: 26px; filter: drop-shadow(0 0 8px rgba(229,9,20,.25)); }

.nav-tabs { display: flex; gap: 2px; }
.nav-tab {
  position: relative;
  padding: 7px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 500; color: var(--text-dim);
  transition: color .25s, background .25s, transform .2s;
}
.nav-tab:hover { color: var(--text); }
.nav-tab:active { transform: scale(.95); }
.nav-tab.active { color: var(--text); background: rgba(255,255,255,.1); }
.nav-tab.active::after {
  content: ""; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 2px; border-radius: 1px;
  background: var(--accent-hot);
  animation: tabDot .3s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes tabDot { from { width: 0; opacity: 0; } to { width: 16px; opacity: 1; } }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }

.search-box {
  position: relative; display: flex; align-items: center;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  transition: border-color .3s, background .3s, box-shadow .3s, width .35s cubic-bezier(.4,0,.2,1);
  min-width: 0;
}
.search-box:focus-within {
  background: rgba(0,0,0,.65);
  border-color: rgba(229,9,20,.35);
  box-shadow: 0 0 0 4px rgba(229,9,20,.08), 0 8px 32px rgba(0,0,0,.3), 0 0 40px rgba(229,9,20,.04);
}
.search-icon { width: 16px; height: 16px; margin-left: 13px; color: var(--text-dim); flex-shrink: 0; transition: color .2s; }
.search-box:focus-within .search-icon { color: var(--accent-hot); }
.search-box input {
  width: clamp(120px, 22vw, 300px);
  background: none; border: 0; outline: 0;
  color: var(--text); font-size: 14px;
  padding: 9px 10px;
  transition: width .35s cubic-bezier(.4,0,.2,1);
}
.search-box:focus-within input { width: clamp(180px, 28vw, 340px); }
.search-box input::placeholder { color: var(--text-faint); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear {
  display: none; padding: 0 12px 0 2px;
  font-size: 20px; line-height: 1; color: var(--text-dim);
}
.search-box.has-value .search-clear { display: block; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: var(--text-dim);
  transition: color .2s, background .2s;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.1); }
.icon-btn svg { width: 20px; height: 20px; }

/* ============ Hero ============ */
.hero {
  position: relative; z-index: 1;
  height: clamp(420px, 65vh, 680px);
  display: flex; align-items: flex-end;
  isolation: isolate;
  overflow: hidden;
}
.hero-bg {
  position: absolute; inset: -2% -1% -2% -1%; z-index: -1;
  background-size: cover; background-position: center 20%;
  animation: heroIn 1.4s cubic-bezier(.4,0,.2,1) both;
  will-change: transform, opacity;
}
@keyframes heroIn {
  from { opacity: 0; transform: scale(1.08); filter: blur(8px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}
.hero-bg::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(to top, var(--bg) 0%, rgba(11,11,15,.55) 25%, rgba(11,11,15,.08) 55%, rgba(11,11,15,.25) 100%),
    linear-gradient(100deg, rgba(11,11,15,.95) 0%, rgba(11,11,15,.5) 35%, transparent 60%);
}
.hero-content {
  position: relative;
  padding: 0 var(--pad) clamp(32px, 7vh, 72px);
  max-width: 640px;
  animation: riseIn .9s .2s ease both;
}
@keyframes riseIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.hero-kicker {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase;
  color: var(--accent-hot); margin-bottom: 14px;
  animation: riseIn .9s .35s ease both;
  text-shadow: 0 0 20px rgba(229,9,20,.3);
}
.hero-kicker::before {
  content: ""; width: 22px; height: 2.5px;
  background: linear-gradient(90deg, var(--accent-hot), var(--accent));
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(229,9,20,.4);
}
.hero-title {
  font-size: clamp(32px, 5.4vw, 60px);
  font-weight: 800; letter-spacing: -.035em; line-height: 1.02;
  text-shadow: 0 4px 40px rgba(0,0,0,.6);
  margin-bottom: 16px;
  animation: riseIn .9s .45s ease both;
}
.hero-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  font-size: 14px; color: var(--text-dim); margin-bottom: 14px; font-weight: 500;
  animation: riseIn .9s .55s ease both;
}
.hero-overview {
  font-size: clamp(14px, 1.4vw, 16px); line-height: 1.6; color: #d4d4d8;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 24px; max-width: 560px;
  text-shadow: 0 2px 16px rgba(0,0,0,.7);
  animation: riseIn .9s .6s ease both;
}
.hero-actions { display: flex; gap: 12px; animation: riseIn .9s .7s ease both; }

/* hero carousel */
#hero { transition: opacity .4s ease; }
#hero.hero-fade { opacity: 0; }
.hero-dots {
  position: absolute;
  bottom: clamp(28px, 5vh, 52px);
  right: var(--pad);
  display: flex; gap: 6px; z-index: 5;
}
.hero-dot {
  width: 28px; height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,.2);
  padding: 0; overflow: hidden;
  transition: background .3s, width .4s cubic-bezier(.4,0,.2,1);
  cursor: pointer;
}
.hero-dot:hover { background: rgba(255,255,255,.35); }
.hero-dot.active { width: 48px; background: rgba(255,255,255,.1); }
.hero-dot.active span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hot));
  border-radius: 2px;
  animation: heroDotFill 8s linear forwards;
  box-shadow: 0 0 8px rgba(229,9,20,.35);
}
.hero-dot:not(.active) span { display: none; }
@keyframes heroDotFill { from { width: 0; } to { width: 100%; } }

/* hero score ring */
.hero-score-ring {
  display: inline-flex; align-items: center; gap: 7px;
}
.hero-score-ring b {
  font-size: 15px; font-weight: 800;
  color: var(--text);
}

/* ============ Buttons ============ */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 13px 28px; border-radius: 10px;
  font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  transition: transform .2s cubic-bezier(.2,.9,.3,1), background .25s, box-shadow .25s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.95); }
.btn svg { width: 20px; height: 20px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hot) 100%);
  color: #fff;
  box-shadow: 0 6px 24px rgba(229,9,20,.35), 0 2px 8px rgba(229,9,20,.2), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hot) 0%, #ff4a3d 100%);
  box-shadow: 0 10px 36px rgba(229,9,20,.5), 0 2px 12px rgba(229,9,20,.3), inset 0 1px 0 rgba(255,255,255,.15);
  transform: translateY(-2px);
}
.btn-primary::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.15) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform .5s ease;
}
.btn-primary:hover::after { transform: translateX(100%); }
.btn-ghost {
  background: rgba(255,255,255,.1); color: var(--text);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.08);
}
.btn-ghost:hover {
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.15);
  transform: translateY(-1px);
}

/* ============ Rows ============ */
#rows { position: relative; z-index: 2; padding-bottom: 90px; }
.row { margin-top: 38px; }
.hero + #rows .row:first-child { margin-top: 8px; }
.row-title {
  font-size: clamp(17px, 1.8vw, 22px); font-weight: 700; letter-spacing: -.02em;
  padding: 0 var(--pad); margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.row-title::before {
  content: "";
  width: 3px; height: 1.15em; flex-shrink: 0;
  background: linear-gradient(to bottom, var(--accent), var(--accent-hot));
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(229,9,20,.25);
}
.row-title small { font-size: 12px; font-weight: 600; color: var(--text-faint); letter-spacing: .06em; text-transform: uppercase; }
.row-scroller {
  display: flex; gap: 10px;
  overflow-x: auto; overscroll-behavior-x: contain;
  padding: 8px var(--pad) 16px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(to right, transparent, black var(--pad), black calc(100% - 40px), transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black var(--pad), black calc(100% - 40px), transparent);
}
.row-scroller::-webkit-scrollbar { display: none; }

/* scroll-reveal animation */
.row { opacity: 0; transform: translateY(20px); }
.row.revealed {
  animation: rowReveal .6s cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes rowReveal { to { opacity: 1; transform: translateY(0); } }
.row.revealed .card {
  opacity: 0; animation: cardReveal .4s cubic-bezier(.4,0,.2,1) forwards;
}
.row.revealed .card:nth-child(1) { animation-delay: .05s; }
.row.revealed .card:nth-child(2) { animation-delay: .08s; }
.row.revealed .card:nth-child(3) { animation-delay: .11s; }
.row.revealed .card:nth-child(4) { animation-delay: .14s; }
.row.revealed .card:nth-child(5) { animation-delay: .17s; }
.row.revealed .card:nth-child(6) { animation-delay: .2s; }
.row.revealed .card:nth-child(7) { animation-delay: .23s; }
.row.revealed .card:nth-child(8) { animation-delay: .26s; }
.row.revealed .card:nth-child(n+9) { animation-delay: .29s; }
@keyframes cardReveal { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }

/* ============ Cards ============ */
.card {
  position: relative; flex: 0 0 var(--card-w);
  scroll-snap-align: start;
  border-radius: var(--radius); overflow: hidden;
  background: var(--bg-card);
  aspect-ratio: 2 / 3;
  cursor: pointer;
  transition: transform .32s cubic-bezier(.2,.9,.3,1.05), box-shadow .32s, filter .32s;
  outline: none;
  will-change: transform;
}
.card img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s cubic-bezier(.4,0,.2,1); }
.card::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: var(--radius);
  background: radial-gradient(
    600px circle at var(--mx, 50%) var(--my, 50%),
    rgba(255,255,255,.08),
    transparent 40%
  );
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity .3s;
}
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.07);
  pointer-events: none;
  transition: box-shadow .3s;
}
@media (hover: hover) {
  .card:hover, .card:focus-visible {
    transform: scale(1.08) translateY(-6px);
    box-shadow: 0 20px 50px rgba(0,0,0,.65), 0 0 80px rgba(229,9,20,.06), 0 0 0 1px rgba(255,255,255,.06);
    z-index: 5;
  }
  .card:hover::before { opacity: 1; }
  .card:hover::after { box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.15); }
  .card:hover img { transform: scale(1.06); }
  .card:hover .card-overlay { opacity: 1; transform: translateY(0); }
}
.card-overlay {
  position: absolute; inset: 0; opacity: 0;
  transform: translateY(6px);
  transition: opacity .3s, transform .3s cubic-bezier(.4,0,.2,1);
  background: linear-gradient(to top, rgba(0,0,0,.95) 0%, rgba(0,0,0,.5) 40%, rgba(0,0,0,.1) 60%, transparent 100%);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 14px;
  z-index: 3;
}
.card-play-ic {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(.7);
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hot));
  display: grid; place-items: center;
  opacity: 0; transition: opacity .25s, transform .3s cubic-bezier(.2,.9,.3,1.2);
  box-shadow: 0 6px 24px rgba(229,9,20,.45), 0 0 0 3px rgba(255,255,255,.1);
}
.card-play-ic svg { width: 20px; height: 20px; margin-left: 2px; }
@media (hover: hover) { .card:hover .card-play-ic { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.card-overlay .card-name { font-size: 13px; font-weight: 700; line-height: 1.25; margin-bottom: 4px; }
.card-overlay .card-sub { font-size: 11.5px; color: var(--text-dim); display: flex; gap: 8px; }
.card-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 14px; text-align: center;
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  background: linear-gradient(160deg, #22222c, #15151b);
}

/* progress bar on continue-watching cards */
.card-progress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: rgba(255,255,255,.12);
  z-index: 3;
}
.card-progress > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hot));
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 10px rgba(229,9,20,.5), 0 0 3px rgba(229,9,20,.8);
}
.card-badge {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  font-size: 10px; font-weight: 800; letter-spacing: .08em;
  padding: 3px 9px; border-radius: 6px;
  background: rgba(0,0,0,.65); color: #fff;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.card-remove {
  position: absolute; top: 6px; right: 6px; z-index: 5;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.7); color: #fff;
  border: 1px solid rgba(255,255,255,.15);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 16px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s ease, background .15s ease;
  pointer-events: auto;
}
.card:hover .card-remove { opacity: 1; }
.card-remove:hover { background: rgba(229,9,20,.85); }
@media (hover: none) { .card-remove { opacity: .85; } }

/* rating stars/score chip */
.score {
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 700; color: #46d369;
  text-shadow: 0 0 12px rgba(70,211,105,.3);
}

/* score ring */
.score-ring { width: 34px; height: 34px; flex-shrink: 0; }
.score-ring circle { transition: stroke-dashoffset .6s cubic-bezier(.4,0,.2,1); }
.score-ring-inline {
  display: inline-flex; align-items: center; gap: 7px;
}
.score-ring-inline .score-ring { width: 30px; height: 30px; }
.score-ring-inline span {
  font-weight: 700; font-size: 14px;
  color: #46d369;
  text-shadow: 0 0 12px rgba(70,211,105,.3);
}

/* ============ Grid view (search / movies / tv / list) ============ */
.grid-view { position: relative; z-index: 2; padding: calc(var(--nav-h) + env(safe-area-inset-top) + 28px) var(--pad) 100px; min-height: 100vh; }
.grid-title {
  font-size: clamp(20px, 2.4vw, 28px); font-weight: 800; letter-spacing: -.02em; margin-bottom: 24px;
  animation: riseIn .5s ease both;
}
.poster-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(clamp(108px, 14vw, 175px), 1fr));
}
.poster-grid .card {
  flex: none; width: 100%;
  opacity: 0; animation: gridCardIn .4s cubic-bezier(.4,0,.2,1) forwards;
}
.poster-grid .card:nth-child(1) { animation-delay: .02s; }
.poster-grid .card:nth-child(2) { animation-delay: .04s; }
.poster-grid .card:nth-child(3) { animation-delay: .06s; }
.poster-grid .card:nth-child(4) { animation-delay: .08s; }
.poster-grid .card:nth-child(5) { animation-delay: .1s; }
.poster-grid .card:nth-child(6) { animation-delay: .12s; }
.poster-grid .card:nth-child(7) { animation-delay: .14s; }
.poster-grid .card:nth-child(8) { animation-delay: .16s; }
.poster-grid .card:nth-child(n+9) { animation-delay: .18s; }
@keyframes gridCardIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }

.grid-empty {
  color: var(--text-dim); font-size: 15px; padding: 60px 20px; text-align: center;
  line-height: 1.6;
}
.grid-empty::before {
  content: ""; display: block; width: 72px; height: 72px; margin: 0 auto 20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(229,9,20,.04), rgba(255,255,255,.02));
  border: 1px dashed rgba(255,255,255,.1);
  box-shadow: 0 0 40px rgba(229,9,20,.03);
}

/* skeleton shimmer */
.skeleton {
  background: linear-gradient(105deg, #14141b 30%, #1f1f2a 48%, #2a2a38 50%, #1f1f2a 52%, #14141b 70%);
  background-size: 300% 100%;
  animation: shimmer 2s infinite ease-in-out;
  border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(4,4,7,.65);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(0px, 4vh, 48px) 0;
  animation: backdropIn .3s ease;
}
@keyframes backdropIn { from { opacity: 0; backdrop-filter: blur(0); } }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  position: relative;
  width: min(880px, 100%);
  background: var(--bg-elev);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.06), 0 0 120px rgba(229,9,20,.03);
  animation: modalIn .4s cubic-bezier(.2,.9,.3,1.05);
  margin-bottom: 40px;
  border: 1px solid rgba(255,255,255,.06);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(30px) scale(.96); } }
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; margin-bottom: 0; border: 0; }
  .modal-close { display: none; }
  .modal-back-bar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 10;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    background: rgba(22,22,29,.92);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,.06);
    color: var(--text); font-size: 16px; font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
  }
  .modal-back-bar svg { width: 22px; height: 22px; flex-shrink: 0; }
}
.modal-back-bar { display: none; }
.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 10;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(10,10,14,.7); color: #fff;
  font-size: 22px; line-height: 1;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.1);
  transition: background .25s, transform .3s cubic-bezier(.2,.9,.3,1.2), border-color .25s, box-shadow .25s;
}
.modal-close:hover {
  background: var(--accent); border-color: var(--accent);
  transform: rotate(90deg) scale(1.08);
  box-shadow: 0 4px 16px rgba(229,9,20,.35);
}

.details-hero {
  position: relative; aspect-ratio: 16 / 8.2;
  background-size: cover; background-position: center 25%;
  animation: heroIn 1s ease both;
}
.details-hero::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(to top, var(--bg-elev) 2%, rgba(22,22,29,.35) 40%, transparent 70%),
    linear-gradient(110deg, rgba(22,22,29,.5) 0%, transparent 40%);
}
.details-body {
  padding: 0 clamp(18px, 4vw, 40px) 36px;
  margin-top: clamp(-56px, -6vw, -30px);
  position: relative;
  animation: riseIn .5s .1s ease both;
}
.details-title {
  font-size: clamp(26px, 3.8vw, 42px); font-weight: 800; letter-spacing: -.035em; line-height: 1.04;
  margin-bottom: 14px; text-shadow: 0 4px 24px rgba(0,0,0,.7);
}
.details-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px;
  font-size: 14px; color: var(--text-dim); font-weight: 500; margin-bottom: 16px;
}
.chip {
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 999px;
  background: rgba(255,255,255,.06); color: var(--text-dim);
  border: 1px solid rgba(255,255,255,.07);
  transition: background .2s, border-color .2s, transform .2s;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.chip:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.14); transform: translateY(-1px); }
.details-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.details-overview { font-size: 15px; line-height: 1.65; color: #d4d4d8; max-width: 680px; margin-bottom: 20px; }
.details-facts { font-size: 13.5px; color: var(--text-dim); line-height: 1.7; margin-bottom: 8px; }
.details-facts b { color: var(--text); font-weight: 600; }

/* ---- episodes ---- */
.season-bar { display: flex; align-items: center; gap: 12px; margin: 26px 0 14px; }
.season-bar h3 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.season-select {
  margin-left: auto;
  background: var(--bg-card); color: var(--text);
  border: 1px solid rgba(255,255,255,.14); border-radius: 8px;
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 12px; cursor: pointer; outline: none;
}
.episode-list { display: flex; flex-direction: column; gap: 6px; }
.episode {
  display: flex; gap: 14px; align-items: center;
  padding: 10px; border-radius: 10px;
  cursor: pointer; transition: background .2s, transform .2s;
  text-align: left; width: 100%;
}
.episode:hover { background: rgba(255,255,255,.05); transform: translateX(4px); box-shadow: inset 3px 0 0 var(--accent); }
.episode.watched { opacity: .6; }
.ep-num { flex: 0 0 24px; text-align: center; font-size: 15px; font-weight: 700; color: var(--text-faint); }
.ep-thumb {
  flex: 0 0 clamp(92px, 16vw, 140px); aspect-ratio: 16/9;
  border-radius: 7px; overflow: hidden; background: var(--bg-card);
  position: relative;
}
.ep-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ep-thumb .play-ic {
  position: absolute; inset: 0; display: grid; place-items: center;
  opacity: 0; transition: opacity .2s; background: rgba(0,0,0,.4);
}
.episode:hover .play-ic { opacity: 1; }
.ep-thumb .play-ic svg { width: 30px; height: 30px; filter: drop-shadow(0 2px 8px rgba(0,0,0,.6)); }
.ep-info { min-width: 0; flex: 1; }
.ep-name { font-size: 14.5px; font-weight: 600; margin-bottom: 3px; display: flex; gap: 8px; align-items: baseline; }
.ep-name .ep-runtime { font-size: 12px; color: var(--text-faint); font-weight: 500; flex-shrink: 0; }
.ep-desc {
  font-size: 12.5px; color: var(--text-dim); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ep-progress { height: 3px; background: rgba(255,255,255,.15); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.ep-progress > i { display: block; height: 100%; background: var(--accent); }

/* ---- cast strip ---- */
.cast-strip { display: flex; gap: 14px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.cast-strip::-webkit-scrollbar { display: none; }
.cast-card { flex: 0 0 86px; text-align: center; transition: transform .2s; }
.cast-card:hover { transform: translateY(-2px); }
.cast-card img, .cast-card .cast-ph {
  width: 74px; height: 74px; border-radius: 50%; object-fit: cover; margin: 0 auto 7px;
  background: var(--bg-card); display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: var(--text-faint);
  border: 2px solid rgba(255,255,255,.06);
  transition: border-color .3s, box-shadow .3s;
}
.cast-card:hover img, .cast-card:hover .cast-ph {
  border-color: rgba(255,255,255,.18);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.cast-card .cast-name { font-size: 12px; font-weight: 600; line-height: 1.25; }
.cast-card .cast-role { font-size: 11px; color: var(--text-faint); line-height: 1.3; margin-top: 2px; }
.section-label { font-size: 16px; font-weight: 700; margin: 24px 0 12px; letter-spacing: -.01em; }

/* ============ Player ============ */
.player-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: #000;
  display: flex; flex-direction: column;
  animation: fadeIn .3s ease;
}
.player-close-zone { display: none; }
.player-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  padding: calc(10px + env(safe-area-inset-top)) 14px 26px;
  background: linear-gradient(to bottom, rgba(0,0,0,.75), transparent);
  opacity: 1; transition: opacity .4s;
  pointer-events: none;
}
.player-overlay.idle .player-top { opacity: 0; }
.player-back {
  display: inline-flex; align-items: center; gap: 10px;
  color: #fff; font-size: 15px; font-weight: 600;
  padding: 8px 12px; border-radius: 10px;
  pointer-events: auto;
  transition: background .2s;
}
.player-back:hover { background: rgba(255,255,255,.12); }
.player-back svg { width: 22px; height: 22px; }
.player-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.player-source {
  display: inline-flex; align-items: center; gap: 8px;
  pointer-events: auto;
  background: rgba(16,16,22,.72);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 6px 8px 6px 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text-dim);
}
.player-source svg { width: 16px; height: 16px; flex-shrink: 0; }
.player-source select {
  background: transparent; color: var(--text);
  border: 0; outline: none;
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; -webkit-appearance: none; appearance: none;
  padding-right: 4px;
}
.player-source select option { background: var(--bg-elev); color: var(--text); }
/* ---- smart source status indicator ---- */
.source-status {
  position: absolute; bottom: 14px; left: 50%; z-index: 6;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(10,10,14,.82);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px; padding: 7px 16px;
  font-size: 13px; font-weight: 600; color: var(--text);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  white-space: nowrap; pointer-events: auto;
  transition: opacity .4s, transform .3s;
  animation: ssIn .3s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes ssIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }
.source-status.ss-hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(8px); }
.player-overlay.idle .source-status:not(.ss-loading):not(.ss-switching):not(.ss-slow) { opacity: 0; pointer-events: none; }
.ss-spinner {
  width: 14px; height: 14px; flex-shrink: 0;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.2);
  border-top-color: var(--accent-hot);
  animation: twSpin .6s linear infinite;
}
.ss-dot {
  width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%;
  background: #46d369; box-shadow: 0 0 6px rgba(70,211,105,.5);
}
.ss-dot-dim { background: var(--text-faint); box-shadow: none; }
.ss-dim { color: var(--text-faint); font-weight: 500; }
.ss-text { display: flex; align-items: center; gap: 6px; }
.ss-loading { border-color: rgba(229,9,20,.3); }
.ss-slow { border-color: rgba(250,204,21,.25); }
.ss-slow .ss-spinner { border-top-color: #facc15; }
.ss-switching { border-color: rgba(96,165,250,.3); }
.ss-switching .ss-spinner { border-top-color: #60a5fa; }
.ss-error { border-color: rgba(239,68,68,.25); }
.ss-try-next {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2);
  color: var(--text); font-size: 12px; font-weight: 700;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
  transition: background .2s, transform .15s;
  margin-left: 2px;
}
.ss-try-next:hover { background: rgba(255,255,255,.24); }
.ss-try-next:active { transform: scale(.95); }

.player-frame-wrap { flex: 1; position: relative; }
.player-frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.click-shield {
  position: absolute; inset: 0; z-index: 2;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}

/* ============ Watch Together ============ */
.player-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---- Watch Together button (idle state) ---- */
.player-chip {
  display: inline-flex; align-items: center; gap: 8px;
  pointer-events: auto;
  background: rgba(16,16,22,.72);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px; font-weight: 600; color: var(--text);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: all .25s ease;
}
.player-chip:hover { background: rgba(40,40,52,.85); border-color: rgba(255,255,255,.32); transform: translateY(-1px); }
.player-chip svg { width: 16px; height: 16px; color: var(--text-dim); transition: color .2s; }
.player-chip:hover svg { color: var(--text); }

/* ---- active party chip with avatar stack ---- */
.together-chip {
  gap: 6px; padding: 5px 14px 5px 5px;
  border-color: rgba(70,211,105,.35);
  background: rgba(16,20,16,.78);
}
.together-chip:hover { border-color: rgba(70,211,105,.6); }
.tw-avatar-stack { display: flex; flex-shrink: 0; }
.tw-avatar-mini {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 800; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
  border: 2px solid rgba(16,20,16,.9);
  margin-left: -6px; position: relative;
}
.tw-avatar-mini:first-child { margin-left: 0; }
.tw-avatar-more { background: rgba(255,255,255,.18) !important; font-size: 9px; }
.tw-chip-text { display: flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }
.tw-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: #46d369; flex-shrink: 0;
  box-shadow: 0 0 6px rgba(70,211,105,.6);
  animation: twPulse 2s ease infinite;
}
@keyframes twPulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: .7; }
}

/* chip status colors */
.tw-chip-ok { border-color: rgba(70,211,105,.35); }
.tw-chip-ok .tw-live { background: #46d369; }
.tw-chip-warn { border-color: rgba(250,204,21,.4); }
.tw-chip-warn .tw-live { background: #facc15; box-shadow: 0 0 6px rgba(250,204,21,.5); }
.tw-chip-error { border-color: rgba(239,68,68,.4); }
.tw-chip-error .tw-live { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,.5); animation: none; }
.tw-chip-syncing { border-color: rgba(96,165,250,.4); }
.tw-chip-syncing .tw-live { background: #60a5fa; box-shadow: 0 0 6px rgba(96,165,250,.5); animation: twSpin .8s linear infinite; }
.tw-chip-paused { border-color: rgba(168,162,158,.35); }
.tw-chip-paused .tw-live { background: #a8a29e; box-shadow: none; animation: none; }

/* ---- host-paused cover (guest side) ---- */
.together-pause {
  position: absolute; inset: 0; z-index: 3;
  background: radial-gradient(ellipse at center, rgba(15,15,20,.95), #000);
  display: grid; place-items: center;
  animation: twPauseIn .4s ease;
}
@keyframes twPauseIn { from { opacity: 0; } }
.tw-pause-inner { text-align: center; padding: 24px; max-width: 440px; }
.tw-pause-inner img {
  width: 140px; border-radius: 14px; margin: 0 auto 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 80px rgba(229,9,20,.08);
}
.tw-pause-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  animation: twPauseBreath 2.5s ease infinite;
}
@keyframes twPauseBreath { 0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,.08); } 50% { box-shadow: 0 0 0 12px rgba(255,255,255,0); } }
.tw-pause-icon svg { width: 24px; height: 24px; }
.tw-pause-inner h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 8px; }
.tw-pause-inner p { color: var(--text-dim); font-size: 14.5px; line-height: 1.55; margin-bottom: 20px; }
.tw-pause-wave {
  display: flex; gap: 5px; justify-content: center; height: 20px; align-items: end;
}
.tw-pause-wave span {
  width: 4px; border-radius: 2px;
  background: rgba(255,255,255,.25);
  animation: twWave 1.2s ease infinite;
}
.tw-pause-wave span:nth-child(1) { animation-delay: 0s; }
.tw-pause-wave span:nth-child(2) { animation-delay: .15s; }
.tw-pause-wave span:nth-child(3) { animation-delay: .3s; }
.tw-pause-wave span:nth-child(4) { animation-delay: .45s; }
.tw-pause-wave span:nth-child(5) { animation-delay: .6s; }
@keyframes twWave {
  0%,100% { height: 6px; opacity: .4; }
  50% { height: 18px; opacity: 1; }
}

/* ---- floating reactions ---- */
.reaction-layer { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.reaction-float {
  position: absolute; bottom: 90px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  animation: reactionRise 3s cubic-bezier(.2,.8,.3,1) both;
  --rot: 0deg;
}
.reaction-float .reaction-emoji {
  font-size: 44px;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,.5));
  animation: reactionWiggle 3s ease both;
}
.reaction-float .reaction-name {
  font-size: 11px; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.6); padding: 3px 10px; border-radius: 999px;
  backdrop-filter: blur(6px);
}
@keyframes reactionRise {
  0% { opacity: 0; transform: translateY(30px) scale(.5) rotate(0); }
  8% { opacity: 1; transform: translateY(0) scale(1.15) rotate(var(--rot)); }
  100% { opacity: 0; transform: translateY(-52vh) scale(.9) rotate(var(--rot)); }
}
@keyframes reactionWiggle {
  0%,100% { transform: rotate(0); }
  15% { transform: rotate(-8deg); }
  30% { transform: rotate(6deg); }
  45% { transform: rotate(-4deg); }
  60% { transform: rotate(0); }
}

/* reaction bar */
.reaction-bar {
  position: absolute; right: 14px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 6;
  display: flex; gap: 3px;
  background: rgba(12,12,16,.8);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px; padding: 5px 8px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  opacity: 1; transition: opacity .4s, transform .3s;
  transform: translateY(0);
}
.player-overlay.idle .reaction-bar { opacity: 0; pointer-events: none; transform: translateY(8px); }
.reaction-btn {
  font-size: 22px; padding: 6px 7px; border-radius: 50%;
  transition: transform .2s cubic-bezier(.2,.9,.3,1.2), background .2s;
  -webkit-tap-highlight-color: transparent;
}
.reaction-btn:hover { background: rgba(255,255,255,.12); transform: scale(1.25); }
.reaction-btn:active { transform: scale(.85); }
.reaction-pop { animation: reactionBtnPop .3s cubic-bezier(.2,.9,.3,1.3); }
@keyframes reactionBtnPop { 0% { transform: scale(1); } 40% { transform: scale(1.4); } 100% { transform: scale(1); } }

/* ---- Watch Together modal ---- */
.together-backdrop { z-index: 390; align-items: center; padding: 20px; }
.together-modal {
  max-width: 480px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(170deg, rgba(26,26,34,.98), rgba(18,18,24,.99));
  overflow: hidden;
}

/* header */
.tw-header {
  display: flex; align-items: center; gap: 14px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.tw-header-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 12px; display: grid; place-items: center;
  background: rgba(229,9,20,.12); border: 1px solid rgba(229,9,20,.2);
}
.tw-header-icon svg { width: 22px; height: 22px; color: var(--accent-hot); }
.tw-header-icon-glow { box-shadow: 0 0 30px rgba(229,9,20,.15); }
.tw-title { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.tw-title-sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* create view */
.tw-desc { color: var(--text-dim); font-size: 14px; line-height: 1.55; padding: 18px 28px 0; margin: 0; }
.tw-input-label {
  display: block; font-size: 12px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint); padding: 16px 28px 6px;
}
.tw-name-input {
  display: block; width: calc(100% - 56px); margin: 0 28px;
  background: rgba(255,255,255,.06); color: var(--text);
  border: 1px solid rgba(255,255,255,.14); border-radius: 10px;
  padding: 12px 14px; font-size: 15px; font-weight: 500;
  outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.tw-name-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(229,9,20,.12); background: rgba(255,255,255,.08); }
.tw-name-input::placeholder { color: var(--text-faint); }
.tw-create-btn {
  display: flex; width: calc(100% - 56px); margin: 14px 28px; justify-content: center;
  padding: 14px; font-size: 15px; gap: 10px;
}
.tw-create-btn svg { width: 20px; height: 20px; }
.tw-privacy { color: var(--text-faint); font-size: 12px; padding: 0 28px 24px; line-height: 1.5; margin: 0; }
.tw-btn-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  animation: twSpin .6s linear infinite; flex-shrink: 0;
}
@keyframes twSpin { to { transform: rotate(360deg); } }
.tw-shake { animation: twShake .4s ease; }
@keyframes twShake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

/* invite section */
.tw-invite-section { padding: 16px 28px 0; }
.tw-invite-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px; }
.tw-linkrow { display: flex; gap: 8px; flex-wrap: wrap; }
.tw-linkrow input {
  flex: 1 1 180px; min-width: 0;
  background: rgba(255,255,255,.06); color: var(--text-dim);
  border: 1px solid rgba(255,255,255,.12); border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px;
  font-family: ui-monospace, monospace;
  outline: none;
}
.tw-linkrow input:focus { border-color: var(--accent); }
.tw-copy-btn { gap: 6px; padding: 10px 16px; font-size: 13px; }
.tw-copy-btn svg { width: 15px; height: 15px; }
.tw-copied { background: #46d369 !important; box-shadow: 0 4px 16px rgba(70,211,105,.3) !important; }
.tw-share-btn { gap: 6px; padding: 10px 14px; font-size: 13px; }
.tw-share-btn svg { width: 15px; height: 15px; }

/* people list */
.tw-people { padding: 18px 28px 0; }
.tw-people-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 12px;
}
.tw-people-count {
  background: rgba(255,255,255,.1); padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 800;
}
.tw-peers { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.tw-peer {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  transition: background .15s;
}
.tw-peer:hover { background: rgba(255,255,255,.04); }
.tw-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  font-size: 12px; font-weight: 800; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.tw-peer-name { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-badge {
  font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,.08); color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .04em;
}
.tw-badge-host { background: rgba(229,9,20,.15); color: var(--accent-hot); }

/* guest controls */
.tw-guest-controls { padding: 14px 28px 0; }
.tw-resync-btn { width: 100%; justify-content: center; gap: 8px; padding: 11px; font-size: 14px; }
.tw-resync-btn svg { width: 16px; height: 16px; }

/* actions */
.tw-actions { padding: 14px 28px 24px; }
.tw-leave-btn {
  width: 100%; justify-content: center; gap: 8px; padding: 11px; font-size: 14px;
  background: rgba(239,68,68,.1); color: #ef4444;
  border: 1px solid rgba(239,68,68,.2); border-radius: 8px;
}
.tw-leave-btn:hover { background: rgba(239,68,68,.18); border-color: rgba(239,68,68,.35); }
.tw-leave-btn svg { width: 16px; height: 16px; }

/* ---- join screen ---- */
.join-modal { text-align: center; max-width: 420px; }
.tw-join-screen {
  display: flex; flex-direction: column; align-items: center;
  padding: clamp(28px, 6vw, 48px) clamp(20px, 5vw, 36px);
}

/* connecting loader */
.tw-join-loader { margin-bottom: 24px; }
.tw-orbit {
  width: 52px; height: 52px; position: relative;
  animation: twSpin 2.5s linear infinite;
}
.tw-orbit span {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); opacity: .8;
}
.tw-orbit span:nth-child(1) { top: 0; left: 50%; transform: translateX(-50%); animation: twOrbitDot 2.5s ease infinite; }
.tw-orbit span:nth-child(2) { bottom: 6px; left: 6px; opacity: .5; animation: twOrbitDot 2.5s ease .8s infinite; }
.tw-orbit span:nth-child(3) { bottom: 6px; right: 6px; opacity: .3; animation: twOrbitDot 2.5s ease 1.6s infinite; }
@keyframes twOrbitDot { 0%,100% { transform: scale(1); } 50% { transform: scale(.5); opacity: .3; } }

/* error icon */
.tw-join-icon { width: 52px; height: 52px; margin-bottom: 20px; border-radius: 50%; display: grid; place-items: center; }
.tw-join-icon svg { width: 28px; height: 28px; }
.tw-join-icon-err { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.25); }
.tw-join-icon-err svg { color: #ef4444; }

/* found screen */
.tw-join-found { gap: 2px; }
.tw-join-poster-wrap { position: relative; margin-bottom: 20px; }
.tw-join-poster {
  width: 120px; border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
  animation: twPosterIn .5s cubic-bezier(.2,.9,.3,1.1) both;
}
@keyframes twPosterIn { from { opacity: 0; transform: scale(.85) translateY(10px); } }
.tw-join-poster-glow {
  position: absolute; inset: -30%; z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(229,9,20,.15), transparent 70%);
  animation: twGlowPulse 3s ease infinite;
}
@keyframes twGlowPulse { 0%,100% { opacity: .6; transform: scale(1); } 50% { opacity: 1; transform: scale(1.1); } }
.tw-join-host-avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-size: 14px; font-weight: 800; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
  margin-bottom: 10px;
  border: 2px solid rgba(255,255,255,.15);
}
.tw-join-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 4px; }
.tw-join-sub { color: var(--text-dim); font-size: 14.5px; line-height: 1.5; margin-bottom: 4px; }
.tw-join-sub b { color: var(--text); }
.tw-join-status { font-size: 12.5px; color: var(--text-faint); margin-bottom: 18px; }
.tw-join-found .tw-name-input { width: 100%; max-width: 260px; margin: 0 0 12px; text-align: center; }
.tw-join-btn { gap: 8px; padding: 14px 28px; font-size: 15px; width: 100%; max-width: 300px; justify-content: center; }
.tw-join-btn svg { width: 18px; height: 18px; }
.tw-decline { margin-top: 16px; font-size: 13px; color: var(--text-faint); padding: 8px 16px; border-radius: 8px; transition: color .2s, background .2s; }
.tw-decline:hover { color: var(--text-dim); background: rgba(255,255,255,.06); }

/* ---- responsive ---- */
@media (max-width: 760px) {
  .tw-btn-label { display: none; }
  .player-chip { padding: 8px 11px; }
  .together-chip { padding: 4px 10px 4px 4px; }
  .tw-avatar-mini { width: 22px; height: 22px; font-size: 8px; }
  .tw-chip-text { font-size: 12px; }
  .reaction-bar { right: 8px; }
  .reaction-btn { font-size: 20px; padding: 5px 6px; }
  .together-modal { margin: 0; border-radius: 14px 14px 0 0; align-self: flex-end; }
  .tw-header { padding: 20px 20px 14px; }
  .tw-invite-section, .tw-people, .tw-guest-controls { padding-left: 20px; padding-right: 20px; }
  .tw-actions { padding: 14px 20px 20px; }
  .tw-name-input { width: calc(100% - 40px); margin-left: 20px; margin-right: 20px; }
  .tw-create-btn { width: calc(100% - 40px); margin-left: 20px; margin-right: 20px; }
  .tw-privacy { padding-left: 20px; padding-right: 20px; }
  .tw-desc { padding-left: 20px; padding-right: 20px; }
  .tw-input-label { padding-left: 20px; }
}

/* ============ Setup modal ============ */
.setup-backdrop { z-index: 400; align-items: center; padding: 20px; }
.setup-modal {
  max-width: 520px; padding: clamp(28px, 5vw, 44px);
  border: 1px solid rgba(255,255,255,.06);
  background: linear-gradient(175deg, rgba(22,22,29,.99), rgba(14,14,19,.99));
}
.setup-logo { width: 48px; height: 48px; margin-bottom: 20px; filter: drop-shadow(0 4px 16px rgba(229,9,20,.3)); }
.setup-header h1 { font-size: 28px; font-weight: 500; letter-spacing: -.025em; margin-bottom: 10px; }
.setup-header h1 b { color: var(--accent-hot); font-weight: 800; }
.setup-sub { color: var(--text-dim); font-size: 14.5px; line-height: 1.55; margin-bottom: 20px; }
.setup-steps { margin: 0 0 22px 18px; display: flex; flex-direction: column; gap: 9px; font-size: 14px; color: #d4d4d8; line-height: 1.5; }
.setup-form { display: flex; gap: 10px; flex-wrap: wrap; }
.setup-form input {
  flex: 1 1 220px;
  background: var(--bg); color: var(--text);
  border: 1px solid rgba(255,255,255,.16); border-radius: 8px;
  padding: 12px 14px; font-size: 14px; font-family: ui-monospace, monospace;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.setup-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(229,9,20,.15); }
.setup-error { color: #ff6b6b; font-size: 13.5px; margin-top: 12px; }
.setup-note { color: var(--text-faint); font-size: 12.5px; margin-top: 16px; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: calc(28px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  z-index: 500;
  background: rgba(20,20,28,.92); color: var(--text);
  border: 1px solid rgba(255,255,255,.1);
  padding: 13px 24px; border-radius: 999px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 16px 48px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.04), 0 0 60px rgba(229,9,20,.04);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  animation: toastIn .35s cubic-bezier(.2,.9,.3,1.15);
  max-width: calc(100vw - 40px); text-align: center;
}
.toast.toast-out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px) scale(.92); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, -8px) scale(.95); } }

/* ============ Mobile tab bar ============ */
.tabbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
  background: rgba(10,10,14,.9);
  backdrop-filter: saturate(180%) blur(28px); -webkit-backdrop-filter: saturate(180%) blur(28px);
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(0,0,0,.3);
}
.tabbar-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 0 5px; color: var(--text-faint);
  font-size: 10px; font-weight: 600; letter-spacing: .02em;
  border-radius: 12px; transition: color .2s, transform .2s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.tabbar-btn:active { transform: scale(.9); }
.tabbar-btn svg { width: 22px; height: 22px; transition: transform .25s cubic-bezier(.2,.9,.3,1.2); }
.tabbar-btn.active { color: var(--text); }
.tabbar-btn.active svg { color: var(--accent-hot); transform: scale(1.1); }
.tabbar-btn.active::after {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 20px; height: 2px; border-radius: 1px;
  background: var(--accent-hot);
  box-shadow: 0 0 8px rgba(229,9,20,.5);
}

/* ============ Responsive tweaks ============ */
@media (max-width: 760px) {
  :root { --nav-h: 56px; --card-w: clamp(112px, 30vw, 150px); }
  .nav-tabs { display: none; }
  .tabbar { display: flex; }
  .nav-inner { gap: 12px; }
  .brand span { display: none; }
  .brand-mark { width: 30px; height: 30px; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; font-size: 16px; }
  .setup-form input { font-size: 16px; }
  .hero { height: clamp(380px, 58vh, 520px); }
  .hero-actions .btn { flex: 1; justify-content: center; }
  .hero-actions { width: 100%; }
  #rows { padding-bottom: 110px; }
  .grid-view { padding-bottom: 120px; }
  .episode { padding: 8px 4px; }
  .ep-num { flex-basis: 18px; font-size: 13px; }
  .player-back { padding: 10px 14px; font-size: 16px; }
  .player-back svg { width: 26px; height: 26px; }
  .modal-close { width: 44px; height: 44px; font-size: 24px; }
  .player-close-zone {
    display: block;
    position: absolute; top: 0; left: 0; right: 0; z-index: 4;
    height: calc(54px + env(safe-area-inset-top));
    -webkit-tap-highlight-color: transparent;
  }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .source-status { bottom: calc(16px + env(safe-area-inset-bottom)); font-size: 12px; padding: 6px 12px; }
}

/* ============ Page transitions ============ */
#main { transition: opacity .25s ease; }
#main.switching { opacity: 0; transform: translateY(6px); transition: opacity .15s, transform .15s; }

/* subtle scrollbar on desktop for modals */
@media (hover: hover) {
  .modal-backdrop::-webkit-scrollbar { width: 6px; }
  .modal-backdrop::-webkit-scrollbar-track { background: transparent; }
  .modal-backdrop::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
  .modal-backdrop::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }
}

/* ============ Focus styles ============ */
:focus-visible { outline: 2px solid var(--accent-hot); outline-offset: 2px; }
button:focus-visible, .card:focus-visible { outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .row { opacity: 1; transform: none; }
  .row .card, .poster-grid .card { opacity: 1; }
}
