:root {
  --bg: #0b0d12;
  --bg2: #12151c;
  --card: #181c25;
  --card2: #20252f;
  --line: #2a303c;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --accent: #7c5cff;
  --accent2: #a48bff;
  --ok: #2fd08a;
  --bad: #ff5d6c;
  --radius: 14px;
  --tabbar: 64px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
[hidden] { display: none !important; }

#view {
  padding: calc(var(--sat) + 12px) 16px calc(var(--tabbar) + var(--sab) + 24px);
  max-width: 1200px;
  margin: 0 auto;
  outline: none;
}
body.no-tabbar #view { padding-bottom: calc(var(--sab) + 24px); }

/* Tabbar */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar) + var(--sab));
  padding-bottom: var(--sab);
  background: rgba(11, 13, 18, .92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
#tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600; min-height: 48px;
}
#tabbar svg { width: 24px; height: 24px; fill: currentColor; }
#tabbar a.on { color: var(--text); }
#tabbar a.on svg { color: var(--accent2); }

/* Kop */
.top { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; min-height: 44px; }
.top h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0;
  background: var(--card); display: grid; place-items: center;
}
.iconbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn.on svg { fill: #ffcc4d; stroke: #ffcc4d; }

.section { margin: 22px 0 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.section h2 { font-size: 18px; font-weight: 750; }
.section a { color: var(--accent2); font-size: 14px; font-weight: 600; padding: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Knoppen en velden */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 12px; border: 0;
  background: var(--accent); color: #fff; font-weight: 700;
}
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn.ghost { background: var(--card2); color: var(--text); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid #4a2830; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input, select.input {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg2); font-size: 16px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.search {
  position: sticky; top: 0; z-index: 5; padding: calc(var(--sat) + 8px) 0 10px; margin-top: calc(-1 * var(--sat) - 8px);
  background: linear-gradient(var(--bg) 80%, transparent);
}

/* Login */
.login { max-width: 420px; margin: 8vh auto 0; }
.logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.logo img { width: 52px; height: 52px; border-radius: 14px; }
.logo h1 { font-size: 30px; font-weight: 850; letter-spacing: -.03em; }
.error { background: #2b1419; color: #ffb3bb; border: 1px solid #4a2830; padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 14px; }

/* Lijst (categorieën, zenders) */
.list { display: flex; flex-direction: column; gap: 2px; border-radius: var(--radius); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px;
  background: var(--card); border: 0; width: 100%; text-align: left;
}
.item:active { background: var(--card2); }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .chev { color: var(--muted); flex: none; }
.item .logo-ch { width: 56px; height: 40px; flex: none; border-radius: 8px; background: #0f1218; object-fit: contain; padding: 3px; }
.item .num { width: 32px; color: var(--muted); font-size: 12px; text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.star { color: #ffcc4d; }
.item .favbtn { width: 44px; height: 44px; border: 0; background: none; display: grid; place-items: center; color: var(--muted); flex: none; margin-right: -8px; }
.item .favbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.item .favbtn.on { color: #ffcc4d; }
.item .favbtn.on svg { fill: currentColor; }

/* Poster-grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px 10px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 14px; } }
.poster { display: block; min-width: 0; }
.poster .img {
  position: relative; aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--card);
}
.poster .img img { width: 100%; height: 100%; object-fit: cover; }
.poster .img .ph { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.poster .cap { font-size: 12.5px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .25); }
.bar i { display: block; height: 100%; background: var(--accent); }
.badge { position: absolute; top: 6px; right: 6px; background: rgba(0, 0, 0, .7); font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }

/* Horizontale rij */
.hrow { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.hrow::-webkit-scrollbar { display: none; }
.hrow > * { flex: none; scroll-snap-align: start; }
.hrow .poster { width: 118px; }
.wide { width: 220px; }
.wide .img { aspect-ratio: 16 / 9; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 8px; border-radius: 12px;
  background: var(--card); max-width: 240px;
}
.chip img { width: 44px; height: 30px; object-fit: contain; border-radius: 6px; background: #0f1218; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; }

/* Detail */
.hero { position: relative; margin: calc(-1 * (var(--sat) + 12px)) -16px 0; }
.hero .bd { height: 240px; background: var(--card) center / cover no-repeat; }
.hero .bd::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(11,13,18,.3), rgba(11,13,18,.2) 40%, var(--bg)); }
.hero .back { position: absolute; top: calc(var(--sat) + 10px); left: 12px; z-index: 2; background: rgba(0,0,0,.55); }
.hero .fav { position: absolute; top: calc(var(--sat) + 10px); right: 12px; z-index: 2; background: rgba(0,0,0,.55); }
.detail-head { display: flex; gap: 14px; margin-top: -110px; position: relative; z-index: 1; align-items: flex-end; }
.detail-head .cover { width: 110px; flex: none; aspect-ratio: 2 / 3; border-radius: 10px; object-fit: cover; background: var(--card); box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.detail-head h1 { font-size: 22px; font-weight: 800; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; color: var(--muted); font-size: 13px; margin-top: 6px; }
.plot { color: #cfd5df; margin: 16px 0; font-size: 14.5px; }
.actions { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
@media (min-width: 560px) { .actions { flex-direction: row; } }

.seasons { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; }
.seasons button { flex: none; min-height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--line); background: none; font-weight: 600; font-size: 14px; }
.seasons button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.ep { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.ep .th { position: relative; width: 132px; flex: none; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--card); }
.ep .th img { width: 100%; height: 100%; object-fit: cover; }
.ep .th .play { position: absolute; inset: 0; display: grid; place-items: center; }
.ep .th .play svg { width: 30px; height: 30px; fill: #fff; filter: drop-shadow(0 1px 4px rgba(0,0,0,.6)); }
.ep .t { flex: 1; min-width: 0; }
.ep .t b { display: block; font-weight: 650; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ep .t small { color: var(--muted); font-size: 12.5px; }
.ep .done { color: var(--ok); font-weight: 700; }
.ep.current { background: linear-gradient(90deg, rgba(124,92,255,.14), transparent); }

/* Status */
.center { display: grid; place-items: center; min-height: 40vh; text-align: center; color: var(--muted); gap: 12px; padding: 20px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); background: var(--card); border-radius: var(--radius); font-size: 14px; }
.sentinel { height: 1px; }
.skel { background: linear-gradient(90deg, var(--card) 0, var(--card2) 50%, var(--card) 100%); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* Instellingen */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; overflow-wrap: anywhere; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch input { width: 48px; height: 28px; accent-color: var(--accent); }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--sab) + 16px); transform: translate(-50%, 20px);
  background: #262b36; color: var(--text); padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
body.playing #toast { bottom: calc(var(--sab) + 90px); }

/* Speler */
#player {
  position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column;
}
#player video { flex: 1; width: 100%; min-height: 0; background: #000; }
#player .ptop {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; gap: 10px;
  padding: calc(var(--sat) + 8px) 12px 28px; background: linear-gradient(rgba(0,0,0,.75), transparent);
  transition: opacity .25s;
}
#player.idle .ptop, #player.idle .pside { opacity: 0; pointer-events: none; }
#player .ptop .iconbtn { background: rgba(255,255,255,.14); }
#player .ptitle { flex: 1; min-width: 0; }
#player .ptitle b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
#player .ptitle small { display: block; color: #c8cdd6; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#player .pside { position: absolute; right: 12px; bottom: calc(var(--sab) + 70px); z-index: 2; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; transition: opacity .25s; }
#player .pside .btn { min-height: 44px; background: rgba(255,255,255,.16); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#player .pside .btn.primary { background: var(--accent); }
#player .pmsg {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; pointer-events: none; padding: 20px;
}
#player .pmsg > div { background: rgba(10,12,16,.88); border-radius: 16px; padding: 20px; text-align: center; max-width: 380px; pointer-events: auto; }
#player .pmsg p { margin: 0 0 14px; color: #d6dbe3; font-size: 14.5px; }
#player .pmsg .row { justify-content: center; }
#player .loading { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 1; }
.chan-nav { display: flex; gap: 10px; }
#player .chan-nav svg { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; width: 22px; height: 22px; }
#player .iconbtn[data-pact=cast].on svg { stroke: var(--accent2); fill: none; }

#player .pseek { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; display: flex; gap: 72px; transition: opacity .25s; pointer-events: none; }
#player .pseek .iconbtn { width: 56px; height: 56px; background: rgba(0,0,0,.45); font-weight: 800; font-size: 15px; pointer-events: auto; }
#player.idle .pseek { opacity: 0; }
#player.idle .pseek .iconbtn { pointer-events: none; }
.disclaimer p { margin: 0 0 10px; color: #cfd5df; font-size: 13.5px; }
