:root {
  --bg: #f6f6f8;
  --panel: #ffffff;
  --text: #1c1c22;
  --muted: #6b6b78;
  --border: #dedee4;
  --accent: #4f46e5;
  --today: #eef0ff;
  --outside: #fafafb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15151a;
    --panel: #1e1e25;
    --text: #ececf1;
    --muted: #9a9aa8;
    --border: #33333d;
    --accent: #8b85ff;
    --today: #26264a;
    --outside: #191920;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
  font: 14px/1.4 system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 24px 0 8px; }
.muted { color: var(--muted); }

button {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }

/* Zijbalk */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
}

#search {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: 0; }
.list img, .list .noimg {
  width: 34px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--border);
  flex: none;
}
.list .info { flex: 1; min-width: 0; }
.list .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { font-size: 12px; color: var(--muted); }
.list .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.list button.name {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}
.list button.name:hover { text-decoration: underline; color: var(--accent); }

.backup { display: flex; gap: 8px; margin-top: 24px; }

/* Afleveringenlijst */
dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: 85vh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgb(0 0 0 / .5); }

.dialog-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.dialog-head h2 { flex: 1; margin: 0; font-size: 17px; }

#episodesBody { overflow-y: auto; padding: 0 16px 16px; }
#episodesBody > p { margin: 16px 0 0; }

.season-head {
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  padding: 12px 0 6px;
  background: var(--panel);
}
.season-head h3 { margin: 0; font-size: 14px; }
.season-head .muted { flex: 1; font-size: 12px; }

.eprow {
  display: grid;
  grid-template-columns: auto 56px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.eprow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eprow .code, .eprow .date { font-size: 12px; color: var(--muted); }
.eprow.future .name { color: var(--muted); }

/* Kalender */
main { padding: 20px; min-width: 0; }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar h2 { margin: 0 8px; font-size: 18px; text-transform: capitalize; }
#status { margin-left: auto; font-size: 12px; }

.weekdays, .calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays div { padding: 4px 8px; font-size: 12px; color: var(--muted); text-transform: capitalize; }

.calendar {
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}
.day {
  min-height: 110px;
  padding: 6px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.day.outside { background: var(--outside); }
.day.outside .num { color: var(--muted); }
.day.today { background: var(--today); }
.day.today .num { color: var(--accent); font-weight: 700; }
.day .num { font-size: 12px; margin-bottom: 4px; }

.ep {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid;
  border-radius: 3px;
  padding: 2px 6px;
  margin-bottom: 3px;
  font-size: 12px;
  background: var(--bg);
}
.ep:hover { filter: brightness(1.08); }
.ep .title, .ep .code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep .title { font-weight: 600; }
.ep .code { color: var(--muted); }
.ep.watched { opacity: .5; }
.ep.watched .code { text-decoration: line-through; }

@media (max-width: 800px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); }
  .day { min-height: 70px; padding: 3px; }
  .ep .code { display: none; }
}
