:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #111517;
  --muted: #657079;
  --line: #dce3e7;
  --soft: #eef3f4;
  --teal: #008b82;
  --teal-dark: #006b65;
  --live: #e63946;
  --shadow: 0 18px 48px rgba(24, 42, 51, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  padding-bottom: 94px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.site-header,
main {
  width: min(1440px, calc(100% - 32px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 850;
  text-decoration: none;
}

.signal-mark {
  position: relative;
  width: 28px;
  height: 28px;
  border: 2px solid var(--teal);
  border-radius: 50%;
}

.signal-mark::before,
.signal-mark::after {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 2px solid var(--teal);
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

.signal-mark::before {
  width: 12px;
  height: 12px;
}

.signal-mark::after {
  width: 3px;
  height: 3px;
  background: var(--teal);
}

.directory-note {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

main {
  padding: 18px 0 24px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 220px 220px auto;
  gap: 10px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
}

input,
select,
#nearby {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
}

input:focus,
select:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(0, 139, 130, 0.12);
}

#nearby {
  align-self: end;
  background: var(--text);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
}

.directory-shell {
  display: grid;
  grid-template-columns: minmax(410px, 0.8fr) minmax(0, 1.35fr);
  height: calc(100dvh - 210px);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.station-panel,
.map-panel {
  min-width: 0;
}

.station-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
}

.panel-heading,
.map-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}

.panel-heading h1,
.map-heading h2 {
  margin: 0;
  font-size: 1.12rem;
}

.panel-heading span,
.map-heading span {
  color: var(--muted);
  font-size: 0.78rem;
}

#refresh {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

#refresh svg,
.player svg,
.row-play svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.row-play svg,
.play-icon {
  fill: currentColor;
  stroke: none;
}

.station-list {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.load-more {
  min-height: 46px;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--soft);
  color: var(--teal-dark);
  font-weight: 850;
  cursor: pointer;
}

.load-more[hidden] {
  display: none;
}

.station-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.station-row.active {
  background: #edf9f7;
  box-shadow: inset 3px 0 var(--teal);
}

.station-main {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 12px 8px 12px 16px;
  text-align: left;
  cursor: pointer;
}

.station-logo,
.player-logo {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 900;
}

.station-logo {
  width: 48px;
  height: 48px;
}

.station-logo img,
.player-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

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

.station-copy small,
.station-quality {
  color: var(--muted);
  font-size: 0.74rem;
}

.station-tags {
  overflow: hidden;
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-quality {
  text-align: right;
  white-space: nowrap;
}

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

.map-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

#map {
  min-height: 360px;
  background: #e5ecec;
}

.map-attribution-note {
  margin: 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 12px;
  font-size: 0.7rem;
}

.station-marker {
  display: grid;
  place-items: center;
  width: 24px !important;
  height: 24px !important;
  margin: -12px 0 0 -12px !important;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 3px 12px rgba(0, 65, 61, 0.35);
}

.station-marker.active {
  background: var(--live);
  transform: scale(1.25);
}

.leaflet-popup-content-wrapper {
  border-radius: 6px;
}

.popup-content {
  display: grid;
  gap: 5px;
  min-width: 170px;
}

.popup-content span {
  color: var(--muted);
  font-size: 0.76rem;
}

.popup-content button {
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  background: var(--text);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.empty {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 240px;
  color: var(--muted);
  text-align: center;
}

.empty[hidden] {
  display: none;
}

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

.player {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(220px, 0.7fr);
  align-items: center;
  gap: 24px;
  min-height: 78px;
  border-top: 1px solid #293238;
  background: #151b1f;
  color: #fff;
  padding: 10px max(16px, calc((100vw - 1440px) / 2));
}

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

.player-logo {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-color: #344149;
  background: #263137;
  color: #fff;
}

.now-playing > div:last-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.now-playing span {
  color: #b9c4ca;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.now-playing i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--live);
}

.now-playing strong,
.now-playing small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-playing small,
.player-meta span {
  color: #aab6bc;
  font-size: 0.74rem;
}

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

#play-toggle {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #111517;
  cursor: pointer;
}

#play-toggle:disabled {
  opacity: 0.45;
  cursor: default;
}

.pause-icon,
.player.playing .play-icon {
  display: none;
}

.player.playing .pause-icon {
  display: block;
}

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

.volume-control input {
  width: 120px;
  min-height: 0;
  padding: 0;
  accent-color: var(--teal);
}

.player-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.player-meta a {
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

@media (max-width: 900px) {
  body {
    padding-bottom: 142px;
  }

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

  .search-control {
    grid-column: 1 / -1;
  }

  .directory-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .station-panel {
    border-right: 0;
  }

  .station-list {
    max-height: 540px;
  }

  .map-panel {
    border-top: 1px solid var(--line);
  }

  #map {
    height: 480px;
  }

  .player {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px 14px;
  }

  .player-meta {
    grid-column: 1 / -1;
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .site-header,
  main {
    width: min(100% - 20px, 1440px);
  }

  .directory-note {
    display: none;
  }

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

  .search-control {
    grid-column: auto;
  }

  .station-main {
    grid-template-columns: 44px minmax(0, 1fr);
    padding-left: 10px;
  }

  .station-logo {
    width: 44px;
    height: 44px;
  }

  .station-quality {
    display: none;
  }

  .row-play {
    margin-right: 8px;
  }

  #map {
    height: 400px;
  }

  .volume-control,
  .player-meta span {
    display: none;
  }
}
