/* ── tokens ───────────────────────────────────────── */
:root {
  --bg: #f3f4f7;
  --sur: #ffffff;
  --sur2: #f8f9fb;
  --bdr: rgba(0, 0, 0, 0.08);
  --bdr2: rgba(0, 0, 0, 0.14);
  --txt: #111318;
  --txt2: #5a6172;
  --txt3: #9aa3b2;
  --grn: #16a34a;
  --grn-bg: rgba(22, 163, 74, 0.09);
  --grn-bdr: rgba(22, 163, 74, 0.3);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.08);
  --red-bdr: rgba(220, 38, 38, 0.28);
  --r: 8px;
  --r-lg: 12px;
}

body.dark-theme {
  --bg: #0d0f14;
  --sur: #13161d;
  --sur2: #191d26;
  --bdr: rgba(255, 255, 255, 0.08);
  --bdr2: rgba(255, 255, 255, 0.14);
  --txt: #eef1f6;
  --txt2: #8a93a6;
  --txt3: #4e5666;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bdr2);
  border-radius: 4px;
}

:focus-visible {
  outline: 2px solid var(--grn);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── header ───────────────────────────────────────── */
.hdr {
  background: var(--sur);
  border-bottom: 0.5px solid var(--bdr);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 46px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 200;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--grn);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
}

.brand-sub {
  font-size: 10px;
  color: var(--grn);
}

.tally {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  border: 0.5px solid var(--red-bdr);
  background: var(--red-bg);
  color: var(--red);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.07em;
  flex-shrink: 0;
}

.tally-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red);
  animation: blink 1.8s ease-in-out infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .35
  }
}

.h-gap {
  flex: 1;
}

.clock {
  font-size: 11px;
  font-weight: 500;
  color: var(--txt2);
  background: var(--sur2);
  border: 0.5px solid var(--bdr);
  padding: 4px 9px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 66px;
  text-align: center;
  letter-spacing: 0.04em;
}

.hbtn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 0.5px solid var(--bdr);
  background: transparent;
  color: var(--txt2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .12s, border-color .12s;
}

.hbtn:hover {
  border-color: var(--bdr2);
  color: var(--txt);
}

.hbtn svg {
  width: 15px;
  height: 15px;
}

/* ── layout ───────────────────────────────────────── */
.layout {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.top {
  display: flex;
  flex-direction: column;
}

@media (min-width: 900px) {
  .top {
    flex-direction: row;
    height: 650px;
  }
}

/* ── player ───────────────────────────────────────── */
.player-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #080a0e;
}

#player-wrap {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at 50% 45%, #12151e 0%, #060709 100%);
  min-height: 220px;
  overflow: hidden;
}

#player-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  cursor: pointer;
}

/* loading */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 9, .95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 10;
  pointer-events: none;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, .1);
  border-top-color: var(--grn);
  border-right-color: var(--grn);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.load-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, .25);
}

/* error */
#error-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 9, .97);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 11;
  text-align: center;
  padding: 0 20px;
}

.err-title {
  font-size: 13px;
  font-weight: 500;
  color: #fca5a5;
}

.err-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, .3);
  line-height: 1.6;
  max-width: 260px;
}

.err-btns {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.ebtn {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: filter .12s;
}

.ebtn.primary {
  background: var(--grn);
  color: #fff;
}

.ebtn.secondary {
  background: var(--sur2);
  color: var(--txt);
  border: 0.5px solid var(--bdr2);
}

.ebtn:hover {
  filter: brightness(1.08);
}

/* live badge */
.live-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, .5);
  border: 0.5px solid rgba(255, 255, 255, .1);
  border-radius: 20px;
  padding: 3px 8px;
  font-size: 10px;
  color: rgba(255, 255, 255, .55);
  backdrop-filter: blur(4px);
  z-index: 5;
  pointer-events: none;
}

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red);
  animation: blink 1.8s ease-in-out infinite;
}

/* timeline */
#timeline-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, .07);
  cursor: pointer;
  z-index: 20;
  opacity: 0;
  transition: opacity .3s, height .15s;
}

#player-wrap:hover #timeline-wrap {
  opacity: 1;
}

#timeline-wrap:hover {
  height: 5px;
}

#timeline-progress {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--grn);
  width: 0%;
  transition: width .2s;
  pointer-events: none;
}

#timeline-progress>div {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--grn);
}

/* controls bar */
.ctrls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 40px;
  background: var(--sur);
  border-top: 0.5px solid var(--bdr);
  flex-shrink: 0;
}

.equalizer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 25px;
  flex-shrink: 0;
}

div#loading-overlay {
  color: #fff;
}

.load-hint {
  color: #ffffff;
}

.equalizer span {
  width: 2px;
  background: var(--grn);
  border-radius: 2px;
  animation: eq .9s ease-in-out infinite;
}

.equalizer span:nth-child(1) {
  height: 40%;
  animation-delay: -.6s;
}

.equalizer span:nth-child(2) {
  height: 100%;
  animation-delay: -.2s;
}

.equalizer span:nth-child(3) {
  height: 65%;
  animation-delay: -.8s;
}

.equalizer span:nth-child(4) {
  height: 85%;
  animation-delay: -.4s;
}

@keyframes eq {

  0%,
  100% {
    transform: scaleY(.3)
  }

  50% {
    transform: scaleY(1)
  }
}

.c-gap {
  flex: 1;
}

.cbtn {
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 8px;
  border-radius: 5px;
  border: 0.5px solid var(--bdr);
  background: var(--sur2);
  color: var(--txt2);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
  font-family: inherit;
}

.cbtn:hover {
  background: var(--sur);
  border-color: var(--bdr2);
  color: var(--txt);
}

.cbtn:active {
  transform: scale(.97);
}

.cbtn.sq {
  width: 26px;
  padding: 0;
}

.cbtn svg {
  width: 14px;
  height: 14px;
}

.quality-wrap {
  position: relative;
  flex-shrink: 0;
}

#quality-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--sur);
  border: 0.5px solid var(--bdr2);
  border-radius: var(--r);
  padding: 3px;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .35);
  min-width: 76px;
  z-index: 9999;
}

#quality-menu button {
  display: block;
  width: 100%;
  text-align: center;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 500;
  background: none;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  color: var(--txt2);
  transition: background .1s;
}

#quality-menu button:hover {
  background: var(--grn-bg);
  color: var(--grn);
}

.vol-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.vol-slider {
  width: 54px;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bdr);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--grn);
  cursor: pointer;
}

.vol-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: none;
  border-radius: 50%;
  background: var(--grn);
}

/* now-playing name */
.np-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--txt2);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── sidebar ──────────────────────────────────────── */
.sidebar {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sur);
  border-left: 0.5px solid var(--bdr);
  overflow: hidden;
}

@media (min-width: 900px) {
  .sidebar {
    width: 300px;
  }
}

.sb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 7px;
  border-bottom: 0.5px solid var(--bdr);
  flex-shrink: 0;
}

.sb-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--txt3);
}

.ch-badge {
  font-size: 10px;
  color: var(--grn);
  background: var(--grn-bg);
  border: 0.5px solid var(--grn-bdr);
  padding: 2px 7px;
  border-radius: 20px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 7px 10px 6px;
  border-bottom: 0.5px solid var(--bdr);
  flex-shrink: 0;
}

.source-btn {
  flex: 1;
  text-align: center;
  padding: 4px 0;
  border-radius: 5px;
  border: 0.5px solid transparent;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  color: var(--txt3);
  background: transparent;
  font-family: inherit;
  transition: all .12s;
}

.source-btn.active {
  background: var(--grn-bg);
  border-color: var(--grn-bdr);
  color: var(--grn);
}

.ch-search {
  margin: 6px 10px 4px;
  position: relative;
  flex-shrink: 0;
}

.ch-search input {
  width: 100%;
  background: var(--sur2);
  border: 0.5px solid var(--bdr);
  border-radius: 6px;
  padding: 5px 8px 5px 26px;
  font-size: 11.5px;
  color: var(--txt);
  font-family: inherit;
  transition: border-color .12s;
}

.ch-search input:focus {
  outline: none;
  border-color: var(--grn);
}

.ch-search input::placeholder {
  color: var(--txt3);
}

.ch-search .s-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--txt3);
  pointer-events: none;
}

.ch-list {
  overflow-y: auto;
  flex: 1;
  padding: 3px 7px 7px;
}

@media (max-width: 899px) {
  .ch-list {
    max-height: 280px;
  }
}

.ch-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 6px;
  cursor: pointer;
  border: 0.5px solid transparent;
  margin-bottom: 1px;
  transition: background .1s, border-color .1s;
  user-select: none;
}

.ch-item:hover {
  background: var(--sur2);
  border-color: var(--bdr);
}

.ch-item.active {
  background: var(--grn-bg);
  border-color: var(--grn-bdr);
}

.ch-item.active .ch-name {
  color: var(--grn);
}

.ch-logo {
  width: 38px;
  height: 24px;
  border-radius: 4px;
  background: var(--sur2);
  border: 0.5px solid var(--bdr);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  overflow: hidden;
}

.ch-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
  background: #fff;
}

.ch-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ch-cat {
  font-size: 9.5px;
  color: var(--txt3);
  margin-top: 1px;
}

.no-results {
  text-align: center;
  padding: 20px 10px;
  color: var(--txt3);
  font-size: 11px;
}

/* ── notice bar ───────────────────────────────────── */
.notice {
  padding: 7px 14px;
  font-size: 15px;
  color: #ff6300;
  background: var(--sur2);
  border-top: 0.5px solid var(--bdr);
  flex-shrink: 0;
}

/* ── schedule section ─────────────────────────────── */
#schedule-section {
  width: 100%;
  background: var(--bg);
}

/* ── modal ────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  padding: 16px;
  transition: opacity .2s;
  pointer-events: none;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--sur);
  border: 0.5px solid var(--bdr2);
  border-radius: var(--r-lg);
  padding: 20px 18px 16px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, .4);
  transform: scale(.95);
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
}

.modal-overlay.show .modal-box {
  transform: scale(1);
}

.modal-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 10px;
}

.modal-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--txt2);
  margin-bottom: 16px;
}

.modal-text strong {
  color: var(--txt);
  font-weight: 500;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-check {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 11px;
  color: var(--txt2);
  user-select: none;
}

.modal-check input {
  accent-color: var(--grn);
  cursor: pointer;
}

.modal-btn {
  background: var(--grn);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: filter .12s;
}

.modal-btn:hover {
  filter: brightness(1.08);
}

/* ── responsive ───────────────────────────────────── */
@media (max-width: 640px) {
  .hdr {
    padding: 0 10px;
    gap: 6px;
  }

  .brand-sub {
    display: none;
  }

  .ctrls {
    padding: 0 8px;
    gap: 5px;
  }

  .cbtn span {
    display: none;
  }

  .cbtn:not(.sq) {
    width: 26px;
    padding: 0;
  }

  .vol-slider {
    width: 40px;
  }
}

/* ── desktop type scale ──────────────────────────────
   mirrors the layout breakpoint at 900px; mobile sizes
   were tuned for small screens and read as too small
   on a full monitor, so scale text up clearly here.   */
@media (min-width: 900px) {
  .hdr {
    height: 64px;
    padding: 0 24px;
    gap: 16px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 19px;
    border-radius: 9px;
  }

  .brand-name {
    font-size: 17px;
  }

  .brand-sub {
    font-size: 13px;
  }

  .tally {
    font-size: 13px;
    padding: 5px 12px;
  }

  .clock {
    font-size: 15px;
    padding: 6px 14px;
    min-width: 88px;
  }

  .hbtn {
    width: 38px;
    height: 38px;
  }

  .hbtn svg {
    width: 20px;
    height: 20px;
  }

  .load-hint {
    font-size: 14px;
  }

  .err-title {
    font-size: 18px;
  }

  .err-sub {
    font-size: 14px;
    max-width: 340px;
  }

  .ebtn {
    font-size: 14px;
    padding: 9px 18px;
  }

  .live-badge {
    font-size: 13px;
    padding: 5px 12px;
  }

  .ctrls {
    padding: 0 20px;
    height: 58px;
    gap: 10px;
  }

  .cbtn {
    font-size: 14px;
    height: 36px;
    padding: 0 14px;
  }

  .cbtn svg {
    width: 18px;
    height: 18px;
  }

  .cbtn.sq {
    width: 36px;
  }

  .np-name {
    font-size: 14px;
    max-width: 280px;
  }

  #quality-menu button {
    font-size: 14px;
    padding: 8px 12px;
  }

  .vol-slider {
    width: 70px;
  }

  .sb-head {
    padding: 12px 16px 10px;
  }

  .sb-title {
    font-size: 13px;
  }

  .ch-badge {
    font-size: 12px;
    padding: 3px 10px;
  }

  .tabs {
    padding: 10px 14px 8px;
    gap: 6px;
  }

  .source-btn {
    font-size: 13px;
    padding: 8px 0;
  }

  .ch-search {
    margin: 8px 14px 6px;
  }

  .ch-search input {
    font-size: 14px;
    padding: 9px 12px 9px 34px;
  }

  .ch-search .s-icon {
    font-size: 16px;
    left: 11px;
  }

  .ch-list {
    padding: 5px 10px 10px;
  }

  .ch-item {
    padding: 9px 11px;
    gap: 11px;
  }

  .ch-logo {
    width: 48px;
    height: 31px;
    font-size: 16px;
    border-radius: 5px;
  }

  .ch-cat {
    font-size: 12px;
    margin-top: 2px;
  }

  .no-results {
    font-size: 14px;
    padding: 26px 12px;
  }

  .notice {
    padding: 15px 24px;
  }

  .modal-box {
    padding: 26px 24px 20px;
    max-width: 420px;
  }

  .modal-title {
    font-size: 20px;
    margin-bottom: 12px;
  }

  .modal-text {
    font-size: 15px;
    line-height: 1.7;
  }

  .modal-check {
    font-size: 13px;
  }

  .modal-btn {
    font-size: 14px;
    padding: 10px 20px;
  }
}

.hide-cursor,
.hide-cursor * {
  cursor: none !important;
}

#player-wrap .ctrls,
#player-wrap #timeline-wrap {
  transition: opacity .3s ease;
}

#player-wrap.fullscreen-hide .ctrls,
#player-wrap.fullscreen-hide #timeline-wrap {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#player-wrap.controls-visible .ctrls,
#player-wrap.controls-visible #timeline-wrap {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}