:root {
  --bg: #0b0b0d;
  --panel: #16161a;
  --line: #26262c;
  --text: #ececf0;
  --muted: #9a9aa6;
  --accent: #e50914;
  --radius: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { display: block; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 28px;
  padding: 14px 4vw;
  background: linear-gradient(#000d, #0000);
  backdrop-filter: blur(6px);
}
.logo { color: var(--accent); font-weight: 900; font-size: 26px; letter-spacing: 1px; text-transform: uppercase; line-height: 1;
  transition: color .3s; -webkit-background-clip: text; background-clip: text; }
.top nav { display: flex; gap: 18px; font-size: 14px; color: #ccc; }
.top nav a:hover { color: #fff; }
.search { margin-left: auto; }
.search input {
  width: 260px; padding: 8px 12px; border-radius: 4px;
  background: #000a; border: 1px solid #555; color: #fff; font: inherit;
}
.search input:focus { outline: none; border-color: #fff; }

/* hero */
.hero {
  position: relative; min-height: 70vh; margin-top: -64px;
  display: flex; align-items: flex-end; padding: 120px 4vw 48px;
  background-color: var(--bg);
  background-image: linear-gradient(90deg, #0b0b0d 0%, #0b0b0dcc 35%, #0b0b0d00 70%), linear-gradient(0deg, #0b0b0d 0%, #0b0b0d00 40%), var(--hero, none);
  background-size: cover; background-position: center top; background-repeat: no-repeat;
}
.hero.detail { min-height: 78vh; }
.hero-in { max-width: 620px; }
.hero h1 { font-size: clamp(32px, 5vw, 56px); line-height: 1.05; margin: 0 0 12px; }
.hero-logo { max-width: min(420px, 80vw); max-height: 160px; object-fit: contain; object-position: left; margin-bottom: 16px; }
.meta { color: #d6d6dc; margin: 0 0 6px; font-weight: 500; }
.meta .imdb { margin-left: 10px; color: #f5c518; font-size: 13px; }
.genres { color: var(--muted); margin: 0 0 10px; font-size: 14px; }
.desc { color: #ddd; margin: 0 0 20px; max-width: 58ch; }
.credits { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; color: var(--muted); margin: 22px 0 0; }
.credits dt { color: #777; }
.credits dd { margin: 0; color: #bbb; }

/* buttons */
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline { display: inline; margin: 0; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 4px; border: 0; cursor: pointer;
  background: #6d6d6eb3; color: #fff; font: 600 15px/1 inherit; font-family: inherit;
}
.btn:hover { background: #6d6d6e80; }
.btn.play { background: #fff; color: #000; }
.btn.play:hover { background: #ffffffcc; }
.btn.ghost { background: transparent; border: 1px solid #555; color: #bbb; }
.btn.small { padding: 6px 12px; font-size: 13px; vertical-align: middle; margin-left: 12px; }

/* rows */
.row { padding: 0 4vw; margin: 28px 0; }
.row h2 { font-size: 19px; margin: 0 0 10px; }
.row h2 a { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 8px; }
.row h2 a:hover { color: #fff; }
.strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: 160px; gap: 10px;
  overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity;
  scrollbar-width: thin; scrollbar-color: #333 transparent;
}
.strip .card { scroll-snap-align: start; }

/* cards */
.card { display: block; transition: transform .15s ease; }
.card:hover { transform: scale(1.04); }
.poster { position: relative; aspect-ratio: 2/3; border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.noposter { display: grid; place-items: center; height: 100%; padding: 12px; text-align: center; color: var(--muted); font-size: 14px; }
.badge { position: absolute; left: 6px; bottom: 6px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 3px; }
.cap { padding: 6px 2px 0; }
.cap strong { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap span { font-size: 12px; color: var(--muted); }

/* pages */
.page { padding: 20px 4vw 60px; }
.page-title { font-size: 28px; margin: 10px 0 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 14px; }
.empty { color: var(--muted); padding: 40px 4vw; }
.empty a { color: #fff; text-decoration: underline; }

/* episodes */
.episodes { max-width: 1000px; }
.season-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.season-bar h2 { margin: 0; font-size: 22px; }
.season-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.season-tabs a { padding: 6px 12px; border-radius: 4px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: #ccc; }
.season-tabs a.on, .season-tabs a:hover { background: #fff; color: #000; }
.eps { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.eps li { border-bottom: 1px solid var(--line); }
.eps li a { display: grid; grid-template-columns: 36px 180px 1fr; gap: 16px; align-items: center; padding: 16px 12px; border-radius: var(--radius); }
.eps li a:hover { background: var(--panel); }
.eps .num { font-size: 22px; color: var(--muted); text-align: center; }
.eps .thumb { position: relative; aspect-ratio: 16/9; background: #222; border-radius: 4px; overflow: hidden; }
.eps .thumb img { width: 100%; height: 100%; object-fit: cover; }
.eps .pi { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; opacity: 0; background: #0008; transition: opacity .15s; }
.eps li a:hover .pi { opacity: 1; }
.eps .info strong { display: block; }
.eps .info small { color: var(--muted); }
.eps .info p { margin: 4px 0 0; color: #bbb; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.eps li.seen .thumb::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--accent); }
.eps li.last { background: #ffffff08; }
.eps li.last .num { color: var(--accent); }
.eps li.future { opacity: .55; }

@media (max-width: 700px) {
  .top { flex-wrap: wrap; gap: 10px 18px; padding: 12px 16px; }
  .search { margin-left: 0; width: 100%; }
  .search input { width: 100%; }
  .hero { min-height: 60vh; padding: 140px 16px 32px; margin-top: -110px; }
  .row, .page { padding-left: 16px; padding-right: 16px; }
  .strip { grid-auto-columns: 120px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .eps li a { grid-template-columns: 110px 1fr; }
  .eps .num { display: none; }
}

/* where to watch */
.wtw { margin-top: 22px; display: grid; gap: 10px; }
.wtw-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wtw-label { font-size: 13px; color: var(--muted); min-width: 120px; }
.prov {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  background: #ffffff14; border: 1px solid #ffffff1f; border-radius: 6px; font-size: 13px;
}
.prov:hover { background: #ffffff26; }
.prov img { width: 26px; height: 26px; border-radius: 5px; }
.prov em { font-style: normal; color: var(--muted); margin-left: 2px; }
.wtw-src { font-size: 11px; color: #777; }
.wtw-src:hover { color: #bbb; }
.wtw-none { font-size: 13px; color: var(--muted); }
@media (max-width: 700px) { .wtw-label { min-width: 100%; } }

/* row arrows */
.strip-wrap { position: relative; }
.arrow {
  position: absolute; top: 0; bottom: 52px; z-index: 2; width: 44px; border: 0; cursor: pointer;
  background: #000a; color: #fff; font-size: 34px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.arrow.left { left: -4vw; border-radius: 0 6px 6px 0; }
.arrow.right { right: -4vw; border-radius: 6px 0 0 6px; }
.row.can-left:hover .arrow.left, .row.can-right:hover .arrow.right { opacity: 1; pointer-events: auto; }
.arrow:hover { background: #000d; }
.strip { scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
@media (hover: none) { .arrow { display: none; } .strip { scrollbar-width: thin; } }

/* browse */
.filters { display: grid; gap: 10px; margin-bottom: 26px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips a { padding: 5px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: #ccc; }
.chips a:hover { border-color: #666; color: #fff; }
.chips a.on { background: #fff; color: #000; border-color: #fff; }
.pager { display: flex; justify-content: center; gap: 12px; margin-top: 36px; }

/* loading skeleton for rows */
.card.skel .poster { background: linear-gradient(100deg, #18181c 30%, #232329 50%, #18181c 70%) 0 0 / 300% 100%; animation: skel 1.4s infinite linear; }
@keyframes skel { to { background-position: -150% 0; } }

/* user menu */
.user { display: flex; align-items: center; gap: 14px; font-size: 14px; color: #ccc; }
.user a:hover { color: #fff; }
.user form { margin: 0; }
.user button { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.user button:hover { color: #fff; }

/* auth pages */
body.auth { min-height: 100vh; display: grid; place-content: center; gap: 24px; padding: 24px 16px;
  background: radial-gradient(ellipse at top, #2a0a0d 0%, var(--bg) 60%); }
body.auth > .logo { text-align: center; font-size: 34px; }
.auth-box { width: min(380px, calc(100vw - 32px)); background: #000c; border: 1px solid var(--line); border-radius: 10px; padding: 32px; }
.auth-box h1 { margin: 0 0 18px; font-size: 26px; }
.auth-box h2 { font-size: 16px; margin: 6px 0 2px; }
.auth-box form { display: grid; gap: 14px; }
.auth-box label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-box .btn { justify-content: center; margin-top: 6px; }
.auth-box a { text-decoration: underline; }
input:not([type=checkbox]), select {
  padding: 10px 12px; border-radius: 4px; background: #222228; border: 1px solid #3a3a42; color: #fff; font: inherit;
}
input:focus, select:focus { outline: none; border-color: #888; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.error, .ok { padding: 10px 12px; border-radius: 4px; font-size: 14px; margin: 0 0 14px; }
.error { background: #e5091422; border: 1px solid #e5091466; color: #ffb3b6; }
.ok { background: #1db95422; border: 1px solid #1db95466; color: #a6f0c0; }
.error-text { color: #ff6b72; } .ok-text { color: #5fd88a; }
.muted { color: var(--muted); } .small { font-size: 12px; }

/* admin */
.admin .tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.admin .tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin .tabs a:hover { color: #fff; }
.admin .tabs a.on { color: #fff; border-bottom-color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 2px; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat strong { font-size: 28px; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; overflow-x: auto; }
.panel h2 { font-size: 15px; margin: 0 0 12px; }
.panel table { width: 100%; border-collapse: collapse; font-size: 14px; }
.panel td, .panel th { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.panel tr:last-child td { border-bottom: 0; }
.panel th { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.panel .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.panel a:hover { text-decoration: underline; }
.grid-table tbody tr:hover { background: #ffffff06; }
.tcell { display: flex; align-items: center; gap: 10px; }
.tcell img, .tcell .noimg { width: 32px; height: 48px; object-fit: cover; border-radius: 3px; background: #222; flex: none; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 3px; background: var(--accent); color: #fff; margin-left: 4px; }
.tag.dim { background: #444; }
.add-user { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; color: #ccc; }
.actions-cell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-form { display: inline-flex; gap: 6px; margin: 0; }
.inline-form input { width: 140px; padding: 6px 8px; font-size: 13px; }
.btn.danger { background: #e5091433; color: #ffb3b6; }
.btn.danger:hover { background: #e50914; color: #fff; }
.btn.small { margin-left: 0; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-filter { display: flex; gap: 10px; margin-bottom: 14px; }
.admin-filter input, .admin-filter select { padding: 7px 10px; font-size: 14px; }
.pager .muted { align-self: center; }
@media (max-width: 700px) { .user { width: 100%; justify-content: flex-end; } }

/* provider dropdown (top bar) */
.pmenu { position: relative; }
.pmenu summary {
  list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  padding: 4px 10px 4px 4px; border-radius: 999px; background: #ffffff12; border: 1px solid #ffffff22; font-size: 13px;
}
.pmenu summary::-webkit-details-marker { display: none; }
.pmenu summary:hover, .pmenu[open] summary { background: #ffffff22; }
.pmenu img, .pall { width: 26px; height: 26px; border-radius: 50%; flex: none; }
.pall { display: inline-grid; place-items: center; background: var(--accent); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .3px; }
.pmenu .caret { color: var(--muted); font-size: 11px; }
.pmenu-list {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; padding: 6px; z-index: 20;
  background: #141418f2; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px #000a; backdrop-filter: blur(8px);
}
.pmenu-list a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; font-size: 14px; color: #ddd; }
.pmenu-list a:hover { background: #ffffff12; color: #fff; }
.pmenu-list a.on { background: #ffffff1a; color: #fff; font-weight: 600; }
.pmenu-list a.on::after { content: "✓"; margin-left: auto; color: var(--accent); }
.pmenu-list .pmenu-all { border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; margin-top: 4px; padding-top: 10px; color: var(--muted); font-size: 13px; }
.provider-note { margin: 10px 4vw 0; font-size: 13px; color: var(--muted); }
.page .provider-note { margin: -8px 0 18px; }
.provider-note a { color: #fff; text-decoration: underline; }

/* "What are you watching?" */
body.choose { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; padding: 18px 4vw 40px; }
body.choose .logo { font-size: 30px; }
body.choose main { display: grid; place-content: center; text-align: center; gap: 34px; padding-top: 4vh; }
body.choose h1 { margin: 0; font-size: clamp(30px, 4.5vw, 54px); font-weight: 500; }
.profiles { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(14px, 2.2vw, 30px); max-width: 1000px; }
.profile { display: grid; justify-items: center; gap: 12px; width: clamp(96px, 11vw, 150px); }
.profile .tile {
  width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; display: grid; place-items: center;
  background: #1c1c22; border: 3px solid transparent; transition: border-color .15s, transform .15s;
}
.profile .tile img { width: 100%; height: 100%; object-fit: cover; }
.profile .tile.all { background: linear-gradient(135deg, var(--accent), #6b0309); color: #fff; font-size: clamp(22px, 3vw, 36px); font-weight: 900; }
.profile .label { color: var(--muted); font-size: clamp(13px, 1.3vw, 17px); }
.profile:hover .tile, .profile:focus-visible .tile { border-color: #fff; transform: scale(1.04); }
.profile:hover .label { color: #fff; }
.profile.on .tile { border-color: #ffffff55; }
.profile.on .label { color: #fff; }
.choose-hint { color: #777; font-size: 13px; margin: 0; }

/* infinite home rows */
.more-rows { display: grid; place-items: center; padding: 30px 0 60px; }
.more-rows span { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #333; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 700px) {
  .pmenu .pname, .pmenu .caret { display: none; }
  .pmenu summary { padding: 3px; }
}

/* per-provider theme: accent colour + wordmark style */
body[data-provider="amp"] { --accent: #1a98ff; }
body[data-provider="amp"] .logo { text-transform: lowercase; font-weight: 800; letter-spacing: -0.5px; font-size: 28px; color: #1a98ff; }

body[data-provider="dnp"] { --accent: #1f6fff; }
body[data-provider="dnp"] .logo {
  text-transform: none; font-style: italic; font-weight: 800; letter-spacing: 0;
  background-image: linear-gradient(90deg, #4b8bff, #29e0ff); color: transparent;
}

body[data-provider="mxx"] { --accent: #8a3cff; }
body[data-provider="mxx"] .logo {
  font-weight: 800; letter-spacing: 5px; font-size: 24px;
  background-image: linear-gradient(90deg, #5b2be0, #c35cff); color: transparent;
}

body[data-provider="atp"] { --accent: #e8e8ed; }
body[data-provider="atp"] .logo {
  text-transform: none; font-weight: 600; letter-spacing: -0.5px; font-size: 27px;
  font-family: -apple-system, "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  background-image: linear-gradient(180deg, #ffffff, #9a9aa3); color: transparent;
}
/* light accent needs dark text on accent-filled things */
body[data-provider="atp"] .badge, body[data-provider="atp"] .tag, body[data-provider="atp"] .pall,
body[data-provider="atp"] .profile .tile.all { color: #000; }

/* ---------- loaders ---------- */
.navbar-loader {
  position: fixed; top: 0; left: 0; z-index: 100; height: 3px; width: 0; pointer-events: none;
  background: var(--accent); box-shadow: 0 0 10px var(--accent), 0 0 4px var(--accent); opacity: 0;
}
.navbar-loader.active { opacity: 1; animation: navload 8s cubic-bezier(.1, .8, .2, 1) forwards; }
@keyframes navload { 0% { width: 0; } 10% { width: 35%; } 40% { width: 70%; } 100% { width: 94%; } }

.switch-overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: #0b0b0dcc; backdrop-filter: blur(10px); opacity: 0; transition: opacity .2s;
}
.switch-overlay.show { opacity: 1; }
.switch-box { display: grid; justify-items: center; gap: 18px; color: var(--muted); font-size: 15px; }
.switch-box p { margin: 0; }
.switch-box strong { color: #fff; }
.switch-box img, .switch-box .pall.big {
  width: 96px; height: 96px; border-radius: 22px; animation: pulse 1.1s ease-in-out infinite;
  box-shadow: 0 10px 40px #000a;
}
.switch-box .pall.big { font-size: 26px; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.9); opacity: .75; } }

button.busy { position: relative; color: transparent !important; pointer-events: none; }
button.busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #8888; border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn.play.busy::after { border-top-color: #000; }
.btn.busy::after { border-top-color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .navbar-loader.active, .switch-box img, .switch-box .pall.big, .more-rows span, button.busy::after { animation-duration: 0s; }
  .navbar-loader.active { width: 60%; }
}

/* admin settings toggles */
.settings { display: grid; gap: 18px; justify-items: start; }
.toggle { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; cursor: pointer; max-width: 640px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .switch { width: 42px; height: 24px; border-radius: 999px; background: #3a3a42; position: relative; transition: background .2s; margin-top: 2px; }
.toggle .switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(18px); }
.toggle input:focus-visible + .switch { outline: 2px solid #fff; outline-offset: 2px; }
.toggle strong { display: block; }
.toggle small { display: block; margin-top: 2px; }
