/* CSS Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* Dark Theme (default) */
:root {
  color-scheme: dark light;
  --bg-primary: #0a0a0a;
  --bg-card: #161616;
  --bg-surface: #1a1a1a;
  --bg-elevated: #2a2a2a;
  --bg-hover: #222;
  --text-primary: #fff;
  --text-secondary: #a0a0a0;
  --text-muted: #666;
  --accent: #00D4AA;
  --accent-dim: rgba(0, 212, 170, 0.15);
  --accent-glow: rgba(0, 212, 170, 0.3);
  --danger: #FF4757;
  --danger-dim: rgba(255, 71, 87, 0.15);
  --border: rgba(255, 255, 255, 0.08);
  --glass-bg: rgba(26, 26, 26, 0.78);
  --glass-border: rgba(255, 255, 255, 0.1);
  --shadow: 0 -2px 20px rgba(0, 0, 0, 0.5);
  --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --img-bg: #1e1e1e;
  --search-bg: #1e1e1e;
  --pill-bg: #222;
  --pill-active-bg: var(--accent);
  --pill-active-text: #000;
  --skeleton: #1e1e1e;
  --overlay: rgba(0, 0, 0, 0.6);
}

/* Light Theme */
@media (prefers-color-scheme:light) {
  :root {
    --bg-primary: #F2F2F7;
    --bg-card: #FFF;
    --bg-surface: #FFF;
    --bg-elevated: #E5E5EA;
    --bg-hover: #F0F0F5;
    --text-primary: #000;
    --text-secondary: #3C3C43;
    --text-muted: #8E8E93;
    --accent: #00B894;
    --accent-dim: rgba(0, 184, 148, 0.12);
    --accent-glow: rgba(0, 184, 148, 0.25);
    --danger: #FF3B30;
    --danger-dim: rgba(255, 59, 48, 0.12);
    --border: rgba(0, 0, 0, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.82);
    --glass-border: rgba(0, 0, 0, 0.06);
    --shadow: 0 -1px 12px rgba(0, 0, 0, 0.08);
    --card-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
    --img-bg: #E5E5EA;
    --search-bg: #E5E5EA;
    --pill-bg: #E5E5EA;
    --pill-active-text: #FFF;
    --skeleton: #E5E5EA;
    --overlay: rgba(0, 0, 0, 0.35);
  }
}

/* Reset */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box
}

html {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased
}

a {
  color: inherit;
  text-decoration: none
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit
}

img {
  display: block;
  max-width: 100%
}

input {
  font-family: inherit
}

/* App Shell */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top)
}

#app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain
}

#app-content::-webkit-scrollbar {
  width: 0
}

.view {
  min-height: 100%;
  padding: 16px 16px 0;
  animation: fadeIn .25s ease
}

.view-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 20px;
  letter-spacing: -.5px
}

/* Tab Bar */
#tab-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 52px;
  min-height: 52px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--glass-border);
  padding-bottom: env(safe-area-inset-bottom);
  box-sizing: content-box;
  z-index: 100
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  flex: 1;
  transition: transform .15s;
  -webkit-user-select: none;
  user-select: none
}

.tab-item:active {
  transform: scale(.9)
}

.tab-item svg {
  width: 24px;
  height: 24px;
  fill: var(--text-muted);
  transition: fill .2s
}

.tab-item span {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color .2s
}

.tab-item.active svg {
  fill: var(--accent)
}

.tab-item.active span {
  color: var(--accent)
}

/* Mini Player */
#mini-player {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--glass-border);
  cursor: pointer;
  z-index: 99
}

#mini-player.visible {
  display: flex
}

#mini-player:active {
  background: var(--bg-hover)
}

.mini-thumb {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--img-bg);
  flex-shrink: 0
}

.mini-info {
  flex: 1;
  min-width: 0
}

.mini-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.mini-meta {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.mini-eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 18px;
  margin-right: 4px
}

.mini-eq .eq-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  animation: eq .6s ease-in-out infinite alternate
}

.mini-eq .eq-bar:nth-child(1) {
  height: 40%;
  animation-delay: 0s
}

.mini-eq .eq-bar:nth-child(2) {
  height: 70%;
  animation-delay: .15s
}

.mini-eq .eq-bar:nth-child(3) {
  height: 50%;
  animation-delay: .3s
}

.mini-eq.paused .eq-bar {
  animation: none;
  height: 30%
}

.mini-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text-primary);
  flex-shrink: 0;
  transition: transform .12s
}

.mini-play-btn:active {
  transform: scale(.88)
}

.mini-play-btn svg {
  width: 16px;
  height: 16px;
  fill: var(--bg-primary)
}

/* Now Playing */
#now-playing {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-primary);
  transform: translateY(100%);
  transition: transform .42s cubic-bezier(.16, 1, .3, 1);
  overflow-y: auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom)
}

#now-playing.open {
  transform: translateY(0)
}

.np-handle {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--text-muted);
  margin: 10px auto 0;
  opacity: .5
}

.np-close {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 16px;
  padding: 8px
}

.np-close svg {
  width: 24px;
  height: 24px;
  fill: var(--text-secondary)
}

.np-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 32px 32px;
  min-height: 100%;
  justify-content: center;
  gap: 24px
}

.np-art-wrap {
  width: min(280px, 70vw);
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .4)
}

.np-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--img-bg)
}

.np-station-name {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -.3px
}

.np-station-country {
  font-size: 14px;
  color: var(--text-secondary)
}

.np-genres {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center
}

.np-genre-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent-dim);
  color: var(--accent)
}

.np-controls {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-top: 8px
}

.np-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s
}

.np-btn:active {
  transform: scale(.85)
}

.np-btn svg {
  fill: var(--text-primary)
}

.np-btn-skip svg {
  width: 28px;
  height: 28px
}

.np-btn-play {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 4px 20px var(--accent-glow)
}

.np-btn-play svg {
  width: 28px;
  height: 28px;
  fill: #000
}

.np-btn-fav svg {
  width: 24px;
  height: 24px
}

.np-btn-fav.active svg {
  fill: var(--danger)
}

.np-volume {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 280px
}

.np-volume svg {
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
  flex-shrink: 0
}

.np-volume input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-elevated);
  outline: none
}

.np-volume input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3)
}

.np-visualizer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 40px;
  margin-top: 8px
}

.np-visualizer .v-bar {
  flex: 1;
  max-width: 4px;
  border-radius: 2px;
  background: var(--accent);
  transition: height .08s ease;
  min-height: 2px
}

/* Search */
.search-wrap {
  position: relative;
  margin-bottom: 20px
}

.search-input {
  width: 100%;
  height: 40px;
  border-radius: 12px;
  background: var(--search-bg);
  border: 1px solid transparent;
  padding: 0 14px 0 40px;
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color .2s, background .2s
}

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

.search-input:focus {
  border-color: var(--accent);
  background: var(--bg-card)
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
  pointer-events: none
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0
}

.search-clear.visible {
  display: flex
}

.search-clear svg {
  width: 12px;
  height: 12px;
  fill: var(--bg-primary)
}

/* Sections */
.section {
  margin-bottom: 28px
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.2px
}

.section-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent)
}

/* Horizontal Scroll */
.h-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: none
}

.h-scroll::-webkit-scrollbar {
  display: none
}

/* Station Cards */
.station-card {
  flex-shrink: 0;
  width: 150px;
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s;
  scroll-snap-align: start;
  box-shadow: var(--card-shadow)
}

.station-card:active {
  transform: scale(.96)
}

.station-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--img-bg)
}

.station-card-body {
  padding: 10px 12px 12px
}

.station-card-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.station-card-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

/* Circle Card */
.circle-card {
  flex-shrink: 0;
  width: 72px;
  text-align: center;
  cursor: pointer;
  transition: transform .15s;
  scroll-snap-align: start
}

.circle-card:active {
  transform: scale(.92)
}

.circle-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--img-bg);
  margin: 0 auto 6px;
  border: 2px solid var(--border)
}

.circle-flag {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: var(--bg-card);
  margin: 0 auto 6px;
  border: 2px solid var(--border)
}

.circle-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

/* Grid Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px
}

.grid-card {
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s;
  box-shadow: var(--card-shadow)
}

.grid-card:active {
  transform: scale(.96)
}

.grid-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--img-bg)
}

.grid-card-body {
  padding: 10px 12px 12px
}

.grid-card-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px
}

.grid-card-meta {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.grid-card-tags {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap
}

.grid-card-tag {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent)
}

/* Filter Pills */
.pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  margin-bottom: 16px
}

.pills::-webkit-scrollbar {
  display: none
}

.pill {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: var(--pill-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .2s;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap
}

.pill:active {
  transform: scale(.95)
}

.pill.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-text)
}

/* Genre Cards */
.genre-card {
  flex-shrink: 0;
  width: 120px;
  height: 72px;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: flex-end;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform .15s;
  scroll-snap-align: start;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .3)
}

.genre-card:active {
  transform: scale(.95)
}

.genre-card:nth-child(1) {
  background: linear-gradient(135deg, #00D4AA, #00897B)
}

.genre-card:nth-child(2) {
  background: linear-gradient(135deg, #FF6B6B, #C0392B)
}

.genre-card:nth-child(3) {
  background: linear-gradient(135deg, #FECA57, #F39C12)
}

.genre-card:nth-child(4) {
  background: linear-gradient(135deg, #54A0FF, #2E86DE)
}

.genre-card:nth-child(5) {
  background: linear-gradient(135deg, #5F27CD, #341F97)
}

.genre-card:nth-child(6) {
  background: linear-gradient(135deg, #FF9FF3, #F368E0)
}

.genre-card:nth-child(7) {
  background: linear-gradient(135deg, #01A3A4, #006266)
}

.genre-card:nth-child(8) {
  background: linear-gradient(135deg, #FF6348, #EB2F06)
}

.genre-card:nth-child(9) {
  background: linear-gradient(135deg, #2ED573, #009432)
}

.genre-card:nth-child(10) {
  background: linear-gradient(135deg, #FFA502, #E67E22)
}

.genre-card:nth-child(n+11) {
  background: linear-gradient(135deg, #747d8c, #57606f)
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: .4
}

.empty-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px
}

.empty-text {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 260px;
  line-height: 1.5
}

/* Live Badge */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--danger);
  letter-spacing: .5px
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.5s ease-in-out infinite
}

/* Playing indicator */
.station-card.playing,
.grid-card.playing {
  outline: 2px solid var(--accent);
  outline-offset: -2px
}

.station-card.playing .station-card-name,
.grid-card.playing .grid-card-name {
  color: var(--accent)
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

@keyframes eq {
  0% {
    height: 20%
  }

  50% {
    height: 80%
  }

  100% {
    height: 40%
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .5
  }
}

/* Responsive */
@media(min-width:500px) {
  .grid {
    grid-template-columns: repeat(3, 1fr)
  }

  .station-card {
    width: 170px
  }
}

@media(min-width:768px) {
  #app {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "sidebar main"
      "sidebar player";
    max-width: none;
    box-shadow: none;
    margin: 0;
  }

  #tab-bar {
    grid-area: sidebar;
    flex-direction: column;
    justify-content: flex-start;
    height: auto;
    border-top: none;
    border-right: 1px solid var(--glass-border);
    padding: 40px 0 0 0;
    align-items: stretch;
    background: transparent;
    backdrop-filter: none;
  }

  .tab-item {
    flex: none;
    flex-direction: row;
    gap: 16px;
    padding: 16px 24px;
    justify-content: flex-start;
  }

  .tab-item svg {
    width: 22px;
    height: 22px;
  }

  .tab-item span {
    font-size: 15px;
    font-weight: 600;
  }

  #app-content {
    grid-area: main;
    padding: 0;
  }

  .view {
    padding: 32px 40px 0;
  }

  #mini-player {
    grid-area: player;
    padding: 16px 32px;
    border-top: 1px solid var(--glass-border);
    border-left: 1px solid var(--glass-border);
  }

  .mini-thumb {
    width: 56px;
    height: 56px;
  }

  .mini-name {
    font-size: 16px;
  }

  #now-playing {
    width: 400px;
    left: auto;
    right: 0;
    border-left: 1px solid var(--glass-border);
    transform: translateX(100%);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
  }

  #now-playing.open {
    transform: translateX(0);
  }

  .np-handle {
    display: none;
  }

  .np-close {
    right: 24px;
    left: auto;
    top: 24px;
  }

  .np-close svg {
    transform: rotate(-90deg);
    width: 32px;
    height: 32px;
  }

  .grid {
    grid-template-columns: repeat(4, 1fr)
  }

  .bottom-spacer {
    height: 80px
  }
}

@media(min-width:1024px) {
  .grid {
    grid-template-columns: repeat(5, 1fr)
  }
}

@media(min-width:1440px) {
  .grid {
    grid-template-columns: repeat(6, 1fr)
  }
}

/* Install Prompt */
.install-prompt {
  position: fixed;
  bottom: 70px;
  left: 16px;
  right: 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 150;
  transform: translateY(200%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.install-prompt.visible {
  transform: translateY(0);
}

.install-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.install-icon img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.install-text strong {
  font-size: 14px;
}

.install-text span {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.install-btn {
  background: var(--accent);
  color: #000;
  font-weight: 600;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 20px;
}

.install-btn:active {
  transform: scale(0.95);
}

.install-close {
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  padding: 0 4px;
}