:root {
  --bg: #101318;
  --bg2: #161a20;
  --bg3: #1c2129;
  --border: #272d37;
  --text: #e7eaf0;
  --muted: #9aa3af;
  --accent: #3ba3d6;
  --danger: #d1563f;
  --ok: #3e9c4e;
  --label-w: 150px;
  --hour-w: 60px;
  --minute-scale: 1px; /* 1px = 1 minuta EPG */
  --row-h: 86px;
  --sports: {
    /* (ignored, nahradene cez CSS custom property na elemente) */
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}

:root { color-scheme: dark; }

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

button {
  font: inherit;
  color: var(--text);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.ghost { background: transparent; }
button.is-active { border-color: var(--accent); color: var(--accent); }

input[type="search"], input[type="date"], input[type="text"] {
  font: inherit;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}
input[type="search"]:focus, input[type="date"]:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* ——— layout ——— */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.logo { font-weight: 700; font-size: 16px; }
.logo-sub { color: var(--muted); margin-left: 8px; font-size: 12px; }

.tabs { display: flex; gap: 6px; }

.content { max-width: 1600px; margin: 0 auto; padding: 14px 12px 40px; }

.view { display: none; }
.view.is-active { display: block; }

.footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ——— toolbar ——— */

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "date zoom"
    "filters filters";
  align-items: center;
  column-gap: 12px;
  row-gap: 10px;
  margin-bottom: 10px;
}
.date-nav { grid-area: date; display: flex; gap: 6px; align-items: center; }
.date-nav button { padding: 6px 11px; }
.filters { grid-area: filters; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
#search-input { width: 260px; max-width: 60vw; }
.voyo-toolbar { margin-bottom: 10px; }
#voyo-search { width: 260px; max-width: 60vw; }

.sport-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 10px; font-size: 12px; border-radius: 999px; }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #06121a; font-weight: 600; }

.zoom { grid-area: zoom; display: flex; gap: 6px; align-items: center; justify-self: end; }
.zoom button { padding: 6px 10px; min-width: 40px; }
.zoom .ghost { color: var(--muted); }

.status {
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--muted);
  white-space: pre-line;
}
.status.is-error { border-color: var(--danger); color: var(--danger); }
.status-head { font-weight: 600; }
.status-details { margin-top: 6px; }
.status-details summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  user-select: none;
}
.status-details summary:hover { text-decoration: underline; }
.status-list {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.status-list li::marker { color: var(--border); }

/* ——— EPG ——— */

.epg-scroll {
  overflow: auto;
  max-height: calc(100vh - 175px);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}
.epg { min-width: max-content; position: relative; }

.epg-text { padding: 30px 16px; color: var(--muted); }

.epg-ruler {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 32px;
  display: flex;
  align-items: center;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.epg-ruler__pad { width: var(--label-w); flex: 0 0 var(--label-w); }
.epg-ruler__cells { display: flex; }
.epg-ruler__hour {
  width: var(--hour-w);
  flex: 0 0 var(--hour-w);
  text-align: left;
  padding-left: 5px;
  font-size: 10px;
  color: var(--muted);
  border-left: 1px solid var(--border);
}

.epg-row {
  position: relative;
  height: var(--row-h);
  display: flex;
  border-bottom: 1px solid var(--border);
}
.epg-row__label {
  width: var(--label-w);
  flex: 0 0 var(--label-w);
  position: sticky;
  left: 0;
  z-index: 20;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}
.epg-row__name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.epg-row__badges { display: flex; gap: 4px; flex-wrap: wrap; }
.badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--bg3);
}
.badge--live { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 700; }

.epg-row__timeline {
  position: relative;
  flex: 0 0 calc(var(--hour-w) * 24);
  height: var(--row-h);
}
.epg-row__gridline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255,255,255,0.045);
}
.epg-event {
  position: absolute;
  top: 5px;
  height: calc(100% - 10px);
  border-radius: 6px;
  padding: 4px 8px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid transparent;
  border-left: 3px solid var(--sport-color, var(--muted));
  background: color-mix(in srgb, var(--sport-color, var(--muted)) 22%, transparent);
  transition: border-color 0.12s ease, filter 0.12s ease;
}
.epg-event:hover { border-color: var(--sport-color, var(--muted)); filter: brightness(1.15); }
.epg-event.is-hidden { display: none; }
.epg-row.is-row-empty { display: none; }
.epg-event__time { font-size: 10px; color: var(--muted); white-space: nowrap; }
.epg-event__title { font-weight: 600; font-size: 12.5px; line-height: 1.25; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.epg-event__sub { font-size: 11px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.epg-event__in-watchlist { position: absolute; top: 3px; right: 5px; opacity: 0.85; }
.epg-event--live { box-shadow: inset 0 0 0 1px var(--danger); }

.epg-nowline {
  position: absolute;
  top: 32px;
  bottom: 0;
  width: 2px;
  background: var(--danger);
  z-index: 15;
  pointer-events: none;
}
.epg-nowline::before {
  content: '';
  position: absolute;
  top: 0;
  left: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

/* ——— watchlist ——— */

.watchlist { display: flex; flex-direction: column; gap: 8px; max-width: 900px; }
.wl-section {
  margin: 12px 0 2px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.wl-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--sport-color, var(--muted));
  border-radius: 8px;
  background: var(--bg2);
}
.wl-item__when { flex: 0 0 130px; font-size: 12px; color: var(--muted); }
.wl-item__info { flex: 1; min-width: 0; }
.wl-item__title { font-weight: 600; }
.wl-item__sub { font-size: 12px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.wl-item__ch { font-size: 12px; color: var(--accent); flex: 0 0 130px; text-align: right; }
.wl-empty { color: var(--muted); padding: 20px 4px; }

/* ——— voyo ——— */

.voyo-panel { display: flex; flex-direction: column; gap: 8px; max-width: 900px; }
.voyo-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.wl-item--live { border-left-color: var(--accent); }
.wl-item__title a { color: inherit; text-decoration: none; }
.wl-item__title a:hover { color: var(--accent); }

/* ——— nastavenia ——— */

h2 { font-size: 15px; margin: 26px 0 6px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 12px; max-width: 900px; }
.settings-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.channel-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 6px;
  max-width: 1100px;
}
.channel-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg2);
  cursor: pointer;
}
.channel-option:hover { border-color: var(--accent); }
.channel-option input { accent-color: var(--accent); }
.channel-option__name { font-weight: 600; font-size: 13px; flex: 1; }
.channel-option__country { font-size: 10px; color: var(--muted); }
.sync-row { display: flex; gap: 8px; align-items: center; max-width: 560px; }
#uid-input { flex: 1; font-family: Consolas, monospace; }

.grp-title {
  grid-column: 1 / -1;
  margin: 8px 0 2px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ——— mobile ——— */

@media (max-width: 760px) {
  html { -webkit-text-size-adjust: 100%; }
  body { font-size: 13px; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .logo { font-size: 14px; }
  .logo-sub { display: none; }
  .tabs { flex: 1; justify-content: flex-end; }
  .tab { padding: 6px 10px; font-size: 12.5px; }
  .content { padding: 10px 8px 30px; }
  .toolbar { column-gap: 8px; row-gap: 8px; }
  .filters { width: 100%; }
  #search-input { width: 100%; }
  #voyo-search { width: 100%; }
  .date-nav button { padding: 6px 9px; }
  .filters { width: 100%; }
  .status { font-size: 12px; }
  .footer { font-size: 11px; flex-direction: column; gap: 6px; }
  .epg-scroll { max-height: calc(100vh - 165px); }
  .epg-event { padding: 2px 6px; }
  .epg-event__title { font-size: 11px; }
  .epg-event__sub { font-size: 10px; }
  .settings-actions { flex-wrap: wrap; }
  .sync-row { flex-wrap: wrap; }
  #uid-input { flex: 1 1 100%; }
  .channel-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 520px) {
  :root {
    --label-w: 92px;
    --row-h: 72px;
    --hour-w: 54px;
  }
  .epg-ruler__hour { font-size: 9px; padding-left: 3px; }
  .epg-row__name { font-size: 11px; }
  .epg-row__label { padding: 6px 8px; }
  .epg-event__time { font-size: 9px; }
  .wl-item { flex-wrap: wrap; row-gap: 6px; }
  .wl-item__when { flex-basis: 100%; }
  .wl-item__ch { text-align: left; }
  .tabs { justify-content: space-between; }
  .tab { flex: 1; }
}