/* Pe Unde — layout compact, desktop + mobil. MIT. */
:root{
  --panel-bg:rgba(255,255,255,.95);
  --panel-border:#ddd7e3;
  --ink:#4f4956;
  --muted:#8b8195;
  --accent:#705399;
  --accent-soft:#f1eafa;
  --shadow:0 3px 14px rgba(28,18,38,.10);
  --radius:16px;
  --marker-hit-size:34px;
}

*{box-sizing:border-box}
html,body{
  height:100%;
  margin:0;
  overflow:hidden;
  font-family:system-ui,-apple-system,"Segoe UI",sans-serif;
  background:#e8f4f0;
  color:var(--ink);
}
body{min-height:100dvh}
button,select,input{font:inherit}

#app{
  position:relative;
  width:100%;
  height:100vh;
  height:100dvh;
  overflow:hidden;
  background:#e8f4f0;
}
#map{width:100%;height:100%;background:#e8f4f0}

/* Bara de sus: identitate + stare, fără comenzi. */
#topbar{
  position:absolute;
  top:10px;
  left:50%;
  transform:translateX(-50%);
  z-index:1000;
  display:flex;
  align-items:center;
  gap:14px;
  width:min(720px,calc(100% - 150px));
  min-height:38px;
  padding:7px 13px;
  border:.5px solid var(--panel-border);
  border-radius:18px;
  background:var(--panel-bg);
  box-shadow:0 1px 8px rgba(0,0,0,.07);
  backdrop-filter:blur(6px);
}
#app-title{
  display:flex;
  align-items:baseline;
  gap:7px;
  flex:0 0 auto;
  white-space:nowrap;
  color:var(--accent);
}
#app-title strong{font-size:15px}
#app-title span{font-size:10px;color:#9484ab}
#counter{
  min-width:0;
  flex:1 1 auto;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  text-align:right;
  color:#7a6892;
  font-size:10px;
}

/* Player propriu: exact două rânduri, fără meniul nativ cu playback speed. */
#controls{
  position:absolute;
  left:50%;
  bottom:12px;
  transform:translateX(-50%);
  z-index:1002;
  width:min(470px,calc(100% - 32px));
  padding:8px 10px;
  border:.5px solid var(--panel-border);
  border-radius:17px;
  background:rgba(255,255,255,.97);
  box-shadow:var(--shadow);
  backdrop-filter:blur(7px);
}
#player-row-station,
#player-row-controls{
  display:flex;
  align-items:center;
  min-width:0;
}
#player-row-station{
  gap:7px;
  height:25px;
  border-bottom:.5px solid #eee9f1;
}
#player-station-text{
  display:flex;
  align-items:baseline;
  gap:7px;
  min-width:0;
  flex:1 1 auto;
  overflow:hidden;
  white-space:nowrap;
}
#station-name{
  flex:0 1 auto;
  max-width:55%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#71579a;
  font-size:11.5px;
  font-weight:650;
}
#station-meta{
  min-width:0;
  flex:1 1 auto;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#918997;
  font-size:8.5px;
}
#player-actions{
  display:flex;
  align-items:center;
  gap:3px;
  flex:0 0 auto;
}
#player-actions button,
#player-play{
  border:0;
  background:transparent;
  color:#5e516b;
  cursor:pointer;
}
#player-actions button{
  width:27px;
  height:24px;
  padding:0;
  border-radius:8px;
  font-size:18px;
  line-height:1;
}
#player-actions button:hover,
#player-play:hover{background:#f4eff8}
#player-actions button:disabled,
#player-play:disabled{opacity:.35;cursor:default}
#favorite-button[aria-pressed="true"]{color:#d49a32}

#player-row-controls{
  height:29px;
  gap:8px;
  padding-top:4px;
}
#player-play{
  width:31px;
  height:25px;
  border-radius:8px;
  font-size:14px;
}
#player-live{
  min-width:30px;
  color:#a09aa4;
  font-size:8px;
  font-weight:700;
  letter-spacing:.08em;
}
#player-live.playing{color:#58ad72}
#volume-wrap{
  display:flex;
  align-items:center;
  gap:6px;
  flex:1 1 auto;
  color:#9a929f;
  font-size:8px;
}
#player-volume{
  width:100%;
  min-width:70px;
  height:16px;
  accent-color:#7b63a1;
}
#audio{display:none}

/* Panoul unic de instrumente. */
#legend{
  position:absolute;
  left:14px;
  bottom:14px;
  z-index:1001;
  width:280px;
  max-height:min(390px,58vh);
  overflow:hidden;
  border:.5px solid var(--panel-border);
  border-radius:var(--radius);
  background:var(--panel-bg);
  box-shadow:var(--shadow);
  backdrop-filter:blur(7px);
}
#legend.collapsed{display:none}
#legend-toggle{
  position:absolute;
  left:14px;
  bottom:14px;
  z-index:1003;
  min-width:34px;
  height:28px;
  padding:0 9px;
  border:.5px solid var(--panel-border);
  border-radius:12px;
  background:rgba(255,255,255,.97);
  color:var(--accent);
  box-shadow:0 1px 7px rgba(0,0,0,.08);
  cursor:pointer;
  font-size:10px;
}
#legend:not(.collapsed) + #legend-toggle{display:none}

#panel-tabs{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:2px;
  padding:5px;
  border-bottom:.5px solid #ece7ef;
  background:rgba(250,248,252,.92);
}
.panel-tab{
  min-width:0;
  padding:6px 3px;
  border:0;
  border-radius:9px;
  background:transparent;
  color:#84758f;
  cursor:pointer;
  font-size:9px;
}
.panel-tab.active{
  background:#eee6f6;
  color:#654985;
  font-weight:650;
}
#panel-body{
  max-height:calc(min(390px,58vh) - 42px);
  overflow:auto;
  overscroll-behavior:contain;
}
.panel-page{padding:10px}
.panel-page[hidden]{display:none!important}

.panel-field{
  display:grid;
  grid-template-columns:auto 1fr;
  align-items:center;
  gap:8px;
  margin-bottom:8px;
}
.panel-field label,
.panel-label{
  color:#897d91;
  font-size:9px;
}
.panel-field select,
#station-search{
  width:100%;
  min-width:0;
  border:.5px solid #dcd4e5;
  border-radius:10px;
  background:#fff;
  color:#554b60;
  padding:6px 8px;
  outline:none;
  font-size:10px;
}
#station-search:focus,
.panel-field select:focus{border-color:#b7a1cf}

#station-search-results{
  margin-top:5px;
  overflow:hidden;
  border:.5px solid #ddd5e6;
  border-radius:11px;
  background:#fff;
}
#station-search-results[hidden]{display:none!important}
.station-search-result,
.saved-station-row{
  display:block;
  width:100%;
  padding:7px 8px;
  border:0;
  border-bottom:.5px solid #eee9f2;
  background:transparent;
  text-align:left;
  color:#555;
  cursor:pointer;
}
.station-search-result:last-child,
.saved-station-row:last-child{border-bottom:0}
.station-search-result:hover,
.saved-station-row:hover{background:#f7f2fb}
.station-search-result strong,
.saved-station-row strong{
  display:block;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:10px;
}
.station-search-result span,
.saved-station-row span{
  display:block;
  margin-top:1px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#8e8595;
  font-size:8px;
}
.station-search-empty,
.saved-stations-empty{
  padding:8px;
  color:#8e8595;
  font-size:9px;
}

#tag-suggestions{
  display:flex;
  flex-wrap:wrap;
  gap:4px;
  margin:5px 0 8px;
}
#tag-suggestions[hidden]{display:none!important}
.tag-suggestion{
  padding:3px 7px;
  border:.5px solid #ddd5e6;
  border-radius:999px;
  background:#faf8fc;
  color:#6d5a83;
  cursor:pointer;
  font-size:8px;
}
.tag-suggestion:hover,
.tag-suggestion.active{
  background:#eee4f7;
  border-color:#c8b3db;
}

.panel-actions{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.panel-actions-inline{
  display:grid;
  grid-template-columns:1fr 1fr;
}
.panel-action{
  padding:6px 8px;
  border:.5px solid #ded7e6;
  border-radius:9px;
  background:#fff;
  color:#70578f;
  text-align:left;
  cursor:pointer;
  font-size:9px;
}
.panel-action:hover{background:#f7f2fb}
.panel-actions-inline .panel-action{text-align:center}
.panel-action:disabled{opacity:.5;cursor:default}

#saved-stations-panel{
  margin-top:8px;
  border-top:.5px solid #ebe5ef;
  padding-top:7px;
}
#saved-stations-panel[hidden]{display:none!important}
#saved-stations-title{
  margin-bottom:4px;
  color:#70578f;
  font-size:9px;
  font-weight:650;
}
#saved-stations-list{max-height:205px;overflow:auto}

#map-legend{
  margin:5px 0 8px;
  color:#716a76;
  font-size:9px;
  line-height:1.7;
}
.legend-dot{
  display:inline-block;
  width:8px;
  height:8px;
  margin-right:5px;
  border-radius:50%;
  vertical-align:0;
}
.legend-exact{background:#78c9e6;border:1px solid #fff;box-shadow:0 0 0 1px #78c9e6}
.legend-city{background:#fff;border:2px solid #b278d1}
.legend-country{background:#fff;border:2px dashed #d08bb0}

#cache-status{
  margin-top:7px;
  padding-top:6px;
  border-top:.5px solid #e7e1eb;
  color:#8b8195;
  font-size:8px;
  line-height:1.4;
}
#data-warning{
  margin-top:7px;
  padding-top:7px;
  border-top:.5px solid #eadfec;
  color:#8a4f6d;
  font-size:8px;
  line-height:1.4;
}
#data-credit{
  margin-top:6px;
  color:#9b949f;
  font-size:7.5px;
  line-height:1.4;
}
#data-credit a{color:#80649f;text-decoration:none}

/* Loader / dialog. */
#loader{
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
  z-index:1100;
  padding:13px 19px;
  border:.5px solid var(--panel-border);
  border-radius:17px;
  background:rgba(255,255,255,.97);
  color:#765b9a;
  text-align:center;
  box-shadow:0 5px 20px rgba(0,0,0,.11);
  font-size:11px;
}
#loader-bar{
  width:200px;
  height:3px;
  margin-top:8px;
  overflow:hidden;
  border-radius:2px;
  background:#eee;
}
#loader-fill{
  width:0;
  height:100%;
  border-radius:2px;
  background:#c8ace5;
  transition:width .2s;
}
#cancel-download{
  margin-top:7px;
  padding:4px 9px;
  border:.5px solid #d8d0e4;
  border-radius:9px;
  background:#fff;
  color:#6a4ea0;
  cursor:pointer;
  font-size:9px;
}
#cancel-download[hidden]{display:none!important}

#data-prompt[hidden]{display:none!important}
#data-prompt{
  position:fixed;
  inset:0;
  z-index:2000;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:rgba(40,32,52,.18);
  backdrop-filter:blur(2px);
}
#data-prompt-card{
  width:min(410px,calc(100% - 12px));
  padding:17px;
  border:.5px solid #d8d0e4;
  border-radius:18px;
  background:#fff;
  color:#555;
  box-shadow:0 8px 28px rgba(0,0,0,.14);
  font-size:12px;
  line-height:1.5;
}
#data-prompt-title{
  display:block;
  margin-bottom:7px;
  color:#6a4ea0;
  font-size:14px;
}
#data-prompt-actions{
  display:flex;
  justify-content:flex-end;
  gap:7px;
  margin-top:13px;
}
#data-prompt-actions button{
  padding:6px 10px;
  border:.5px solid #d8d0e4;
  border-radius:10px;
  background:#fff;
  color:#654d89;
  cursor:pointer;
}
#data-prompt-primary{background:#f3ecfb!important}

/* Harta / markere. */
.radio-marker-hit{
  width:var(--marker-hit-size);
  height:var(--marker-hit-size);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  background:transparent;
  touch-action:manipulation;
}
.radio-marker-failed{opacity:.58;filter:grayscale(1)}
.radio-tip{
  padding:5px 9px!important;
  border:.5px solid #ddd!important;
  border-radius:6px!important;
  background:#fff!important;
  color:#444!important;
  box-shadow:0 2px 6px rgba(0,0,0,.08)!important;
  font-size:11px!important;
  line-height:1.5!important;
}
.radio-tip::before{display:none!important}

.leaflet-control-zoom{
  margin-top:10px!important;
  margin-right:10px!important;
  overflow:hidden;
  border:.5px solid #ddd!important;
  border-radius:9px!important;
  box-shadow:0 1px 7px rgba(0,0,0,.08)!important;
}
.leaflet-control-zoom a{
  background:rgba(255,255,255,.94)!important;
  color:#555!important;
  border-bottom:.5px solid #eee!important;
}
.leaflet-control-zoom a:hover{background:#f5f5f5!important}

/* Panoul și playerul nu trebuie să se calce pe ecrane intermediare. */
@media(max-width:1100px){
  #legend{bottom:82px}
  #legend-toggle{bottom:82px}
}

@media(max-width:720px){
  :root{--marker-hit-size:40px}

  #topbar{
    top:6px;
    left:8px;
    right:54px;
    width:auto;
    min-height:34px;
    transform:none;
    padding:6px 9px;
    border-radius:14px;
  }
  #app-title strong{font-size:13px}
  #app-title span{font-size:9px}
  #counter{font-size:8px}

  .leaflet-control-zoom{
    margin-top:6px!important;
    margin-right:6px!important;
  }

  #controls{
    bottom:7px;
    width:calc(100% - 14px);
    max-width:none;
    padding:6px 8px;
    border-radius:14px;
  }
  #player-row-station{height:23px}
  #player-row-controls{height:26px;padding-top:3px}
  #station-name{font-size:10.5px;max-width:54%}
  #station-meta{font-size:7.5px}
  #player-actions button{width:25px;height:22px}
  #player-play{width:29px;height:23px}

  #legend{
    left:7px;
    right:7px;
    bottom:72px;
    width:auto;
    max-height:50vh;
    border-radius:14px;
  }
  #legend-toggle{
    left:7px;
    bottom:72px;
  }
  #panel-body{max-height:calc(50vh - 42px)}
  .panel-page{padding:9px}
}

@media(max-width:560px){
  #legend{display:none}
  #legend:not(.collapsed){display:block}
  #legend-toggle{display:block}
  #app-title span{display:none}
  #counter{font-size:7.5px}
  #station-meta{display:none}
  #station-name{max-width:100%}
  #player-station-text{display:block}
  #volume-wrap span{display:none}
  #data-prompt-actions{flex-direction:column}
  #data-prompt-actions button{width:100%}
}

@media(min-resolution:192dpi){
  :root{--marker-hit-size:40px}
}

/* v26: căutarea și filtrele sunt în același context vizual */
#station-search-control{
  margin-bottom:8px;
}
.search-filter-row{
  margin-bottom:4px;
}
#country-filter-control{
  margin-bottom:6px;
}
#country-filter-control label{
  min-width:30px;
}

/* v28: starea neutră a filtrului de gen */
.tag-suggestion-reset{
  border-style:dashed;
  background:#f3f0f6;
  color:#62586b;
  font-weight:600;
}
.tag-suggestion-reset.active{
  background:#ded4e8;
  border-color:#9f8cb4;
  color:#4f3f62;
}

/* v29: reglaje fine de densitate */

/* Bara de sus: mai puțin spațiu gol. */
#topbar{
  width:min(610px,calc(100% - 170px));
  min-height:34px;
  padding:5px 11px;
}
#app-title{
  gap:6px;
}
#app-title strong{
  font-size:14px;
}
#app-title span{
  font-size:9px;
}
#counter{
  font-size:9px;
}

/* Player: ceva mai lat și cu mai mult spațiu pentru textul postului. */
#controls{
  width:min(560px,calc(100% - 32px));
}
#player-row-station{
  gap:5px;
}
#player-station-text{
  gap:6px;
}
#station-name{
  max-width:64%;
  font-size:11.5px;
}
#station-meta{
  font-size:8.5px;
}
#player-actions{
  gap:1px;
}
#player-actions button{
  width:25px;
}

/* Tag-uri: două rânduri compacte, fără eticheta "Gen". */
#tag-suggestions{
  margin-top:2px;
  margin-bottom:8px;
  gap:4px;
}
.tag-suggestion{
  padding:3px 7px;
  font-size:8px;
}

/* Panoul nu trebuie să crească doar pentru tag-uri. */
.panel-page[data-page="search"]{
  padding-bottom:9px;
}

@media(max-width:720px){
  #topbar{
    right:54px;
  }
  #controls{
    width:calc(100% - 14px);
  }
  #station-name{
    max-width:62%;
  }
}

/* v30: aliniere bara de sus + control coerent pentru strângerea panoului */
#topbar{
  align-items:center;
}
#app-title{
  align-items:center;
}
#app-title strong,
#app-title span,
#counter{
  line-height:1.15;
}

/* Taburile ocupă spațiul disponibil; chevronul are o coloană proprie. */
#panel-tabs{
  grid-template-columns:repeat(3,1fr) 28px;
  align-items:center;
}
#panel-collapse{
  width:26px;
  height:26px;
  padding:0;
  border:0;
  border-radius:8px;
  background:transparent;
  color:#766689;
  cursor:pointer;
  font-size:16px;
  line-height:1;
}
#panel-collapse:hover{
  background:#eee6f6;
}

/* Butonul extern există numai când panoul este strâns. */
#legend-toggle{
  display:block;
  width:34px;
  min-width:34px;
  height:30px;
  padding:0;
  font-size:16px;
  line-height:1;
}
#legend-toggle[hidden]{
  display:none!important;
}

/* v32: avertisment mai lizibil și separat în paragrafe */
#data-warning{
  font-size:9.5px;
  line-height:1.5;
}
#data-warning p{
  margin:0;
}
#data-warning p + p{
  margin-top:7px;
}

/* v35: pe mobil playerul lasă liberă atribuirea hărții */
@media(max-width:720px){
  #controls{
    bottom:24px;
  }
  #legend{
    bottom:88px;
  }
  #legend-toggle{
    bottom:88px;
  }
}

/* v36: dropdown-uri proprii, cu font controlat */
.native-select-shadow{
  position:absolute!important;
  width:1px!important;
  height:1px!important;
  opacity:0!important;
  pointer-events:none!important;
  overflow:hidden!important;
}

.custom-select{
  position:relative;
  width:100%;
  min-width:0;
}

.custom-select-button{
  width:100%;
  min-width:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:6px 8px;
  border:.5px solid #dcd4e5;
  border-radius:10px;
  background:#fff;
  color:#554b60;
  cursor:pointer;
  text-align:left;
  font-size:10px;
}

.custom-select-value{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.custom-select-chevron{
  flex:0 0 auto;
  color:#83758e;
  font-size:11px;
}

.custom-select-menu{
  position:absolute;
  left:0;
  right:0;
  top:calc(100% + 4px);
  z-index:1300;
  max-height:220px;
  overflow:auto;
  padding:4px;
  border:.5px solid #d9d1e1;
  border-radius:10px;
  background:#fff;
  box-shadow:0 5px 18px rgba(0,0,0,.14);
}

.custom-select-menu[hidden]{
  display:none!important;
}

.custom-select-option{
  display:block;
  width:100%;
  padding:6px 7px;
  border:0;
  border-radius:7px;
  background:transparent;
  color:#554b60;
  cursor:pointer;
  text-align:left;
  font-size:9.5px;
  line-height:1.25;
}

.custom-select-option:hover,
.custom-select-option[aria-selected="true"]{
  background:#f1eafa;
  color:#654985;
}

@media(max-width:560px){
  .custom-select-button{
    font-size:10px;
  }
  .custom-select-option{
    font-size:10px;
    padding:7px 8px;
  }
  .custom-select-menu{
    max-height:190px;
  }
}

/* v37: dropdown-urile plutesc peste panou și aleg automat sus/jos */
.custom-select-menu{
  z-index:2200!important;
  overflow-y:auto!important;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  max-height:320px;
}

@media(max-width:560px){
  .custom-select-menu{
    max-height:min(320px,55vh);
  }
}

/* v38: meniurile custom sunt portal-uri în body; nu mai pot fi tăiate de panou */
body > .custom-select-menu{
  position:fixed!important;
  right:auto!important;
  z-index:5000!important;
  overflow-y:auto!important;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  touch-action:pan-y;
  max-height:360px;
  margin:0!important;
}

body > .custom-select-menu[hidden]{
  display:none!important;
}

body > .custom-select-menu .custom-select-option{
  touch-action:manipulation;
}

/* v39: scroll real în dropdown pe desktop și touch */
body > .custom-select-menu{
  overflow-y:scroll!important;
  scrollbar-gutter:stable;
  touch-action:pan-y!important;
  -webkit-overflow-scrolling:touch;
}

body > .custom-select-menu .custom-select-option{
  touch-action:manipulation;
  user-select:none;
  -webkit-user-select:none;
}
