:root {
  color-scheme: light dark;
  --bg: #fff;
  --fg: #1a1a1a;
  --muted: #666;
  --border: #ddd;
  --head-bg: #f4f4f4;
  --block-bg: #eef3fb;
  --block-hover-bg: #dde8f8;
  --block-border: #b9cbe8;
  --live-bg: #fff4cc;
  --live-border: #e0b400;
  --accent: #1a4fa0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e8e8e8;
    --muted: #999;
    --border: #333;
    --head-bg: #1e2126;
    --block-bg: #1c2a3f;
    --block-hover-bg: #26385a;
    --block-border: #2d4470;
    --live-bg: #4a3c00;
    --live-border: #a98600;
    --accent: #6fa0e8;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 32px;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.35;
}

a { color: var(--accent); }

header {
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

h1 { font-size: 18px; margin: 0 0 8px; }
h1 a { color: var(--fg); text-decoration: none; }
h2 { font-size: 15px; font-weight: 600; color: var(--muted); margin: 16px 0 8px; }

.tagenav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tagenav a {
  padding: 4px 8px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
  font-size: 13px;
  white-space: nowrap;
}

.tagenav a:hover { background: var(--head-bg); }
.tagenav a.active { background: var(--accent); color: #fff; }

.hint { color: var(--muted); font-size: 12px; margin-top: 8px; }

footer {
  color: var(--muted);
  font-size: 12px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* Tagesansicht: Sender-Spalte (.chan-col) und Zeitraster (.grid-scroll)
   sind zwei nebeneinanderliegende Flex-Kinder von .epg-wrap, nicht Teil
   desselben CSS-Grids. Grund: ein position:sticky-Element, das selbst
   Grid-Item in einem sehr breiten Grid ist, bleibt nur sichtbar, solange
   seine eigene (schmale) Spalte noch im sichtbaren Bereich liegt - bei
   288 Zeit-Spalten wuerde die Sender-Spalte beim Scrollen also
   verschwinden. Als eigenstaendige, nicht horizontal scrollende Spalte
   ausserhalb von .grid-scroll bleibt sie dagegen immer sichtbar, ganz
   ohne Sticky-Trick. .epg-wrap selbst ist der "Frame": scrollt vertikal
   mit fester Hoehe, unabhaengig vom Seiten-Scroll. */
.epg-wrap {
  display: flex;
  align-items: flex-start;
  border: 1px solid var(--border);
  overflow-y: auto;
  max-height: min(70vh, 720px);
}

.chan-col {
  flex: 0 0 84px;
  width: 84px;
}

.corner {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 32px;
  background: var(--head-bg);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 4px 6px;
  display: flex;
  align-items: center;
}

.chan-label {
  height: 52px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.grid-scroll {
  flex: 1 1 auto;
  min-width: 0; /* Flex-Item muss unter seine Inhaltsbreite schrumpfen duerfen, sonst kein internes Scrollen */
  overflow-x: auto;
  overflow-y: visible;
}

.day-grid {
  display: grid;
  position: relative;
}

.hour-label {
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--head-bg);
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  padding: 4px 6px;
  display: flex;
  align-items: center;
}

.programme {
  margin: 3px 1px 1px 2px;
  padding: 4px 7px;
  background: var(--block-bg);
  border-left: 3px solid var(--block-border);
  border-radius: 2px;
  overflow: hidden;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.programme:hover { background: var(--block-hover-bg); }
.programme:hover .ptitle { text-decoration: underline; }

.programme.continues-before { box-shadow: inset 3px 0 0 0 var(--muted); }
.programme.continues-after { border-right: 2px dashed var(--muted); }

.programme .ptime { color: var(--muted); margin-right: 4px; }
.programme .ptitle { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.programme .psub {
  display: block;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.programme.live {
  background: var(--live-bg);
  border-left-color: var(--live-border);
}

.now-line {
  position: absolute;
  width: 2px;
  background: var(--live-border);
  z-index: 1;
  pointer-events: none;
}

