:root {
  --bg: #0b0b0f;
  --bg-elev: #16161d;
  --bg-soft: #1c1c26;
  --text: #f4f4f7;
  --text-muted: #9b9ba8;
  --border: rgba(255,255,255,0.08);
  --accent: #e50914;
  --accent-soft: rgba(229,9,20,0.18);
  --accent-press: #ff4d55;
  --danger: #ff6b6b;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 12px 40px rgba(0,0,0,0.45);
  --header-h: 148px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #14121a;
    --bg-elev: #1e1c28;
    --bg-soft: #262433;
    --text: #f7f6fb;
    --text-muted: #a8a6b8;
    --border: rgba(255,255,255,0.1);
    --accent: #e85c42;
    --accent-soft: rgba(232,92,66,0.2);
    --accent-press: #ff7a62;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 50% -10%, #2a1220 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(96px + var(--safe-bottom));
}
button, input, textarea, select {
  font: inherit; color: inherit; background: transparent; border: 0; outline: none;
}
button { cursor: pointer; }
.muted { color: var(--text-muted); }
.hidden { display: none !important; }

.app-header {
  position: sticky; top: 0; z-index: 20;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: linear-gradient(180deg, rgba(11,11,15,0.96), rgba(11,11,15,0.82));
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.app-header.scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.header-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.header-actions { display: flex; align-items: center; gap: 8px; }
#header-title {
  margin: 0; font-size: 1.55rem; font-weight: 800; letter-spacing: -0.03em;
}
.status-pill {
  font-size: 0.72rem; font-weight: 700; padding: 6px 10px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-muted); border: 1px solid var(--border);
}
.status-pill.online { color: #7dffa3; background: rgba(40,180,90,0.15); }
.status-pill.offline { color: #ffb4b4; background: rgba(220,60,60,0.15); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; background: var(--bg-soft);
  display: grid; place-items: center; font-size: 1.1rem;
}
.search-wrap { margin-top: 10px; }
.search-wrap input {
  width: 100%; min-height: 44px; border-radius: 14px; padding: 0 14px;
  background: var(--bg-elev); border: 1px solid var(--border);
}
.filters {
  display: flex; gap: 8px; overflow-x: auto; margin-top: 10px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--border); font-weight: 700; font-size: 0.86rem;
  color: var(--text-muted);
}
.chip.active { background: #fff; color: #111; border-color: #fff; }

main { padding: 8px 0 24px; }
.list { padding: 0 0 8px; }

.join-banner {
  margin: 10px 16px 0; padding: 14px; border-radius: var(--radius);
  background: var(--accent-soft); display: flex; flex-direction: column; gap: 12px;
}
.join-banner-text { display: flex; flex-direction: column; gap: 4px; }
.join-banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.join-banner-actions .btn { flex: 1 1 auto; min-height: 44px; }

.confirm-banner {
  margin: 8px 16px 12px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent-press); font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.confirm-banner button {
  min-height: 40px; padding: 0 14px; border-radius: 12px;
  background: var(--accent); color: #fff; font-weight: 700;
}

/* Hero */
.movie-hero {
  margin: 4px 16px 18px; position: relative; border-radius: 20px; overflow: hidden;
  min-height: 220px; background: var(--bg-soft); box-shadow: var(--shadow);
}
.movie-hero img.hero-backdrop {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55;
}
.movie-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 20%, rgba(0,0,0,0.85) 100%);
}
.movie-hero-inner {
  position: relative; z-index: 1; display: flex; gap: 14px; padding: 18px; align-items: flex-end;
  min-height: 220px;
}
.movie-hero .hero-poster {
  width: 96px; flex: 0 0 96px; aspect-ratio: 2/3; border-radius: 10px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); background: #222;
}
.movie-hero .hero-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.movie-hero .hero-meta { flex: 1; min-width: 0; }
.movie-hero .eyebrow { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #ffd0d0; }
.movie-hero h2 { margin: 4px 0 6px; font-size: 1.35rem; letter-spacing: -0.02em; }
.movie-hero .hero-sub { font-size: 0.88rem; color: var(--text-muted); }

/* Rails */
.movie-sections { display: flex; flex-direction: column; gap: 22px; }
.movie-row-title {
  margin: 0 16px 10px; font-size: 1.08rem; font-weight: 800; letter-spacing: -0.02em;
}
.poster-rail {
  display: flex; gap: 12px; overflow-x: auto; padding: 0 16px 6px;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.poster-rail::-webkit-scrollbar { display: none; }
.poster-card {
  flex: 0 0 118px; width: 118px; scroll-snap-align: start;
  background: transparent; text-align: left; padding: 0;
}
.poster-art {
  position: relative; aspect-ratio: 2/3; border-radius: 12px; overflow: hidden;
  background: linear-gradient(160deg, #2a2a36, #15151c);
  box-shadow: 0 10px 28px rgba(0,0,0,0.4);
}
.poster-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-art.dimmed { opacity: 0.55; filter: grayscale(0.25); }
.poster-ph {
  width: 100%; height: 100%; display: grid; place-items: center; padding: 10px;
  text-align: center; font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
}
.poster-badge {
  position: absolute; top: 8px; left: 8px; z-index: 1;
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.04em;
  padding: 4px 7px; border-radius: 6px; background: rgba(0,0,0,0.75); color: #fff;
}
.poster-card .poster-title {
  margin-top: 8px; font-size: 0.82rem; font-weight: 700; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.poster-card .poster-year { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.skeleton-rail { display: flex; gap: 12px; padding: 0 16px; }
.skeleton-card {
  flex: 0 0 118px; aspect-ratio: 2/3; border-radius: 12px;
  background: linear-gradient(90deg, #1a1a22 0%, #2a2a36 50%, #1a1a22 100%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.empty {
  margin: 40px 24px; text-align: center; color: var(--text-muted);
  display: flex; flex-direction: column; gap: 8px;
}
.empty strong { color: var(--text); font-size: 1.1rem; }

.fab {
  position: fixed; right: 18px; bottom: calc(22px + var(--safe-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 1.8rem; font-weight: 500;
  box-shadow: 0 12px 30px rgba(229,9,20,0.45); z-index: 30;
}

.btn {
  min-height: 48px; padding: 0 16px; border-radius: 14px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg-soft); border: 1px solid var(--border); }
.btn-danger { background: rgba(255,80,80,0.15); color: var(--danger); }
.btn:disabled { opacity: 0.5; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.row-btns .btn { flex: 1 1 auto; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; min-height: 48px; border-radius: 14px; padding: 12px 14px;
  background: var(--bg-elev); border: 1px solid var(--border);
}
.field textarea { min-height: 100px; resize: vertical; }
.check-row {
  display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600;
}
.check-row input { width: 22px; height: 22px; accent-color: var(--accent); }

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); opacity: 0;
  pointer-events: none; transition: opacity .22s ease; z-index: 40;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-height: min(92vh, 900px); background: var(--bg-elev);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  transform: translateY(110%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column;
}
.sheet.open { transform: translateY(0); }
.sheet-compact { max-height: 46vh; }
.sheet-handle {
  width: 42px; height: 5px; border-radius: 999px; background: rgba(255,255,255,0.18);
  margin: 10px auto 0;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 8px;
}
.sheet-header h2 { margin: 0; font-size: 1.15rem; }
.sheet-body {
  padding: 4px 16px calc(20px + var(--safe-bottom));
  overflow: auto; -webkit-overflow-scrolling: touch;
}

.chooser-body { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.chooser-btn {
  display: flex; gap: 14px; align-items: center; text-align: left;
  padding: 14px; border-radius: 16px; background: var(--bg-soft); border: 1px solid var(--border);
}
.chooser-btn strong { display: block; font-size: 1.05rem; }
.chooser-btn small { display: block; margin-top: 2px; }
.chooser-icon { font-size: 1.5rem; width: 44px; height: 44px; display: grid; place-items: center; background: var(--bg-elev); border-radius: 12px; }

.sync-box {
  background: var(--bg-soft); border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.import-preview-list { display: flex; flex-direction: column; gap: 8px; }
.import-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-soft);
}
.import-row .title { font-weight: 700; }
.import-row .meta { color: var(--text-muted); font-size: 0.82rem; }
.import-row .include-row { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.import-progress {
  margin-bottom: 12px; padding: 10px 12px; border-radius: 12px;
  background: var(--accent-soft); font-weight: 700; font-size: 0.9rem;
}

.picker-list { display: flex; flex-direction: column; gap: 8px; }
.picker-row {
  display: flex; gap: 12px; align-items: center; text-align: left;
  padding: 10px; border-radius: 14px; background: var(--bg-soft); border: 1px solid var(--border);
}
.picker-row img, .picker-ph {
  width: 48px; height: 72px; border-radius: 8px; object-fit: cover; background: #222; flex: 0 0 48px;
}
.picker-ph { display: grid; place-items: center; font-size: 0.55rem; padding: 4px; text-align: center; }
.picker-row .title { font-weight: 700; }

/* Detail */
.detail-hero {
  position: relative; margin: -4px -16px 14px; min-height: 200px; overflow: hidden;
  background: #111;
}
.detail-hero img.backdrop {
  width: 100%; height: 220px; object-fit: cover; display: block; opacity: 0.65;
}
.detail-hero-fade {
  position: absolute; inset: auto 0 0 0; height: 100px;
  background: linear-gradient(180deg, transparent, var(--bg-elev));
}
.detail-top {
  display: flex; gap: 14px; margin-top: -72px; position: relative; z-index: 1; padding: 0 2px;
}
.detail-poster {
  width: 110px; flex: 0 0 110px; aspect-ratio: 2/3; border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow); background: #222;
}
.detail-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-top.no-backdrop { margin-top: 0; }
.detail-top.no-backdrop .detail-title-block { padding-top: 0; }
.detail-title-block { flex: 1; min-width: 0; padding-top: 48px; }
.hero-backdrop[data-broken], .poster-art img[data-broken] { display: none; }

.detail-title-block h2 { margin: 0 0 6px; font-size: 1.4rem; letter-spacing: -0.02em; }
.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tag {
  display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  background: var(--bg-soft); color: var(--text-muted); border: 1px solid var(--border);
}
.detail-section { margin-top: 16px; }
.detail-section h3 { margin: 0 0 8px; font-size: 0.95rem; }
.stars { display: flex; gap: 6px; }
.stars button {
  width: 40px; height: 40px; border-radius: 10px; background: var(--bg-soft); font-size: 1.15rem;
}
.stars button.on { background: rgba(255,200,60,0.2); }
.provider-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.provider-logo {
  width: 42px; height: 42px; border-radius: 10px; object-fit: cover; background: #222;
  border: 1px solid var(--border);
}
.provider-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--border); font-size: 0.8rem; font-weight: 600;
}

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%) translateY(12px);
  background: #fafafa; color: #111; padding: 12px 16px; border-radius: 14px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: .22s ease; z-index: 80; max-width: min(92vw, 360px);
  box-shadow: var(--shadow); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.link-out { color: var(--accent-press); font-weight: 700; text-decoration: none; }
