:root {
  --bg: #0b0d12;
  --bg-2: #12151d;
  --panel: #171b25;
  --line: #232838;
  --text: #e8ecf5;
  --muted: #8b93a7;
  --accent: #7c5cff;
  --accent-2: #37e0c0;
  --live: #ff4d6d;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 15% -10%, #1b1630 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #10222a 0%, transparent 55%), var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system,
    "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 18, 0.72);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.brand .logo {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #4b8dff);
  font-size: 12px;
  color: #fff;
}

.badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-2);
  border: 1px solid rgba(55, 224, 192, 0.35);
  background: rgba(55, 224, 192, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
}

.channels {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}

.channels::-webkit-scrollbar {
  display: none;
}

.channel {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.15s;
}

.channel:hover {
  color: var(--text);
  border-color: #33405c;
}

.channel.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.22), rgba(75, 141, 255, 0.16));
  border-color: rgba(124, 92, 255, 0.6);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.2), 0 6px 20px -10px rgba(124, 92, 255, 0.8);
}

.clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.clock #clock {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
}

.clock .tz {
  font-size: 11px;
  color: var(--muted);
}

/* ---------------- 布局 ---------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  padding: 18px 22px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9);
}

.video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(180deg, rgba(5, 7, 12, 0.55), rgba(5, 7, 12, 0.86));
  backdrop-filter: blur(2px);
  transition: opacity 0.25s;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.start-btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 34px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #4b8dff);
  cursor: pointer;
  box-shadow: 0 16px 40px -16px rgba(124, 92, 255, 0.9);
}

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

.overlay .hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.overlay .error {
  margin: 0;
  color: #ffb3c0;
  font-size: 13px;
  max-width: 70%;
  text-align: center;
}

.live-tag {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #fff;
  background: var(--live);
  padding: 4px 10px;
  border-radius: 6px;
  opacity: 0.92;
}

.live-tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

/* ---------------- 正在播放 ---------------- */

.nowbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
}

.nowline {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.nowline .series {
  font-size: 17px;
  font-weight: 700;
}

.nowline .ep {
  font-size: 13px;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

.nowline .seg {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

.subline {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  margin: 12px 0 8px;
  height: 5px;
  border-radius: 999px;
  background: #0e1119;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.9s linear;
}

.times {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.times .sync.ok {
  color: var(--accent-2);
}

.times .sync.warn {
  color: #ffd166;
}

.times .sync.bad {
  color: #ff8095;
}

/* ---------------- 节目单 ---------------- */

.epg {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.epg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.epg-head h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 1px;
}

.epg-sub {
  font-size: 11px;
  color: var(--muted);
}

.epg-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  max-height: calc(100vh - 340px);
  min-height: 280px;
  flex: 1;
}

.epg-item {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 4px 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: default;
  border-left: 2px solid transparent;
}

.epg-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.epg-item.current {
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.16), transparent 70%);
  border-left-color: var(--accent);
}

.epg-item .t {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

.epg-item.current .t {
  color: var(--accent-2);
}

.epg-item .body {
  min-width: 0;
}

.epg-item .name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.epg-item .meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.epg-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

/* ---------------- 底栏 ---------------- */

.foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 22px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.foot .spacer {
  flex: 1;
}

.foot a {
  color: var(--muted);
  text-decoration: none;
}

.foot a:hover {
  color: var(--text);
}

.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}

.ghost:hover {
  color: var(--text);
  border-color: #33405c;
}

a.ghost.link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.overlay .start-btn {
  text-decoration: none;
}

.unmute-hint {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 10, 14, 0.72);
  color: #e8ecf5;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.unmute-hint[hidden] {
  display: none;
}

.debug-panel {
  position: absolute;
  left: 12px;
  bottom: 12px;
  margin: 0;
  padding: 10px 12px;
  max-width: 90%;
  background: rgba(5, 7, 12, 0.82);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #b9c3d6;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre;
  overflow: auto;
  pointer-events: none;
}

#subtitleBtn.on {
  color: var(--accent-2);
  border-color: rgba(55, 224, 192, 0.45);
}

.compat-panel {
  position: absolute;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  width: min(460px, 80%);
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(8, 10, 16, 0.88);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.compat-panel[hidden] {
  display: none;
}
.compat-panel .cp-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}
.compat-panel .bar {
  height: 5px;
  border-radius: 999px;
  background: #0e1119;
  overflow: hidden;
}
.compat-panel .bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s;
}
.compat-panel .cp-sub {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}
#compatBtn.on {
  color: var(--accent-2);
  border-color: rgba(55, 224, 192, 0.45);
}

/* 留空时段（待机） */
.overlay .off-title {
  font-size: clamp(20px, 3.2vw, 34px);
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
  color: var(--fg, #f5f5f7);
}
.overlay .off-time {
  font-size: clamp(14px, 1.8vw, 20px);
  margin: 0 0 8px;
  color: var(--accent, #6ea8fe);
}
