:root {
  --bg: #fff;
  --fg: #1d1d1f;
  --muted: #6b6b70;
  --accent: #1a5fb4;
  --line: #0001;
  --panel: #ffffffee;
  --sea: #cfe0ee;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--sea); color: var(--fg);
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#map { position: fixed; inset: 0; background: var(--sea); }
button { font: inherit; color: inherit; background: #f2f2f4; border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 8px; cursor: pointer; }
button:active { background: #e4e4e8; }

.box { position: absolute; z-index: 1000; background: var(--panel); border-radius: 10px;
  box-shadow: 0 2px 10px #0002; backdrop-filter: blur(6px); }

/* ricerca */
#top { top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; max-width: 420px; margin: 0 auto;
  display: flex; gap: 6px; padding: 6px; }
#q { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 7px 10px; border: 1px solid #0002;
  border-radius: 7px; background: #fff; }
#gps { font-size: 18px; padding: 0 10px; }
#sugg { position: absolute; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px 0; list-style: none;
  background: #fff; border-radius: 10px; box-shadow: 0 4px 14px #0003; max-height: 50vh; overflow: auto; }
#sugg li { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#sugg li.sel, #sugg li:hover { background: #eef4fc; }
#sugg small { color: var(--muted); white-space: nowrap; }
#sugg .empty { color: var(--muted); cursor: default; }

/* preferiti */
#side { left: 8px; top: 64px; width: 290px; max-height: calc(100% - 140px); display: flex; flex-direction: column; }
#sidehead { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 6px; gap: 6px; }
#sidehead button { padding: 2px 8px; font-size: 12px; }
#favs { list-style: none; margin: 0; padding: 0 4px; overflow: auto; }
#favs li { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 8px;
  padding: 6px 6px; border-radius: 7px; cursor: pointer; }
#favs li:hover { background: #0000000a; }
#favs li.active { background: #fff3c4; }
#favs .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#favs .name small { color: var(--muted); }
#favs .val { font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
#favs .chip { width: 10px; height: 10px; border-radius: 3px; border: 1px solid #0003; }
#favs .spark { display: flex; align-items: flex-end; gap: 1px; height: 18px; }
#favs .spark i { width: 4px; background: #9bb; border-radius: 1px 1px 0 0; min-height: 1px; }
#favs .spark i.cur { outline: 1px solid #333; }
#favs .del { border: 0; background: none; color: #a00; padding: 0 2px; font-size: 13px; }
#favs .empty { display: block; color: var(--muted); cursor: default; padding: 4px 6px 8px; }
#status { color: var(--muted); font-size: 12px; padding: 6px 10px 8px; border-top: 1px solid var(--line); }
#status.err { color: #b00; }
#side.collapsed #favs, #side.collapsed #status { display: none; }

/* barra tempo */
#bar { bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; padding: 7px 12px; }
#slider { width: 180px; }
#ts { font-variant-numeric: tabular-nums; min-width: 44px; }

/* legenda */
#legendbtn { right: 8px; top: 64px; padding: 5px 9px; font-size: 12px; }
#legend { right: 8px; top: 96px; padding: 6px 10px; font-size: 12px; }
#legend i { display: inline-block; width: 14px; height: 10px; margin-right: 6px; border-radius: 2px; }

/* etichette sulla mappa */
.lbl { white-space: nowrap; color: #222; font-size: 11px; pointer-events: none;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff; }
.lbl::before { content: ''; display: inline-block; width: 4px; height: 4px; border-radius: 50%;
  background: #333; margin-right: 3px; vertical-align: middle; }
.lbl.k0 { font-size: 14px; font-weight: 700; }
.lbl.k1 { font-size: 13px; font-weight: 700; }
.lbl.k2 { font-size: 12px; font-weight: 600; }
.lbl.k4 { font-size: 10px; color: #444; }
.lbl.k4::before { width: 3px; height: 3px; background: #666; }
.lbl.prov { font-size: 11px; font-style: italic; letter-spacing: .12em; text-transform: uppercase; color: #6a5f80; }
.lbl.prov::before { display: none; }
.lbl.act { font-weight: 700; font-size: 13px; color: #000; }
.lbl.fav { font-weight: 600; font-size: 12px; color: #111; }
.lbl.act::before, .lbl.fav::before { display: none; }

.pin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px #333, 0 1px 4px #0006; }
.pin.act { width: 22px; height: 22px; box-shadow: 0 0 0 2.5px #000, 0 1px 6px #0008; }

/* telefono */
@media (max-width: 700px) {
  #top { max-width: none; }
  #side { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(66px + env(safe-area-inset-bottom)); max-height: 38vh; }
  #bar { left: 8px; right: 8px; transform: none; }
  #slider { flex: 1; width: auto; }
  .leaflet-control-zoom { display: none; }
  .leaflet-control-attribution { font-size: 9px; max-width: 70vw; }
}
