:root {
  --bg: #f6f7f5;
  --panel: #ffffff;
  --ink: #14231b;
  --muted: #6d7d74;
  --line: #e4e8e4;
  --accent: #2f6b4f;
  --accent-soft: #e7f1eb;
  --hover: #f0f3f0;
  --player: rgba(255, 255, 255, 0.92);
  --strip: var(--accent);
  --strip-ink: rgba(255, 255, 255, 0.88);
  --strip-line: rgba(255, 255, 255, 0.40);
  --strip-hover: rgba(255, 255, 255, 0.14);
  --chip-bg: #ffffff;
  --player-ink: #ffffff;
  --player-btn-bg: #ffffff;
  --shadow: 0 1px 2px rgba(20, 35, 27, 0.06), 0 10px 30px rgba(20, 35, 27, 0.06);
  --radius: 14px;
  --h: 92px;
}

[data-theme="dark"] {
  --bg: #0e1512;
  --panel: #141d19;
  --ink: #e9f0eb;
  --muted: #93a59c;
  --line: #23312b;
  --accent: #6fbf95;
  --accent-soft: #1a2a23;
  --hover: #1b2621;
  --player: rgba(20, 29, 25, 0.94);
  --strip: var(--accent);
  --strip-ink: #0d1b15;
  --strip-line: rgba(13, 27, 21, 0.40);
  --strip-hover: rgba(13, 27, 21, 0.10);
  --chip-bg: #262b27;
  --player-ink: #0b1410;
  --player-btn-bg: #0b1410;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--h) + 56px);
  transition: background-color 0.25s ease, color 0.25s ease;
}

.ico {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  display: block;
}

/* ---------- header ---------- */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 3px solid color-mix(in srgb, var(--ink) 20%, transparent);
}

.brand { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }

.brand-mark { display: inline-flex; align-items: flex-end; gap: 2.5px; height: 20px; }
.brand-mark i {
  width: 3px; border-radius: 2px; background: var(--accent);
  animation: idle 2.4s ease-in-out infinite;
}
.brand-mark i:nth-child(1) { height: 8px;  animation-delay: 0s; }
.brand-mark i:nth-child(2) { height: 16px; animation-delay: 0.2s; }
.brand-mark i:nth-child(3) { height: 11px; animation-delay: 0.4s; }
.brand-mark i:nth-child(4) { height: 18px; animation-delay: 0.6s; }

@keyframes idle {
  0%, 100% { transform: scaleY(0.75); }
  50% { transform: scaleY(1); }
}

.brand-name { font-weight: 800; letter-spacing: 0.05em; font-size: 1.32rem; text-transform: uppercase; }
.brand-accent { color: var(--accent); }

.search-wrap {
  position: relative; flex: 1 1 auto; max-width: 460px;
  display: flex; align-items: center;
}
.search-wrap .ico {
  position: absolute; left: 12px; color: var(--muted);
  width: 17px; height: 17px; pointer-events: none;
}
#search {
  width: 100%; height: 40px; padding: 0 36px 0 38px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--ink);
  font-size: 0.95rem; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#search::placeholder { color: var(--muted); }
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.clear {
  position: absolute; right: 8px; width: 26px; height: 26px;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.clear:hover { background: var(--hover); color: var(--ink); }

.actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); transition: background 0.15s; }
.pill[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.pill[aria-pressed="true"] .dot { background: var(--accent); }
.pill:hover { border-color: var(--muted); }

.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--panel); color: var(--ink); cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { background: var(--hover); }

#themeBtn .moon { display: none; }
[data-theme="dark"] #themeBtn .sun { display: none; }
[data-theme="dark"] #themeBtn .moon { display: block; }

/* ---------- chips ---------- */

.chips {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px 12px;
  background: var(--strip);
  border-bottom: 3px solid color-mix(in srgb, var(--ink) 20%, transparent);
}
.chips-secondary { padding-top: 8px; padding-bottom: 4px; }
.chip {
  flex: 0 0 auto; height: 32px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 0.86rem; font-weight: 500; cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { color: var(--ink); border-color: var(--muted); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* chips keep their own solid surface on the green strip */
.chips .chip { background: var(--chip-bg); border-color: var(--line); color: var(--ink); }
.chips .chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ---------- list ---------- */

main { padding: 8px 14px 20px; max-width: 1080px; margin: 0 auto; }

.station-list { display: flex; flex-direction: column; }

.station {
  display: grid; grid-template-columns: 48px 1fr auto; align-items: center;
  gap: 14px; padding: 10px 12px; border-radius: var(--radius);
  cursor: pointer; border: 1px solid transparent;
  transition: background 0.12s ease;
}
.station:hover { background: var(--hover); }
.station.playing { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.station.dead { opacity: 0.45; }

.logo {
  width: 48px; height: 48px; border-radius: 10px; object-fit: cover;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.05rem; text-transform: uppercase;
  overflow: hidden;
}
.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.meta { min-width: 0; }
.name {
  font-weight: 600; font-size: 0.98rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.sub {
  font-size: 0.82rem; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.right { display: flex; align-items: center; gap: 10px; }

.badge {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 3px 7px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
}
.badge.low { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.star {
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.station:hover .star, .station.faved .star { opacity: 1; }
.star:hover { color: var(--accent); transform: scale(1.08); }
.station.faved .star { color: var(--accent); }
.station.faved .star svg { fill: currentColor; }

/* heart glyphs, both in the list and in the player */
.star .ico { width: 24px; height: 24px; }
.fav .ico { width: 24px; height: 24px; }

.eq { display: none; }

/* ---------- states ---------- */

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

.more {
  display: block; width: 100%; max-width: 320px; margin: 14px auto 8px;  height: 44px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 0.9rem; font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.more:hover { background: var(--hover); border-color: var(--muted); }
.more[hidden] { display: none; }.empty p { margin: 0 0 4px; font-weight: 600; color: var(--ink); }
.empty span { font-size: 0.88rem; }

.skeleton { display: flex; flex-direction: column; gap: 6px; }
.sk-row {
  height: 68px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--panel) 25%, var(--hover) 50%, var(--panel) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- player ---------- */

.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--h);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center; gap: 18px;
  padding: 0 24px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--player);
  backdrop-filter: blur(16px);
  border-top: 3px solid color-mix(in srgb, var(--ink) 20%, transparent);
  box-shadow: var(--shadow);
}

.play-btn {
  position: relative;
  width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex: 0 0 auto;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
[data-theme="dark"] .play-btn { color: #0e1512; }
.play-btn:hover { transform: scale(1.04); }
.play-btn:active { transform: scale(0.97); }
.play-btn .ico { width: 32px; height: 32px; }
.play-btn .pause { display: none; }
.player.playing .play-btn .play { display: none; }
.player.playing .play-btn .pause { display: block; }

.spinner {
  position: absolute; inset: 0; margin: auto;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  display: none; animation: spin 0.8s linear infinite;
}
[data-theme="dark"] .spinner { border-color: rgba(14, 21, 18, 0.3); border-top-color: #0e1512; }
.player.loading .spinner { display: block; }
.player.loading .play-btn .ico { opacity: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.now { min-width: 0; }
.now-title {
  font-weight: 600; font-size: 1rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.now-sub {
  font-size: 0.8rem; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.now-track {
  font-size: 0.86rem; color: var(--ink); margin-top: 3px;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.vol { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.vol .ico { width: 17px; height: 17px; }
#vol {
  -webkit-appearance: none; appearance: none;
  width: 92px; height: 4px; border-radius: 2px;
  background: var(--line); outline: none; cursor: pointer;
}
#vol::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 0; cursor: pointer;
}
#vol::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--accent); border: 0; }

.fav { width: 38px; height: 38px; border: 0; background: transparent; }
.fav[aria-pressed="true"] { color: var(--accent); }
.fav[aria-pressed="true"] svg { fill: currentColor; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--h) + 18px);
  transform: translate(-50%, 12px);
  background: var(--ink); color: var(--bg);
  padding: 9px 16px; border-radius: 999px; font-size: 0.85rem;
  opacity: 0; pointer-events: none; transition: all 0.22s ease; z-index: 40;
  max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  :root { --h: 72px; }
  .top { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
  .search-wrap { order: 3; flex: 1 1 100%; max-width: none; }
  .actions { margin-left: auto; }
  .chips { padding: 12px 14px 12px; }
  main { padding: 6px 8px 18px; }
  .station { grid-template-columns: 44px 1fr auto; gap: 12px; padding: 9px 8px; }
  .logo { width: 44px; height: 44px; }
  .badge { display: none; }
  .star { opacity: 1; }
  .player { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; padding: 0 12px; }
  .vol { display: none; }
  .now-title { font-size: 0.9rem; }
  .now-track { font-size: 0.78rem; }
  .play-btn { width: 46px; height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* ---------- player on the green strip ---------- */

.player {
  background: var(--strip);
  backdrop-filter: none;
}
.player .now-title { color: var(--player-ink); }
.player .now-sub,
.player .now-track { color: var(--player-ink); opacity: 0.82; }
.player .vol,
.player .vol .ico { color: var(--player-ink); }
.player .icon-btn,
.player .fav { color: var(--player-ink); border-color: var(--strip-line); background: transparent; }
.player .fav { border: 0; }
.player .fav[aria-pressed="true"] { color: var(--player-ink); }
.player .play-btn { background: var(--player-btn-bg); color: var(--accent); }
[data-theme="dark"] .player .play-btn { color: var(--accent); }
.player #vol { background: var(--strip-line); }
.player #vol::-webkit-slider-thumb { background: var(--player-ink); }
.player #vol::-moz-range-thumb { background: var(--player-ink); }


/* ---------- mobile volume ---------- */

.vol-wrap { position: relative; display: none; }

.vol-pop {
  position: absolute; right: 0; top: 44px; z-index: 60;
  width: 46px; height: 158px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
#volMobile {
  -webkit-appearance: none; appearance: none;
  position: absolute; left: 50%; top: 50%;
  width: 126px; height: 4px; border-radius: 2px;
  background: var(--line); outline: none; cursor: pointer;
  transform: translate(-50%, -50%) rotate(-90deg);
}
#volMobile::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 0;
}
#volMobile::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 0; }

@media (max-width: 720px) {
  .vol-wrap { display: block; }
}
