:root {
  --sfondo: #0d1117;
  --superficie: #161b24;
  --superficie-2: #1e2531;
  --bordo: #2a3240;
  --testo: #e8ecf2;
  --testo-2: #9aa6b8;
  --rosa: #ff3d81;
  --arancio: #ff9f43;
  --turchese: #2ee6c9;
  --raggio: 12px;
  --alt-header: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--sfondo);
  color: var(--testo);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--turchese); }
.page[hidden] { display: none !important; }
.solo-lettori { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 24px;
  min-height: var(--alt-header); padding: 0 20px;
  background: rgba(13, 17, 23, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bordo);
}
.logo { display: flex; align-items: center; gap: 10px; color: var(--testo); text-decoration: none; font-size: 18px; white-space: nowrap; }
.logo b { color: var(--rosa); }
.logo-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--rosa), var(--arancio)); color: #111; font-weight: 800; font-size: 14px;
}
.nav { display: flex; gap: 4px; }
.nav a { color: var(--testo-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.nav a:hover { color: var(--testo); background: var(--superficie-2); }
.nav a.attivo { color: var(--testo); background: var(--superficie-2); box-shadow: inset 0 -2px 0 var(--rosa); }
.progresso-top { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--testo-2); font-size: 13px; white-space: nowrap; }
.progresso-top .barra { width: 120px; }

/* Barre di progresso */
.barra { height: 6px; background: var(--superficie-2); border-radius: 99px; overflow: hidden; }
.barra i { display: block; height: 100%; background: var(--c, var(--rosa)); border-radius: 99px; transition: width .3s; }

/* Pagina mappa */
#page-mappa { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - var(--alt-header)); }
.pannello { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--superficie); border-right: 1px solid var(--bordo); overflow-y: auto; }
.mappa-wrap { position: relative; height: 100%; min-height: 0; }
#map { height: 100%; background: #071d2c; }
#map.scelta { cursor: crosshair; }

button.primario {
  padding: 10px 14px; border-radius: 10px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--rosa), var(--arancio)); color: #111; font: inherit; font-weight: 800;
}
button.primario:hover { filter: brightness(1.08); }
button.primario:disabled { opacity: .6; cursor: wait; }
button.link { border: 0; background: none; padding: 0; color: var(--turchese); font: inherit; text-decoration: underline; cursor: pointer; }

.avviso {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1001;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 12px;
  background: var(--superficie); border: 1px solid var(--rosa); box-shadow: 0 6px 24px rgba(0,0,0,.5);
  font-weight: 600; white-space: nowrap;
}
.avviso[hidden] { display: none; }

/* Finestra "Segnala un punto" */
.dialogo {
  width: min(540px, calc(100% - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 24px; border: 1px solid var(--bordo); border-radius: 16px;
  background: var(--superficie); color: var(--testo);
}
.dialogo::backdrop { background: rgba(0, 0, 0, .6); }
.dialogo h2 { margin: 0 0 4px; }
.dialogo form { display: flex; flex-direction: column; gap: 12px; }
.dialogo label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
.dialogo label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; color: var(--testo-2); }
.dialogo label.check input { margin-top: 3px; flex: none; }
.dialogo input:not([type="checkbox"]):not([type="file"]), .dialogo select, .dialogo textarea {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--bordo);
  background: var(--sfondo); color: var(--testo); font: inherit; font-weight: 400;
}
.dialogo textarea { resize: vertical; }
.dialogo input[type="file"] { font: inherit; font-weight: 400; color: var(--testo-2); }
.dialogo :focus-visible { outline: 2px solid var(--rosa); outline-offset: 1px; }
.campi-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.aiuto { margin: 0; color: var(--testo-2); font-size: 14px; }
.anteprima { max-width: 100%; max-height: 200px; object-fit: contain; border-radius: 10px; border: 1px solid var(--bordo); align-self: flex-start; }
.anteprima[hidden] { display: none; }
.esito { margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.esito.ok { background: rgba(46, 230, 201, .12); color: var(--turchese); }
.esito.errore { background: rgba(255, 61, 129, .12); color: var(--rosa); }
.azioni { display: flex; justify-content: flex-end; gap: 10px; }

input[type="search"] {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--bordo);
  background: var(--sfondo); color: var(--testo); font: inherit;
}
input[type="search"]:focus { outline: 2px solid var(--rosa); outline-offset: 1px; }
input[type="checkbox"] { accent-color: var(--rosa); width: 16px; height: 16px; }

.filtri { display: flex; flex-direction: column; gap: 4px; }
.filtro { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.filtro:hover { background: var(--superficie-2); }
.filtro .nome { flex: 1; }
.conteggio { color: var(--testo-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.pallino {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c); color: #111; font-size: 12px; font-weight: 800; flex: none;
}
.toggle { display: flex; align-items: center; gap: 8px; color: var(--testo-2); cursor: pointer; }

.lista { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--bordo); padding-top: 12px; }
.lista button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--testo); font: inherit; cursor: pointer;
}
.lista button:hover { background: var(--superficie-2); }
.lista button small { display: block; color: var(--testo-2); }
.lista .fatto { opacity: .5; }
.vuoto { color: var(--testo-2); font-style: italic; }

.editor { border-top: 1px solid var(--bordo); padding-top: 12px; color: var(--testo-2); font-size: 13px; }
.editor summary { cursor: pointer; color: var(--testo); font-weight: 600; }
.editor pre { white-space: pre-wrap; word-break: break-all; background: var(--sfondo); padding: 10px; border-radius: 8px; border: 1px solid var(--bordo); color: var(--turchese); }

button.secondario, #copia {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--bordo);
  background: var(--superficie-2); color: var(--testo); font: inherit; font-weight: 600; cursor: pointer;
}
button.secondario:hover, #copia:hover { border-color: var(--rosa); }

/* Segnaposti sulla mappa */
.pin span {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--c); color: #111; font-weight: 800; font-size: 14px;
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.5);
  transition: transform .15s;
}
.pin:hover span { transform: scale(1.15); }
.pin-ok span { filter: grayscale(.7); opacity: .55; }

/* Nomi delle zone sulla mappa */
.etichetta-zona span {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font-weight: 800; font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: #fff;
  text-shadow: 0 0 4px #000, 0 0 10px rgba(0,0,0,.8), 0 2px 2px #000;
}

/* Popup Leaflet scuri */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--superficie); color: var(--testo); box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.leaflet-popup-content-wrapper { border: 1px solid var(--bordo); border-radius: var(--raggio); }
.leaflet-container a.leaflet-popup-close-button { color: var(--testo-2); }
.leaflet-container { font: inherit; }
.leaflet-bar a { background: var(--superficie); color: var(--testo); border-color: var(--bordo); }
.leaflet-bar a:hover { background: var(--superficie-2); }
.popup { min-width: 200px; }
.popup h3 { margin: 4px 0 6px; font-size: 16px; }
.popup p { margin: 0 0 8px; color: var(--testo-2); }
.popup-cat { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--c); }
.popup .nota { color: var(--arancio); font-size: 12px; }
.popup .fonte { font-size: 12px; margin-top: 6px; }
.affidabilita { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; color: #111; }
.aff-ufficiale { background: var(--turchese); }
.aff-giornale { background: #8ab4ff; }
.aff-guida { background: var(--arancio); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }

/* Pagine di contenuto */
.contenuto { max-width: 1040px; margin: 0 auto; padding: 32px 20px 48px; }
.contenuto h1 { margin: 0 0 6px; font-size: 30px; }
.testa-pagina { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.testa-pagina p { margin: 0; color: var(--testo-2); }

.gruppo { background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 16px; margin-bottom: 16px; }
.gruppo-testa { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.gruppo h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 18px; }
.gruppo ul { list-style: none; margin: 12px 0 0; padding: 0; }
.gruppo li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px; border-top: 1px solid var(--bordo); }
.gruppo li label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.gruppo li small { display: block; color: var(--testo-2); }
.gruppo li.fatto b { text-decoration: line-through; color: var(--testo-2); }
.gruppo li a { font-size: 13px; white-space: nowrap; }

.schede { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 20px; }
.scheda { display: block; padding: 18px; background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); color: var(--testo); text-decoration: none; }
.scheda:hover { border-color: var(--rosa); }
.scheda h2 { font-size: 18px; margin: 6px 0; }
.scheda p { margin: 0; color: var(--testo-2); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #111; background: var(--arancio); padding: 2px 8px; border-radius: 99px; }

.guida-layout { display: grid; grid-template-columns: 1fr 300px; gap: 32px; align-items: start; }
.articolo { max-width: 70ch; }
.articolo h2 { margin-top: 28px; }
.articolo li { margin-bottom: 6px; }
.meta { color: var(--testo-2); margin-top: 0; }
.indietro { display: inline-block; margin-bottom: 12px; text-decoration: none; }
.ad-slot {
  position: sticky; top: calc(var(--alt-header) + 20px);
  display: grid; place-items: center; min-height: 250px; border: 1px dashed var(--bordo); border-radius: var(--raggio);
  color: var(--testo-2); font-size: 13px;
}

/* Pagine statiche: guide e zone */
.briciole { font-size: 13px; color: var(--testo-2); margin-bottom: 16px; }
.briciole a { text-decoration: none; }
.intro { font-size: 17px; color: var(--testo); }
.punti { display: flex; flex-direction: column; gap: 12px; }
.scheda-punto { padding: 14px 16px; background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); }
.scheda-punto h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 16px; }
.scheda-punto p { margin: 0 0 8px; color: var(--testo-2); }
.piccolo { font-size: 12px; color: var(--testo-2); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.vai-mappa { font-size: 13px; font-weight: 600; }
.correlati { margin-top: 40px; padding-top: 8px; border-top: 1px solid var(--bordo); }
.link-seo { max-width: 900px; margin: 0 auto 14px; }
.link-seo p { margin: 0 0 6px; }

.piede { border-top: 1px solid var(--bordo); padding: 20px; text-align: center; color: var(--testo-2); font-size: 13px; }
.piede p { margin: 0 auto; max-width: 70ch; }

/* Telefono */
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .progresso-top { margin-left: 0; width: 100%; }
  .progresso-top .barra { flex: 1; }
  #page-mappa { grid-template-columns: 1fr; grid-template-rows: auto 65vh; height: auto; }
  .avviso { white-space: normal; width: calc(100% - 24px); justify-content: space-between; }
  .campi-2 { grid-template-columns: 1fr; }
  .dialogo { padding: 18px; }
  .pannello { border-right: 0; border-bottom: 1px solid var(--bordo); }
  .lista { max-height: 220px; overflow-y: auto; }
  .contenuto { padding: 24px 16px 40px; }
  .guida-layout { grid-template-columns: 1fr; }
  .ad-slot { position: static; min-height: 120px; }
}
