:root {
  --bg: #0e0f11;
  --panel: #1a1c20;
  --panel-2: #24272c;
  --tile: #5d626b;
  --line: #34373e;
  --text: #f4f4f2;
  --muted: #9a9ea6;
  --accent: #d0202e;
  --accent-2: #b51b27;
  --now: rgba(208, 32, 46, .16);
  --good: #4cc38a;
  --warn: #e0a84a;
  --bad: #ef5b5b;
  --radius: 10px;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --gutter: 32px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  overflow: hidden;
}
#screen { height: 100%; display: flex; flex-direction: column; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--text); text-decoration-color: var(--accent); }
h1, h2 { margin: 0 0 6px; font-weight: 800; }
h2 { font-size: 20px; letter-spacing: -.01em; }
p { margin: 8px 0; }
code { font-size: 12px; word-break: break-all; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error, .form-error { color: var(--bad); }
.form-error:empty { display: none; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.row.end { justify-content: flex-end; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.btn {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 18px; cursor: pointer; white-space: nowrap; font-weight: 600;
}
.btn:hover { border-color: var(--text); }
.btn.primary { background: var(--text); border-color: var(--text); color: #111; }
.btn.primary:hover { background: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 12px; font-size: 12px; }
.icon-btn { background: none; border: 0; cursor: pointer; padding: 4px 8px; font-size: 16px; color: var(--text); border-radius: 6px; }
.icon-btn:hover { background: rgba(255,255,255,.08); }
.linkish { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.linkish:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

input:where(:not([type=checkbox]):not([type=range])), .select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; width: 100%;
}
:where(input):focus, .select:focus { border-color: var(--text); outline: none; }
.select { width: auto; max-width: 100%; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.field.inline { flex-direction: row; align-items: center; margin: 0; }
.field.inline input { width: 70px; }
.field-label { font-size: 12px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--muted); }

.badge { display: inline-block; font-size: 10px; padding: 1px 5px; border-radius: 4px; background: var(--panel-2); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.badge.warn { color: var(--warn); }
.tag { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--panel-2); color: var(--muted); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.progress { display: block; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.notice { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-top: 12px; }
.empty-note { padding: 24px; text-align: center; }

.center-screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; width: min(560px, 100%); }
.card.narrow { width: min(420px, 100%); }
.card h1, .card h2 { font-family: var(--serif); font-weight: 700; }
.brand { font: 700 26px/1 var(--serif); letter-spacing: -.5px; white-space: nowrap; }
.brand b { color: var(--accent); font-weight: 700; }
.brand.big { font-size: 36px; margin-bottom: 10px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 8px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 10px 0; }
.tab { white-space: nowrap; background: none; border: 0; padding: 7px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--text); color: #111; }
.tab .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }

.topbar { display: flex; align-items: center; gap: 36px; padding: 0 var(--gutter); height: 76px; border-bottom: 1px solid var(--line); background: var(--bg); flex: none; }
.topbar .tab { font-size: 16px; padding: 9px 20px; }
.topbar .gear { font-size: 20px; padding: 6px 12px; flex: none; }
.topbar .note { flex: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
button.note { cursor: pointer; font: inherit; font-size: 13px; color: var(--muted); }
button.note:hover { color: var(--text); border-color: var(--muted); }
.note { font-size: 13px; color: var(--muted); border: 1px solid var(--line); padding: 7px 12px; border-radius: 8px; white-space: nowrap; background: none; width: auto; }
select.note { cursor: pointer; }
#view { flex: 1; min-height: 0; display: flex; }
#view > * { flex: 1; min-width: 0; }

/* Player */
.player { position: relative; width: 100%; height: 100%; background: #000; overflow: hidden; }
.player video { width: 100%; height: 100%; display: block; background: #000; }
.player.idle video { visibility: hidden; }
.player-top { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 14px; background: linear-gradient(rgba(0,0,0,.7), transparent); opacity: 0; transition: opacity .2s; pointer-events: none; }
.player-top button { pointer-events: auto; }
.player-extra { display: flex; gap: 8px; margin: 0 10px 0 auto; }
.player-extra:empty { display: none; }
.player-title { font: 700 20px/1.2 var(--serif); }
.player-sub { font-size: 12px; color: #cfd6e0; }
.player-controls { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: linear-gradient(transparent, rgba(0,0,0,.8)); opacity: 0; transition: opacity .2s; }
.player.show-controls .player-controls, .player.show-controls .player-top, .player:focus-within .player-controls, .player.failed .player-top, .player:not(.idle) .player-top:hover { opacity: 1; }
#theater .player .player-top { opacity: 1; }
.player.idle .player-controls, .player.idle .player-top { display: none; }
.player-seek { flex: 1; accent-color: var(--accent); }
.player.is-live .player-seek { visibility: hidden; }
.player-volume { width: 80px; accent-color: var(--accent); }
.player-time { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.player-select { background: rgba(0,0,0,.6); border: 1px solid var(--line); border-radius: 4px; font-size: 12px; padding: 2px 4px; max-width: 140px; }
.live-badge { background: var(--accent); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: 1px; padding: 3px 7px; border-radius: 5px; }
.player:not(.is-live) .live-badge { display: none; }
.player-status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 20px; pointer-events: none; text-shadow: 0 1px 3px #000; }
.player-status .row { pointer-events: auto; justify-content: center; }
.player-status.empty { display: none; }
.player-status.error { background: rgba(0,0,0,.75); color: #ffd2d2; }
.player.buffering .player-status.empty { display: flex; }
.player.buffering .player-status.empty::after { content: ''; width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.player-close { font-size: 26px; line-height: 1; }

#theater { position: fixed; inset: 0; z-index: 50; background: #000; }
#theater[hidden] { display: none; }

/* Dialogs, toasts */
.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 26px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.dialog.wide { width: min(900px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog-close { position: absolute; right: 10px; top: 8px; font-size: 22px; }
.programme-head { display: flex; gap: 14px; }
.programme-icon { width: 120px; height: 80px; object-fit: cover; border-radius: 6px; }
.programme-desc { white-space: pre-line; }
#toasts { position: fixed; left: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast > span { flex: 1; }

/* Settings */
.settings-view { overflow-y: auto; padding: 28px var(--gutter) 80px; }
.settings-section { max-width: 820px; margin: 0 auto 34px; }
.settings-section > h2 { font: 700 24px var(--serif); }
.list { display: flex; flex-direction: column; gap: 6px; }
.list-row { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 14px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--panel); border: 2px solid transparent; border-radius: 12px; color: var(--text); text-align: left; cursor: pointer; }
.stat strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat.active { border-color: var(--accent); }
.channel-filters .search { flex: 1 1 220px; min-width: 0; }
.channel-list { margin-top: 14px; }
.channel-row { width: 100%; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.channel-row:hover, .channel-row:focus-visible { border-color: var(--text); outline: none; }
.channel-num { width: 3.5em; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.channel-logo { width: 44px; height: 30px; flex: none; object-fit: contain; border-radius: 4px; }
.channel-logo.blank { background: var(--panel-2); }
.channel-name { font-weight: 700; overflow-wrap: anywhere; }
.channel-sub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-play { flex: none; color: var(--accent); }
.suggest-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }

.provider-form h2 { margin-bottom: 4px; }
.paste-box { margin: 12px 0 4px; }
.paste-row { margin: 0; flex-wrap: nowrap; align-items: stretch; }
.paste { flex: 1; resize: vertical; min-height: 44px; background: var(--bg); border: 1px dashed var(--muted); border-radius: 10px; padding: 8px 10px; font: inherit; color: inherit; }
.detect-out { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.url-list { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.url-row { display: flex; gap: 4px; width: 100%; align-items: center; }
.file-row { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 6px 6px 12px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.found-text { color: #fff; font-weight: 600; }
.notice-text { color: #f0c36a; font-weight: 600; }
.detect-out .check { margin: 4px 0; }
.league-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 12px; }
.league-grid .check { margin: 4px 0; }
#theater .player-title { font-size: 26px; }

/* Live games */
.brand-btn { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; }
.topbar .back { font-size: 15px; flex: none; }
.sports-view { overflow-y: auto; padding: 28px var(--gutter) 60px; scrollbar-width: thin; }
.sports-head h2 { font: 700 34px/1.1 var(--serif); margin: 0; }
.sports-head p { margin: 4px 0 0; font-size: 16px; }
.sport-icon, .game-pic-icon, .empty-icon { display: inline-block; flex: none; }
.sport-icon svg, .game-pic-icon svg, .empty-icon svg { width: 100%; height: 100%; display: block; }
.sport-bar { display: flex; gap: 12px; overflow-x: auto; padding: 22px 0 6px; scrollbar-width: none; }
.sport-bar::-webkit-scrollbar { display: none; }
.sport-bar[hidden] { display: none; }
.sport-btn { flex: none; position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 108px; padding: 16px 8px 12px; background: var(--panel); border: 2px solid transparent; border-radius: 18px; cursor: pointer; color: var(--text); transition: transform .15s, border-color .15s, background-color .15s; }
.sport-btn:hover { border-color: var(--muted); }
.sport-btn:active { transform: scale(.97); }
.sport-btn.active { border-color: var(--accent); background: #2a1216; }
.sport-btn .sport-icon { width: 42px; height: 42px; color: var(--accent); }
.sport-label { font-weight: 700; font-size: 14px; }
.sport-count { position: absolute; top: 8px; right: 10px; font-size: 12px; font-weight: 800; color: var(--muted); }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; margin-top: 18px; }
.game-card { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 0 0 16px; overflow: hidden; background: var(--panel); border: 2px solid transparent; border-radius: 18px; color: var(--text); text-align: left; cursor: pointer; transition: transform .15s, border-color .15s; }
.game-card > :not(.game-pic) { margin: 0 18px; }
.game-card:hover, .game-card:focus-visible { border-color: var(--text); outline: none; }
.game-card:active { transform: scale(.98); }
.game-pic { position: relative; aspect-ratio: 16 / 9; background: #000; margin-bottom: 6px; }
.game-pic.blank { display: grid; place-items: center; background: linear-gradient(135deg, #3a0f14, #8c1520); }
.game-pic-icon { width: 30%; aspect-ratio: 1; color: rgba(255, 255, 255, .85); }
.game-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.game-pic .live-badge, .start-badge { position: absolute; left: 12px; top: 12px; }
.start-badge { padding: 3px 8px; border-radius: 5px; background: rgba(0, 0, 0, .75); color: #fff; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.game-score { position: absolute; right: 12px; bottom: 12px; padding: 4px 10px; border-radius: 8px; background: rgba(0, 0, 0, .75); color: #fff; font: 800 18px var(--sans); font-variant-numeric: tabular-nums; }
.game-sport { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--accent); font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; }
.game-sport .sport-icon { width: 18px; height: 18px; }
.game-sport .muted { font-weight: 600; letter-spacing: 0; text-transform: none; overflow: hidden; text-overflow: ellipsis; }
.game-title { font: 700 22px/1.15 var(--serif); }
.games-section { font: 700 22px var(--serif); margin: 26px 0 0; }
.games-none { margin: 22px 0 0; font-size: 16px; }
.games-empty { text-align: center; padding: 70px 16px 20px; }
.empty-icon { width: 56px; height: 56px; color: var(--muted); }
.games-empty-title { font: 700 24px var(--serif); margin: 12px 0 0; }
.watch-line { margin-top: 30px; text-align: center; }

@media (max-width: 680px) {
  :root { --gutter: 16px; }
  body { overflow: auto; }
  .topbar { gap: 10px; padding: 0 8px 0 16px; height: 60px; }
  .topbar .brand { font-size: 20px; }
  .topbar .note { display: none; }
  .sports-view { padding-top: 20px; }
  .sports-head h2 { font-size: 28px; }
  .sport-bar { gap: 8px; padding-top: 16px; }
  .sport-btn { width: 84px; padding: 12px 6px 10px; border-radius: 14px; }
  .sport-btn .sport-icon { width: 32px; height: 32px; }
  .sport-label { font-size: 12px; }
  .game-grid { grid-template-columns: 1fr; gap: 14px; }
  .game-title { font-size: 20px; }
  .two { grid-template-columns: 1fr; }
  .player-volume { display: none; }
}
.coming-note { margin: 22px 0 0; }
.coming-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; border-radius: 14px; overflow: hidden; }
.coming-row { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px 16px; background: var(--panel); }
.coming-time { flex: none; min-width: 64px; font-weight: 800; font-variant-numeric: tabular-nums; }
.coming-row .sport-icon { flex: none; width: 20px; height: 20px; color: var(--accent); }
.coming-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coming-row .badge { flex: none; }
.coming-more { margin-top: 12px; }
@media (max-width: 680px) {
  .coming-row { flex-wrap: wrap; gap: 4px 10px; }
  .coming-name { flex-basis: 100%; order: 3; white-space: normal; }
}
.coming-time.live { color: var(--accent); }
.coming-score { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; }
.channels-explain { max-width: 720px; margin: 10px 0 0; line-height: 1.5; }
