:root {
  --bg: #0b0d10;
  --surface: #151922;
  --surface-2: #1c2230;
  --border: #2a3142;
  --text: #e8eaef;
  --muted: #8b93a7;
  --accent: #ff3b5c;
  --accent-2: #ff7a45;
  --ok: #3dd68c;
  --card: #ffffff;
  --overlay: #002e3b;
  --radius: 10px;
  --mini-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --header-h: 56px;
  /* radioonline cover ratio ~96x66 */
  --logo-ratio: 96 / 66;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  min-height: 100%; min-height: 100dvh;
}

/* Hide scrollbars — scroll still works (touch / trackpad / wheel) */
html {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* old Edge */
}
html::-webkit-scrollbar,
body::-webkit-scrollbar,
.app::-webkit-scrollbar,
.main::-webkit-scrollbar,
.np-sheet::-webkit-scrollbar,
.now-playing::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
body,
.app,
.main,
.np-sheet,
.now-playing {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
body { -webkit-tap-highlight-color: transparent; }
.hidden, [hidden] { display: none !important; }

.app {
  min-height: 100dvh;
  padding-bottom: calc(var(--mini-h) + var(--safe-b) + 10px);
}

.header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: var(--header-h); padding: 8px 12px;
  background: rgba(11, 13, 16, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.logo-title {
  margin: 0; font-size: 1.15rem; font-weight: 800; letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.header-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.country-toggle { display: inline-flex; gap: 4px; }

.chip {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); border-radius: 999px; padding: 6px 10px;
  font-size: 0.75rem; font-weight: 700; cursor: pointer;
}
.chip-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 28px;
  padding: 0 !important;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #111 !important;
}
.chip-flag.is-on,
.chip-flag[aria-pressed="true"],
.chip.chip-flag.is-on,
.chip.chip-flag[aria-pressed="true"] {
  color: inherit;
  border: 2px solid #ff3b5c !important;
  background: #111 !important;
  box-shadow: none !important;
}
.chip-flag .flag-img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  border-radius: 0;
  object-fit: cover;
  box-shadow: none !important;
  pointer-events: none;
}
.chip-flag.is-on .flag-img,
.chip-flag[aria-pressed="true"] .flag-img {
  box-shadow: none !important;
}
.chip[aria-pressed="true"], .chip.is-on, .chip.is-active {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.chip-autoplay[aria-pressed="false"], .chip-autoplay:not(.is-on) {
  color: var(--muted); background: var(--surface); border-color: var(--border);
}

.tabs {
  display: flex; gap: 4px; padding: 8px 12px;
  position: sticky; top: var(--header-h); z-index: 15; background: var(--bg);
}
.tab {
  flex: 1; border: 0; background: var(--surface); color: var(--muted);
  border-radius: 10px; padding: 10px 8px; font-weight: 700; cursor: pointer;
}
.tab.is-active {
  color: #fff; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}

.main { padding: 4px 10px 16px; }

/* Dense tiles — wider cards to fit radioonline 96x66 logos */
.station-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.station-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 0; background: transparent; border: 0; cursor: pointer;
  color: inherit; text-align: center;
}
.station-card .cover {
  position: relative;
  width: 100%;
  aspect-ratio: var(--logo-ratio);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 1px 0 rgba(0,0,0,0.25);
}
.station-card.is-playing .cover,
.station-card.is-selected .cover {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.station-card .avatar {
  width: 100%; height: 100%;
  border-radius: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #fff;
  font-size: 0.85rem;
  color: #333;
}
.station-card .name {
  font-size: 0.68rem; font-weight: 650; line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; width: 100%; min-height: 0;
}

.empty-state { text-align: center; color: var(--muted); padding: 40px 12px; }

.avatar {
  display: inline-grid; place-items: center;
  background: var(--surface-2); color: #fff; font-weight: 800; overflow: hidden;
  background-size: contain; background-repeat: no-repeat; background-position: center;
  flex-shrink: 0;
}
.avatar.lg {
  width: min(72vw, 280px); aspect-ratio: var(--logo-ratio);
  height: auto; border-radius: 12px; font-size: 2rem;
  background-color: #fff; color: #333;
}

.mini-player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  min-height: var(--mini-h);
  padding: 8px 12px calc(8px + var(--safe-b));
  background: rgba(21, 25, 34, 0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.icon-btn, .play-large {
  appearance: none; border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; width: 44px; height: 44px; border-radius: 50%;
  font-size: 1rem; cursor: pointer; flex-shrink: 0;
}
.mini-meta {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0;
  background: transparent; border: 0; color: inherit; cursor: pointer;
  padding: 0; text-align: left;
}
.mini-meta .mini-text { text-align: center; }
.mini-meta .avatar {
  width: 52px; height: auto; aspect-ratio: var(--logo-ratio);
  border-radius: 6px; font-size: 0.7rem; background-color: #fff; color: #333;
}
.mini-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  align-items: center;
  text-align: center;
}
.mini-freq {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.np-freq {
  margin: 2px 0 0;
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--accent-2);
  letter-spacing: 0.04em;
}
.mini-name {
  font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.mini-fav {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  flex-shrink: 0;
}
.mini-fav.is-on { color: #ff4d6d; }
.vol-wrap {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
  max-width: 140px;
}
.vol-wrap-np {
  margin-top: 18px;
  gap: 0;
}
.vol-wrap-np .vol-slider {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  height: 6px;
  margin: 0 12px;
}
.vol-step:active { transform: scale(0.96); background: rgba(255,255,255,0.1); }
.vol-mute {
  border: 0; background: transparent; color: var(--text);
  font-size: 1rem; cursor: pointer; padding: 4px; line-height: 1;
}
.vol-slider {
  width: 90px; accent-color: var(--accent); cursor: pointer;
}
@media (max-width: 420px) {
  .vol-slider { width: 64px; }
}

.np-sheet {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: min(360px, 100%);
  max-width: 100%;
  padding: 8px 4px 4px;
  cursor: default;
}
.now-playing {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px calc(28px + var(--safe-b));
  background: rgba(8, 10, 14, 0.96);
  backdrop-filter: blur(16px);
  cursor: pointer;
}
.np-close {
  position: absolute; top: 12px; right: 12px; border: 0;
  background: var(--surface); color: var(--text);
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
}
.np-name {
  margin: 14px 0 0;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.np-country {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.np-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}
.np-transport,
.vol-wrap-np {
  width: 220px;
  max-width: 220px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}
.np-transport {
  margin-top: 22px;
  gap: 0;
}
.np-skip,
.vol-step {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  padding: 0;
  flex: 0 0 46px;
  -webkit-tap-highlight-color: transparent;
}
.np-skip {
  padding: 0 0 2px;
  font-size: 1.5rem;
  font-weight: 400;
}
.np-skip:active { transform: scale(0.96); }
.np-skip:disabled { opacity: 0.35; cursor: default; }
.np-sheet .play-large {
  width: 76px;
  height: 76px;
  font-size: 1.55rem;
  margin-top: 0;
  box-shadow: 0 8px 24px rgba(255, 90, 60, 0.28);
}
.sleep-status { min-height: 1.2em; color: var(--ok); font-size: 0.8rem; }

@media (min-width: 480px) {
  .station-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
}
@media (min-width: 720px) {
  .header { padding-inline: 16px; }
  .station-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
  .main { padding-inline: 16px; max-width: 1100px; margin-inline: auto; }
}
@media (min-width: 1000px) {
  .station-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
  .station-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); max-width: 1200px; margin-inline: auto; }
}

/* Full station name when logo image missing — larger, wraps up to 3 lines */
.avatar.avatar--text,
.station-card .avatar.avatar--text {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 6px 7px;
  font-size: clamp(0.82rem, 3.1vw, 1.02rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-align: center;
  color: #141414;
  white-space: normal;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  max-height: 100%;
}
.avatar.lg.avatar--text {
  font-size: clamp(1.4rem, 4.8vw, 1.95rem);
  padding: 18px 22px;
  line-height: 1.25;
}
.mini-meta .avatar.avatar--text {
  font-size: 0.62rem;
  padding: 3px 4px;
  line-height: 1.15;
}

.station-card.is-drop-target .cover {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
  background: rgba(255, 90, 60, 0.12);
}
.station-card.is-drop-target .avatar {
  opacity: 0.85;
}


/* Now Playing — clean vertical rhythm */
.np-sheet .avatar.lg,
.np-sheet .np-logo.avatar.lg {
  width: min(58vw, 220px);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);
}
.np-sheet .chip {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.82rem;
}
.vol-wrap-np .vol-slider::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
}
.sleep-status {
  margin-top: 10px;
  min-height: 1.1em;
}


/* NP volume must match transport width; beat .vol-wrap max-width:140px */
.vol-wrap.vol-wrap-np {
  width: 220px;
  max-width: 220px;
  gap: 0;
}


/* Footer: SVG fav + mute (no emoji); fav sits with volume on the right */
.mini-player {
  gap: 10px;
}
.mini-meta {
  justify-content: center;
  text-align: center;
}
.mini-text {
  max-width: min(42vw, 220px);
  align-items: center;
  text-align: center;
}
.mini-end {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}
.mini-fav {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  padding: 6px;
  line-height: 0;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0;
}
.mini-fav .ico-heart { display: block; }
.mini-fav .ico-heart path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}
.mini-fav.is-on { color: #ff4d6d; }
.mini-fav.is-on .ico-heart path {
  fill: currentColor;
  stroke: none;
}
.vol-mute {
  position: relative;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  padding: 6px;
  line-height: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0;
}
.vol-mute .ico-speaker { display: block; }
.vol-mute .mute-badge {
  display: none;
  position: absolute;
  inset: 2px;
  border: 2px solid #ff3b5c;
  border-radius: 50%;
  box-sizing: border-box;
  pointer-events: none;
}
.vol-mute .mute-badge::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120%;
  height: 2px;
  background: #ff3b5c;
  transform: translate(-50%, -50%) rotate(-45deg);
  border-radius: 1px;
}
.vol-mute.is-muted .mute-badge { display: block; }
@media (max-width: 420px) {
  .mini-text { max-width: 34vw; }
}
