:root {
  color-scheme: dark;
  --bg: #080912;
  --panel: #121621;
  --panel-soft: #191f2d;
  --text: #f8fbff;
  --muted: #aeb8c8;
  --line: rgba(255,255,255,0.13);
  --accent: #4cc7ff;
  --accent-2: #f04bd8;
  --warn: #ff7b7b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  background:
    linear-gradient(140deg, rgba(76,199,255,0.18), transparent 34rem),
    radial-gradient(circle at 100% 0%, rgba(240,75,216,0.20), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button,
input { font: inherit; }
button { cursor: pointer; }
body.search-is-open,
body.history-is-open { overflow: hidden; }

.app-shell {
  min-height: 100svh;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(154px + env(safe-area-inset-bottom));
}

.app-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  max-width: 920px;
  margin: 0 auto 14px;
}

.brand-logo {
  display: block;
  width: clamp(120px, 42vw, 180px);
  height: auto;
  object-fit: contain;
}

.header-copy {
  display: grid;
  gap: 1px;
}

.header-copy span,
.eyebrow,
.section-label,
.modal-header span,
.search-box span,
.player-copy span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.header-copy strong {
  font-size: 18px;
}

.install-chrome-hint {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.install-button,
.station-play,
.player-bar button,
.view-tabs button,
.genre-row,
.search-launch {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  min-height: 42px;
  padding: 0 14px;
  font-weight: 850;
}

.install-button,
.station-play {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #040711;
  box-shadow: 0 16px 34px rgba(76,199,255,0.18);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.app-main {
  display: grid;
  gap: 14px;
  max-width: 920px;
  margin: 0 auto;
}

.hero-panel,
.energy-panel,
.tools-panel,
.status-card,
.station-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(18,22,33,0.84);
  box-shadow: 0 18px 48px rgba(0,0,0,0.24);
}

.hero-panel {
  padding: 20px;
}

.hero-panel h1,
.section-heading h2,
.modal-header h2 {
  margin: 0;
  line-height: 1.05;
}

.hero-panel h1 {
  font-size: clamp(40px, 12vw, 70px);
}

.hero-panel p:not(.eyebrow) {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 36rem;
  font-size: 17px;
  line-height: 1.45;
}

.energy-panel,
.tools-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.section-heading h2 {
  font-size: 25px;
}

.energy-grid,
.station-list,
.genre-stations,
.search-results,
.history-results {
  display: grid;
  gap: 10px;
}

.energy-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.search-launch {
  width: 100%;
  min-height: 48px;
  justify-content: flex-start;
  border-radius: 14px;
  background: #070d17;
  color: var(--muted);
}

.view-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.view-tabs::-webkit-scrollbar { display: none; }
.view-tabs button {
  flex: 0 0 auto;
}

.view-tabs button.is-active {
  border-color: rgba(76,199,255,0.85);
  background: rgba(76,199,255,0.16);
  color: #dff7ff;
}

.status-card {
  padding: 12px 14px;
  color: var(--muted);
}

.status-card[data-state="ok"],
.status-card:empty {
  display: none;
}

.status-card[data-state="error"] {
  color: var(--warn);
}

.station-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
}

.station-card.is-featured {
  grid-template-columns: 1fr;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}

.station-card.is-featured .station-art {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 0;
}

.station-card.is-featured .station-copy,
.station-card.is-featured .station-actions {
  padding: 0 12px;
}

.station-card.is-featured .station-actions {
  padding-bottom: 12px;
}

.station-art,
.player-art {
  display: grid;
  place-items: center;
  width: 64px;
  aspect-ratio: 1;
  border-radius: 12px;
  background-color: #101827;
  background-size: cover;
  background-position: center;
  color: #8fd7ff;
  font-weight: 950;
}

.station-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.station-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-copy span,
.station-copy em {
  overflow: hidden;
  color: var(--muted);
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-copy em {
  font-size: 13px;
}

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

.favorite-button {
  width: 42px;
  padding: 0;
  color: var(--text);
}

.genre-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.035);
}

.genre-row em {
  color: var(--muted);
  font-style: normal;
}

.empty {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  color: var(--muted);
  background: rgba(255,255,255,0.03);
}

.search-modal,
.history-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.search-backdrop,
.history-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: rgba(0,0,0,0.74);
}

.search-dialog,
.history-dialog {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100svh - 32px);
  margin: 16px auto;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #0b101a;
  padding: 16px;
  box-shadow: 0 28px 80px rgba(0,0,0,0.45);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.modal-close {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.search-box {
  display: grid;
  gap: 7px;
}

.search-box input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #07101a;
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.search-box input:focus {
  border-color: rgba(76,199,255,0.8);
  box-shadow: 0 0 0 3px rgba(76,199,255,0.13);
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.history-item strong,
.history-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item span,
.history-item time {
  color: var(--muted);
  font-size: 13px;
}

.history-item time {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
}

.player-bar {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: min(920px, calc(100vw - 24px));
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8,9,18,0.96);
  padding: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.42);
  backdrop-filter: blur(16px);
}

.player-bar.is-idle .player-art {
  width: 92px;
  aspect-ratio: 2.3 / 1;
  background-size: contain;
  background-repeat: no-repeat;
}

.player-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.player-copy strong,
.player-copy em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-copy em {
  color: var(--muted);
  font-style: normal;
}

.player-actions {
  display: flex;
  gap: 8px;
}

.player-actions button {
  min-width: 70px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .app-shell {
    padding-inline: 12px;
  }

  .app-header {
    grid-template-columns: auto 1fr auto;
  }

  .brand-logo {
    width: clamp(108px, 37vw, 150px);
  }

  .energy-grid {
    grid-template-columns: 1fr;
  }

  .station-card.is-featured {
    grid-template-columns: 78px minmax(0, 1fr) auto;
    align-items: center;
    padding: 10px;
  }

  .station-card.is-featured .station-art {
    width: 78px;
    border-radius: 12px;
  }

  .station-card.is-featured .station-copy,
  .station-card.is-featured .station-actions {
    padding: 0;
  }

  .station-card {
    grid-template-columns: 56px minmax(0, 1fr) auto;
  }

  .station-art {
    width: 56px;
  }

  .favorite-button {
    width: 40px;
  }

  .station-play {
    min-width: 58px;
    padding-inline: 12px;
  }

  .player-bar {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .player-bar.is-idle .player-art {
    width: 74px;
  }

  .player-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 44px repeat(3, 1fr);
  }

  .player-actions button {
    min-width: 0;
  }
}

@media (max-width: 420px) {
  .app-header {
    grid-template-columns: 1fr auto;
  }

  .header-copy {
    display: none;
  }

  .hero-panel h1 {
    font-size: 42px;
  }

  .station-card,
  .station-card.is-featured {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .station-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 44px 1fr;
  }
}
