:root{
  --bg: #0b1020;
  --panel: rgba(255,255,255,0.06);
  --panel2: rgba(255,255,255,0.08);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.68);
  --border: rgba(255,255,255,0.12);
  --accent: #6d5efc;
  --accent2: #22c55e;
  --danger: #ef4444;
  --shadow: 0 18px 50px rgba(0,0,0,0.45);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

@media (prefers-color-scheme: light){
  :root{
    --bg: #f6f7fb;
    --panel: rgba(0,0,0,0.04);
    --panel2: rgba(0,0,0,0.055);
    --text: rgba(0,0,0,0.88);
    --muted: rgba(0,0,0,0.62);
    --border: rgba(0,0,0,0.12);
    --shadow: 0 18px 50px rgba(0,0,0,0.12);
  }
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 15% 10%, rgba(109,94,252,0.35), transparent 60%),
    radial-gradient(900px 700px at 85% 20%, rgba(34,197,94,0.22), transparent 60%),
    radial-gradient(900px 700px at 60% 90%, rgba(59,130,246,0.16), transparent 60%),
    var(--bg);
}

.app{ max-width: 1280px; margin: 0 auto; padding: 22px; }
.header{
  display:flex; align-items:center; justify-content:space-between;
  padding: 16px 16px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.brand__title{ font-weight: 720; letter-spacing: 0.2px; font-size: 18px; }
.brand__subtitle{ color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.header__actions{ display:flex; gap: 10px; }

.grid{
  margin-top: 14px;
  display:grid;
  grid-template-columns: 1.1fr 1.2fr 1.3fr;
  gap: 14px;
}
@media (max-width: 1100px){
  .grid{ grid-template-columns: 1fr; }
}

.panel{
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 180px;
}
.panel--player{ display:flex; flex-direction:column; }
.panel__title{
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 650;
}

.btn{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 650;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
.btn:hover{ background: rgba(255,255,255,0.10); }
.btn:active{ transform: translateY(1px); }
.btn--ghost{ background: transparent; }
.btn--danger{ background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.35); }

.input, .textarea{
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.12);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}
@media (prefers-color-scheme: light){
  .input, .textarea{ background: rgba(255,255,255,0.8); }
}
.input:focus, .textarea:focus{ border-color: rgba(109,94,252,0.75); box-shadow: 0 0 0 3px rgba(109,94,252,0.18); }
.input--select{ padding-right: 34px; }
.textarea{ min-height: 140px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }

.inputGrid{ padding: 14px; display:grid; gap: 12px; }
.field__label{ display:block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field__row{ display:flex; gap: 10px; align-items:center; }
.field__row--end{ justify-content:flex-end; }
.field--full{ grid-column: 1 / -1; }
.hint{ color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.35; }

.toolbar{
  padding: 14px;
  display:flex;
  gap: 10px;
  align-items:center;
}
.pill{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.channels{ padding: 0 10px 10px 10px; }
.channels__list{
  display:flex;
  flex-direction:column;
  gap: 8px;
  padding: 4px 4px 10px 4px;
  max-height: 520px;
  overflow: auto;
}
.empty{
  padding: 16px 12px;
  color: var(--muted);
}

.chan{
  display:flex;
  gap: 10px;
  align-items:center;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  border-radius: 14px;
  padding: 10px 10px;
  cursor:pointer;
  transition: background .15s ease, border-color .15s ease, transform .06s ease;
}
.chan:hover{ background: rgba(255,255,255,0.08); }
.chan:active{ transform: translateY(1px); }
.chan--active{ border-color: rgba(109,94,252,0.65); background: rgba(109,94,252,0.12); }
.chan__logo{
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(0,0,0,0.14);
  border: 1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
  flex: 0 0 auto;
}
.chan__logo img{ width: 100%; height: 100%; object-fit: cover; display:block; }
.chan__meta{ min-width: 0; flex: 1 1 auto; }
.chan__name{ font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan__sub{ color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan__badge{
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
  padding: 5px 8px;
  flex: 0 0 auto;
}

.nowPlaying{
  display:flex; justify-content:space-between; align-items:center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.nowPlaying__title{ font-weight: 700; }
.nowPlaying__sub{ color: var(--muted); font-size: 12px; margin-top: 2px; }
.nowPlaying__right{ display:flex; gap: 10px; align-items:center; }

.playerWrap{ padding: 12px 14px; }
.video{
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.35);
}
.playerMsg{
  padding: 0 14px 14px 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
}

.epg{
  border-top: 1px solid var(--border);
  padding: 12px 14px 4px 14px;
}
.epg__head{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap: 10px;
}
.epg__title{ font-weight: 750; }
.epg__chan{
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.epg__msg{
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.5px;
}
.epg__list{
  margin-top: 10px;
  display:flex;
  flex-direction:column;
  gap: 8px;
  padding-bottom: 10px;
  max-height: 220px;
  overflow:auto;
}
.epgItem{
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  padding: 10px 10px;
}
.epgItem--now{
  border-color: rgba(34,197,94,0.55);
  background: rgba(34,197,94,0.10);
}
.epgItem__top{
  display:flex;
  justify-content:space-between;
  gap: 10px;
  align-items:baseline;
}
.epgItem__title{
  font-weight: 700;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.epgItem__time{
  font-family: var(--mono);
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
}
.epgItem__desc{
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.debug{
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  padding: 10px 12px;
}
.debug summary{
  cursor: pointer;
  color: var(--text);
  font-weight: 650;
}
.debug__body{
  margin-top: 10px;
  display: grid;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
}
.debug__row{
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 10px;
}
.debug__k{ color: var(--muted); }
.debug__v{ color: var(--text); word-break: break-all; }

.dialog{ border: 1px solid var(--border); border-radius: 16px; padding: 0; background: rgba(20,24,40,0.96); color: var(--text); width: min(720px, 92vw); }
@media (prefers-color-scheme: light){
  .dialog{ background: rgba(255,255,255,0.96); }
}
.dialog::backdrop{ background: rgba(0,0,0,0.55); }
.dialog__content{ padding: 0; margin: 0; }
.dialog__title{ padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.dialog__body{ padding: 14px 16px; color: var(--muted); }
.dialog__body b{ color: var(--text); }
.dialog__actions{ padding: 14px 16px; border-top: 1px solid var(--border); display:flex; justify-content:flex-end; }
