:root {
  color-scheme: light;
  --bg: #f7f7f3;
  --panel: #ffffff;
  --panel-soft: #edf2f7;
  --text: #15171c;
  --muted: #657181;
  --line: rgba(15,23,42,0.12);
  --accent: #19b9ff;
  --accent-2: #3563ff;
  --good: #18844a;
  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:
    radial-gradient(circle at 18% 0%, rgba(25,185,255,0.18), transparent 24rem),
    linear-gradient(180deg, #ffffff, var(--bg) 22rem),
    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(112px + env(safe-area-inset-bottom));
}

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

.brand-logo {
  display: block;
  width: min(156px, 42vw);
  height: auto;
  object-fit: contain;
  padding: 8px 10px;
  border-radius: 12px;
  background: #1f2024;
  box-shadow: 0 8px 18px rgba(15,23,42,0.16);
}

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

.header-copy span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

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

.install-button,
.hero-play,
.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,
.hero-play,
.station-play {
  border: 0;
  background: linear-gradient(135deg, var(--accent), #47d5ff);
  color: #001018;
  box-shadow: 0 14px 30px rgba(25,185,255,0.2);
}

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

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

.hero-panel,
.tools-panel,
.status-card,
.station-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 12px 34px rgba(15,23,42,0.09);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero-panel h1 {
  margin: 0;
  max-width: 14ch;
  font-size: clamp(30px, 7vw, 42px);
  line-height: 1.06;
}

.hero-panel p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 36rem;
}

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

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

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

.search-box span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

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

.search-modal,
.history-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: start;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
}

.search-modal[hidden],
.history-modal[hidden] {
  display: none;
}

.search-backdrop,
.history-backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(247,247,243,0.92);
  backdrop-filter: blur(10px);
}

.search-dialog,
.history-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  width: min(100%, 860px);
  max-height: calc(100svh - 28px);
  margin: 0 auto;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 22px 70px rgba(15,23,42,0.18);
  padding: 16px;
}

.search-header,
.history-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.search-header span,
.history-header span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.search-header h2,
.history-header h2 {
  margin: 3px 0 0;
  font-size: 24px;
  line-height: 1.05;
}

.search-close,
.history-close {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.search-results,
.history-results {
  display: grid;
  gap: 8px 10px;
}

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

.view-tabs::-webkit-scrollbar { display: none; }

.view-tabs button {
  flex: 0 0 auto;
}

.view-tabs button.is-active {
  border-color: rgba(25,185,255,0.7);
  background: rgba(25,185,255,0.15);
  color: #063047;
}

.status-card {
  padding: 13px 15px;
  color: var(--muted);
}

.status-card:empty {
  display: none;
}

.status-card[data-state="ok"] { color: var(--good); }
.status-card[data-state="error"] { color: #ff9a9a; }

.station-list {
  display: grid;
  gap: 10px;
}

.section-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.genre-group {
  display: grid;
  gap: 10px;
}

.genre-row {
  width: 100%;
  min-height: 58px;
  justify-content: space-between;
  display: flex;
  align-items: center;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 12px 34px rgba(15,23,42,0.07);
}

.genre-row span {
  font-size: 18px;
}

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

.genre-stations {
  display: grid;
  gap: 10px;
}

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

.station-art {
  width: 68px;
  aspect-ratio: 1;
  border-radius: 14px;
  background: var(--panel-soft) center / cover;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 950;
}

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

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

.station-copy strong { font-size: 16px; }
.station-copy span {
  color: var(--muted);
  font-size: 13px;
}

.station-copy em {
  color: #596779;
  font-size: 12px;
  font-style: normal;
}

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

.favorite-button {
  width: 42px;
  padding: 0;
  color: #ffd166;
}

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

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  padding: 11px 12px;
}

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

.history-item strong {
  color: var(--text);
}

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

.history-item time {
  grid-row: 1 / span 2;
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.player-bar {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 10;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  max-width: 860px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 20px 60px rgba(15,23,42,0.18);
  padding: 9px;
  backdrop-filter: blur(18px);
}

.player-art {
  width: 50px;
  aspect-ratio: 1;
  border-radius: 14px;
  background: var(--panel-soft) center / cover;
  display: grid;
  place-items: center;
  font-weight: 950;
}

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

.player-copy span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

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

.player-bar button {
  min-width: 0;
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
}

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

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

.player-actions [data-player-favorite] {
  padding: 0;
  font-size: 20px;
}

.player-bar audio { display: none; }

@media (max-width: 620px) {
  .app-shell { padding-left: 10px; padding-right: 10px; }
  .hero-panel { grid-template-columns: 1fr; }
  .hero-panel h1 {
    max-width: 100%;
    font-size: clamp(30px, 8.8vw, 42px);
  }
  .hero-play { width: 100%; }
  .station-card { grid-template-columns: 58px minmax(0, 1fr); }
  .station-art { width: 58px; }
  .station-actions {
    grid-column: 1 / -1;
  }
  .station-play { flex: 1; }
  .player-bar { grid-template-columns: 46px minmax(0, 1fr); }
  .player-art { width: 46px; }
  .player-actions {
    grid-template-columns: 44px repeat(3, minmax(0, 1fr));
  }
}
