:root {
  color-scheme: dark light;
  --bg: #0b0d12;
  --bg-2: #11141b;
  --card: #151921;
  --card-hover: #1c2230;
  --text: #eef1f6;
  --muted: #8b93a4;
  --line: rgba(255, 255, 255, .08);
  --accent: #5b8cff;
  --accent-2: #8a5bff;
  --live: #ff4757;
  --hot: #ff5a36;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa; --bg-2: #fff; --card: #fff; --card-hover: #f0f3f9; --text: #151a24; --muted: #667085;
    --line: rgba(15, 23, 42, .09); --shadow: 0 8px 24px rgba(15, 23, 42, .08);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh; display: flex; flex-direction: column;
  background-image: radial-gradient(900px 400px at 15% -10%, rgba(91, 140, 255, .13), transparent 60%),
                    radial-gradient(700px 360px at 95% -5%, rgba(138, 91, 255, .10), transparent 60%);
  background-repeat: no-repeat;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.bar {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.bar-inner { max-width: 1280px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { border-radius: 8px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.brand small { font-size: 12px; color: var(--muted); }
.bar-note { font-size: 13px; color: var(--muted); }
@media (max-width: 640px) { .bar-note { display: none; } .bar-inner { padding: 8px 16px; } }

/* Layout */
.layout { width: 100%; max-width: 1280px; margin: 0 auto; padding: 20px; flex: 1; display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; padding: 28px 20px; gap: 24px; }
  .stage { position: sticky; top: 84px; }
  .panel { max-height: calc(100vh - 112px); }
}
@media (max-width: 640px) { .layout { padding: 0 0 12px; gap: 0; } .panel { margin: 16px 12px 0; } }

/* Player */
.player {
  position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; user-select: none; -webkit-user-select: none;
  border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line);
}
@media (max-width: 640px) { .player { border-radius: 0; border-left: 0; border-right: 0; } }
.player video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.player:fullscreen { aspect-ratio: auto; border-radius: 0; border: 0; }
.player:fullscreen video { width: 100vw; height: 100vh; }

.status {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: 80%; padding: 10px 16px; border-radius: 999px; text-align: center; font-size: 14px;
  background: rgba(15, 18, 25, .72); color: #fff; pointer-events: none;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, .12);
}
.status:empty { display: none; }

.controls { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; transition: opacity .2s; color: #fff; }
.controls.hidden { opacity: 0; pointer-events: none; }
.controls .row { display: flex; align-items: center; gap: 4px; padding: 28px 14px 12px; background: linear-gradient(transparent, rgba(0, 0, 0, .8)); }
.controls .spacer { flex: 1; }
.controls .icon, .controls .text {
  min-width: 42px; height: 42px; font-size: 19px; font-weight: 600; color: #fff; border-radius: 10px;
  text-shadow: 0 0 3px rgba(0, 0, 0, .7); transition: background .15s;
}
.controls .icon:hover, .controls .text:hover { background: rgba(255, 255, 255, .16); }
.controls .text { font-size: 13px; padding: 0 12px; background: rgba(255, 255, 255, .12); }
.top-left { position: absolute; top: 14px; left: 14px; }

.menu-wrap { position: relative; margin-right: 4px; }
.menu {
  position: absolute; right: 0; bottom: 50px; margin: 0; padding: 6px; list-style: none; min-width: 110px;
  background: rgba(20, 24, 33, .96); border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; box-shadow: var(--shadow);
}
.menu li button { display: block; width: 100%; padding: 9px 12px; text-align: left; color: #fff; font-size: 14px; border-radius: 8px; }
.menu li button:hover { background: rgba(255, 255, 255, .1); }
.menu li button[aria-checked="true"] { color: var(--accent); }
.menu li button[aria-checked="true"]::after { content: " ✓"; }

/* Now playing */
.now { padding: 16px 4px 0; }
@media (max-width: 640px) { .now { padding: 14px 16px 0; } }
.now-main { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.now h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .2px; }
.now p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.live-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 1px; color: #fff; background: var(--live);
}
.live-badge i { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Channel panel */
.panel { display: flex; flex-direction: column; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.search input {
  width: 150px; height: 34px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--muted); }
.channels { padding: 6px 10px 12px; overflow-y: auto; overscroll-behavior: contain; }
.channels section[hidden], .channels li[hidden] { display: none; }
.channels h3 { margin: 14px 8px 6px; font-size: 12px; font-weight: 600; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.channels ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.channels li button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; text-align: left; border-radius: 10px;
  transition: background .15s;
}
.channels li button:hover { background: var(--card-hover); }
.channels li button.active { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.channels .avatar {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  font-size: 15px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.channels .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.channels .active .name { color: var(--accent); font-weight: 600; }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq[hidden] { display: none; }
.eq i { width: 3px; background: var(--accent); border-radius: 1px; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(1) { height: 60%; animation-delay: -.4s; }
.eq i:nth-child(2) { height: 100%; animation-delay: -.2s; }
.eq i:nth-child(3) { height: 40%; }
@keyframes eq { 50% { transform: scaleY(.4); transform-origin: bottom; } }
.empty { margin: 0; padding: 24px; text-align: center; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .eq i, .live-badge i { animation: none; } }

/* Footer */
.foot { border-top: 1px solid var(--line); background: var(--bg-2); }
.foot-inner { max-width: 1280px; margin: 0 auto; padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.foot p { margin: 0; font-size: 12.5px; color: var(--muted); max-width: 760px; }
.mark { display: flex; flex-direction: column; gap: 1.5px; width: 22px; flex: none; padding: 6px 0; box-sizing: content-box; }
.mark span { display: block; height: 2px; border-radius: 2px; background: var(--muted); }
.mark span:nth-child(1), .mark span:nth-child(7) { width: 18%; }
.mark span:nth-child(2), .mark span:nth-child(6) { width: 50%; }
.mark span:nth-child(3), .mark span:nth-child(5) { width: 82%; }
.mark span:nth-child(4) { width: 100%; }
.mark .hot { background: var(--hot); }

/* About dialog */
dialog { width: min(560px, calc(100vw - 32px)); max-height: 80vh; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); padding: 22px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
dialog h3 { margin: 18px 0 4px; font-size: 12px; font-weight: 600; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
dialog p, dialog li { font-size: 14px; color: var(--text); }
dialog a { color: var(--accent); }
dialog .done { float: right; color: var(--accent); font-weight: 600; }
