:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1c2430;
  --line: #2a3441;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #f5a524;
  --accent-2: #ffcf70;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 10px;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); align-self: center; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: 1px; white-space: nowrap; }
.updated { color: var(--muted); font-size: 12px; white-space: nowrap; }
.search { flex: 1; max-width: 520px; margin-left: auto; }
.search input {
  width: 100%; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 14px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; white-space: nowrap; }
.ghost:hover { border-color: var(--accent); color: var(--accent-2); }

.notice { background: #2b2111; color: var(--accent-2); padding: 10px 18px; border-bottom: 1px solid #4a3a1a; font-size: 14px; }

.layout { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 57px); }
.side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.groups { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; border-bottom: 1px solid var(--line); }
.groups button {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; color: var(--muted);
}
.groups button b { font-weight: 400; opacity: .6; margin-left: 4px; font-size: 11px; }
.groups button.on { background: var(--accent); border-color: var(--accent); color: #1a1205; font-weight: 600; }
.groups button.on b { opacity: .7; }
.filter { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }
.filter em { font-style: normal; margin-left: auto; font-size: 12px; }
.filter input { accent-color: var(--accent); }

.channels { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.channels li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.channels li:hover { background: var(--panel-2); }
.channels li.on { background: #2b2111; outline: 1px solid #5a4418; }
.channels li .ico {
  width: 34px; height: 34px; border-radius: 6px; background: var(--panel-2); flex: none;
  display: grid; place-items: center; font-size: 12px; color: var(--muted); overflow: hidden;
}
.channels li .ico img { width: 100%; height: 100%; object-fit: contain; }
.channels li .nm { flex: 1; min-width: 0; }
.channels li .nm div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.channels li .nm small { color: var(--muted); font-size: 11px; }
.channels li .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--line); }
.dot.ok { background: var(--ok); } .dot.unsure { background: var(--warn); } .dot.dead { background: var(--bad); }
.channels .empty { color: var(--muted); padding: 24px; text-align: center; cursor: default; }

.stage { padding: 18px 22px; overflow-y: auto; min-width: 0; }
.player { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; max-height: calc(100vh - 230px); margin: 0 auto; }
.player video { width: 100%; height: 100%; display: block; background: #000; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; background: rgba(0,0,0,.55); }
.overlay.hide { display: none; }
.overlay-box { text-align: center; padding: 20px; max-width: 80%; }
.overlay p { margin: 10px 0 0; color: #d0d7de; line-height: 1.6; }
.spinner { width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.now { display: flex; align-items: center; gap: 12px; margin: 14px 2px 8px; }
.now img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: var(--panel-2); }
.now-text { flex: 1; min-width: 0; }
.now h2 { margin: 0; font-size: 20px; }
.now p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.fav { background: transparent; border: 1px solid var(--line); border-radius: 999px; width: 38px; height: 38px; font-size: 18px; color: var(--accent); }

.lines { display: flex; flex-wrap: wrap; gap: 8px; }
.lines button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; font-size: 13px;
  display: flex; align-items: center; gap: 6px;
}
.lines button.on { border-color: var(--accent); color: var(--accent-2); }
.lines button.na { opacity: .45; }
.lines button small { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin-top: 14px; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; max-width: 720px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.subs-box { padding: 20px 22px; }
.subs-box h3 { margin: 0 0 6px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.6; }
.small { font-size: 12px; }
.sub-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.sub-row span { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.sub-row code { background: var(--bg); padding: 7px 10px; border-radius: 6px; font-size: 12px; overflow-x: auto; white-space: nowrap; }
.sub-row button, .right button { border: 1px solid var(--accent); background: transparent; color: var(--accent-2); border-radius: 6px; padding: 6px 12px; }
.right { text-align: right; margin-top: 10px; }

@media (max-width: 860px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .updated { display: none; }
  .ghost { margin-left: auto; }
  .layout { display: flex; flex-direction: column-reverse; height: auto; }
  .stage { padding: 0; }
  .player { border-radius: 0; max-height: none; position: sticky; top: 0; z-index: 3; }
  .now, .lines, .hint { margin-left: 12px; margin-right: 12px; }
  .hint { display: none; }
  .side { border-right: 0; border-top: 1px solid var(--line); }
  .groups { flex-wrap: nowrap; overflow-x: auto; }
  .groups button { flex: none; }
  .channels { max-height: none; overflow: visible; }
}
