:root {
  --bg: #0e0f13;
  --surface: #17191f;
  --surface-2: #1f222a;
  --border: #2a2e38;
  --text: #f2f3f5;
  --muted: #9097a3;
  --accent: #2f6bff;
  --accent-2: #5b8cff;
  --radius: 14px;
  --tabs-h: 64px;
  --mini-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f6f8;
    --surface: #ffffff;
    --surface-2: #eef0f3;
    --border: #e1e4e9;
    --text: #15171c;
    --muted: #6b7280;
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 16px);
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { fill: currentColor; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(var(--safe-t) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.top h1 { margin: 0 0 10px; font-size: 30px; letter-spacing: -0.02em; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border-radius: 12px; padding: 0 12px;
}
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input {
  flex: 1; min-width: 0; height: 40px; border: 0; outline: 0; background: none;
  color: var(--text); font-size: 16px;
}

main { padding: 0 16px; max-width: 760px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.section-title { font-size: 18px; margin: 22px 0 8px; }

/* Genre chips */
.install-banner {
  display: flex; align-items: center; gap: 12px; padding: 10px 6px 10px 12px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.install-banner[hidden] { display: none; }
.install-banner img { border-radius: 10px; flex: none; }
.install-banner .text { flex: 1; min-width: 0; display: grid; font-size: 15px; }
.install-banner .text span { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.install-open { padding: 8px 16px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; flex: none; }
.install-close { width: 36px; height: 36px; color: var(--muted); }
.icon-btn.install-close svg { width: 20px; height: 20px; }
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 2px;
  scrollbar-width: none; margin: 0 -16px; padding-inline: 16px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 500;
}
.chip.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }

/* Station list */
.stations { list-style: none; margin: 0; padding: 0; }
.station {
  display: flex; align-items: center; gap: 12px; padding: 10px 4px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.station:active { opacity: .6; }
.station .meta { flex: 1; min-width: 0; }
.station .name, .mini .name {
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.station .sub, .mini .sub {
  color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.station.playing .name { color: var(--accent); }
.fav-btn { width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); flex: none; }
.fav-btn svg { width: 22px; height: 22px; }
.fav-btn.on { color: var(--accent); }

.art {
  width: 48px; height: 48px; border-radius: 10px; flex: none; overflow: hidden;
  display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 17px;
  background: var(--surface-2);
}
.art img { width: 100%; height: 100%; object-fit: cover; background: #fff; }

.empty, .loading { color: var(--muted); text-align: center; padding: 32px 0; list-style: none; }
.loading::after {
  content: ""; display: block; width: 22px; height: 22px; margin: 12px auto 0;
  border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.more { display: block; width: 100%; padding: 14px; color: var(--accent); font-weight: 600; }

/* Countries */
.countries { list-style: none; margin: 0; padding: 0; }
.countries li:not(.loading):not(.empty) {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 4px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.countries .flag { font-size: 22px; margin-right: 12px; }
.countries .count { color: var(--muted); font-size: 14px; }
.back { color: var(--accent); font-weight: 600; padding: 4px 0 8px; }

/* Bottom tabs */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}
.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; color: var(--muted);
}
.tabs button svg { width: 24px; height: 24px; }
.tabs button.active { color: var(--accent); }

/* Mini player */
.mini {
  position: fixed; z-index: 11; left: 8px; right: 8px;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 8px);
  height: var(--mini-h); max-width: 744px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; padding: 0 8px 0 10px;
  background: var(--surface-2); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgb(0 0 0 / .35); cursor: pointer;
  transition: transform .25s, opacity .25s;
}
.mini.hidden { transform: translateY(20px); opacity: 0; pointer-events: none; }
.mini .meta { flex: 1; min-width: 0; }

.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn.big { width: 76px; height: 76px; background: var(--text); color: var(--bg); }
.icon-btn.big svg { width: 36px; height: 36px; }
.icon-btn.on { color: var(--accent); }
.spinner {
  width: 24px; height: 24px; border: 2.5px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
}
.icon-btn.big .spinner { width: 32px; height: 32px; }

/* Full player */
.player {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--safe-t) + 12px) 24px calc(var(--safe-b) + 24px);
  background: var(--bg); overflow-y: auto;
  transform: translateY(100%); transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
.player.open { transform: none; }
.player .close { align-self: flex-start; color: var(--muted); }
.player-art {
  flex: none; width: min(72vw, 320px); aspect-ratio: 1; border-radius: 24px; margin: 24px 0 28px;
  display: grid; place-items: center; overflow: hidden; color: #fff;
  font-size: 72px; font-weight: 800; box-shadow: 0 20px 60px rgb(0 0 0 / .4);
}
.player-art img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.player-art img.small { width: 40%; height: 40%; background: none; border-radius: 12px; }
.player-art.has-img { background: #fff !important; }
.player-art.cover img { object-fit: cover; }
.player-name { font-size: 24px; font-weight: 700; text-align: center; }
.player-sub { color: var(--muted); text-align: center; margin-top: 4px; }
.player-track {
  flex: none; max-width: 100%; margin-top: 14px; padding: 8px 14px; border-radius: 12px;
  background: var(--surface-2); font-size: 15px; font-weight: 600; text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.player-track[hidden] { display: none; }
.player-status { color: var(--accent); font-size: 14px; min-height: 20px; margin-top: 10px; text-align: center; }
.player-controls { display: flex; align-items: center; gap: 36px; margin: 24px 0; }
.player-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 420px; }
.player-tags span { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.player-home { margin-top: 20px; color: var(--muted); font-size: 14px; }

.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 16px); z-index: 30;
  transform: translate(-50%, calc(-100% - 60px)); transition: transform .3s;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 500; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

/* Stream quality */
.badge {
  display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 600; line-height: 18px;
}
.quality { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.quality .chip { font-size: 13px; padding: 6px 12px; }

/* About */
body[data-view="about"] .search { display: none; }
.about-hero { text-align: center; padding: 8px 0 20px; }
.about-hero img { border-radius: 20px; }
.about-hero h2 { margin: 12px 0 4px; font-size: 24px; }
.about-hero p { margin: 0; color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card h3 { margin: 0 0 8px; font-size: 17px; }
.card p { margin: 8px 0 0; color: var(--muted); font-size: 15px; }
.card a:not(.button) { color: var(--accent); }
.platform-tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 10px; margin: 4px 0 12px; }
.platform-tabs button { flex: 1; padding: 8px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.platform-tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .2); }
.platform { display: none; }
.platform.active { display: block; }
.steps { margin: 0; padding-left: 22px; }
.steps li { margin: 8px 0; }
.inline-icon { width: 18px; height: 18px; vertical-align: -3px; color: var(--accent); }
.note { font-size: 14px !important; }
.button {
  display: block; text-align: center; padding: 14px; border-radius: 12px; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-weight: 600; text-decoration: none;
}
.support-links { display: grid; gap: 8px; margin-top: 12px; }
.button.support { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; }
.button.support svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.support-bmc { background: #ffdd00; color: #0d0c22; }
.support-kofi { background: #13c3ff; color: #fff; }
.support-vipps { background: #ff5b24; color: #fff; }
.support-paypal { background: #0070ba; color: #fff; }
.support-github { background: #24292f; color: #fff; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .12); }
.support-github svg { color: #db61a2; }
.support-patreon { background: #ff424d; color: #fff; }
