:root {
  --bg: #14161a;
  --panel: #1d2026;
  --line: #2c3038;
  --text: #e8eaee;
  --muted: #9aa1ad;
  --accent: #5aa9ff;
  --ok: #58c27d;
  --danger: #ff6b6b;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-top: var(--safe-top);
  padding-bottom: calc(24px + var(--safe-bottom)); /* grows with the player bar via JS (syncPlayerPadding) */
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
code { font-size: 0.9em; }

.top { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 18px; margin: 0; flex: 1; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; font-size: 20px; }
.icon-btn { position: relative; }
.dot { position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge { background: #7a4dff; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.badge.warn { background: var(--danger); display: inline-block; margin: 2px 0; }

.banner { margin: 10px 16px 0; padding: 10px 12px; border-radius: 10px; background: #2a2f3a; font-size: 14px; }
.banner.error { background: #4a2528; }
.banner button { margin-left: 8px; }

.channels { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 4px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 14px; font-size: 15px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.chip.group-toggle.open { border-color: var(--accent); color: var(--accent); font-weight: 600; } /* open group: outline, the selected channel is filled */
.channels.sub { padding-top: 4px; }
.chip.archive-group { border-style: dashed; }
.chip.archived { font-size: 14px; padding: 4px 12px; }
.chip .count { opacity: 0.75; font-size: 12px; margin-left: 4px; }

.channel-bar { display: flex; gap: 16px; flex-wrap: wrap; padding: 6px 16px; color: var(--muted); font-size: 14px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; }

.list { padding: 4px 16px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item.played .name { color: var(--muted); }
.item.played .item-main { opacity: 0.75; }
.item.current .name { color: var(--accent); }
.item-main { flex: 1; min-width: 0; background: none; border: 0; text-align: left; padding: 0; }
.name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.dl > i { background: var(--ok); }
.item-actions { display: flex; gap: 6px; }
.mini { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; min-width: 36px; height: 36px; font-size: 15px; padding: 0 8px; }
.mini.on { border-color: var(--ok); color: var(--ok); }

.settings { position: fixed; inset: 0; overflow-y: auto; background: var(--bg); padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); z-index: 20; }
.settings h2 { margin-top: 0; }
.settings h3 { margin: 20px 0 6px; font-size: 16px; }
.settings label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.settings select { width: 100%; padding: 10px; font-size: 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); margin-bottom: 4px; }
.settings .toggle { color: var(--text); margin-top: 10px; }
.link-btn { background: none; border: 0; color: var(--accent); padding: 0; font-size: 14px; }
.channel-settings-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.channel-settings-row strong { display: block; margin-bottom: 6px; }
.channel-settings-row label { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; color: var(--text); font-size: 14px; }
.channel-settings-row input[type="number"] { width: 70px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.settings input[type="text"], .settings input[type="email"] { width: 100%; padding: 10px; font-size: 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.hint { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn { border: 0; background: var(--accent); color: #06121f; border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.btn.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--panel); color: var(--danger); border: 1px solid var(--danger); }

.player { position: fixed; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 10px 16px calc(12px + var(--safe-bottom)); z-index: 10; }
.now-title { font-weight: 600; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; line-height: 1.3; overflow-wrap: anywhere; }
.now-channel { font-size: 12px; color: var(--muted); }
#seek { width: 100%; margin: 8px 0 0; accent-color: var(--accent); }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.controls { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 4px; }
.ctl { background: none; border: 1px solid var(--line); border-radius: 50%; width: 52px; height: 52px; font-size: 16px; font-weight: 600; }
.ctl.play { width: 64px; height: 64px; font-size: 26px; background: var(--accent); color: #06121f; border: 0; }
.ctl.rate { border-radius: 12px; width: 64px; font-size: 15px; }
.ctl:disabled, #seek:disabled { opacity: 0.4; }
