:root {
  --bg: #08080a;
  --bg-elev: #121216;
  --panel: rgba(18, 18, 22, 0.72);
  --panel-solid: #121216;
  --glass: rgba(255, 255, 255, 0.035);
  --glass-border: rgba(255, 255, 255, 0.08);
  --accent: #A4D007;
  --accent-soft: #C8E600;
  --accent-dim: #6f9008;
  --accent-glow: rgba(164, 208, 7, 0.22);
  --accent-wash: rgba(164, 208, 7, 0.12);
  --text: #f2f2f7;
  --text-secondary: #c4c4ce;
  --muted: #8e8e9a;
  --muted-dim: #5c5c68;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --danger: #e88888;
  --danger-bg: rgba(232, 136, 136, 0.1);
  --warn: #d4bc78;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "SF Pro Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
  --blur: 20px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(88, 70, 180, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(60, 50, 140, 0.1), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -0.01em;
  overflow-x: hidden;
  overflow-y: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.25rem 0.65rem;
  padding-top: calc(1rem + env(safe-area-inset-top, 0px));
  padding-right: calc(1.25rem + env(safe-area-inset-right, 0px));
  padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  padding-left: calc(1.25rem + env(safe-area-inset-left, 0px));
  gap: 0.75rem;
}

/* ——— Header ——— */

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-mark {
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.brand .title {
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.15;
}

.subtitle {
  margin: 0.12rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.7rem;
  font-weight: 550;
  letter-spacing: 0.04em;
  color: var(--muted);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.status-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.status-pill[data-state="playing"] {
  color: var(--accent-soft);
  border-color: rgba(164, 208, 7, 0.35);
  background: var(--accent-wash);
}
.status-pill[data-state="playing"] .status-dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.status-pill[data-state="buffering"] {
  color: var(--warn);
  border-color: rgba(212, 188, 120, 0.3);
}
.status-pill[data-state="buffering"] .status-dot {
  background: var(--warn);
  animation: pulse 1s ease-in-out infinite;
}
.status-pill[data-state="error"] {
  color: var(--danger);
  border-color: rgba(232, 136, 136, 0.3);
  background: var(--danger-bg);
}
.status-pill[data-state="error"] .status-dot { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ——— Stage / panels ——— */

.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(340px, 1.05fr);
  gap: 0.9rem;
}

.player-panel,
.list-panel {
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow-md);
}

.player-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.35rem 1.25rem 1.35rem;
  gap: 0.85rem;
}

.list-panel {
  display: flex;
  flex-direction: column;
  padding: 0.85rem;
  min-height: 0;
}

/* ——— Disc / visualizer ——— */

.disc-wrap {
  position: relative;
  width: min(240px, 40vw);
  height: min(240px, 40vw);
  display: grid;
  place-items: center;
}

#viz {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
  pointer-events: none;
}

.disc {
  position: relative;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  z-index: 2;
  box-shadow:
    0 0 0 1px var(--border-strong),
    0 0 0 6px rgba(164, 208, 7, 0.06),
    0 14px 36px rgba(0, 0, 0, 0.5);
  transition: transform 0.45s var(--ease-out), box-shadow 0.35s var(--ease);
}

.disc.spinning {
  animation: spin 18s linear infinite;
  box-shadow:
    0 0 0 1px rgba(164, 208, 7, 0.35),
    0 0 0 6px rgba(164, 208, 7, 0.1),
    0 14px 40px rgba(0, 0, 0, 0.55);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.disc-art {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #2a3a14, #0e0e12 72%);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.disc-art.has-favicon {
  background-size: cover;
}

.disc-ring {
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.disc-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15%;
  height: 15%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2a2a32, #08080a 70%);
  border: 1.5px solid var(--accent-dim);
  z-index: 3;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.08);
}

/* ——— Now playing ——— */

.now-playing {
  text-align: center;
  width: 100%;
  max-width: 24rem;
}

.np-label {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-soft);
  opacity: 0.9;
}

#stationName {
  margin: 0.28rem 0 0.15rem;
  font-size: clamp(1.1rem, 1.9vw, 1.4rem);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 450;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem;
  margin-top: 0.5rem;
  min-height: 1.4rem;
}

.tag {
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 550;
  letter-spacing: 0.02em;
  color: var(--accent-soft);
  border: 1px solid rgba(164, 208, 7, 0.28);
  background: var(--accent-wash);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

/* ——— Controls ——— */

.controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.15rem;
}

.play-btn {
  width: 3.75rem;
  height: 3.75rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text);
  background: linear-gradient(145deg, #A4D007, #6f9008);
  box-shadow:
    0 4px 16px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition:
    transform 0.2s var(--ease-out),
    box-shadow 0.25s var(--ease),
    filter 0.2s var(--ease);
}

.play-btn:hover {
  filter: brightness(1.08);
  transform: scale(1.04);
  box-shadow:
    0 6px 22px rgba(164, 208, 7, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.play-btn:active {
  transform: scale(0.95);
  filter: brightness(0.96);
}

.icon-btn {
  width: 2.6rem;
  height: 2.6rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    border-color 0.2s var(--ease),
    color 0.2s var(--ease),
    background 0.2s var(--ease),
    transform 0.15s var(--ease-out);
}

.icon-btn:hover {
  border-color: rgba(164, 208, 7, 0.4);
  color: var(--accent-soft);
  background: var(--accent-wash);
  transform: scale(1.05);
}
.icon-btn:active { transform: scale(0.94); }

.fav-btn.active {
  color: var(--accent-soft);
  border-color: rgba(164, 208, 7, 0.45);
  background: var(--accent-wash);
}

.volume-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: min(100%, 18.5rem);
  margin-top: 0.1rem;
}

.vol-label {
  font-size: 0.68rem;
  font-weight: 550;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
.vol-value {
  min-width: 1.85rem;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  font-weight: 500;
}

#volume {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 0.3rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  outline: none;
  cursor: pointer;
}

#volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.15s var(--ease-out);
}
#volume::-webkit-slider-thumb:hover { transform: scale(1.12); }

#volume::-moz-range-thumb {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.retry-btn {
  margin-top: 0.15rem;
  padding: 0.4rem 0.95rem;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(232, 136, 136, 0.35);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease-out);
}
.retry-btn:hover { background: rgba(232, 136, 136, 0.16); }
.retry-btn:active { transform: scale(0.97); }
.retry-btn.hidden { display: none; }

/* ——— Search / chips / tabs ——— */

.search-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

#searchInput {
  width: 100%;
  padding: 0.55rem 0.85rem;
  min-height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 450;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}

#searchInput:focus {
  border-color: rgba(164, 208, 7, 0.45);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: rgba(0, 0, 0, 0.45);
}

#searchInput::placeholder { color: var(--muted-dim); }

.chip, .tab {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    color 0.2s var(--ease),
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    transform 0.15s var(--ease-out);
}

.chip {
  padding: 0 0.75rem;
  min-height: 42px;
  white-space: nowrap;
}

.chip:hover, .tab:hover {
  color: var(--text-secondary);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.05);
}

.chip.active, .tab.active {
  color: var(--text);
  background: var(--accent-wash);
  border-color: rgba(164, 208, 7, 0.4);
  box-shadow: 0 0 0 1px rgba(164, 208, 7, 0.08);
}

.chip:active, .tab:active { transform: scale(0.97); }

.genre-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  margin: 0 0 0.5rem;
  padding: 0.05rem 0.05rem 0.25rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}

.genre-chips::-webkit-scrollbar { height: 3px; }
.genre-chips::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border-radius: 999px;
}

.genre-chip {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 0.7rem;
  font-size: 0.7rem;
  font-weight: 550;
  border-radius: 999px;
}

.list-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.tab {
  padding: 0.38rem 0.85rem;
  min-height: 38px;
  border-radius: 999px;
}

/* ——— Station list ——— */

.station-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}

.station-list::-webkit-scrollbar { width: 4px; }
.station-list::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border-radius: 999px;
}

.station-item {
  display: grid;
  grid-template-columns: 2.35rem 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.48rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition:
    background 0.18s var(--ease),
    border-color 0.18s var(--ease),
    transform 0.15s var(--ease-out),
    box-shadow 0.18s var(--ease);
}

.station-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
}

.station-item.active {
  background: var(--accent-wash);
  border-color: rgba(164, 208, 7, 0.35);
  box-shadow: inset 0 0 0 1px rgba(164, 208, 7, 0.06);
}

.station-item:active { transform: scale(0.992); }

.station-item .thumb {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 28%, #3a4a18, #16141f);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.station-item.active .thumb {
  border-color: rgba(164, 208, 7, 0.45);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.station-item .info { min-width: 0; }
.station-item .name {
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.station-item .sub {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 450;
  margin-top: 0.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-item .star {
  border: none;
  background: transparent;
  color: var(--muted-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), transform 0.15s var(--ease-out);
}

.station-item .star:hover {
  color: var(--accent-soft);
  background: var(--accent-wash);
}
.station-item .star.on { color: var(--accent-soft); }
.station-item .star:active { transform: scale(0.9); }

.list-hint {
  margin: 0.45rem 0 0;
  font-size: 0.65rem;
  font-weight: 450;
  color: var(--muted-dim);
  letter-spacing: 0.01em;
}

/* ——— Footer ——— */

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.65rem;
  font-weight: 450;
  color: var(--muted-dim);
  letter-spacing: 0.015em;
  padding-bottom: 0.1rem;
}

/* ——— Responsive ——— */

@media (min-width: 1400px) {
  html { font-size: 16px; }
}

@media (max-width: 900px) {
  html, body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
  }

  .app {
    height: auto;
    min-height: 100dvh;
  }

  .stage {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    overflow: visible;
    flex: 1 1 auto;
    min-height: 0;
  }

  .player-panel { order: 0; flex-shrink: 0; }

  .list-panel {
    order: 1;
    min-height: 300px;
    max-height: none;
    flex: 1 1 auto;
  }

  .station-list {
    max-height: 50vh;
    max-height: 50dvh;
  }

  .disc-wrap {
    width: min(190px, 52vw);
    height: min(190px, 52vw);
  }

  .search-row { grid-template-columns: 1fr 1fr; }
  #searchInput { grid-column: 1 / -1; }

  .foot {
    flex-wrap: wrap;
    padding-bottom: calc(0.3rem + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 480px) {
  .app {
    padding: 0.7rem 0.75rem 0.55rem;
    padding-top: calc(0.7rem + env(safe-area-inset-top, 0px));
    padding-right: calc(0.75rem + env(safe-area-inset-right, 0px));
    padding-bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(0.75rem + env(safe-area-inset-left, 0px));
    gap: 0.55rem;
  }

  .brand .title { font-size: 1.15rem; }
  .player-panel { padding: 1.1rem 0.95rem 1.15rem; }
  .play-btn { width: 3.5rem; height: 3.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .disc.spinning { animation: none; }
}