:root {
  --bg: #0b0b12;
  --surface: #16161f;
  --surface-hi: #1e1e2a;
  --accent: #ff6b2c;
  --text: #f2f2f5;
  --muted: #9a9aa8;
  --live: #2ee6a8;
  --border: rgba(255, 255, 255, 0.10);
  --radius: 20px;
  --bar: #12121a;
}

html[data-theme="light"] {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-hi: #eeeef2;
  --accent: #e05a1e;
  --text: #16161c;
  --muted: #6c6c78;
  --live: #0f9d68;
  --border: rgba(0, 0, 0, 0.10);
  --bar: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  /* The tab bar is fixed, so the page must not end under it. */
  padding-bottom: 73px;
}

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

.head {
  padding: 18px 20px 0;
}

.head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  flex: none;
}

.brand-text { min-width: 0; }

.brand-text h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.4px;
  white-space: nowrap;
}

.brand-text p {
  margin: 1px 0 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover { background: var(--surface-hi); }
.icon-btn svg { fill: currentColor; }

.search {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.search svg { fill: var(--accent); flex: none; }

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

.search input::placeholder { color: var(--muted); }

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

.chips {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover { background: var(--surface-hi); }

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.list-wrap {
  flex: 1;
  /* Room for the sticky player and the fixed tab bar. */
  padding: 10px 20px 24px;
  overflow-y: auto;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.row:last-child { border-bottom: 0; }

.row-art {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  letter-spacing: -0.3px;
}

.row-main { flex: 1; min-width: 0; }

.row-name {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-region {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

.row-song {
  margin-top: 3px;
  font-size: 13px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-song:empty { display: none; }

.row-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.fav {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.fav:hover { background: var(--surface-hi); }
.fav svg { fill: none; stroke: currentColor; stroke-width: 2; }
.fav.is-on { color: var(--accent); }
.fav.is-on svg { fill: currentColor; stroke: currentColor; }

.row-play {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  flex: none;
}

.row-play svg { fill: currentColor; }
.row-play:hover { filter: brightness(1.1); }
.row-play.is-playing { background: var(--live); }

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

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

.player {
  /* Sticky so it stays visible while the list scrolls. The bottom offset
     lifts it above the fixed tab bar. */
  position: sticky;
  bottom: 73px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 20px 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.player-art {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 16px;
}

.player-meta { flex: 1; min-width: 0; }

.player-name {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The song title is normal text; only the LIVE badge is a badge. */
.player-sub {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-sub.is-live {
  color: var(--live);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* The song title is the accent colour, so it reads as the important line. */
.player-sub.is-song { color: var(--accent); }

.player-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.ctl {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface-hi);
  color: var(--text);
  cursor: pointer;
}

.ctl:hover { filter: brightness(1.15); }
.ctl svg { fill: currentColor; }

.ctl-main {
  width: 46px;
  height: 46px;
  background: var(--accent);
  color: #fff;
}

.ctl-small {
  width: 34px;
  height: 34px;
  background: none;
  color: var(--muted);
}

.volume {
  display: flex;
  align-items: center;
  gap: 2px;
}

#volume {
  width: 96px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- bottom tabs ---------- */

/* Fixed footer: the player is sticky above it, so the two never overlap. */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--bar);
  border-top: 1px solid var(--border);
}

/* The app is centred and narrower than the screen, so the footer is pulled
   back to the same width. */
@media (min-width: 1140px) {
  .tabs { left: 50%; right: auto; width: 1100px; transform: translateX(-50%); }
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab svg { fill: currentColor; }
.tab:hover { background: var(--surface); }
.tab.is-active { color: var(--accent); }

/* ---------- sheets ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
}

.sheet[hidden] { display: none; }

.sheet-panel {
  width: min(560px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
}

.sheet-panel h2 { margin: 0 0 16px; font-size: 20px; }

.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.region-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-hi);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.region-card:hover { border-color: var(--accent); }

.region-code {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.region-count { margin-left: auto; font-size: 13px; color: var(--muted); }

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.setting label { font-weight: 600; }

.setting select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-hi);
  color: var(--text);
  font: inherit;
}

.sheet-close {
  margin-top: 18px;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 640px) {
  .brand-text h1 { font-size: 20px; }
  #volume { width: 64px; }
  .player { margin: 0 12px 8px; }
  .list-wrap { padding: 10px 12px 24px; }
  .player-art { width: 40px; height: 40px; }
  .player-name { font-size: 15px; }
  .player-sub { font-size: 12px; }
}

@media (max-width: 480px) {
  /* The controls shrink so the station name and the song title keep their
     space: the title is the reason the user looks at the player. */
  .ctl { width: 34px; height: 34px; }
  .ctl-main { width: 40px; height: 40px; }
  .ctl-main svg { width: 20px; height: 20px; }
  .ctl svg { width: 16px; height: 16px; }
  .player-controls { gap: 4px; }
  .player { gap: 9px; padding: 8px 10px; }
}

@media (max-width: 420px) {
  .volume { display: none; }
}
