:root {
  --bg: #0b0d10; --panel: #15191e; --panel2: #1c2128; --line: #262c34; --text: #e8ecf1;
  --muted: #8b95a3; --accent: #3e8bff; --bad: #ff5d5d; --ok: #3ecf8e; --star: #ffc940;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 18px/1.4 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 12px; background: var(--panel);
  padding: 12px 18px; min-height: 52px; }
button:active { transform: scale(.98); }
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; border: 1px solid var(--line); }
input[type=search], input[type=password] { background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; min-height: 52px; width: 100%; outline: none; }
input:focus { border-color: var(--accent); }
.hidden { display: none !important; }
.err { color: var(--bad); min-height: 1.4em; }
.msg { color: var(--muted); padding: 8px 4px; }

/* Inloggen */
#login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
#login form { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
#login h1 { margin: 0 0 8px; font-size: 28px; }

/* Bladeren */
#browse { height: 100%; display: flex; flex-direction: column; }
#top { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
#tabs { display: flex; gap: 8px; }
#tabs button { font-weight: 600; }
#tabs button.on { background: var(--accent); color: #fff; }
.searchbox { flex: 1; min-width: 120px; }
#main { flex: 1; display: flex; min-height: 0; }
#cats { width: 290px; flex: 0 0 auto; overflow-y: auto; border-right: 1px solid var(--line); padding: 10px; }
#cats button { display: block; width: 100%; text-align: left; background: transparent; min-height: 50px;
  padding: 10px 12px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cats button.on { background: var(--panel2); color: #fff; font-weight: 600; }
#cats .sep { height: 1px; background: var(--line); margin: 8px 4px; }
#content { flex: 1; overflow-y: auto; padding: 14px 18px 40px; }
#listHead { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
#listHead h2 { margin: 0; font-size: 22px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#filter { max-width: 300px; }

#grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
#grid.posters { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { position: relative; display: flex; flex-direction: column; align-items: stretch; text-align: left;
  padding: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); min-height: 0; }
.tile .art { aspect-ratio: 16 / 9; background: #0f1216 center / contain no-repeat; display: flex;
  align-items: center; justify-content: center; color: var(--muted); font-size: 28px; font-weight: 700; }
.posters .tile .art { aspect-ratio: 2 / 3; background-size: cover; }
.live .tile .art { background-size: contain; background-origin: content-box; padding: 14px; }
.tile .name { padding: 8px 10px 10px; font-size: 15px; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .sub { padding: 0 10px 8px; font-size: 13px; color: var(--muted); margin-top: -6px; }
.tile .star { position: absolute; top: 6px; right: 6px; min-height: 0; width: 40px; height: 40px; padding: 0;
  border-radius: 50%; background: rgba(0,0,0,.55); font-size: 20px; line-height: 40px; text-align: center; }
.tile .star.on { color: var(--star); }
.tile .prog { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); }
#more { text-align: center; margin: 18px 0; }

/* Detail film / serie */
#detail .wrap { display: flex; gap: 24px; align-items: flex-start; }
#detail .poster { width: 220px; flex: 0 0 auto; aspect-ratio: 2 / 3; border-radius: 12px;
  background: var(--panel) center / cover no-repeat; }
#detail .info { flex: 1; min-width: 0; }
#detail h2 { margin: 0 0 6px; font-size: 28px; }
#detail .meta { color: var(--muted); margin-bottom: 12px; }
#detail .plot { margin: 0 0 18px; max-width: 900px; }
#detail .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
#detail .seasons { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
#detail .seasons button.on { background: var(--accent); color: #fff; }
.ep { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; margin-bottom: 8px;
  border: 1px solid var(--line); position: relative; overflow: hidden; }
.ep .n { color: var(--muted); width: 36px; flex: 0 0 auto; text-align: right; }
.ep .t { flex: 1; }
.ep .d { color: var(--muted); font-size: 14px; }
.ep .prog { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }

/* Speler */
#player { position: fixed; inset: 0; background: #000; display: flex; flex-direction: column; }
#bar, #seekbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(11,13,16,.94);
  flex: 0 0 auto; }
#bar { border-bottom: 1px solid var(--line); }
#seekbar { border-top: 1px solid var(--line); }
#bar .title { flex: 1; min-width: 0; padding: 0 6px; }
#bar .title b, #bar .title small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bar .title small { color: var(--muted); }
#pEpg { margin-left: 10px; color: var(--text); }
#fav.on { color: var(--star); }
#stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#stage canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
#overlay { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(0,0,0,.55); }
#overlay p { margin: 0; max-width: 680px; }
#overlay .row { display: flex; gap: 10px; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid #fff3; border-top-color: #fff;
  animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#unmute { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); }
#seek { flex: 1; height: 40px; accent-color: var(--accent); }
#time { min-width: 130px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
#player:not(.is-live) .live-only { display: none; }
#player:not(.is-vod) .vod-only { display: none !important; }
#player.immersive #bar, #player.immersive #seekbar { display: none !important; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px;
  background: var(--muted); vertical-align: middle; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }

@media (max-width: 800px) {
  #top { flex-wrap: wrap; }
  #main { flex-direction: column; }
  #cats { width: auto; max-height: 30vh; border-right: 0; border-bottom: 1px solid var(--line); }
  #detail .wrap { flex-direction: column; }
  #filter { max-width: 160px; }
}

#pStatus { cursor: pointer; }
#dbg { position: absolute; top: 10px; left: 10px; margin: 0; padding: 10px 12px; max-width: 92%;
  background: rgba(0,0,0,.78); color: #d6f5d6; font: 14px/1.45 ui-monospace, Menlo, Consolas, monospace;
  border-radius: 8px; white-space: pre-wrap; pointer-events: none; }

/* Tv-gids */
#guideToggle.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tile .arch { position: absolute; top: 6px; left: 6px; padding: 2px 8px; border-radius: 8px;
  background: rgba(0,0,0,.6); font-size: 13px; color: var(--muted); }
#grid.guide { display: flex; flex-direction: column; gap: 8px; }
.grow { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; padding: 8px 12px;
  border: 1px solid var(--line); position: relative; overflow: hidden; min-height: 72px; }
.grow .logo { width: 84px; height: 48px; flex: 0 0 auto; background: #0f1216 center / contain no-repeat;
  border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; }
.grow .cn { width: 190px; flex: 0 0 auto; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow .pr { flex: 1; min-width: 0; }
.grow .pr div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow .nx { color: var(--muted); font-size: 15px; }
.grow .tm { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }
.grow .bar, .prg .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }
.guide-days { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.guide-days button { min-height: 46px; padding: 8px 14px; }
.guide-days button.on { background: var(--accent); color: #fff; }
.prg { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; margin-bottom: 6px;
  border: 1px solid var(--line); position: relative; overflow: hidden; padding: 10px 12px; }
.prg .tm { width: 112px; flex: 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.prg .tt { flex: 1; min-width: 0; }
.prg .tt b { display: block; font-weight: 600; }
.prg .tt small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--muted); font-size: 14px; }
.prg .act { flex: 0 0 auto; font-size: 15px; color: var(--accent); font-weight: 600; padding-top: 2px; }
.prg .act.two { display: flex; gap: 8px; }
.prg .act.two span { padding: 8px 12px; margin: -6px 0; border-radius: 10px; background: var(--panel); }
.prg .act.two .beg { background: var(--accent); color: #fff; }
.prg.past { opacity: .5; }
.prg.past.replay { opacity: 1; }
.prg.now { border-color: var(--accent); background: var(--panel2); }
.prg.playing { border-color: var(--ok); }
.prg.future { cursor: default; }
.prg.future .tt b { font-weight: 500; }
#guidePanel { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 92%); overflow-y: auto;
  background: rgba(11,13,16,.96); border-left: 1px solid var(--line); padding: 12px 14px 30px; }
#guidePanel h3 { margin: 4px 0 8px; font-size: 20px; display: flex; align-items: center; gap: 10px; }
#guidePanel h3 span { flex: 1; }
#guidePanel h3 button { min-height: 44px; padding: 6px 14px; }
#guideBtn.on { background: var(--accent); color: #fff; }
@media (max-width: 800px) { .grow .cn { width: 110px; } .prg .tm { width: 90px; } }
