/* ==========================================================================
   Token di design — unica fonte di colori, tipografia, raggi, ombre, livelli.
   Interfaccia chiara di default; il tema scuro sostituisce solo i token (vedi [data-tema="scuro"]).
   ========================================================================== */
:root {
  color-scheme: light;

  /* superfici, testo, bordi */
  --surface: #fff;
  --surface-alt: #fafbfd;
  --surface-hover: #eaeaf0;
  --text: #1b1f24;
  --text-muted: #5b6570;
  --border: #d0d7de;
  --border-ui: #d6d6e8;

  /* accento: --accent per i riempimenti (con testo --accent-ink, contrasto > 9:1);
     --accent-strong per icone, chevron e testo accentato su bianco (contrasto > 4.5:1) */
  --accent: #f5a623;
  --accent-ink: #1a1206;
  --accent-strong: #b45309;
  --accent-soft: rgba(245, 166, 35, .14);
  --accent-strong-ink: #fff; /* testo su riempimento --accent-strong (nel tema scuro --accent-strong è ambra chiaro) */
  --link: #2f5fc7;
  --focus: #0b5fff;
  --avviso: #fff4ce;
  --avviso-scheda: #fff4e0;
  --avviso-scheda-ink: #7a4a10;
  --positivo: #22a55a;
  --pericolo: #b42318;        /* testo e tratti di errore/allarme */
  --pericolo-vivo: #ef4444;   /* segnaposto su mappa (GCP) */
  --blu-dati: #1971c2;        /* valori in evidenza nei grafici della scheda */
  --evidenza: #e6007e;        /* particella cercata */
  --trasporto: #364fc7;       /* simbolo fermate */
  --prec-alta: #2e9e4f; --prec-media: #e8b923; --prec-bassa: #d64545; /* precisione delle mappe storiche */
  /* bianco fisso: aloni su mappa/foto e testo su riempimenti colorati (non cambia col tema) */
  --bianco: #fff;
  --overlay-hover: rgba(0, 0, 0, .08);
  --tooltip-bg: rgba(250, 251, 254, .97);
  --tooltip-bordo: rgba(30, 50, 110, .12);
  --tooltip-enfasi: #1e3ca0;
  --invito-bg: rgba(35, 38, 43, .88);
  --invito-bg-hover: #23262b;

  /* classi 1–5 della scheda (1 = migliore) */
  --c1-bg: #dcfce7; --c1-fg: #166534; --c1-bd: #86efac;
  --c2-bg: #ecfccb; --c2-fg: #3a5a0a; --c2-bd: #a3e635;
  --c3-bg: #fef9c3; --c3-fg: #854d0e; --c3-bd: #fde047;
  --c4-bg: #ffedd5; --c4-fg: #9a3412; --c4-bd: #fdba74;
  --c5-bg: #fee2e2; --c5-fg: #991b1b; --c5-bd: #fca5a5;

  /* tipografia (rem: 1rem = 16px) */
  --fs-3xs: .6875rem; /* 11: minimo assoluto, solo etichette secondarie */
  --fs-2xs: .75rem;   /* 12 (come --fs-xs, tenuto per i punti già in uso) */
  --fs-xs: .75rem;    /* 12 */
  --fs-sm: .8125rem;  /* 13 */
  --fs-base: .875rem; /* 14 */
  --fs-md: 1rem;      /* 16 */
  --fs-lg: 1.125rem;  /* 18 */

  /* raggi e ombre */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  --ombra: 0 4px 24px rgba(0, 0, 0, .12);
  --ombra-tooltip: 0 4px 18px rgba(30, 50, 110, .12);
  --ombra-sm: 0 1px 4px rgba(0, 0, 0, .45);
  --ombra-pannello-dx: -8px 0 28px rgba(20, 30, 60, .14); /* pannello ancorato a destra */
  --ombra-pannello-sx: 8px 0 28px rgba(20, 30, 60, .14);  /* pannello ancorato a sinistra */

  /* durate */
  --t-rapida: .12s;
  --t-media: .2s;

  /* livelli */
  --z-mappa-ui: 2;
  --z-barra: 3;
  --z-foglio: 4;
  --z-crediti: 20;
  --z-header: 30;
  --z-viewer: 200;

  /* scheda del luogo: larghezza e ingombro (0 quando è chiusa) */
  --scheda-w: 440px;
  --scheda-l: 0px;
  --rail-w: 44px;
  /* ingombro a sinistra: su mobile resta il valore storico (legende a 112px); il desktop lo ridefinisce */
  --sx: 100px;
}

/* tema scuro: sostituisce solo i token; il chiaro resta il predefinito. La base cartografica si sceglie a parte. */
:root[data-tema="scuro"] {
  color-scheme: dark;
  --surface: #1c2128;
  --surface-alt: #232a33;
  --surface-hover: #2d3641;
  --text: #e6e9ed;
  --text-muted: #9aa5b1;
  --border: #38414c;
  --border-ui: #3f4a57;
  --accent-strong: #f5a623;
  --accent-strong-ink: var(--accent-ink);
  --accent-soft: rgba(245, 166, 35, .2);
  --link: #7ea6ff;
  --focus: #6ea0ff;
  --avviso: #4a3d12;
  --avviso-scheda: #3a2f1a;
  --avviso-scheda-ink: #f1cf9a;
  --c1-bg: #14532d; --c1-fg: #bbf7d0; --c1-bd: #166534;
  --c2-bg: #365314; --c2-fg: #d9f99d; --c2-bd: #4d7c0f;
  --c3-bg: #713f12; --c3-fg: #fef08a; --c3-bd: #a16207;
  --c4-bg: #7c2d12; --c4-fg: #fed7aa; --c4-bd: #c2410c;
  --c5-bg: #7f1d1d; --c5-fg: #fecaca; --c5-bd: #b91c1c;
  --ombra: 0 4px 24px rgba(0, 0, 0, .5);
  --ombra-tooltip: 0 4px 18px rgba(0, 0, 0, .5);
  --ombra-sm: 0 1px 4px rgba(0, 0, 0, .7);
  --ombra-pannello-dx: -8px 0 28px rgba(0, 0, 0, .5);
  --ombra-pannello-sx: 8px 0 28px rgba(0, 0, 0, .5);
  --pericolo: #f87171;
  --blu-dati: #74a7f0;
  --overlay-hover: color-mix(in srgb, var(--bianco) 10%, transparent);
  --tooltip-bg: rgba(28, 33, 40, .97);
  --tooltip-bordo: color-mix(in srgb, var(--bianco) 14%, transparent);
  --tooltip-enfasi: #9db8ff;
}
#app-logo .logo-scuro { display: none; }
:root[data-tema="scuro"] #app-logo .logo-chiaro { display: none; }
:root[data-tema="scuro"] #app-logo .logo-scuro { display: block; }

* { box-sizing: border-box; }
button, input, select, textarea { font-family: inherit; }
/* Montserrat (SIL OFL), self-hosted, sottoinsieme latino */
@font-face { font-family: 'Montserrat'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/montserrat-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 500; font-style: normal; font-display: swap; src: url('fonts/montserrat-Medium.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 600; font-style: normal; font-display: swap; src: url('fonts/montserrat-SemiBold.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/montserrat-Bold.woff2') format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/atkinson-400.woff2') format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/atkinson-700.woff2') format('woff2'); }
html, body { height: 100%; margin: 0; font: var(--fs-base)/1.4 var(--font-ui, 'Montserrat', system-ui, sans-serif); color: var(--text); background: var(--surface); }
/* --scala-testo e --font-ui li imposta il pannello Tema (js/core/tema-interfaccia.js); senza scelta nulla cambia.
   La dimensione della radice (14px × scala) è la base di tutti i rem: l'interfaccia in rem la segue. Va dopo la regola con `font`. */
html { font-size: calc(var(--scala-testo, 1) * .875rem); }
/* la pagina non scorre né rimbalza mai (su iPad e Surface un trascinamento o uno zoom del browser porterebbe fuori vista barra e ricerca) */
html, body { overflow: hidden; overscroll-behavior: none; }
#barra-strumenti, #area-ricerca, #legende, #pannello { touch-action: manipulation; } /* niente zoom con doppio tocco sull'interfaccia */
#mappa { position: absolute; inset: 0; }
button { cursor: pointer; }
label { display: block; padding: 2px 0; }
select { width: 100%; margin: 2px 0 6px; }
/* campo di testo e select: un solo aspetto per tutta l'interfaccia (le singole regole aggiungono solo le dimensioni) */
.sotto-pannello select, #pannello-filtri select, #cerca-particella input, .strato-cerca, .strato-tema select, .gi-campo select, .agg-campo input, #stampa-menu select {
  border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit;
}

/* focus da tastiera visibile ovunque; la ricerca lo mostra sul contenitore */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#cerca-testo:focus-visible { outline: 0; }
#cerca:focus-within { border-color: var(--focus); box-shadow: var(--ombra), 0 0 0 2px var(--focus); }

.solo-lettori { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Legende, avvisi, tooltip, finestre
   ========================================================================== */
.legenda div { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); }
.legenda i { width: 14px; height: 14px; border: 1px solid var(--border); display: inline-block; }
.legenda .nota-stime, .legenda .nota-omi { font-style: italic; color: var(--text-muted); }

/* avvisi: pila sopra la ricerca (mai sotto i filtri), ognuno con la sua chiusura e scomparsa dopo qualche secondo */
#avvisi { display: flex; flex-direction: column; gap: 4px; }
#avvisi:empty { display: none; }
#avvisi div { display: flex; align-items: flex-start; gap: 8px; background: var(--avviso); border: 1px solid var(--border); border-radius: var(--r-sm); box-shadow: var(--ombra); padding: 4px 4px 4px 10px; font-size: var(--fs-sm); }
#avvisi div span { flex: 1; padding: 2px 0; }
#avvisi button { flex: none; width: 24px; height: 24px; padding: 0; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: none; color: var(--text-muted); }
#avvisi button:hover { background: var(--overlay-hover); color: var(--text); }

/* tooltip sulla mappa: uno solo (core/tooltip.js), con una sezione per fonte (trasporto, sicurezza, confini) */
.mappa-tooltip .maplibregl-popup-content {
  padding: 6px 10px; font-size: var(--fs-xs); border-radius: var(--r-sm); pointer-events: none;
  background: var(--tooltip-bg); border: 1px solid var(--tooltip-bordo); box-shadow: var(--ombra-tooltip);
}
.mappa-tooltip .maplibregl-popup-tip { display: none; }
.mappa-tooltip-sezione + .mappa-tooltip-sezione { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--tooltip-bordo); }
.confini-tooltip strong { color: var(--tooltip-enfasi); margin-right: 4px; }

dialog { max-width: 640px; width: calc(100% - 32px); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-sm); }
dialog li { margin: 4px 0; }

/* logo Open Data Sicilia: in basso a destra (sopra le attribuzioni), si sposta a sinistra quando la scheda è aperta */

/* ==========================================================================
   Barra degli strumenti
   ========================================================================== */
#barra-strumenti {
  position: fixed; z-index: var(--z-barra); top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 7px 14px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-pill); box-shadow: var(--ombra);
}
#barra-strumenti button {
  position: relative; width: 32px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border-ui); border-radius: 50%; color: var(--text-muted); transition: background var(--t-rapida), color var(--t-rapida);
}
#btn-3d { font-size: var(--fs-2xs); font-weight: 700; }
#barra-strumenti button:hover { background: var(--surface-hover); color: var(--text); }
#barra-strumenti button[aria-pressed="true"], #barra-gruppi button[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#barra-gruppi { display: flex; gap: 6px; }
.barra-sep { width: 1px; height: 22px; flex-shrink: 0; background: var(--border-ui); }
#barra-strumenti .et { display: none; } /* etichette sotto le icone: solo nella barra verticale (mobile) */
#barra-strumenti button[data-attivo="true"]::after { content: ''; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--positivo); border: 1px solid var(--bianco); }

.zoom-wrap { display: flex; flex-direction: column; }
#zoom-slider { width: 180px; height: 4px; margin: 6px 0 0; appearance: none; -webkit-appearance: none; background: var(--border-ui); border-radius: 2px; outline: none; cursor: pointer; }
#zoom-slider:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
#zoom-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; background: var(--accent); border-radius: 50%; border: 2px solid color-mix(in srgb, var(--bianco) 80%, transparent); box-shadow: var(--ombra-sm); cursor: pointer; }
#zoom-slider::-moz-range-thumb { width: 16px; height: 16px; background: var(--accent); border-radius: 50%; border: 2px solid color-mix(in srgb, var(--bianco) 80%, transparent); cursor: pointer; }
.zoom-ticks { display: flex; justify-content: space-between; padding: 1px 7px 0; width: 180px; }
.zoom-ticks span { font-size: var(--fs-2xs); color: var(--text-muted); }
#zoom-badge { width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--accent); border-radius: 50%; font-size: var(--fs-2xs); font-weight: 700; color: var(--accent-ink); }

/* sotto-pannelli della barra */
#pannello {
  position: fixed; z-index: var(--z-barra); top: 68px; left: 50%; transform: translateX(-50%);
  width: min(320px, calc(100% - 16px)); max-height: calc(100% - 200px); overflow: auto;
}
#pannello:not(:has(.sotto-pannello:not([hidden]))) { display: none; }
.sotto-pannello { padding: 10px 14px; background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-md); box-shadow: var(--ombra); }
.sotto-pannello[hidden] { display: none; }
.sotto-pannello h2 { margin: 0 0 6px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.colonnine-filtri { margin: 2px 0 6px 22px; }
.colonnine-filtri h3 { margin: 6px 0 2px; }
.colonnine-filtri input:disabled + * , .colonnine-filtri label:has(input:disabled) { opacity: .5; }
.sotto-pannello h3 { margin: 10px 0 6px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text); }
.sotto-pannello select { padding: 5px; }

/* selettore delle cartografie di base (cerchi con miniatura, come nell'atlante) */
.base-suggerimento { margin: 0 0 6px; font-size: var(--fs-xs); color: var(--text-muted); }
.base-atlante { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; padding: 9px 12px; border-radius: var(--r-sm); background: var(--accent); color: var(--accent-ink); font-size: var(--fs-sm); font-weight: 700; text-decoration: none; }
.base-atlante:hover { filter: brightness(.95); }
.base-atlante:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.base-griglia { display: flex; flex-wrap: wrap; gap: 10px; }
.base-scelta { position: relative; display: flex; flex-direction: column; align-items: center; width: 64px; padding: 0; cursor: pointer; }
.base-scelta input { position: absolute; top: 0; left: 50%; width: 56px; height: 56px; margin: 0 0 0 -28px; opacity: 0; cursor: pointer; }
.base-cerchio { width: 56px; height: 56px; border-radius: 50%; background: #eee center / cover; border: 2px solid var(--bianco); box-shadow: 0 0 0 1px var(--border-ui), 0 2px 6px rgba(0, 0, 0, .2); transition: box-shadow var(--t-rapida); }
.base-scelta:hover .base-cerchio { box-shadow: 0 0 0 2px var(--border-ui), 0 2px 8px rgba(0, 0, 0, .3); }
.base-scelta input:checked + .base-cerchio { box-shadow: 0 0 0 3px var(--accent), 0 2px 8px rgba(0, 0, 0, .3); }
.base-scelta input:focus-visible + .base-cerchio { outline: 2px solid var(--focus); outline-offset: 3px; }
.base-precisione { position: absolute; top: 42px; left: 50%; margin-left: 12px; pointer-events: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bianco); box-shadow: 0 0 0 1px var(--border-ui); }
.base-precisione-alta { background: var(--prec-alta); }
.base-precisione-media { background: var(--prec-media); }
.base-precisione-bassa { background: var(--prec-bassa); }
.base-et { margin-top: 4px; font-size: var(--fs-xs); font-weight: 700; color: var(--text); text-align: center; }
.base-mini { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--miniatura) center / cover; box-shadow: 0 0 0 1.5px var(--bianco), 0 0 0 2.5px var(--border-ui); }
#barra-gruppi button[aria-expanded="true"] .base-mini { box-shadow: 0 0 0 1.5px var(--bianco); }

#legende { position: fixed; z-index: var(--z-mappa-ui); left: 8px; bottom: 28px; max-width: 260px; display: flex; flex-direction: column; gap: 6px; }
#legende .legenda { padding: 8px 10px; background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-md); box-shadow: var(--ombra); }
#legende [hidden], #legende .legenda-sostituita { display: none; }
#legende .legenda-tema strong { display: block; margin-bottom: 4px; font-size: var(--fs-xs); }

/* ==========================================================================
   Ricerca e filtri
   ========================================================================== */
#area-ricerca {
  position: fixed; z-index: var(--z-barra); bottom: calc(40px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  width: clamp(280px, calc((100vw - var(--scheda-l)) * .42), 400px); display: flex; flex-direction: column; gap: 6px; align-items: stretch;
}
#cerca {
  position: relative; display: flex; align-items: center; height: 48px;
  background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-pill); box-shadow: var(--ombra);
}
.cerca-icona { flex-shrink: 0; padding: 0 10px 0 16px; color: var(--text-muted); display: flex; align-items: center; pointer-events: none; }
#cerca-testo { flex: 1; min-width: 0; padding: 0; background: transparent; border: 0; outline: 0; font: inherit; font-size: var(--fs-sm); color: var(--text); }
#cerca-testo::placeholder { color: var(--text-muted); }
#cerca-testo { text-overflow: ellipsis; } /* il segnaposto lungo si accorcia con i puntini invece di tagliare a metà parola */
.cerca-sep { width: 1px; height: 22px; margin: 0 4px; flex-shrink: 0; background: var(--border-ui); }
#cerca-filtri { flex-shrink: 0; height: 36px; padding: 0 14px 0 11px; gap: 6px; margin-right: 8px; display: flex; align-items: center; justify-content: center; background: var(--accent); border: 0; border-radius: var(--r-pill); color: var(--accent-ink); font-size: var(--fs-sm); font-weight: 600; }
#cerca-ripristina { flex-shrink: 0; width: 38px; height: 38px; margin-right: 4px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); border: 0; border-radius: 50%; color: var(--accent-strong); cursor: pointer; }
#cerca-ripristina:hover { background: color-mix(in srgb, var(--accent) 28%, transparent); }
#cerca-filtri:hover { filter: brightness(1.1); }
#cerca-filtri[aria-expanded="true"] { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
#cerca-risultati {
  position: absolute; bottom: calc(100% + 10px); left: 0; right: 0; list-style: none; margin: 0; padding: 4px 0;
  max-height: 300px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-md); box-shadow: var(--ombra);
}
#cerca-risultati[hidden] { display: none; }
#cerca-risultati button { display: block; width: 100%; padding: 7px 14px; border: 0; background: none; text-align: left; font: inherit; font-size: var(--fs-sm); color: var(--text); }
#cerca-risultati button:hover, #cerca-risultati button:focus { background: var(--surface-hover); }
#cerca-risultati button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.cerca-vuoto { padding: 12px 14px; font-size: var(--fs-sm); color: var(--text-muted); text-align: center; }

#pannello-filtri h2:not(:first-child) { margin-top: 14px; }
#cerca-filtri { position: relative; }
#cerca-filtri[data-attivo="true"]::after { content: attr(data-n); position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-pill); background: var(--text); color: var(--surface); font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
#pannello-filtri label { font-size: var(--fs-xs); color: var(--text-muted); }
#pannello-filtri select { width: 100%; margin: 2px 0 6px; padding: 5px; }
#cerca-particella { display: flex; gap: 6px; }
#cerca-particella input { width: 30%; min-width: 0; padding: 6px 8px; }
#cerca-particella button { flex: 1; padding: 6px; border: 0; border-radius: var(--r-sm); background: var(--accent); color: var(--accent-ink); font-weight: 600; }
#cerca-particella-esito { margin: 0; padding: 6px 12px; font-size: var(--fs-xs); color: var(--text-muted); background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-md); box-shadow: var(--ombra); }
#pannello-filtri[hidden], #cerca-particella-esito[hidden], #filtri-chips[hidden], #filtri-linea-chips[hidden] { display: none; }
#filtri-chips, #filtri-linea-chips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.chip-zona { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px 6px 12px; font-size: var(--fs-sm); font-weight: 700; color: var(--accent-ink); background: var(--accent); border: 2px solid var(--bianco); border-radius: var(--r-md); box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.chip-zona button { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--accent-ink) 18%, transparent); color: var(--accent-ink); font-size: var(--fs-2xs); }
.chip-zona button:hover { background: color-mix(in srgb, var(--accent-ink) 35%, transparent); }

/* ==========================================================================
   Informazioni: pagina a tutta larghezza aperta dal menu in testata (non modale)
   ========================================================================== */
#crediti {
  position: absolute; z-index: var(--z-crediti); inset: 0; width: auto; max-width: none; height: auto; max-height: none; margin: 0; padding: 0;
  border: 0; border-radius: 0; box-shadow: none; overflow: hidden; background: transparent; color: var(--text);
}
#crediti[open] { display: flex; flex-direction: column; }
.tab-corpo {
  padding: 24px 16px 40px; --velo: color-mix(in srgb, var(--surface) 98%, transparent); --velo-bordo: color-mix(in srgb, var(--surface) 80%, transparent);
  background: var(--velo);
}
/* colonna del testo opaca al 95%; ai due lati lo sfondo sfuma verso i bordi e lascia intravedere la mappa */
@media (min-width: 1240px) {
  .tab-corpo { background: linear-gradient(to right, var(--velo-bordo), var(--velo) calc(50% - 600px), var(--velo) calc(50% + 600px), var(--velo-bordo)); }
}
.info-sezione { box-sizing: border-box; width: 100%; max-width: 1100px; margin: 0 auto; }
.info-sezione[hidden] { display: none; }
.tab-corpo { flex: 1; min-height: 0; overflow-y: auto; }
/* Pagine informative: stessa struttura in ogni tab (titolo, introduzione, blocchi a scheda) */
.info-sezione h2 { margin: 0 0 4px; font-size: 1.75rem; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; }
.info-sezione h2.pagina-sezione { margin-top: 36px; }
.pagina-intro { margin: 0 0 20px; color: var(--text-muted); font-size: 1.0625rem; line-height: 1.5; }
.info-blocco { margin: 0 0 14px; padding: 16px 18px; background: var(--surface-alt); border: 1px solid var(--border-ui); border-radius: var(--r-md); }
.info-blocco h3 { margin: 0 0 8px; font-size: var(--fs-lg); font-weight: 700; }
.info-blocco h4 { margin: 14px 0 4px; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.info-blocco p { margin: 0 0 8px; color: var(--text); font-size: var(--fs-md); line-height: 1.55; }
.info-blocco p:last-child, .info-blocco ul:last-child, .info-blocco ol:last-child { margin-bottom: 0; }
.info-blocco ul, .info-blocco ol { margin: 0 0 8px; padding-left: 20px; font-size: var(--fs-md); line-height: 1.55; }
.info-blocco li { margin: 3px 0; }
.info-blocco a, .guida-indice a { color: var(--accent-strong); font-weight: 600; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.info-blocco code { font-size: .9em; overflow-wrap: anywhere; }
.info-blocco img { display: block; width: 100%; height: auto; margin: 12px 0 0; border: 1px solid var(--border-ui); border-radius: var(--r-sm); }
.info-blocco figure { margin: 12px 0 0; }
.info-blocco figure img { margin: 0; }
.info-blocco figcaption { margin-top: 6px; color: var(--text-muted); font-size: var(--fs-xs); }
.guida-passo { scroll-margin-top: 8px; }
.guida-evidenza { margin: 12px 0; padding: 10px 14px; border-left: 4px solid var(--accent); border-radius: var(--r-sm); background: var(--surface-alt); font-weight: 600; }
/* schermi larghi: contenuto a sinistra, indice a destra sempre in vista mentre la guida scorre */
@media (min-width: 1000px) {
  .guida-pagina { display: grid; grid-template-columns: minmax(0, 1fr) 250px; column-gap: 20px; align-items: start; }
  .guida-pagina > * { grid-column: 1; }
  .guida-pagina > .guida-indice { grid-column: 2; grid-row: 1 / span 60; position: sticky; top: 0; align-self: start; max-height: calc(100dvh - 150px); overflow-y: auto; margin: 0; }
  .guida-pagina > .guida-indice ol { columns: 1; font-size: .9375rem; line-height: 1.5; }
  .guida-pagina > .guida-indice li { margin: 4px 0; }
}
.guida-indice { margin: 0 0 14px; padding: 16px 18px; background: var(--surface-alt); border: 1px solid var(--border-ui); border-radius: var(--r-md); }
.guida-indice ol { margin: 0; padding-left: 20px; font-size: var(--fs-md); line-height: 1.7; columns: 2 280px; }
.argomenti-griglia { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.argomenti-griglia > .argomento { display: flex; flex-direction: column; margin: 0; }
.argomento-mostra { align-self: flex-start; margin-top: auto; }
@media (max-width: 640px) { .argomenti-griglia { grid-template-columns: 1fr; } }
.argomento ul { margin-bottom: 12px; color: var(--text-muted); }
.argomento-mostra { padding: 6px 14px; border: 1px solid var(--accent); border-radius: var(--r-pill); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; cursor: pointer; }
.argomento-mostra:hover:not(:disabled) { filter: brightness(.96); }
.argomento-mostra:disabled { opacity: .45; cursor: default; }
.info-sezione h2.pagina-sezione + .info-blocco { margin-top: 14px; }
.guida-media { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px; }
.guida-video { position: relative; display: block; min-width: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; background: linear-gradient(135deg, #0e141f, #24405f); cursor: pointer; aspect-ratio: 16 / 9; }
.guida-video-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.guida-video-play { position: absolute; left: 50%; top: 40%; width: 36px; height: 36px; margin: -18px 0 0 -18px; border-radius: 50%; background: var(--accent); }
.guida-video-play::after { content: ''; position: absolute; left: 50%; top: 50%; width: 12px; height: 14px; margin: -7px 0 0 -3px; background: var(--accent-ink); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.guida-video-titolo { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; font-size: .8125rem; line-height: 1.25; color: #fff; background: rgb(0 0 0 / .65); text-align: left; }
.video-finestra-nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#crediti button { padding: 6px 14px; border: 0; border-radius: var(--r-sm); background: var(--accent); color: var(--accent-ink); font-weight: 600; }
/* «torna in cima»: tondo, bianco con anello ambra a riposo, ambra pieno al passaggio del mouse */
#crediti .in-cima { position: absolute; right: 24px; bottom: 16px; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border: 2px solid var(--accent); border-radius: 50%; background: var(--surface); color: var(--text); box-shadow: var(--ombra); transition: background .15s, color .15s, transform .15s; }
#crediti .in-cima svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
#crediti .in-cima:hover, #crediti .in-cima:focus-visible { background: var(--accent); color: #fff; transform: translateY(-2px); }
#crediti .in-cima[hidden] { display: none; }

#crediti .crediti-x { position: absolute; top: 8px; right: 12px; z-index: 1; width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: transparent; color: var(--text-muted); }
#crediti .crediti-x:hover { background: var(--surface-hover); color: var(--text); }

/* ==========================================================================
   Monumenti, trasporto: popup, schede, legende
   ========================================================================== */
.monumento-popup-box .maplibregl-popup-content { padding: 0; border-radius: var(--r-md); overflow: hidden; }
.monumento-popup { font-size: var(--fs-sm); }
.monumento-popup h3 { margin: 8px 10px 0; font-size: var(--fs-base); }
.monumento-foto, .scheda-foto { display: block; width: 100%; max-height: 140px; object-fit: cover; }
.scheda-foto { border-radius: var(--r-sm); margin: 6px 0; }
.scheda-tag.scheda-tag--scomparso { background: var(--c5-bg); color: var(--c5-fg); border: 1px solid var(--c5-bd); }
.scheda-avviso, .monumento-scomparso { margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--c5-fg); background: var(--c5-bg); color: var(--c5-fg); font-size: var(--fs-sm); font-weight: 600; line-height: 1.35; }
.monumento-scomparso { margin: 4px 10px; }
.monumento-cat { margin: 2px 10px; color: var(--text-muted); font-size: var(--fs-xs); }
.monumento-desc { margin: 4px 10px; line-height: 1.35; max-height: 72px; overflow-y: auto; }
.monumento-popup .monumento-foto { max-height: 110px; }
.monumento-link { display: block; margin: 8px 10px 10px; padding: 7px 10px; border-radius: var(--r-sm); background: var(--link); color: var(--bianco); text-align: center; text-decoration: none; font-weight: 600; }
.monumento-fonte { margin: 6px 10px 10px; color: var(--text-muted); font-size: var(--fs-xs); }
.legenda-omi strong, .legenda-catasto strong, .legenda-trasporto strong, .legenda-monumenti strong { display: block; margin-bottom: 4px; font-size: var(--fs-xs); }
.monumenti-cat { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: var(--fs-xs); cursor: pointer; }
/* la voce si accende e si spegne cliccando la riga: la casella resta (tastiera, lettori di schermo) ma non si vede */
.monumenti-cat input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.monumenti-cat:has(input:not(:checked)) { opacity: .45; }
.monumenti-cat:has(input:not(:checked)) > :not(input) { filter: grayscale(1); }
.monumenti-cat:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: var(--r-sm); }
.legenda i.catasto-particella { background: var(--bianco); border-color: #000; opacity: .9; }
.legenda i.catasto-etichetta { width: auto; min-width: 14px; border: 0; font-size: var(--fs-3xs); font-style: normal; font-weight: 600; text-align: center; text-shadow: 0 0 2px var(--bianco); }
.legenda i.catasto-cercata { height: 4px; border: 0; background: var(--evidenza); }
.legenda i.monumenti-pallino { width: 10px; height: 10px; border-radius: 50%; border-color: rgba(0, 0, 0, .3); }

.trasporto-vicina { padding: 4px 0 6px; }
.trasporto-vicina-nome { all: unset; cursor: pointer; font-weight: 600; color: var(--accent-strong); text-decoration: underline dotted; text-underline-offset: 3px; }
.trasporto-vicina-nome:hover, .trasporto-vicina-nome:focus-visible { text-decoration-style: solid; }
.trasporto-vicina-linee { display: flex; flex-wrap: wrap; gap: 4px; }
.trasporto-chip-bottone { all: unset; cursor: pointer; border-radius: var(--r-sm); }
.trasporto-chip-bottone:hover .trasporto-chip, .trasporto-chip-bottone:focus-visible .trasporto-chip { outline: 2px solid var(--accent-strong); }
.trasporto-chip { display: inline-block; min-width: 2.2em; padding: 1px 6px; border-radius: var(--r-sm); font-weight: 700; font-size: var(--fs-xs); text-align: center; }
.trasporto-giorno { display: block; margin: 6px 0; font-size: var(--fs-xs); color: var(--text-muted); }
.trasporto-giorno input { font: inherit; margin-left: 4px; }
.trasporto-testata { margin: 8px 0 2px; font-size: var(--fs-xs); }
.trasporto-ore { margin: 0 0 6px; line-height: 1.5; font-variant-numeric: tabular-nums; word-spacing: 1px; }
.trasporto-fermate { margin: 4px 0 0; padding-left: 20px; font-size: var(--fs-xs); line-height: 1.5; max-height: 220px; overflow-y: auto; }
/* Schema a striscia: la linea passa nel centro di ogni voce (x = 0 della voce) e il pallino sta sopra, all'altezza della prima riga di testo. Niente bordo sulla lista: `overflow` ne ritaglierebbe metà pallino. */
.trasporto-strip { list-style: none; margin: 4px 0 0; padding: 0 0 0 10px; }
.trasporto-strip li { position: relative; padding: 3px 0 3px 18px; --y: calc(3px + .75em); }
.trasporto-strip li::before, .trasporto-strip li::after { content: ""; position: absolute; box-sizing: border-box; }
.trasporto-strip li::after { left: -2px; top: 0; bottom: 0; width: 4px; background: var(--colore-linea, var(--trasporto)); }
.trasporto-strip li:first-child::after { top: var(--y); }
.trasporto-strip li:last-child::after { bottom: auto; height: var(--y); }
.trasporto-strip li:only-child::after { display: none; }
.trasporto-strip li::before { z-index: 1; left: -5px; top: var(--y); width: 10px; height: 10px; margin-top: -5px; border: 2px solid var(--colore-linea, var(--trasporto)); border-radius: 50%; background: var(--bianco); }
.trasporto-strip .trasporto-strip-capolinea { font-weight: 700; }
.trasporto-strip .trasporto-strip-capolinea::before { left: -7px; width: 14px; height: 14px; margin-top: -7px; border-width: 3px; }
.trasporto-strip-nome { all: unset; cursor: pointer; color: var(--accent-strong); text-decoration: underline dotted; text-underline-offset: 3px; }
.trasporto-strip-nome:hover, .trasporto-strip-nome:focus-visible { text-decoration-style: solid; }
.trasporto-strip .trasporto-chip { font-size: 10px; padding: 0 4px; min-width: 1.8em; }
.legenda-trasporto { margin-top: 8px; }
.legenda-selezione .selezione-testa { justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.legenda-selezione strong { font-size: var(--fs-xs); }
.selezione-tooltip { position: relative; display: inline-flex; padding: 3px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: none; color: var(--text-muted); cursor: pointer; }
.selezione-tooltip[aria-pressed="false"]::after { content: ''; position: absolute; left: 3px; right: 3px; top: 50%; height: 2px; background: currentColor; transform: rotate(-45deg); box-shadow: 0 0 0 1px var(--surface); }
.selezione-tooltip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.legenda .selezione-testo { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.legenda .selezione-testo b { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.legenda .selezione-testo > span { color: var(--text-muted); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .03em; }
.mappa-tooltip .legenda { max-width: 260px; }
.mappa-tooltip .legenda div { align-items: flex-start; padding: 3px 0; }
.mappa-tooltip .legenda i.selezione-simbolo { flex: none; margin-top: 2px; }
.legenda i.selezione-simbolo { width: 14px; height: 14px; border: 3px solid var(--colore); border-radius: var(--r-xs); background: color-mix(in srgb, var(--colore) 20%, transparent); }
.legenda .selezione-voci { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
.legenda i.selezione-simbolo--punto { border-radius: 50%; }
.trasporto-legenda-riga { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); }
.legenda i.trasporto-tratto { width: 22px; height: 4px; border: 0; border-radius: 2px; }
.legenda i.trasporto-tratto--tram { height: 7px; }
.legenda i.trasporto-pallino { width: 10px; height: 10px; border: 2px solid var(--trasporto); border-radius: 50%; background: var(--bianco); }
.legenda i.trasporto-tratto--binario { height: 6px; background: repeating-linear-gradient(90deg, #1a1a1a 0 5px, #fff 5px 8px); border: 1px solid #1a1a1a; box-sizing: border-box; }
.legenda img.trasporto-logo-metro { width: 14px; height: 14px; display: inline-block; vertical-align: middle; }
.trasporto-tooltip-linea { margin: 2px 0; display: flex; align-items: baseline; gap: 6px; } /* il nome va a capo dentro il riquadro, accanto alla sigla */
.trasporto-tooltip-linea .trasporto-chip { flex: none; }
.trasporto-tooltip-altre { margin-top: 2px; color: var(--text-muted); font-style: italic; }
.legenda .sicurezza-sezione { flex-direction: column; align-items: stretch; gap: 0; }
.legenda i.sicurezza-tratto, .legenda i.sicurezza-pallino { flex: none; }
.sicurezza-legenda-riga { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); }
.sicurezza-legenda-titolo { margin: 8px 0 3px; font-weight: 600; font-size: var(--fs-xs); }
.legenda i.sicurezza-tratto { width: 22px; height: 5px; border: 0; border-radius: 2px; }
.legenda i.sicurezza-tratto--spesso { height: 8px; }
.legenda i.sicurezza-pallino { width: 10px; height: 10px; border: 1px solid var(--bianco); border-radius: 50%; box-shadow: 0 0 0 1px #888; }
.legenda-sicurezza select { width: 100%; margin-top: 2px; }

/* ==========================================================================
   Scheda del luogo: pannello laterale a tutta altezza, una colonna,
   testata fissa e corpo scorrevole (su mobile: foglio dal basso)
   ========================================================================== */
#scheda {
  position: fixed; z-index: var(--z-mappa-ui); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  top: auto; bottom: 120px; right: 8px; left: 8px; width: auto; max-height: 45%; overflow: hidden; padding: 0;
  display: flex; flex-direction: column; touch-action: pan-y;
}
/* mobile: a tutto schermo (pulsante nella testata) per leggere la scheda con comodo */
#scheda.scheda-piena { top: 0; bottom: 0; left: 0; right: 0; max-height: none; border-radius: 0; border-width: 0; z-index: var(--z-foglio); }
#scheda[hidden] { display: none; }
#scheda h2 { font-size: var(--fs-md); margin: 0; }
.scheda-testata { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.scheda-azioni { flex: none; display: flex; gap: 2px; }
.scheda-x, .scheda-espandi, .scheda-personalizza { flex: none; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text-muted); }
.scheda-x:hover, .scheda-espandi:hover, .scheda-personalizza:hover, .scheda-personalizza[aria-expanded='true'] { background: var(--surface-hover); color: var(--text); }
.scheda-coordinate { margin: 2px 0 0; color: var(--text-muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.scheda-contesto { margin: 6px 0 4px; padding: 6px 8px; background: var(--avviso); border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 600; }

.scheda-intestazione { flex: none; padding: 14px 18px 10px; background: var(--surface-alt); border-bottom: 1px solid var(--border); }
#scheda .scheda-intestazione h2 { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.scheda-intestazione .scheda-contesto { margin: 10px 0 0; background: var(--avviso-scheda); color: var(--avviso-scheda-ink); border-left: 3px solid var(--accent-strong); border-radius: var(--r-xs) var(--r-sm) var(--r-sm) var(--r-xs); font-weight: 500; }
.scheda-pref { margin-top: 10px; padding: 10px 12px; max-height: 40vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); }
.scheda-pref[hidden] { display: none; }
.scheda-pref-nota { margin: 0 0 8px; font-size: var(--fs-xs); color: var(--text-muted); }
.scheda-pref-sez { margin: 0 0 8px; padding: 0; border: 0; }
.scheda-pref-voce { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: var(--fs-sm); }
.scheda-pref-titolo { font-weight: 600; }
.scheda-pref-sez .scheda-pref-voce:not(.scheda-pref-titolo) { padding-left: 22px; color: var(--text-muted); }
.scheda-pref-voce input:disabled + * { opacity: .5; }
.scheda-pref-cerca { box-sizing: border-box; width: 100%; margin: 0 0 8px; padding: 5px 8px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font-size: var(--fs-sm); }
.scheda-pref-sez[hidden], .scheda-pref-voce[hidden] { display: none; }
.scheda-pref-azioni { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.scheda-pref-bottone { padding: 4px 10px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font-size: var(--fs-xs); }
.scheda-pref-bottone:disabled { opacity: .45; cursor: default; }
.scheda-vuota { margin: 16px 0; color: var(--text-muted); font-size: var(--fs-sm); }
.scheda-corpo { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 6px 10px; overscroll-behavior: contain; }
.scheda-corpo > .scheda-sez:first-child { border-top: 0; margin-top: 12px; padding-top: 0; }

.scheda-sez { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 6px; }
.scheda-sez h3 { display: inline; margin: 0; font-size: var(--fs-base); font-weight: 700; color: var(--text); }
.scheda-icona { display: inline-flex; vertical-align: -.2em; margin-right: 8px; color: var(--accent-strong); }
.scheda-link .scheda-icona { color: inherit; margin-right: 6px; }
.scheda-acc > summary .scheda-icona { margin-right: 6px; }
.scheda-tag { display: inline-block; margin: 3px 0 3px 6px; padding: 1px 8px; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-ink); font-size: var(--fs-xs); font-weight: 700; text-transform: none; letter-spacing: 0; }
.scheda-gruppo { margin-top: 6px; }
.scheda-gruppo h4 { margin: 8px 0 2px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }

.scheda-riga { display: flex; justify-content: space-between; gap: 12px; padding: 3px 6px; margin: 0 -6px; border-radius: var(--r-sm); }
.scheda-gruppo > .scheda-riga:nth-of-type(even) { background: color-mix(in srgb, var(--text) 7%, transparent); }
.scheda-riga--lunga { flex-direction: column; gap: 0; }
.scheda-riga--lunga .scheda-val { text-align: left; }
.scheda-et { color: var(--text-muted); }
.scheda-riga--lunga .scheda-et a { color: var(--accent-strong); font-weight: 600; }
.scheda-val { text-align: right; font-weight: 600; }
.scheda-riga--lunga .scheda-val.scheda-val--nota { font-weight: 400; font-size: var(--fs-xs); color: var(--text-muted); overflow-wrap: anywhere; }
.scheda-dettaglio { flex-basis: 100%; font-size: var(--fs-xs); color: var(--text-muted); text-align: right; }
.scheda-riga:has(.scheda-dettaglio) { flex-wrap: wrap; }
.scheda-mancanti { margin: 4px 0 0; font-size: var(--fs-xs); color: var(--text-muted); font-style: italic; }
.scheda-badge { padding: 1px 8px; border: 1px solid transparent; border-radius: var(--r-pill); font-size: var(--fs-xs); white-space: nowrap; }
.scheda-badge-num { display: inline-block; min-width: 14px; margin-right: 4px; font-weight: 800; }
.scheda-badge--c1 { background: var(--c1-bg); color: var(--c1-fg); border-color: var(--c1-bd); }
.scheda-badge--c2 { background: var(--c2-bg); color: var(--c2-fg); border-color: var(--c2-bd); }
.scheda-badge--c3 { background: var(--c3-bg); color: var(--c3-fg); border-color: var(--c3-bd); }
.scheda-badge--c4 { background: var(--c4-bg); color: var(--c4-fg); border-color: var(--c4-bd); }
.scheda-badge--c5 { background: var(--c5-bg); color: var(--c5-fg); border-color: var(--c5-bd); }
.scheda-griglia { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.scheda-cella { text-align: center; padding: 8px 6px; border-radius: var(--r-sm); background: var(--accent-soft); overflow-wrap: anywhere; }
.scheda-cella-val { display: block; font-weight: 700; font-size: var(--fs-md); }
.scheda-cella-chiave { font-size: var(--fs-xs); color: var(--text-muted); }
.scheda-link { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; padding: 7px 10px; border-radius: var(--r-sm); background: var(--link); color: var(--bianco); text-decoration: none; font-weight: 600; }
.scheda-link-et { padding: 1px 8px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--bianco) 20%, transparent); font-size: var(--fs-xs); }
.scheda-link[hidden] { display: none; }
.scheda-acc { margin-top: 6px; }
.scheda-acc > summary { padding: 6px 8px; background: var(--avviso); font-weight: 600; }
.scheda-tipo { border-bottom: 1px solid var(--border); padding: 4px 0 4px 8px; }
.scheda-tipo > summary { display: flex; gap: 6px; align-items: baseline; }
.scheda-tipo-nome { font-weight: 600; flex: 1; }
.scheda-tipo-stato { font-size: var(--fs-2xs); color: var(--text-muted); text-transform: uppercase; }
.scheda-tipo-anteprima { color: var(--accent-strong); font-weight: 700; font-size: var(--fs-xs); white-space: nowrap; }
.scheda-nota { margin: 8px 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.scheda-legale { margin-top: 16px; padding-top: 8px; border-top: 1px solid var(--border); }
.scheda-testo { margin: 4px 0; line-height: 1.35; }
.scheda-suggerimento { margin: 4px 0 2px 4px; font-size: var(--fs-xs); color: var(--text-muted); font-style: italic; }

/* parti espandibili: chevron che ruota, cursore ed evidenziazione, così si capisce che si possono aprire */
.scheda-acc > summary, .scheda-tipo > summary, details.scheda-sez > summary { list-style: none; cursor: pointer; border-radius: var(--r-sm); }
.scheda-acc > summary::-webkit-details-marker, .scheda-tipo > summary::-webkit-details-marker, details.scheda-sez > summary::-webkit-details-marker { display: none; }
.scheda-acc > summary::before, .scheda-tipo > summary::before, details.scheda-sez > summary::before {
  content: '▸'; display: inline-block; width: 1em; margin-right: 4px; color: var(--accent-strong); font-weight: 700;
}
.scheda-acc[open] > summary::before, .scheda-tipo[open] > summary::before, details.scheda-sez[open] > summary::before { transform: rotate(90deg); }
.scheda-acc > summary:hover, .scheda-tipo > summary:hover, details.scheda-sez > summary:hover { background: var(--accent-soft); }

@media (min-width: 721px) {
  #scheda {
    top: 0; right: var(--rail-w); bottom: 0; left: auto; width: var(--scheda-w); max-height: none; padding: 0; overflow: hidden;
    display: flex; flex-direction: column; border-width: 0 0 0 1px; border-radius: 0;
    box-shadow: var(--ombra-pannello-dx);
  }
  #scheda[hidden] { display: none; }
  .scheda-espandi { display: none; }
  /* con la scheda aperta, barra strumenti, ricerca e fogli si centrano sulla parte di mappa rimasta visibile */
  body { --scheda-l: var(--rail-w); }
  body:has(#scheda:not([hidden]):not(.collassato), #rndt-pannello:not([hidden]):not(.collassato), #geoimage-pannello:not([hidden]):not(.collassato), #tema-ui-pannello:not([hidden]):not(.collassato)) { --scheda-l: calc(var(--scheda-w) + var(--rail-w)); }
  #barra-strumenti, #area-ricerca, #pannello { left: calc((100% - var(--scheda-l)) / 2); transition: left var(--t-media) ease; }
  /* la barra non esce mai dalla mappa visibile: se non ci sta, scorre di lato */
  #barra-strumenti { max-width: calc(100% - var(--scheda-l) - 16px); overflow-x: auto; scrollbar-width: none; }
}
/* schermi medi: lo slider (che il badge già ripete) lascia posto alla barra; con la scheda aperta la legenda sale sopra la ricerca */
@media (min-width: 721px) and (max-width: 1180px) { .zoom-wrap { display: none; } }
@media (min-width: 721px) and (max-width: 1320px) { body:has(#scheda:not([hidden])) #legende { bottom: 100px; } }

/* ==========================================================================
   Mobile: barra verticale sul bordo sinistro, sotto-pannelli accanto alla barra,
   niente slider (c'è il pinch)
   ========================================================================== */
@media (max-width: 720px) {
  .scheda-espandi { display: flex; }
  #area-ricerca { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: calc(100% - 16px); }
  #legende { bottom: 120px; left: 64px; }
  #barra-strumenti {
    top: 8px; bottom: auto; left: 8px; transform: none; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px;
    max-height: calc(100% - 72px); overflow-y: auto; border-radius: var(--r-md);
  }
  #barra-strumenti > button, #barra-gruppi button { width: 56px; height: auto; min-height: 44px; padding: 4px 0; flex-direction: column; gap: 2px; border-radius: var(--r-md); }
  #barra-strumenti .et { display: block; font-size: var(--fs-2xs); font-weight: 600; line-height: 1; }
  #barra-gruppi { flex-direction: column; gap: 4px; }
  .barra-sep { width: 26px; height: 1px; }
  .zoom-wrap, #zoom-badge { display: none; }
  #pannello { top: 8px; bottom: auto; left: 76px; transform: none; width: min(300px, calc(100% - 84px)); max-height: calc(100% - 72px); }
  #legende { left: 76px; }
}

.uffici-popup .uffici-suggerimento { margin-top: 6px; font-style: italic; color: var(--text-muted); }
.legenda-uffici { max-height: 45vh; overflow-y: auto; }
.legenda-incendi i.incendi-campione { width: 14px; height: 10px; border: 1.5px solid; border-radius: 2px; }
.legenda-mef .mef-legenda-riga { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.legenda-mef i.mef-campione { width: 14px; height: 10px; border-radius: 2px; border: 1px solid #5c2e0b; flex: none; }
.incendi-popup-voce + .incendi-popup-voce { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.legenda-pai { max-height: 50vh; overflow-y: auto; }
.legenda-pai .pai-legenda-tema { display: flex; flex-direction: column; align-items: flex-start; }
.legenda-pai .pai-legenda-tema + .pai-legenda-tema { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.legenda-pai i.pai-campione { width: 18px; height: 12px; border: 1.5px solid; border-radius: 2px; flex: none; background-size: 12px; }
.legenda-pai i.pai-campione--linea { border: 0; border-radius: 1px; }
.pai-popup-voce + .pai-popup-voce { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.legenda-uffici .uffici-nota { margin: 0 0 4px; font-size: var(--fs-2xs); color: var(--text-muted); }


/* ==========================================================================
   Barra strati verticale con etichette, strumenti separati,
   legenda riducibile, scheda con indice, sezioni con riassunto, piede fisso e bottom sheet a tre altezze
   ========================================================================== */
.barra-sep { display: none !important; }
#apri-strati, #chiudi-strati, .scheda-maniglia { display: none; }

#barra-strati {
  position: fixed; z-index: var(--z-barra); top: 12px; left: 12px; bottom: 12px; width: 92px;
  display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin;
  background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-lg); box-shadow: var(--ombra);
}
.barra-titolo { margin: 0; padding: 0 0 4px; text-align: center; font-size: var(--fs-2xs); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
#barra-gruppi { display: flex; flex-direction: column; gap: 2px; }
#barra-gruppi button {
  position: relative; width: 100%; height: auto; min-height: 56px; padding: 6px 2px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: transparent; border: 0; border-radius: var(--r-md); color: var(--text); font-size: var(--fs-xs); font-weight: 600; line-height: 1.1;
}
#barra-gruppi button:hover { background: var(--surface-hover); }
#barra-gruppi button[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); }
#barra-gruppi .et { display: block; text-align: center; }
#barra-gruppi button[data-attivo="true"]::after {
  content: attr(data-n); position: absolute; top: 2px; right: calc(50% - 28px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--text); color: var(--surface); font-size: var(--fs-2xs); font-weight: 700; line-height: 18px; text-align: center;
}

#barra-strumenti {
  position: fixed; z-index: var(--z-barra); top: 12px; left: auto; right: calc(var(--scheda-l) + 12px); transform: none; max-width: none; overflow: visible;
  display: flex; align-items: center; gap: 4px; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none;
}
/* stessi pulsanti tondi della scheda: 36 px, filo sottile, icone da 18 px, hover ambra */
#barra-strumenti button { width: 36px; height: 36px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--ombra); transition: background var(--t-rapida), border-color var(--t-rapida), color var(--t-rapida); }
#barra-strumenti button svg { width: 18px; height: 18px; }
#barra-strumenti button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
#barra-strumenti button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }


#legende-box { position: fixed; z-index: var(--z-mappa-ui); left: calc(var(--sx) + 12px); bottom: 28px; width: 260px; max-width: calc(100% - var(--sx) - 20px); background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-md); box-shadow: var(--ombra); }
#legende-box:not(:has(#legende > :not([hidden]))) { display: none; }
#legende-riduci { width: 100%; padding: 8px 10px; border: 0; background: none; text-align: left; font-size: var(--fs-xs); font-weight: 700; color: var(--text); }
#legende-box.ridotta #legende { display: none; }
#legende { position: static; max-width: none; padding: 0 10px 8px; overflow-y: auto; min-height: 0; }
#legende-box { --legende-bottom: 28px; --legende-alto: 172px; display: flex; flex-direction: column; max-height: calc(100dvh - var(--legende-bottom) - var(--legende-alto)); }
#legende .legenda { padding: 0; border: 0; box-shadow: none; background: none; }

.scheda-intestazione { padding-bottom: 0; }
.scheda-indice { display: flex; gap: 2px; margin: 8px -18px 0; padding: 0 14px; overflow-x: auto; scrollbar-width: none; }
.scheda-indice[hidden] { display: none; }
.scheda-indice button { flex: 1 0 auto; max-width: none; min-height: 40px; padding: 8px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--text-muted); font-size: var(--fs-sm); }
.scheda-indice button[aria-current="true"] { border-bottom-color: var(--accent); color: var(--text); font-weight: 700; }
.scheda-sez { margin-top: 0; padding-top: 0; }
details.scheda-sez > summary { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 0; }
.scheda-riassunto { margin-left: auto; padding-left: 12px; color: var(--text-muted); font-weight: 400; font-size: var(--fs-sm); text-align: right; }
.scheda-sez > :not(summary) { margin-left: 1.4em; }
.scheda-piede { flex: none; padding: 6px 10px 12px; background: var(--surface); border-top: 1px solid var(--border); }
.scheda-piede[hidden] { display: none; }
.scheda-piede .scheda-link { margin-top: 0; min-height: 44px; }
.scheda-piede .scheda-legale { margin: 8px 0 0; padding: 0; border: 0; }

@media (min-width: 721px) {
  #area-ricerca { left: calc(var(--sx) + (100% - var(--sx) - var(--scheda-l)) / 2); }
}
@media (min-width: 721px) and (max-width: 1320px) { #legende-box { --legende-bottom: 100px; bottom: 100px; } }

@media (max-width: 720px) {
  #barra-strati { display: none; }
  body.strati-aperti #barra-strati { display: flex; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 70%; z-index: var(--z-foglio); padding: 12px; border-radius: var(--r-lg) var(--r-lg) 0 0; border-width: 1px 0 0; }
  /* riquadri tre per riga: Strati ha base, layer, filtri e la Tabella (a tutta riga); Aggiungi ha i miei layer, RNDT, Geoimage */
  body.strati-aperti #barra-gruppi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  body.strati-aperti #barra-gruppi button { border: 1px solid var(--border-ui); min-height: 64px; }
  body.strati-aperti #barra-gruppi button[aria-expanded="true"] { border-color: var(--accent); }
  body.strati-aperti .barra-titolo { text-align: left; padding: 0 0 8px; font-size: var(--fs-xs); }
  #chiudi-strati { display: block; margin-top: 10px; min-height: 44px; border: 0; border-radius: var(--r-sm); background: var(--accent); color: var(--accent-ink); font-weight: 600; }
  #apri-strati {
    position: fixed; z-index: var(--z-barra); top: 12px; left: 12px; height: 44px; padding: 0 14px; display: flex; align-items: center; gap: 6px;
    background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-pill); box-shadow: var(--ombra); color: var(--text); font-weight: 600; font-size: var(--fs-sm);
  }
  #pannello { top: 64px; bottom: auto; left: 8px; right: 8px; width: auto; transform: none; max-height: 45%; z-index: calc(var(--z-foglio) + 1); }
  #barra-strumenti { top: 12px; right: 12px; left: auto; max-height: none; flex-direction: row; align-items: center; gap: 8px; padding: 0; overflow: visible; background: none; border: 0; border-radius: 0; box-shadow: none; }
  #barra-strumenti > button { width: 44px; height: 44px; min-height: 44px; padding: 0; flex-direction: row; background: var(--surface); border: 1px solid var(--border-ui); border-radius: 50%; box-shadow: var(--ombra); }
  #barra-strumenti .et { display: none; }
  #legende-box { --legende-bottom: 72px; --legende-alto: 112px; left: 8px; bottom: 72px; width: 220px; }

  #scheda { top: auto; bottom: 64px; left: 0; right: 0; width: auto; max-height: none; border-width: 1px 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -8px 32px rgba(0, 0, 0, .2); }
  #scheda[data-altezza="peek"] { height: 168px; }
  #scheda[data-altezza="meta"] { height: 55%; }
  #scheda.scheda-piena { height: auto; border-radius: 0; }
  #scheda[data-altezza="peek"] .scheda-corpo, #scheda[data-altezza="peek"] .scheda-indice, #scheda[data-altezza="peek"] .scheda-piede { display: none; }
  .scheda-maniglia { flex: none; width: 100%; height: 28px; padding: 0; display: flex; align-items: center; justify-content: center; border: 0; background: none; touch-action: none; cursor: grab; }
  .scheda-maniglia i { width: 40px; height: 4px; border-radius: 2px; background: var(--border); }
  .scheda-x, .scheda-personalizza { width: 44px; height: 44px; margin: 0; }
  .scheda-testata { align-items: center; }
  .scheda-espandi { display: none; }
}

.scheda-piede { display: flex; flex-flow: row wrap; gap: 6px; }
.scheda-piede .scheda-link { margin-top: 0; flex: 1 1 calc(50% - 4px); min-width: 0; }
.scheda-piede .scheda-legale { margin: 0; flex: 1 1 100%; }

.scheda-tabs { display: flex; align-items: stretch; margin: 8px -18px 0; border-top: 1px solid var(--border); }
.scheda-tabs[hidden] { display: none; }
.scheda-tabs-freccia { flex: none; width: 32px; padding: 0; border: 0; background: var(--surface-alt); color: var(--text); font-size: 22px; line-height: 1; }
.scheda-tabs-freccia:hover:not(:disabled) { background: var(--surface-hover); }
.scheda-tabs-freccia:disabled { opacity: .3; cursor: default; }
.scheda-tabs-freccia[hidden] { display: none; }
.scheda-indice { position: relative; flex: 1; min-width: 0; margin: 0; padding: 0 4px; gap: 0; overflow-x: auto; scrollbar-width: none; }
.scheda-indice button { flex: none; max-width: none; padding: 8px 12px; }
.scheda-indice button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--text); font-weight: 700; }
.scheda-sez[hidden] { display: none; }
@media (max-width: 720px) {
  #scheda[data-altezza="peek"] .scheda-tabs { display: none; }
}

/* zoom: slider verticale compatto in basso a destra (solo desktop; su mobile c'è il pinch) */
#zoom-box { position: fixed; z-index: var(--z-mappa-ui); right: calc(var(--scheda-l) + 12px); bottom: 54px; width: 44px; padding: 8px 0 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-lg); box-shadow: var(--ombra); transition: right var(--t-rapida); }
#zoom-box .zoom-wrap { display: block; position: relative; width: 24px; height: 140px; }
#zoom-box #zoom-slider { position: absolute; left: 50%; top: 50%; width: 140px; margin: 0; transform: translate(-50%, -50%) rotate(-90deg); }
@media (max-width: 720px) { #zoom-box { display: none; } }

#barra-gruppi .et { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .01em; }
.scheda-et { font-size: var(--fs-base); }
.scheda-riassunto { font-size: var(--fs-sm); }
.scheda-nota, .scheda-dettaglio, .scheda-coordinate, .scheda-contesto { font-size: var(--fs-sm); }
.legenda div, .legenda .nota-stime, .legenda .nota-omi { font-size: var(--fs-sm); }

/* bersagli di tocco: almeno 36 px su desktop, 44 px con puntatore grossolano (touch) e su mobile */
.scheda-x, .scheda-personalizza { width: 36px; height: 36px; }
.scheda-tabs-freccia { min-height: 40px; }
#legende-riduci { min-height: 36px; }
#avvisi button { width: 32px; height: 32px; }
#cerca-risultati button { min-height: 40px; padding-top: 8px; padding-bottom: 8px; }
.legenda i.catasto-etichetta { font-size: var(--fs-2xs); }
@media (pointer: coarse), (max-width: 720px) {
  .scheda-x, .scheda-personalizza, .scheda-espandi { width: 44px; height: 44px; }
  .scheda-indice button, .scheda-tabs-freccia { min-height: 44px; }
  .scheda-tabs-freccia { width: 40px; }
  #legende-riduci, #cerca-risultati button, #cerca-particella input, #cerca-particella button, .sotto-pannello select, #pannello-filtri select { min-height: 44px; }
  #avvisi button { width: 44px; height: 44px; }
  #cerca-filtri { height: 44px; margin-right: 2px; }
  #cerca-ripristina { width: 44px; height: 44px; }
  #barra-strumenti button { width: 44px; height: 44px; }
  .sotto-pannello label, #pannello-filtri label { min-height: 36px; display: flex; align-items: center; gap: 8px; }
  .sotto-pannello input[type=checkbox], .sotto-pannello input[type=radio] { width: 20px; height: 20px; }
  #crediti button { min-height: 44px; }
  #crediti .crediti-x { width: 44px; height: 44px; }
}

.scheda-sunto { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; margin: 12px 0 4px; }
.scheda-sunto > div { padding: 8px 6px; border-radius: var(--r-sm); background: var(--accent-soft); text-align: center; overflow-wrap: anywhere; }
.scheda-sunto b { display: block; font-size: var(--fs-md); }
.scheda-sunto span { font-size: var(--fs-xs); color: var(--text-muted); }

/* schermi stretti con scheda aperta: ricerca mai sopra i controlli a destra, scheda più stretta, logo nascosto */
@media (min-width: 721px) {
  #area-ricerca { width: clamp(220px, calc(100vw - var(--scheda-l) - var(--sx) - 150px), 400px); }
}
@media (min-width: 721px) and (max-width: 1000px) {
  :root { --scheda-w: 380px; }
  body:has(#scheda:not([hidden])) #zoom-box { bottom: 54px; }
}

/* campo di ricerca negli strati e chip degli strati accesi */
.strato-cerca { display: block; width: 100%; margin: 0 0 8px; padding: 8px 10px; font-size: var(--fs-sm); }
.sotto-pannello label[hidden] { display: none; }
/* interruttore a occhio: acceso = icona piena con alone, spento = occhio barrato attenuato */
.sotto-pannello label.strato, .sotto-pannello label.sotto-voce { position: relative; display: flex; align-items: center; gap: 8px; padding: 3px 6px; min-height: 0; border-radius: var(--r-sm); cursor: pointer; font-size: var(--fs-sm); transition: background var(--t-media), box-shadow var(--t-media); }
.sotto-pannello label.strato:hover, .sotto-pannello label.sotto-voce:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.sotto-pannello label.strato:has(input:checked), .sotto-pannello label.sotto-voce:has(input:checked) { background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.sotto-pannello label.strato > input[type=checkbox], .sotto-pannello label.sotto-voce > input[type=checkbox] { position: absolute; opacity: 0; width: 100%; height: 100%; inset: 0; margin: 0; cursor: pointer; }
.occhio { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; color: var(--text-muted); background: color-mix(in srgb, var(--text-muted) 12%, transparent); transition: transform var(--t-media), color var(--t-media), background var(--t-media), box-shadow var(--t-media); }
.occhio .on { display: none; }
label.strato:has(input:checked) .occhio, label.sotto-voce:has(input:checked) .occhio { color: var(--accent-ink); background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent), 0 1px 5px color-mix(in srgb, var(--accent) 50%, transparent); }
label.strato:has(input:checked) .occhio .on, label.sotto-voce:has(input:checked) .occhio .on { display: block; }
label.strato:has(input:checked) .occhio .off, label.sotto-voce:has(input:checked) .occhio .off { display: none; }
label.strato:active .occhio, label.sotto-voce:active .occhio { transform: scale(.88); }
label.strato:has(input:focus-visible) .occhio, label.sotto-voce:has(input:focus-visible) .occhio { outline: 2px solid var(--accent); outline-offset: 2px; }
label.strato:has(input:disabled), label.sotto-voce:has(input:disabled) { opacity: .5; cursor: not-allowed; }
/* sottovoci: occhio più piccolo (-30%), senza sfondo né bordo colorato sulla riga accesa */
label.sotto-voce .occhio { width: 17px; height: 17px; }
label.sotto-voce .occhio svg { width: 10px; height: 10px; }
.sotto-pannello label.sotto-voce:has(input:checked) { background: none; box-shadow: none; font-weight: inherit; }
.sotto-pannello label.sotto-voce:has(input:checked):hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
label.sotto-voce:has(input:checked) .occhio { box-shadow: none; }
.strato-opacita { display: grid; grid-template-columns: auto 1fr 2.6em auto auto; align-items: center; gap: 8px; margin: 0 0 6px 38px; font-size: var(--fs-xs); color: var(--text-muted); }
.strato-opacita[hidden], .strato-opacita.filtrata { display: none; }
.strato-opacita input[type=range] { width: 100%; margin: 0; accent-color: var(--accent); }
.strato-zoom { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; background: none; border: 1px solid var(--border-ui); border-radius: 50%; color: var(--text-muted); cursor: pointer; }
.strato-zoom:hover { background: var(--surface-hover); color: var(--text); }
.strato-tema-btn[hidden], .strato-tema[hidden] { display: none; }
.strato-tema { grid-column: 1 / -1; display: grid; gap: 6px; padding: 8px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface-alt); color: var(--text); }
.tema-categorie { display: grid; gap: 4px; max-height: 220px; overflow-y: auto; padding-top: 4px; border-top: 1px solid var(--border); }
.tema-categorie[hidden] { display: none; }
.strato-tema .tema-riga { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; min-height: 0; }
.strato-tema .tema-riga:has(input[type=range]) { grid-template-columns: 5em 1fr 2.6em; }
.strato-tema .tema-riga[hidden] { display: none; }
.strato-tema input[type=color] { width: 36px; height: 24px; padding: 0; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: none; cursor: pointer; }
.tema-attributo { display: grid; gap: 6px; padding-top: 4px; border-top: 1px solid var(--border); }
.strato-tema select { min-width: 0; max-width: 11em; padding: 2px 4px; }
.strato-tema .tema-riga[hidden] { display: none; }
.rampa-riga { position: relative; }
.rampa-inverti { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; font-size: var(--fs-xs); }
.rampa-scelta, .rampa-elenco button { display: grid; grid-template-columns: 5.5em 1fr; align-items: center; gap: 8px; width: 100%; padding: 3px 6px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.rampa-scelta { width: 11em; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); }
.rampa-scelta i, .rampa-elenco i { height: 12px; border: 1px solid var(--border-ui); border-radius: 2px; }
.rampa-elenco { position: absolute; right: 0; top: 100%; z-index: 5; width: 15em; max-height: 14em; overflow-y: auto; padding: 4px 0; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); box-shadow: var(--ombra); }
.rampa-elenco[hidden] { display: none; }
.rampa-elenco strong { display: block; padding: 4px 6px 2px; font-size: var(--fs-2xs); color: var(--text-muted); }
.rampa-elenco button:hover, .rampa-elenco button:focus-visible { background: var(--surface-alt); }
.rampa-elenco button[aria-selected=true] { font-weight: 600; }
.tema-campione { width: 36px; height: 14px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); }
.strato-tema input[type=range] { width: 100%; margin: 0; accent-color: var(--accent); }
.tema-azioni { display: flex; flex-wrap: wrap; gap: 6px; }
.tema-msg { margin: 0; min-height: 1em; font-size: var(--fs-xs); color: var(--text-muted); }
.strato-opacita output { text-align: right; font-variant-numeric: tabular-nums; }
#strati-chip { position: fixed; z-index: var(--z-mappa-ui); top: 14px; left: calc(var(--sx) + 12px); right: calc(var(--scheda-l) + 240px); display: flex; flex-wrap: nowrap; gap: 6px; overflow: hidden; pointer-events: none; }
#strati-chip:empty { display: none; }
.strato-chip { pointer-events: auto; flex: none; max-width: 180px; height: 32px; padding: 0 8px 0 12px; display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-pill); box-shadow: var(--ombra); color: var(--text); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.strato-chip span { overflow: hidden; text-overflow: ellipsis; }
.strato-chip i { font-style: normal; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: var(--fs-md); line-height: 1; }
button.strato-chip:hover { background: var(--surface-hover); }
button.strato-chip:hover i { color: var(--text); }
.strato-chip--altri { padding: 0 12px; color: var(--text-muted); pointer-events: none; }
@media (max-width: 720px) { #strati-chip { display: none; } }

/* azioni della scheda, contatore sui tab, stampa */
.scheda-azione { flex: none; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text-muted); }
@media (pointer: coarse), (max-width: 720px) { .scheda-azione { width: 44px; height: 44px; } }
.scheda-tab-n { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-strong); font-size: var(--fs-2xs); font-weight: 700; line-height: 18px; text-align: center; }
.scheda-disclaimer { display: none; }
@media print {
  .scheda-disclaimer { display: block; margin: 12px 0 0; padding-top: 8px; border-top: 1px solid #999; font-size: 11px; line-height: 1.4; color: #333; break-inside: avoid; }
  html, body { height: auto; overflow: visible; background: #fff; }
  #app-header, #app-footer, #mappa, #barra-strati, #zoom-box, #strati-chip, #legende-box, #area-ricerca, #apri-strati, #avvisi, #pannello,
  .scheda-azioni, .scheda-tabs, .scheda-maniglia, .scheda-pref { display: none !important; }
  #scheda { position: static !important; width: auto !important; height: auto !important; max-height: none !important; box-shadow: none !important; border: 0 !important; display: block !important; }
  .scheda-corpo { overflow: visible !important; }
  .scheda-sez[hidden] { display: block !important; }
  .scheda-intestazione { background: #fff; }
  .scheda-sez { break-inside: avoid; }
  .scheda-piede { border-top: 1px solid #999; }
  .scheda-piede .scheda-link { display: none !important; }
  .scheda-stralcio { display: block; width: 100%; margin: 8px 0; border: 1px solid #999; break-inside: avoid; }
}

/* interruttore «Mappa» nell'intestazione delle sezioni della scheda: accende lo strato collegato */
.scheda-strato { flex: none; margin-left: auto; padding: 2px 10px; border: 1px solid var(--border); border-radius: var(--r-pill); background: transparent; color: var(--text-muted); font: inherit; font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.scheda-riassunto + .scheda-strato { margin-left: auto; }
/* intestazione sezione: titolo + «Mappa» sulla prima riga, riassunto sotto allineato al titolo (mai due righe a destra) */
details.scheda-sez > summary { flex-wrap: wrap; row-gap: 0; align-items: flex-start; padding: 8px 0 4px; }
details.scheda-sez > summary::before, details.scheda-sez > summary > h3 { line-height: 28px; }
details.scheda-sez > summary > h3 { flex: 1 1 0; min-width: 0; }
details.scheda-sez > summary > .scheda-sez-extra { order: 2; flex: none; display: flex; flex-direction: column; align-items: flex-end; max-width: 50%; }
.scheda-sez-extra:empty { display: none; }
.scheda-sez-extra > .scheda-tag { margin: 3px 0; height: 22px; box-sizing: border-box; display: inline-flex; align-items: center; padding: 0 10px; line-height: 1; }
.scheda-sez-extra > .scheda-strato { margin: 3px 0; height: 22px; box-sizing: border-box; display: inline-flex; align-items: center; padding: 0 10px; font-size: var(--fs-xs); line-height: 1; }
details.scheda-sez > summary > .scheda-riassunto { order: 3; flex: 0 0 100%; margin-left: 0; padding: 0 0 4px calc(1em + 10px); text-align: left; }
/* a sezione aperta il riassunto ripete la prima riga del corpo: si mostra solo da chiusa */
details.scheda-sez[open] > summary > .scheda-riassunto { display: none; }
.scheda-strato[hidden] { display: none; }
.scheda-strato:hover:not(:disabled) { background: var(--accent-soft); }
.scheda-strato[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.scheda-strato:disabled { opacity: .5; cursor: not-allowed; }
@media print { .scheda-strato { display: none; } }

/* classifica dei residenti nella tab Popolazione (come nel pannello di palermo_popolazione) */
.pop-classifica { margin-top: 10px; padding: 0px 10px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-alt); --pop-it: #e8b84a; --pop-st: #3aa89a; }
.pop-classifica-titolo { margin-bottom: 6px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-muted); }
.pop-livelli { display: flex; gap: 4px; margin-bottom: 6px; }
.pop-livello { flex: 1; padding: 3px 4px; font: inherit; font-size: var(--fs-xs); color: var(--text); background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-sm); cursor: pointer; }
.pop-livello:hover { background: var(--surface-hover); }
.pop-livello[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pop-legenda { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; font-size: var(--fs-2xs); color: var(--text-muted); }
.pop-legenda span { display: inline-flex; align-items: center; gap: 4px; }
.pop-legenda-pct { margin-left: auto; }
.pop-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.pop-dot.pop-it, .pop-barra .pop-it { background: var(--pop-it); }
.pop-dot.pop-st, .pop-barra .pop-st { background: var(--pop-st); }
.pop-lista.lunga { padding: 1px; max-height: clamp(200px, calc(100dvh - 830px), 400px); overflow-x: hidden; overflow-y: auto; position: relative; }
.pop-lista { position: relative; }
.pop-riga { display: flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 4px; border-radius: var(--r-sm); font-size: var(--fs-sm); }
.pop-riga.corrente { background: var(--accent-soft); outline: 1px solid var(--accent); }
.pop-n { flex: 0 0 18px; font-size: var(--fs-2xs); color: var(--text-muted); text-align: right; }
.pop-riga.corrente .pop-n { color: var(--accent-strong); font-weight: 700; }
.pop-nome { flex: 0 0 56px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop-lista.lunga .pop-nome { flex-basis: 96px; }
.pop-barra { flex: 1; display: flex; height: 8px; min-width: 20px; border-radius: var(--r-xs); overflow: hidden; background: var(--surface-hover); }
.pop-barra span { display: block; height: 100%; }
.pop-valore { font-weight: 700; font-variant-numeric: tabular-nums; }
.pop-pct { flex: 0 0 38px; text-align: right; font-size: var(--fs-2xs); color: var(--text-muted); }
.pop-trend { flex: 0 0 auto; padding: 1px 6px; border-radius: var(--r-pill); font-size: var(--fs-2xs); font-weight: 600; white-space: nowrap; }
.pop-trend.up { background: var(--c1-bg); color: var(--c1-fg); }
.pop-trend.down { background: var(--c5-bg); color: var(--c5-fg); }
.pop-trend.flat { background: var(--surface-hover); color: var(--text-muted); }
.pop-totale { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.pop-totale-valore { font-weight: 700; }
@media print { .pop-lista.lunga { max-height: none; overflow: visible; } }

/* grafici delle colonnine (tab «Servizi su strada»): indicatore delle occupate e barre dello stato */
.col-grafici { display: grid; gap: 8px; margin: 6px 0 10px; }
.col-graf { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-alt); }
.col-graf-titolo { margin: 0 0 6px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-muted); }
.col-graf-nota { margin: 6px 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.col-graf-di-cui { margin: 2px 0; font-size: var(--fs-xs); font-style: italic; color: var(--text-muted); text-align: center; }
.col-gauge { width: min(220px, 80%); margin: 0 auto; }
.col-gauge svg { display: block; width: 100%; }
.col-gauge-val { margin-top: -14px; text-align: center; font-size: var(--fs-lg); font-weight: 700; color: var(--blu-dati); }
.col-gauge-sub { text-align: center; font-size: var(--fs-sm); }
.col-barra { display: flex; gap: 2px; height: 22px; margin: 4px 0; }
.col-barra-seg { display: flex; align-items: center; justify-content: center; min-width: 4px; border-radius: var(--r-xs); font-size: var(--fs-xs); }
.col-legenda { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: var(--fs-xs); color: var(--text-muted); }
.col-legenda span { display: inline-flex; align-items: center; gap: 4px; }
.col-legenda i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.col-legenda b { color: var(--text); }
@media print { .col-grafici { break-inside: avoid; } }
.gruppo-sezione { margin: 10px 0 2px; }

/* Catalogo RNDT: pannello che si sovrappone alla scheda del luogo */
#rndt-pannello { position: fixed; z-index: var(--z-foglio); left: 0; right: 0; bottom: 0; top: 8vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm) var(--r-sm) 0 0; box-shadow: var(--ombra); overflow: hidden; }
#rndt-pannello[hidden] { display: none; }
@media (min-width: 721px) { #rndt-pannello { top: 0; left: auto; right: var(--rail-w); width: var(--scheda-w); border-radius: 0; } }
.rndt-testata, .gi-testata { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.rndt-testata h2, .gi-testata h2 { flex: 1; min-width: 0; margin: 0; font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.01em; }
.rndt-autore, .gi-autore { flex: none; margin: 0; padding: 6px 14px; background: var(--surface-alt); font-size: var(--fs-sm); color: var(--text-muted); border-bottom: 1px solid var(--border); }
.rndt-autore a { color: inherit; font-weight: 600; }
.plugin-merito-titolo { margin: 0 0 4px; font-weight: 700; font-size: var(--fs-md); }
.plugin-merito p { margin: 0 0 6px; }
.plugin-merito { padding: 10px 12px; border-radius: var(--r-md); background: var(--accent-soft); }
.rndt-layer { flex: none; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-alt); font-size: var(--fs-sm); }
.rndt-layer[hidden] { display: none; }
.rndt-layer summary { cursor: pointer; font-weight: 600; }
.rndt-layer-riga { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; }
.rndt-layer-riga label { overflow-wrap: anywhere; }
.rndt-layer-riga em { color: var(--text-muted); }
.rndt-rimuovi { flex: none; border: 0; background: none; color: var(--link); font: inherit; cursor: pointer; }
.rndt-contenuto { flex: 1; min-height: 0; overflow: auto; }
.rndt-attesa, .rndt-errore { margin: 16px; color: var(--text-muted); }
.rndt-errore { color: var(--avviso-scheda-ink); }

/* Gruppo «RNDT» della barra strati */
.rndt-gruppo-aggiungi { width: 100%; margin: 0 0 6px; padding: 6px 10px; border: 1px dashed var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--link); font: inherit; font-weight: 600; cursor: pointer; }
.rndt-gruppo-aggiungi:hover { background: var(--surface-hover); }
.rndt-gruppo-riga { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rndt-gruppo-riga label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rndt-gruppo-riga em { color: var(--text-muted); font-size: var(--fs-sm); }
.rndt-gruppo-togli { flex: none; width: 28px; height: 28px; border: 0; border-radius: var(--r-pill); background: none; color: var(--text-muted); display: inline-grid; place-items: center; cursor: pointer; }
.rndt-gruppo-togli:hover { background: var(--surface-hover); color: var(--text); }
.rndt-gruppo-vuoto { margin: 4px 0; color: var(--text-muted); font-size: var(--fs-sm); }
.rndt-gruppo-azioni { display: grid; gap: 6px; margin: 0 0 6px; }
.rndt-gruppo-azioni .rndt-gruppo-aggiungi { margin: 0; }

/* ==========================================================================
   Restyling di scheda e catalogo RNDT (ispirato a GeoLibre, con i nostri colori):
   testata con pulsanti tondi, tab a pillola, riquadri tratteggiati per gli stati vuoti,
   risultati a scheda, azioni in ambra
   ========================================================================== */
.scheda-intestazione { padding: 12px 14px 8px; background: var(--surface); }
.scheda-azioni { gap: 4px; }
.scheda-x, .scheda-azione, .scheda-personalizza, .scheda-espandi { border: 1px solid var(--border); background: var(--surface); transition: background var(--t-rapida), border-color var(--t-rapida), color var(--t-rapida); }
.scheda-x:hover, .scheda-azione:hover, .scheda-personalizza:hover, .scheda-personalizza[aria-expanded='true'] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }

/* tab: controllo segmentato, voce attiva in rilievo con filo ambra */
.scheda-tabs { margin: 10px 0 0; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-alt); }
.scheda-tabs-freccia { min-height: 34px; border-radius: var(--r-sm); background: none; }
.scheda-indice { padding: 0; gap: 2px; }
.scheda-indice button { min-height: 34px; padding: 6px 12px; border: 1px solid transparent; border-bottom-width: 1px; border-radius: var(--r-sm); transition: background var(--t-rapida), color var(--t-rapida); }
.scheda-indice button:hover { background: var(--surface-hover); color: var(--text); }
.scheda-indice button[aria-selected="true"], .scheda-indice button[aria-current="true"] { border-color: var(--accent); background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); color: var(--text); font-weight: 700; }

/* corpo: sezioni come riquadri, stati vuoti tratteggiati */
.scheda-corpo { padding: 6px 12px 12px; }
.scheda-sez { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.scheda-corpo > .scheda-sez:first-child { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); }
.scheda-vuota, .rndt-attesa, .rndt-gruppo-vuoto { padding: 18px 14px; border: 1px dashed var(--border-ui); border-radius: var(--r-md); background: var(--surface-alt); color: var(--text-muted); text-align: center; }
.rndt-gruppo-vuoto { margin: 6px 0; padding: 12px 10px; }
.scheda-piede { padding: 8px 12px 12px; background: var(--surface-alt); }

/* catalogo RNDT: testata e pannello */
.rndt-layer { margin: 10px 12px 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.rndt-rimuovi { color: var(--accent-strong); font-weight: 600; }
.rndt-contenuto { background: var(--surface-alt); }

/* il contenuto del plugin usa le variabili del plugin: le portiamo sui nostri colori */
#rndt-pannello .ordt-panel {
  --ordt-fg: var(--text); --ordt-muted: var(--text-muted); --ordt-border: var(--border); --ordt-input: var(--border-ui);
  --ordt-bg: var(--surface); --ordt-accent: var(--surface-alt);
  --ordt-primary: var(--accent); --ordt-primary-fg: var(--accent-ink);
  --ordt-radius: var(--r-sm);
  padding: 12px; gap: 12px; font-size: var(--fs-sm);
}
#rndt-pannello .ordt-input { background: var(--surface); }
#rndt-pannello .ordt-input:focus, #rndt-pannello .ordt-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent-strong); }
#rndt-pannello .ordt-button { padding: 6px 12px; border-radius: var(--r-pill); background: var(--surface); transition: background var(--t-rapida), border-color var(--t-rapida); }
#rndt-pannello .ordt-button:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
#rndt-pannello .ordt-primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 700; }
#rndt-pannello .ordt-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(.96); }
#rndt-pannello .ordt-link, #rndt-pannello .ordt-org, #rndt-pannello .ordt-badge-service { color: var(--accent-strong); }
#rndt-pannello .ordt-badge-service { border-color: var(--accent); background: var(--accent-soft); }
#rndt-pannello .ordt-badge { padding: 0 8px; border-radius: var(--r-pill); }
#rndt-pannello .ordt-result-title:hover { color: var(--accent-strong); }
#rndt-pannello .ordt-fieldset, #rndt-pannello .ordt-contact, #rndt-pannello .ordt-service { border-radius: var(--r-md); }
#rndt-pannello .ordt-results { gap: 8px; }
#rndt-pannello .ordt-result { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); transition: border-color var(--t-rapida), box-shadow var(--t-rapida); }
#rndt-pannello .ordt-result:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0, 0, 0, .06); }
#rndt-pannello .ordt-footer, #rndt-pannello .ordt-detail-bar, #rndt-pannello .ordt-add-row { background: var(--surface); }
#rndt-pannello .ordt-detail-title { font-size: var(--fs-md); }

/* barra verticale dei pannelli a destra: tab con testo ruotato, pannello attivo evidenziato */
#scheda.collassato, #rndt-pannello.collassato, #geoimage-pannello.collassato, #tema-ui-pannello.collassato { display: none; }
#rail-pannelli { display: none; }
@media (min-width: 721px) {
  #rail-pannelli {
    position: fixed; z-index: var(--z-foglio); top: 0; right: 0; bottom: 0; width: var(--rail-w);
    display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 8px 0;
    background: var(--surface); border-left: 1px solid var(--border);
  }
  .rail-tab {
    display: flex; flex-direction: column; align-items: center; gap: 8px; width: 34px; padding: 8px 0;
    border: 1px solid transparent; border-radius: var(--r-md); background: none; color: var(--text-muted);
    font: inherit; font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .03em; text-transform: uppercase; cursor: pointer;
    transition: background var(--t-rapida), color var(--t-rapida), border-color var(--t-rapida);
  }
  .rail-tab svg { width: 16px; height: 16px; }
  .rail-tab[hidden] { display: none; }
  .rail-tab[aria-disabled="true"] { opacity: .4; cursor: default; }
  .rail-tab[aria-disabled="true"]:hover { background: none; color: var(--text-muted); }
  .rail-tab span { writing-mode: vertical-rl; transform: rotate(180deg); }
  .rail-tab:hover { background: var(--surface-hover); color: var(--text); }
  .rail-tab.attivo { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
  #zoom-box { right: calc(var(--scheda-l) + 12px); }
  .maplibregl-ctrl-bottom-right { right: var(--scheda-l); }
}

/* ==========================================================================
   Barra sinistra a tab e pannello ancorato (desktop), come la barra di destra
   ========================================================================== */
@media (min-width: 721px) {
  /* il pannello sinistro ospita le sezioni di Layer: più stretto di quello della scheda */
  body { --pannello-w: 320px; --sx: var(--rail-w); }
  body:has(#pannello .sotto-pannello:not([hidden])) { --sx: calc(var(--pannello-w) + var(--rail-w)); }

  #barra-strati {
    z-index: var(--z-foglio); top: 0; left: 0; bottom: 0; width: var(--rail-w); padding: 8px 0; gap: 0; align-items: center;
    border-width: 0 1px 0 0; border-radius: 0; box-shadow: none; border-color: var(--border);
  }
  .barra-titolo { display: none; }
  #barra-gruppi { align-items: center; gap: 14px; }
  #barra-gruppi button.rail-tab {
    width: 34px; min-height: 0; padding: 8px 0; gap: 8px; border: 1px solid transparent; border-radius: var(--r-md);
    background: none; color: var(--text-muted); font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  }
  #barra-gruppi button.rail-tab svg { width: 16px; height: 16px; }
  #barra-gruppi button.rail-tab .et { writing-mode: vertical-rl; transform: rotate(180deg); }
  #barra-gruppi button.rail-tab:hover { background: var(--surface-hover); color: var(--text); }
  #barra-gruppi button.rail-tab[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
  #barra-gruppi button[data-attivo="true"]::after { top: -4px; right: -2px; min-width: 16px; height: 16px; line-height: 16px; padding: 0 3px; }

  #pannello {
    z-index: var(--z-foglio); top: 0; bottom: 0; left: var(--rail-w); width: var(--pannello-w); max-height: none; transform: none;
    overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); box-shadow: var(--ombra-pannello-sx);
  }
  /* schermi bassi: 14 tab con il testo ruotato non entrano; resta il testo solo sul tab aperto (gli altri hanno icona e tooltip) */
  @media (max-height: 1100px) {
    #barra-gruppi button.rail-tab[aria-expanded="false"], #rail-pannelli .rail-tab:not(.attivo) { padding: 8px 0; }
    #barra-gruppi button.rail-tab[aria-expanded="false"] .et, #rail-pannelli .rail-tab:not(.attivo) span { display: none; }
  }
  #pannello .sotto-pannello { min-height: 100%; padding: 14px 14px; border: 0; border-radius: 0; box-shadow: none; }
  #pannello .sotto-pannello h2 { margin-bottom: 10px; font-size: var(--fs-sm); }

  #area-ricerca, #barra-strumenti { transition: left var(--t-media) ease; }
  .maplibregl-ctrl-bottom-left { left: var(--sx); }
}

/* albero ripiegabile e riordino degli strati */
.albero-chiuso { display: none !important; }
.strato-azioni { position: relative; z-index: 2; margin-left: auto; display: inline-flex; align-items: center; gap: 2px; flex: none; }
.strato-btn { width: 22px; height: 22px; padding: 0; display: inline-grid; place-items: center; border: 0; border-radius: var(--r-sm); background: none; color: var(--text-muted); font: inherit; font-size: var(--fs-3xs); line-height: 1; cursor: pointer; }
.strato-btn:disabled { opacity: .3; cursor: default; }
.strato-btn--su::before { content: '▲'; }
.strato-btn--giu::before { content: '▼'; }
.strato-btn--albero::before { content: '▾'; font-size: var(--fs-base); }
.strato-btn--albero[aria-expanded=false]::before { content: '▸'; }
.strato-btn--trascina { cursor: grab; touch-action: none; font-size: 15px; }
.strato-btn--trascina::before { content: '⠿'; }
label.strato.trascinato, .rndt-gruppo-riga.trascinato { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); box-shadow: var(--ombra); }
label.strato.trascinato .strato-btn--trascina, .rndt-gruppo-riga.trascinato .strato-btn--trascina { cursor: grabbing; }
.strato-strumenti { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.strato-strumento { padding: 4px 10px; border: 1px solid var(--border-ui); border-radius: var(--r-pill); background: var(--surface); color: var(--link); font: inherit; font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.strato-strumento:hover { background: var(--surface-hover); }
.strato-btn[hidden] { display: none; }
/* Ordine di disegno: elenco unico degli strati accesi, di qualsiasi gruppo */
.ordine-nota { margin: 4px 12px 6px; color: var(--text-muted); font-size: var(--fs-xs); }
.ordine-elenco { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.ordine-riga { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: var(--r-sm); background: var(--surface); font-size: var(--fs-sm); }
.ordine-riga.trascinato { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); box-shadow: var(--ombra); }
.ordine-riga.trascinato .strato-btn--trascina { cursor: grabbing; }
.ordine-nome { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; text-overflow: ellipsis; }
.ordine-nome small { color: var(--text-muted); font-size: var(--fs-xs); }
.ordine-elenco[hidden], .ordine-nota[hidden] { display: none; }

/* Sezioni del tab «Layer»: ognuna si apre e si chiude da sola */
.layer-sezione { border-top: 1px solid var(--border); }
.layer-sezione:first-of-type { border-top: 0; }
.layer-sezione > summary {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 10px 2px; cursor: pointer; list-style: none; user-select: none;
}
.layer-sezione > summary::-webkit-details-marker { display: none; }
.layer-sezione > summary h2 { margin: 0; flex: 1; }
.layer-sezione > summary::before { content: '▸'; flex: none; width: 12px; text-align: center; color: var(--text-muted); font-size: var(--fs-xs); line-height: 1; transition: transform var(--t-rapida); }
.layer-sezione[open] > summary::before { transform: rotate(90deg); }
.layer-sezione > summary:hover h2 { color: var(--text); }
.layer-sezione > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-radius: var(--r-sm); }
.layer-sezione > summary[data-attivo="true"]::after {
  content: attr(data-n); flex: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink); font-size: var(--fs-2xs); font-weight: 700; line-height: 18px; text-align: center;
}
.layer-sezione[open] { padding-bottom: 8px; }

/* «Ordine layer in mappa»: una scheda con l'accento, perché si distingua dai gruppi di strati e si noti */
.layer-sezione.ordine-strumento { margin: 8px 0 12px; border: 1px solid var(--accent); border-radius: var(--r-md); background: var(--accent-soft); }
.ordine-strumento > summary { padding: 10px 12px; gap: 10px; }
.ordine-strumento > summary::before { color: var(--accent-strong); }
.ordine-ico { flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-ink); }
.ordine-testi { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ordine-strumento > summary h2 { flex: none; color: var(--accent-strong); font-weight: 700; }
.ordine-strumento > summary:hover h2 { color: var(--accent-strong); }
.ordine-sotto { color: var(--text-muted); font-size: var(--fs-xs); font-weight: 400; }
.ordine-conta { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-ink); font-size: var(--fs-2xs); font-weight: 700; line-height: 20px; text-align: center; }
.ordine-conta[hidden] { display: none; }
.ordine-strumento[open] { padding-bottom: 10px; }
.ordine-strumento .strato-strumenti { padding: 8px 12px 0; }

/* Icona del tab RNDT: pezzo di puzzle (img/puzzle.webp) usato come maschera, così segue il colore del tema */
.icona-puzzle { display: block; flex: none; width: 18px; height: 18px; background: currentColor; -webkit-mask: url(../img/puzzle.webp) center / contain no-repeat; mask: url(../img/puzzle.webp) center / contain no-repeat; }

/* ==========================================================================
   Geoimage: mappa storica sulla base, pannello a destra (come RNDT)
   ========================================================================== */
#geoimage-pannello, #tema-ui-pannello { position: fixed; z-index: var(--z-foglio); left: 0; right: 0; bottom: 0; top: 8vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm) var(--r-sm) 0 0; box-shadow: var(--ombra); overflow: hidden; }
#geoimage-pannello[hidden], #tema-ui-pannello[hidden] { display: none; }
@media (min-width: 721px) { #geoimage-pannello, #tema-ui-pannello { top: 0; left: auto; right: var(--rail-w); width: var(--scheda-w); border-radius: 0; } }
/* .gi-autore: stile condiviso con .rndt-autore (sopra) */
.gi-autore a { color: inherit; font-weight: 600; }
.gi-stato { flex: none; margin: 0; padding: 6px 12px; font-size: var(--fs-sm); background: var(--accent-soft); border-bottom: 1px solid var(--border); }
.gi-corpo { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 12px 16px; }
.gi-sezione { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.gi-sezione[hidden] { display: none; }
.gi-sezione h3 { margin: 0; font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.gi-riga { display: flex; flex-wrap: wrap; gap: 6px; }
.gi-riga > .gi-btn { flex: 1 1 0; }
.gi-nota, .gi-info { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.gi-info:empty { display: none; }
.gi-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 32px; padding: 4px 10px; border: 1px solid var(--border-ui); border-radius: var(--r-pill); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); cursor: pointer; text-decoration: none; transition: background var(--t-rapida), border-color var(--t-rapida); }
.gi-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.gi-btn:disabled { opacity: .45; cursor: default; }
.gi-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.gi-btn:focus-visible, .gi-campo input:focus-visible, .gi-campo select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.gi-primario { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.gi-primario:hover:not(:disabled) { background: var(--accent); filter: brightness(.96); }
.gi-pericolo { color: var(--pericolo); }
.gi-zona { flex-direction: column; gap: 2px; padding: 16px 10px; width: 100%; border: 2px dashed var(--border-ui); border-radius: var(--r-md); }
.gi-zona span { font-size: var(--fs-xs); color: var(--text-muted); }
.gi-zona.trascina, .gi-zona.ha-immagine { border-color: var(--accent); background: var(--accent-soft); }
.gi-campo { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); }
.gi-campo input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.gi-campo select { flex: 1; min-width: 0; min-height: 32px; padding: 2px 6px; }
.gi-campo-colonna { flex-direction: column; align-items: stretch; gap: 2px; }
.gi-valore { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.gi-frecce { display: grid; grid-template-columns: repeat(3, 40px); gap: 4px; justify-content: center; }
.gi-frecce .gi-btn { padding: 0; }
.gi-anteprima canvas { display: block; width: 100%; height: auto; border: 1px solid var(--border-ui); border-radius: var(--r-sm); }
.gi-scorri { max-height: 180px; overflow: auto; }
.gi-tabella { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.gi-tabella th, .gi-tabella td { padding: 3px 4px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.gi-tabella th { position: sticky; top: 0; background: var(--surface-alt); color: var(--text-muted); }
.tui-avanzati > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.tui-tipo { display: grid; gap: 8px; }
.tui-tipo input[type=range] { width: 100%; }
.tui-campione { margin: 0; padding: 8px 10px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); }
.tui-preset { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.tui-preset .gi-btn { justify-content: flex-start; gap: 8px; }
.tui-anteprima { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 3px; width: 46px; height: 32px; padding: 4px; box-sizing: border-box; border: 1px solid; border-radius: var(--r-xs); }
.tui-anteprima i { display: block; height: 3px; border-radius: 2px; }
.tui-anteprima .tui-barra { height: 6px; width: 60%; }
.tui-anteprima .tui-riga { width: 100%; opacity: .85; }
.tui-anteprima .tui-corta { width: 65%; opacity: .85; }
.tui-anteprima .tui-link { width: 40%; }
/* colori: etichetta, campione e valore in tre colonne fisse, così i campioni restano allineati */
.gi-campo.tui-colore { display: grid; grid-template-columns: minmax(0, 1fr) 64px 8ch; align-items: center; gap: 10px; }
.tui-colore input[type="color"] { width: 64px; height: 30px; padding: 2px; box-sizing: border-box; }
.tui-colore .gi-valore { min-width: 0; text-align: left; }
.gi-res-buono td:nth-child(6) { color: var(--c1-fg); }
.gi-res-medio td:nth-child(6) { color: var(--c4-fg); }
.gi-res-alto td:nth-child(6) { color: var(--pericolo); font-weight: 700; }
.gi-x { min-height: 22px; padding: 0 6px; }
.gi-gtiff { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 8px 10px 10px; border: 1px solid var(--border-ui); border-radius: var(--r-md); }
.gi-gtiff[hidden] { display: none; }
.gi-gtiff legend { padding: 0 4px; font-size: var(--fs-sm); font-weight: 700; }
.gi-spento { opacity: .4; pointer-events: none; }

/* sulla mappa: immagine, maniglie, linea dello Swipe, cerchio dello Spotlight, GCP */
.gi-overlay { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.gi-overlay[hidden] { display: none; }
.gi-immagine { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; user-select: none; }
.gi-maniglia { box-sizing: border-box; cursor: grab; }
.gi-maniglia:active { cursor: grabbing; }
.gi-centro { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bianco); box-shadow: var(--ombra-sm); }
.gi-centro::before { content: "✥"; display: flex; align-items: center; justify-content: center; height: 100%; color: var(--accent-ink); font-size: var(--fs-md); line-height: 1; }
.gi-rota { width: 22px; height: 22px; border-radius: 50%; background: var(--bianco); border: 2px solid var(--accent); box-shadow: var(--ombra-sm); }
.gi-rota::before { content: "⟳"; display: flex; align-items: center; justify-content: center; height: 100%; color: var(--accent-strong); font-size: 14px; line-height: 1; }
.gi-scala { width: 16px; height: 16px; background: var(--accent); border: 2px solid var(--bianco); border-radius: var(--r-xs); box-shadow: var(--ombra-sm); }
.gi-deforma { width: 14px; height: 14px; background: var(--link); border: 2px solid var(--bianco); transform: rotate(45deg); box-shadow: var(--ombra-sm); }
.gi-divisore { position: absolute; top: 0; bottom: 0; width: 0; z-index: 1; border-left: 2px solid var(--bianco); box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); pointer-events: none; }
.gi-divisore[hidden] { display: none; }
.gi-divisore-maniglia { position: absolute; top: 50%; left: -16px; width: 32px; height: 32px; margin-top: -16px; padding: 0; border: 2px solid var(--bianco); border-radius: 50%; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; cursor: ew-resize; pointer-events: auto; touch-action: none; box-shadow: var(--ombra-sm); }
.gi-cerchio { position: absolute; z-index: 1; transform: translate(-50%, -50%); border: 2px solid var(--accent); border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .3); }
.gi-cerchio[hidden] { display: none; }
.gi-gcp { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--bianco); background: var(--pericolo-vivo); color: var(--bianco); font-size: var(--fs-3xs); font-weight: 700; box-shadow: var(--ombra-sm); cursor: grab; }
.gi-gcp-attesa { background: color-mix(in srgb, var(--accent) 90%, transparent); pointer-events: none; }

/* invito all'avvio: pill e schema sopra la mappa, non intercettano i clic */
.invito-clic {
  position: fixed; z-index: var(--z-barra); top: 20%; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  display: flex; flex-direction: column; align-items: center; gap: 12px; pointer-events: none;
}
.invito-clic p {
  margin: 0; padding: 10px 20px; border: 2px solid var(--bianco); border-radius: var(--r-pill); background: var(--accent-strong); color: var(--accent-strong-ink);
  font-size: var(--fs-base); font-weight: 700; text-align: center; box-shadow: var(--ombra);
}
.invito-clic img { display: block; width: min(640px, 60vw); height: auto; border-radius: var(--r-md); box-shadow: var(--ombra); }
.invito-mai {
  pointer-events: auto; cursor: pointer; padding: 6px 16px; border: 2px solid var(--bianco); border-radius: var(--r-pill);
  background: var(--invito-bg); color: var(--bianco); font: inherit; font-size: var(--fs-sm); font-weight: 600; box-shadow: var(--ombra);
}
.invito-mai:hover { background: var(--invito-bg-hover); }
@media (max-width: 600px) {
  .invito-clic { top: 30%; }
  .invito-clic p { padding: 8px 14px; font-size: var(--fs-sm); }
  .invito-clic img { display: none; } /* a 390 px il testo dello schema sarebbe illeggibile: sta nella Guida */
}

/* Isole di calore: legenda con metodo e numero di classi, grafico 2019–2025 */
.legenda-isole-calore { max-width: 300px; }
.legenda-isole-calore .ic-etichetta { display: block; margin: 8px 0 4px; font-size: var(--fs-3xs); text-transform: uppercase; color: var(--text-muted); }
.legenda-isole-calore .ic-etichetta input { display: block; width: 60%; margin-top: 6px; accent-color: var(--accent-strong); }
.legenda-isole-calore .ic-metodi { display: flex; gap: 5px; }
.legenda-isole-calore .ic-metodo { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px 7px; border: 1.5px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface-alt); color: var(--text-muted); font: inherit; font-size: 10px; font-weight: 600; line-height: 1.2; cursor: pointer; }
.legenda-isole-calore .ic-metodo:hover { color: var(--text); border-color: var(--accent-strong); }
.legenda-isole-calore .ic-metodo[aria-pressed="true"] { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-strong-ink); }
.legenda-isole-calore .ic-icona { width: 100%; height: 20px; }
.legenda-isole-calore .ic-rottura { stroke: var(--pericolo); stroke-width: 1; }
.legenda-isole-calore .ic-metodo[aria-pressed="true"] .ic-rottura { stroke: var(--accent-strong-ink); }
.legenda-isole-calore .ic-barra { display: flex; height: 22px; border-radius: var(--r-xs); overflow: hidden; }
.legenda-isole-calore .ic-classe { flex: 1; align-self: stretch; }
.legenda-isole-calore .ic-assi { display: flex; align-items: center; gap: 4px; margin-top: 5px; font-size: 9px; font-weight: 600; color: var(--text-muted); }
.legenda-isole-calore .ic-freccia { flex: 1; height: 2px; border: 0; background: linear-gradient(90deg, var(--border), var(--accent-strong)); }
.legenda-isole-calore .ic-nd { display: flex; align-items: center; gap: 6px; margin-top: 5px; font-size: var(--fs-xs); }
.legenda-isole-calore .ic-nd i { width: 14px; height: 10px; border: 1px solid var(--border); }
.legenda-isole-calore .ic-link { display: block; margin-top: 6px; font-size: var(--fs-xs); color: var(--link); }
.ic-graf .ic-svg svg { display: block; width: 100%; height: auto; }
.ic-asse { font-size: 8.5px; fill: var(--text-muted); }
.ic-graf .col-legenda i.ic-tratteggio { height: 0; border: 0; border-top: 2px dashed var(--text-muted); border-radius: 0; background: none; }
.ic-graf .col-legenda i.ic-fascia { width: 12px; border-radius: 2px; background: var(--text-muted); opacity: .25; }
.ic-graf .col-legenda i.ic-tratteggio { width: 14px; }
/* `.legenda div` dispone i figli in riga: scala e grafico stanno in colonna */
.legenda-isole-calore .ic-scala, .legenda-isole-calore .ic-graf, .legenda-isole-calore .ic-svg { display: block; }
.legenda-isole-calore .ic-graf { margin-top: 8px; }
.legenda-isole-calore .ic-assi i.ic-freccia { width: auto; border: 0; }
.legenda-isole-calore .col-legenda { display: flex; flex-wrap: wrap; }

/* Albero di «I miei layer» (stile Browser di QGIS) */
.agg-albero { margin: 0 0 8px; }
.agg-cerca { width: 100%; margin: 0 0 8px; box-sizing: border-box; }
.agg-nodo > summary { display: flex; align-items: center; gap: 6px; padding: 4px 2px; cursor: pointer; font-weight: 600; list-style: none; }
.agg-nodo > summary::-webkit-details-marker { display: none; }
.agg-nodo > summary::before { content: '▸'; flex: none; width: 10px; color: var(--text-muted); font-size: var(--fs-3xs); }
.agg-nodo[open] > summary::before { content: '▾'; }
.agg-ico { flex: none; display: inline-grid; place-items: center; color: var(--text-muted); }
.agg-nome { flex: 1; min-width: 0; }
.agg-conteggio { flex: none; color: var(--text-muted); font-weight: 400; font-size: var(--fs-sm); }
.agg-azione { flex: none; width: 26px; height: 26px; border: 0; border-radius: var(--r-pill); background: none; color: var(--text-muted); display: inline-grid; place-items: center; cursor: pointer; }
/* pulsanti-icona senza bordo: stesso hover ovunque */
.scheda-azione:hover, .strato-btn:hover:not(:disabled), .agg-azione:hover { background: var(--surface-hover); color: var(--text); }
/* su touch le azioni di riga diventano un bersaglio comodo */
@media (pointer: coarse) { .strato-btn, .agg-azione { width: 32px; height: 32px; } }
.agg-figli { padding-left: 16px; }
.agg-tipo > summary { font-weight: 500; }
.agg-nota { margin: 2px 0 6px; color: var(--text-muted); font-size: var(--fs-sm); }
.agg-modulo { display: grid; gap: 6px; padding: 6px 0 8px; }
.agg-da-web { grid-template-columns: minmax(0, 1fr) auto; align-items: end; column-gap: 6px; padding-top: 10px; }
.agg-da-web > .agg-esito { grid-column: 1 / -1; }
.agg-info > summary { cursor: pointer; color: var(--text-muted); font-size: var(--fs-sm); }
.agg-info > .agg-nota { margin-top: 4px; }
.agg-campo { display: grid; gap: 2px; font-size: var(--fs-sm); }
.agg-campo input { width: 100%; box-sizing: border-box; padding: 6px 8px; }
.agg-bottone { padding: 6px 10px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.agg-primario { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.agg-bottone:disabled { opacity: .6; cursor: progress; }
.agg-esito { margin: 0; font-size: var(--fs-sm); }
.agg-esito[data-errore="true"] { color: var(--avviso-scheda-ink); }
.agg-scelta { display: grid; gap: 4px; max-height: 240px; overflow: auto; }
.agg-voce em { color: var(--text-muted); }
.agg-salvato { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 1px 0; }
.agg-salvato-nome { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; text-align: left; border: 0; background: none; color: var(--link); font: inherit; cursor: pointer; overflow-wrap: anywhere; }
.agg-salvato > .agg-esito, .agg-salvato > .agg-modulo { flex-basis: 100%; }
.agg-titolo-layer { margin: 10px 0 4px; font-weight: 700; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }

/* ==========================================================================
   Struttura della pagina: header, mappa, footer (la pagina non scorre mai)
   ========================================================================== */
body { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; height: 100dvh; }
/* contain: layout fa di #corpo il riferimento di tutti gli elementi fixed dell'interfaccia: restano dentro la mappa */
/* posizioni esplicite: un elemento estraneo nel body (estensioni del browser, tooltip) non deve spostare le tre righe */
#app-header { grid-area: 1 / 1; }
#corpo { grid-area: 2 / 1; position: relative; min-height: 0; overflow: hidden; contain: layout; }
#app-footer { grid-area: 3 / 1; }
body { grid-auto-rows: 0; } /* righe in più, se ce ne sono, non rubano spazio */

#app-header {
  position: relative; z-index: var(--z-header); box-sizing: border-box; min-height: 64px; padding: 8px 16px;
  display: flex; align-items: center; gap: 16px; background: var(--surface); border-bottom: 1px solid var(--border-ui);
}
#app-logo { flex: none; display: block; line-height: 0; }
#menu-info { display: flex; align-items: center; gap: 2px; margin-left: auto; min-width: 0; }
#menu-info button, #menu-info a { display: block; box-sizing: border-box; text-decoration: none; padding: 10px 12px; border: 0; border-bottom: 3px solid transparent; border-radius: var(--r-sm) var(--r-sm) 0 0; background: none; color: var(--text-muted); font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; }
#menu-info button:hover, #menu-info a:hover { background: var(--surface-hover); color: var(--text); }
#menu-info button[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
#menu-info-toggle { display: none; margin-left: auto; width: 44px; height: 44px; padding: 0; align-items: center; justify-content: center; border: 0; border-radius: var(--r-sm); background: none; color: var(--text); cursor: pointer; }
#menu-info-toggle:hover { background: var(--surface-hover); }
#switch-lingua { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 10px; border: 1px solid var(--border-ui); border-radius: var(--r-pill); background: var(--surface-alt); color: var(--text); font: inherit; font-size: .8125rem; font-weight: 600; cursor: pointer; }
#switch-lingua:hover { background: var(--surface-hover); }
#switch-lingua:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* sotto i 1180 px le otto voci non stanno in una riga: menu a tendina con l'icona a tre righe */
@media (max-width: 1180px) {
  #menu-info-toggle { display: flex; }
  #menu-info { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: calc(var(--z-header) + 1); flex-direction: column; align-items: stretch; gap: 0; margin: 0; padding: 4px 0 8px; background: var(--surface); border-bottom: 1px solid var(--border-ui); box-shadow: 0 8px 20px rgba(0, 0, 0, .15); }
  #menu-info.aperto { display: flex; }
  #menu-info button, #menu-info a { min-height: 48px; padding: 12px 16px; border-bottom: 0; border-left: 3px solid transparent; border-radius: 0; text-align: left; }
  #menu-info button[aria-current="page"] { border-left-color: var(--accent); background: var(--surface-hover); }
}
/* tablet (721-1180 px): la tendina ha la stessa forma di quella del telefono, mezza larghezza a destra, testo a destra, a due gruppi */
@media (min-width: 721px) and (max-width: 1180px) {
  #menu-info { left: auto; right: 8px; top: calc(100% + 4px); width: 260px; max-height: 75dvh; overflow-y: auto; padding: 10px 0; text-align: right; border: 1px solid var(--border-ui); border-radius: var(--r-md); box-shadow: var(--ombra); }
  #menu-info button, #menu-info a { text-align: right; border-left-width: 0; border-right: 3px solid transparent; }
  #menu-info button[aria-current="page"] { border-left-color: transparent; border-right-color: var(--accent); }
  #menu-info .menu-gruppo { display: block; margin: 4px 0; padding: 0 19px 0 16px; font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
  #menu-info [data-scheda="mappa"] { order: 0; }
  #menu-info .menu-gruppo[data-gruppo="guide"] { order: 1; }
  #menu-info [data-scheda="guida"] { order: 2; } #menu-info [data-scheda="plugin"] { order: 3; } #menu-info [data-scheda="geoimage"] { order: 4; }
  #menu-info .menu-gruppo[data-gruppo="info"] { order: 5; margin-top: 12px; }
  #menu-info [data-scheda="digitaltwin"] { order: 6; } #menu-info [data-scheda="argomenti"] { order: 7; }
  #menu-info [data-scheda="fonti"] { order: 8; } #menu-info [data-scheda="privacy"] { order: 9; } #menu-info #link-presentazione { order: 10; } #menu-info [data-scheda="about"] { order: 11; }
}
#app-logo img { display: block; height: 44px; width: auto; }

#app-footer {
  box-sizing: border-box; min-height: 36px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--surface); border-top: 1px solid var(--border-ui); font-size: var(--fs-xs); color: var(--text-muted);
}
.piede-avviso { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.piede-avviso strong { color: var(--text); }
#piede-coord { margin-left: auto; flex: none; font-family: ui-monospace, Consolas, monospace; font-weight: 500; }
#piede-copyright { flex: 0 1 auto; min-width: 0; padding-block: 4px; }
#piede-copyright .piede-licenza { display: inline-block; } /* se il testo va a capo, la frase della licenza passa intera sulla seconda riga */
#piede-copyright a { color: var(--text); font-weight: 600; text-underline-offset: 2px; }
#logo-ods { flex: none; display: block; line-height: 0; }
#logo-ods img { display: block; height: 24px; width: auto; }

@media (max-width: 720px) {
  #app-header { flex-wrap: wrap; row-gap: 8px; padding: 8px 12px; min-height: 0; }
  #app-header { column-gap: 8px; }
  #app-logo img { height: 30px; }
      #piede-coord, .piede-avviso, #piede-copyright .piede-licenza { display: none; }
  #piede-copyright { font-size: var(--fs-2xs); }
}

/* stampa della mappa visibile (pulsante «Stampa» della barra strumenti): il foglio compare solo in stampa */
#foglio-stampa { display: none; }
@media print {
  body.stampa-mappa > *:not(#foglio-stampa) { display: none !important; }
  body.stampa-mappa #foglio-stampa { display: block; color: #000; background: #fff; font-family: inherit; }
  #foglio-stampa h1 { margin: 0; font-size: 18pt; }
  #foglio-stampa h2 { margin: 8px 0 4px; font-size: 11pt; }
  #foglio-stampa header p { margin: 2px 0 8px; font-size: 9pt; color: #333; }
  #foglio-stampa .stampa-mappa { display: block; width: 100%; max-height: var(--mappa-a, 62vh); object-fit: contain; border: 1px solid #999; }
  #foglio-stampa .stampa-legende { margin-top: 8px; font-size: 9pt; column-count: 2; }
  #foglio-stampa .stampa-legende h2 { column-span: all; }
  #foglio-stampa .stampa-legende * { color: #000 !important; max-height: none !important; overflow: visible !important; }
  #foglio-stampa .stampa-attribuzioni { margin-top: 8px; padding-top: 4px; border-top: 1px solid #999; font-size: 8pt; line-height: 1.35; color: #333; break-inside: avoid; }
  #foglio-stampa .stampa-attribuzioni p { margin: 0; }
}

/* menu del pulsante «Stampa»: vista attuale o scala fissa */
#stampa-menu { width: max-content; top: 70px; right: calc(var(--scheda-l) + 12px); left: auto; transform: none; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 24px); position: fixed; z-index: var(--z-barra); display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-lg); box-shadow: var(--ombra); font-size: var(--fs-sm); color: var(--text); }
#stampa-menu[hidden] { display: none; }
#stampa-menu label { display: inline; padding: 0; }
#stampa-menu select { width: auto; margin: 0; padding: 4px 8px; }
#stampa-menu button { padding: 5px 14px; font: inherit; font-weight: 600; color: var(--accent-ink); background: var(--accent); border: 1px solid var(--accent); border-radius: var(--r-pill); cursor: pointer; }
#stampa-menu button:disabled { opacity: .6; cursor: wait; }
#condividi-menu { position: fixed; z-index: var(--z-barra); top: 70px; right: calc(var(--scheda-l) + 12px); width: min(360px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-lg); box-shadow: var(--ombra); font-size: var(--fs-sm); color: var(--text); }
#condividi-menu[hidden] { display: none; }
#condividi-menu h2 { margin: 0; font-size: var(--fs-sm); font-weight: 700; }
#condividi-menu .condividi-testa { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#condividi-menu .condividi-chiudi { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; color: var(--text-muted); background: transparent; border: 1px solid var(--border-ui); border-radius: 50%; }
#condividi-menu .condividi-chiudi:hover { background: var(--surface-hover); color: var(--text); }
#condividi-menu .condividi-link { display: flex; gap: 6px; }
#condividi-menu input { flex: 1; min-width: 0; padding: 5px 8px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-pill); }
#condividi-menu button { padding: 5px 14px; font: inherit; font-weight: 600; color: var(--accent-ink); background: var(--accent); border: 1px solid var(--accent); border-radius: var(--r-pill); cursor: pointer; text-decoration: none; }
#condividi-menu .condividi-reti { display: flex; flex-wrap: wrap; gap: 8px; }
#condividi-menu .condividi-rete { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; color: var(--text-muted); background: transparent; border: 1px solid var(--border-ui); border-radius: 50%; transition: background var(--t-rapida), color var(--t-rapida); }
#condividi-menu .condividi-rete:hover { background: var(--surface-hover); color: var(--text); }
#condividi-menu .condividi-rete:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#condividi-menu .condividi-nota { margin: 0; color: var(--text-muted); }
#condividi-menu .condividi-nota[hidden] { display: none; }
@media print {
  #foglio-stampa.in-scala .stampa-mappa { width: var(--mappa-l); height: var(--mappa-a); max-height: none; object-fit: fill; }
  #foglio-stampa .stampa-scala { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 8pt; }
  #foglio-stampa .stampa-scala-barra { display: inline-block; height: 3mm; border: 1px solid #000; border-top-width: 3px; box-sizing: border-box; }
}

/* su desktop le sezioni sono pagine: si torna alla mappa dal menu o dal logo, senza X */
@media (min-width: 961px) { #crediti .crediti-x { display: none; } }

/* a pagina informazioni aperta, il suggerimento di avvio non deve restarle sopra */
body:has(#crediti[open]) :is(.invito-clic, .invito-mai) { display: none; }

/* schermi stretti: il pulsante Strati diventa icona + numero, così non finisce sotto la barra strumenti */
@media (max-width: 480px) { #apri-strati .lbl-strati { display: none; } }

/* pulsante di chiusura dei pannelli RNDT e Geoimage (su mobile la barra laterale non c'è) */
.rndt-testata .pannello-chiudi, .gi-testata .pannello-chiudi { margin-left: auto; flex: none; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-muted); cursor: pointer; }
.rndt-testata .pannello-chiudi:hover, .gi-testata .pannello-chiudi:hover { background: var(--surface-hover); color: var(--text); }
@media (pointer: coarse), (max-width: 720px) { .rndt-testata .pannello-chiudi, .gi-testata .pannello-chiudi { width: 44px; height: 44px; } }
/* Geoimage nel pannello Strati: solo dove non c'è la barra laterale */
@media (min-width: 721px) { #barra-gruppi .btn-pannello-mobile { display: none; } }
@media (max-width: 720px) { body.strati-aperti #barra-gruppi .btn-pannello-mobile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; } }
/* l'invito all'avvio non sta sopra un pannello aperto */
body:has(#rndt-pannello:not([hidden]):not(.collassato), #geoimage-pannello:not([hidden]):not(.collassato), #tema-ui-pannello:not([hidden]):not(.collassato)) .invito-clic { display: none; }

/* Visore delle immagini della guida */
.guida-figura img, img.dt-fig { cursor: zoom-in; }
.viewer-img { position: fixed; inset: 0; z-index: var(--z-viewer); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 48px 56px 20px; background: rgba(10, 12, 16, .88); }
.viewer-img-scena { flex: 1; min-height: 0; width: 100%; overflow: auto; display: flex; align-items: flex-start; justify-content: center; }
.viewer-img-scena img { max-width: 100%; max-height: 100%; margin: auto; border-radius: var(--r-sm); background: var(--bianco); cursor: zoom-in; }
.viewer-img-scena img.zoom { max-width: none; max-height: none; width: 200%; margin: 0; cursor: zoom-out; }
.viewer-img-cap { margin: 0; max-width: 900px; color: #e8eaee; font-size: .9375rem; text-align: center; }
.viewer-img button { position: absolute; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--bianco) 14%, transparent); color: var(--bianco); font: inherit; line-height: 1; cursor: pointer; }
.viewer-img button:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }
.viewer-img button:disabled { opacity: .3; cursor: default; }
.viewer-img-x { top: 10px; right: 14px; width: 40px; height: 40px; font-size: 1.75rem; }
.viewer-img-nav { top: 50%; width: 44px; height: 44px; margin-top: -22px; font-size: 2rem; }
.viewer-img-prec { left: 6px; }
.viewer-img-succ { right: 6px; }
.viewer-img button[hidden] { display: none; }
@media (max-width: 720px) { .viewer-img { padding: 52px 8px 14px; } .viewer-img-nav { top: auto; bottom: 14px; margin: 0; } }

/* ==========================================================================
   Telefono (fino a 720 px): barra a quattro tab (Mappa, Strati, Aggiungi, Info), ricerca in alto,
   strumenti della mappa in colonna a destra. Sopra i 720 px resta l'interfaccia a barre laterali.
   ========================================================================== */
:root { --tab-h: 60px; --footer-h: 36px; }
#barra-tab, #switch-tema, .menu-gruppo { display: none; }
@media (max-width: 720px) {
  #barra-tab {
    position: fixed; z-index: calc(var(--z-foglio) + 1); left: 0; right: 0; bottom: 0; height: var(--tab-h); display: flex;
    background: var(--surface); border-top: 1px solid var(--border-ui);
  }
  #barra-tab button {
    position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; border-top: 3px solid transparent; background: none; color: var(--text-muted); font: inherit; font-size: var(--fs-xs); font-weight: 600;
  }
  #barra-tab button[aria-pressed="true"] { color: var(--text); border-top-color: var(--accent); }
  #barra-tab .conta-strati {
    position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box; display: flex; align-items: center; justify-content: center;
    border-radius: var(--r-pill); background: var(--text); color: var(--surface); font-size: 11px; font-style: normal; font-weight: 700; line-height: 1;
  }
  #barra-tab .conta-strati[hidden] { display: none; }

  /* tema scuro: interruttore nell'header, a destra */
  #switch-tema { display: flex; align-items: center; margin-left: auto; width: 64px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; }
  #switch-tema .switch-pista { position: relative; width: 56px; height: 28px; box-sizing: border-box; border: 1px solid var(--border-ui); border-radius: var(--r-pill); background: var(--surface-alt); transition: background var(--t-rapida), border-color var(--t-rapida); }
  #switch-tema .switch-sole, #switch-tema .switch-luna { position: absolute; top: 6px; color: var(--text-muted); }
  #switch-tema .switch-sole { left: 7px; }
  #switch-tema .switch-luna { right: 7px; }
  #switch-tema .switch-manopola { position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border-ui); box-shadow: var(--ombra); transition: transform var(--t-rapida), background var(--t-rapida); }
  #switch-tema[aria-checked="true"] .switch-pista { background: var(--accent); border-color: var(--accent); }
  #switch-tema[aria-checked="true"] .switch-sole, #switch-tema[aria-checked="true"] .switch-luna { color: var(--accent-ink); }
  #switch-tema[aria-checked="true"] .switch-manopola { transform: translateX(28px); }
  #switch-tema:focus-visible .switch-pista { outline: 2px solid var(--focus); outline-offset: 2px; }

  /* il pulsante «Strati» in alto e l'icona a tre righe lasciano il posto ai tab */
  #apri-strati, #menu-info-toggle { display: none; }

  /* ricerca in alto, sotto il titolo; i risultati si aprono verso il basso */
  #area-ricerca { top: 8px; bottom: auto; left: 8px; right: 8px; width: auto; transform: none; }
  #cerca { order: -1; }
  #cerca-risultati { bottom: auto; top: calc(100% + 8px); }

  /* l'invito a toccare la mappa non copre la colonna degli strumenti a destra */
  .invito-clic { left: calc(50% - 32px); max-width: calc(100% - 88px); }
  .invito-clic p { text-align: center; }

  /* strumenti della mappa: colonna a destra sotto la ricerca; tema scuro e catalogo RNDT stanno nei tab */
  #barra-strumenti { top: 68px; right: 12px; left: auto; flex-direction: column; align-items: center; gap: 8px; }
  #barra-strumenti > #btn-rndt, #barra-strumenti > #btn-tema { display: none; }

  /* i fogli e i pannelli finiscono sopra la barra dei tab */
  body.strati-aperti #barra-strati { bottom: var(--tab-h); }
  #scheda { bottom: var(--tab-h); }
  #rndt-pannello, #geoimage-pannello, #tema-ui-pannello { bottom: var(--tab-h); }
  #legende-box { --legende-bottom: calc(var(--tab-h) + 12px); bottom: calc(var(--tab-h) + 12px); }

  /* foglio «Strati»: basi, layer, filtri. Foglio «Aggiungi»: i miei layer, catalogo RNDT, Geoimage */
  #btn-gruppo-rndt { display: none !important; } /* l'elenco dei layer RNDT aggiunti è in cima al pannello del catalogo */
  body[data-foglio="strati"] #barra-gruppi > :is(#btn-gruppo-miei, #btn-rndt-m, #btn-geoimage-m),
  body[data-foglio="aggiungi"] #barra-gruppi > :is(#btn-gruppo-base, #btn-gruppo-layer, #btn-gruppo-filtri, #btn-tabella-m) { display: none; }
  #btn-gruppo-miei { order: 1; } #btn-rndt-m { order: 2; } #btn-geoimage-m { order: 3; }
  #btn-tabella-m { order: 4; grid-column: 1 / -1; } /* foglio Strati: base, layer, filtri in riga, la tabella sotto a tutta larghezza (niente riquadro orfano) */

  /* foglio «Menu»: un menù a comparsa sopra il tab Menu, mezza larghezza, testo a destra, a due gruppi */
  body.info-aperto #menu-info {
    display: flex; position: fixed; top: auto; left: auto; right: 8px; bottom: calc(var(--tab-h) + var(--footer-h) + 8px); width: 50%; min-width: 190px; max-height: 70dvh; overflow-y: auto;
    flex-direction: column; align-items: stretch; margin: 0; padding: 10px 0; z-index: calc(var(--z-header) + 1); text-align: right;
    background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-md); box-shadow: var(--ombra);
  }
  #menu-info button, #menu-info a { text-align: right; border-left-width: 0; border-right: 3px solid transparent; }
  #menu-info button[aria-current="page"] { border-left-color: transparent; border-right-color: var(--accent); }
  #menu-info [data-scheda="mappa"] { display: none; }
  #menu-info .menu-gruppo { display: block; }
  #menu-info .menu-gruppo { margin: 4px 0; padding: 0 19px 0 16px; font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
  #menu-info .menu-gruppo[data-gruppo="guide"] { order: 1; }
  #menu-info [data-scheda="guida"] { order: 2; } #menu-info [data-scheda="plugin"] { order: 3; } #menu-info [data-scheda="geoimage"] { order: 4; }
  #menu-info .menu-gruppo[data-gruppo="info"] { order: 5; margin-top: 12px; }
  #menu-info [data-scheda="digitaltwin"] { order: 6; } #menu-info [data-scheda="argomenti"] { order: 7; }
  #menu-info [data-scheda="fonti"] { order: 8; } #menu-info [data-scheda="privacy"] { order: 9; } #menu-info #link-presentazione { order: 10; } #menu-info [data-scheda="about"] { order: 11; }
}
.btn-consenso { min-height: 44px; padding: 8px 16px; border: 2px solid var(--accent-strong, #b45309); border-radius: var(--r-md); background: transparent; color: inherit; font-weight: 700; cursor: pointer; }
.strati-tooltip-corpo strong { color: var(--tooltip-enfasi); }
.strati-tooltip-corpo > div + div { margin-top: 4px; }
.strati-tooltip-altre { color: var(--text-muted); }

/* scala: a sinistra del box zoom, con il pannello laterale */
.maplibregl-ctrl-bottom-right { transition: right var(--t-rapida); }
@media (min-width: 721px) { .maplibregl-ctrl-bottom-right .maplibregl-ctrl-scale { margin-right: 68px; } }
#bussola-ago { transition: transform .1s linear; }
#barra-strumenti button[hidden] { display: none; }

/* Street View: finestra flottante, spostabile e ridimensionabile */
dialog.streetview-finestra { position: fixed; margin: 0; inset: auto; z-index: 1000; width: min(640px, 94vw); height: min(480px, 70vh); min-width: 280px; min-height: 220px; resize: both; padding: 0; box-shadow: 0 8px 30px rgb(0 0 0 / .35); border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); overflow: hidden; }
dialog.streetview-finestra[open] { display: flex; flex-direction: column; }
dialog.streetview-finestra.trascinata iframe { pointer-events: none; }
.streetview-barra { cursor: move; touch-action: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.streetview-barra a { color: var(--accent-strong); font-weight: 600; text-decoration: none; }
.streetview-barra button { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; }
.streetview-finestra iframe { flex: 1; width: 100%; border: 0; }
@media (max-width: 720px) {
  dialog.streetview-finestra { width: 94vw; height: 55dvh; }
  .streetview-barra button { width: 44px; height: 44px; font-size: 1.1rem; }
  .streetview-barra a { padding: 10px 0; }
}

/* ==========================================================================
   Tabella dei dati: cassetto in basso, tra la barra sinistra e la scheda destra.
   È figlio del body (non di #corpo): poggia sul piè di pagina (36 px) e --tabella-h
   (impostata da ui.js sul body) fa salire sopra di esso i controlli della mappa.
   ========================================================================== */
:root { --tabella-h: 0px; }
#tabella-dati {
  position: fixed; z-index: var(--z-barra); left: var(--sx); right: var(--scheda-l); bottom: var(--footer-h, 36px);
  box-sizing: border-box; display: flex; flex-direction: column; min-height: 160px; max-height: calc(100dvh - 64px - var(--footer-h, 36px) - 8px);
  background: var(--surface); border: 1px solid var(--border-ui); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--ombra); font-size: var(--fs-sm); color: var(--text); transition: left var(--t-rapida), right var(--t-rapida);
}
#tabella-dati[hidden] { display: none; }
.tabella-maniglia { height: 14px; padding: 0; border: 0; background: none; cursor: ns-resize; flex: none; touch-action: none; }
.tabella-maniglia::after { content: ''; display: block; width: 40px; height: 4px; margin: 5px auto; border-radius: 2px; background: var(--border-ui); }
.tabella-maniglia:focus-visible { outline: 2px solid var(--focus); }
.tabella-testata { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px 4px; flex: none; }
.tabella-schede { display: flex; gap: 4px; padding: 0 8px; overflow-x: auto; flex: none; }
.tabella-scheda { padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; white-space: nowrap; cursor: pointer; }
.tabella-scheda:hover { background: var(--surface-hover); }
.tabella-scheda[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tabella-barra { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; padding: 6px 8px; flex: none; overflow-x: auto; scrollbar-width: thin; } /* una sola riga: se manca spazio scorre */
.tabella-barra > * { flex: none; }
.tabella-barra > .tabella-filtro { flex: 0 1 170px; width: 170px; min-width: 120px; }
.tabella-barra > .tabella-esporti { margin-left: auto; }
.tabella-strumenti, .tabella-azioni-righe, .tabella-esporti { display: flex; flex-wrap: nowrap; gap: 4px; align-items: center; }
.tabella-azioni-righe, .tabella-colonne, .tabella-esporti { padding-left: 8px; border-left: 1px solid var(--border-ui); } /* separatori tra i gruppi, come la barra di QGIS */
.tabella-strumento, .tabella-azione, .tabella-esporta, .tabella-sposta, .tabella-colonne summary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 32px; height: 32px; padding: 0 6px; box-sizing: border-box;
  border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--text); font: inherit; cursor: pointer;
}
.tabella-esporta { padding: 0 8px; }
.tabella-esporta-nome { font-size: var(--fs-xs); font-weight: 600; }
.tabella-esporta-n { font-size: var(--fs-2xs); color: var(--text-muted); font-variant-numeric: tabular-nums; padding: 1px 5px; border-radius: 8px; background: var(--surface-hover); }
.tabella-sposta { min-width: 0; height: auto; padding: 2px 6px; border-color: var(--border-ui); background: var(--surface); }
.tabella-strumento svg, .tabella-azione svg, .tabella-esporta svg, .tabella-colonne summary svg { flex: none; display: block; }
.tabella-strumento:hover, .tabella-azione:hover, .tabella-esporta:hover, .tabella-sposta:hover, .tabella-colonne summary:hover { background: var(--surface-hover); border-color: var(--border-ui); }
.tabella-strumento[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tabella-strumento:focus-visible, .tabella-azione:focus-visible, .tabella-esporta:focus-visible, .tabella-sposta:focus-visible,
.tabella-colonne summary:focus-visible, .tabella-livello:focus-visible, .tabella-filtro:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tabella-azione:disabled, .tabella-esporta:disabled, .tabella-sposta:disabled { opacity: .5; cursor: default; }
.tabella-esporta:disabled:hover { background: transparent; border-color: transparent; }
.tabella-azioni-righe { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tabella-livello, .tabella-filtro { padding: 4px 8px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; }
.tabella-livello, .tabella-filtro { height: 32px; box-sizing: border-box; padding-top: 0; padding-bottom: 0; }
.tabella-livello { width: 130px; }
.tabella-nota { margin: 0; padding: 0 8px 4px; color: var(--text-muted); font-size: var(--fs-xs); flex: none; }
.tabella-corpo { flex: 1; min-height: 0; overflow: auto; }
.tabella-vuota { margin: 0; padding: 16px; color: var(--text-muted); }
.tabella-griglia { border-collapse: collapse; width: 100%; }
.tabella-griglia th, .tabella-griglia td { padding: 3px 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.tabella-griglia thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.tabella-griglia tbody tr[aria-selected="true"] { background: var(--accent-soft); }
.tabella-griglia tbody tr:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.tabella-ordina { all: unset; cursor: pointer; font-weight: 600; }
.tabella-ordina:focus-visible { outline: 2px solid var(--focus); }
.tabella-casella { width: 28px; text-align: center; }
.tabella-colonne summary { display: inline-block; list-style: none; }
.tabella-colonne-elenco { position: fixed; z-index: 30; margin: 0; padding: 6px; list-style: none; max-height: 240px; overflow: auto; background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-sm); box-shadow: var(--ombra); }
.tabella-colonne-elenco li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.tabella-colonna-nome { flex: 1; min-width: 100px; }
.tabella-riquadro { position: absolute; z-index: 2; border: 2px dashed var(--accent-strong); background: var(--accent-soft); pointer-events: none; }
/* i controlli della mappa salgono sopra il cassetto aperto */
body:has(#tabella-dati:not([hidden])) #zoom-box { bottom: calc(54px + var(--tabella-h)); }
body:has(#tabella-dati:not([hidden])) .maplibregl-ctrl-bottom-right,
body:has(#tabella-dati:not([hidden])) .maplibregl-ctrl-bottom-left { bottom: var(--tabella-h); }
body:has(#tabella-dati:not([hidden])) #legende-box { bottom: calc(var(--legende-bottom) + var(--tabella-h)); max-height: calc(100dvh - var(--legende-bottom) - var(--tabella-h) - var(--legende-alto)); }
/* ricerca e avvisi (#avvisi sta dentro #area-ricerca) salgono sopra il cassetto; su telefono la ricerca è in alto e non si sposta */
body:has(#tabella-dati:not([hidden])) #area-ricerca { bottom: calc(40px + env(safe-area-inset-bottom, 0px) + var(--tabella-h)); }
/* telefono: a tutta larghezza sopra la barra a tab. I fogli (scheda, strati, menu, RNDT, geoimage) stanno dentro #corpo, che è uno
   stacking context sotto il cassetto (figlio di body) e occupano la stessa fascia: con un foglio aperto il cassetto si nasconde
   e --tabella-h torna a 0 (!important batte il valore scritto in linea da ui.js) */
@media (max-width: 720px) {
  #tabella-dati { left: 0; right: 0; bottom: calc(var(--tab-h) + var(--footer-h)); max-height: min(60dvh, calc(100dvh - 64px - var(--tab-h) - var(--footer-h) - 8px)); }
  body:has(#tabella-dati:not([hidden])) #area-ricerca { bottom: auto; }
  body:has(#tabella-dati:not([hidden])):not(.strati-aperti):not(.info-aperto):not(:has(#scheda:not([hidden]):not(.collassato), #rndt-pannello:not([hidden]):not(.collassato), #geoimage-pannello:not([hidden]):not(.collassato), #tema-ui-pannello:not([hidden]):not(.collassato))) :is(.maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left) { bottom: calc(var(--tabella-h) + var(--tab-h)); }
  body.strati-aperti #tabella-dati, body.info-aperto #tabella-dati,
  body:has(#scheda:not([hidden]):not(.collassato), #rndt-pannello:not([hidden]):not(.collassato), #geoimage-pannello:not([hidden]):not(.collassato), #tema-ui-pannello:not([hidden]):not(.collassato)) #tabella-dati { display: none; }
  body.strati-aperti, body.info-aperto, body:has(#scheda:not([hidden]):not(.collassato), #rndt-pannello:not([hidden]):not(.collassato), #geoimage-pannello:not([hidden]):not(.collassato), #tema-ui-pannello:not([hidden]):not(.collassato)) { --tabella-h: 0px !important; }
  .tabella-barra { flex-wrap: wrap; overflow-x: visible; }
  .tabella-barra > .tabella-filtro { flex: 1 1 170px; width: auto; }
  .tabella-barra > .tabella-esporti { margin-left: 0; }
  .tabella-strumenti, .tabella-azioni-righe, .tabella-esporti { flex-wrap: wrap; }
  .tabella-livello, .tabella-filtro { height: 38px; }
  .tabella-strumento, .tabella-azione, .tabella-esporta, .tabella-colonne summary { min-width: 38px; height: 38px; }
  .tabella-strumento[data-modo="riquadro"], .tabella-strumento[data-modo="poligono"] { display: none; } /* senza tocco: solo clic e area */
}
.tabella-titolo { font-weight: 600; }
.tabella-chiudi { min-width: 32px; min-height: 32px; padding: 0 8px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; font-size: 18px; line-height: 1; cursor: pointer; }
.tabella-chiudi:hover { background: var(--surface-hover); }
.tabella-chiudi:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.guida-indice li.guida-indice-gruppo { list-style: none; margin-left: -20px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: .8125em; color: var(--text-muted, inherit); break-after: avoid; }
.guida-indice li.guida-indice-gruppo:not(:first-child) { margin-top: 10px; }
.guida-pagina > h2.guida-gruppo { margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border-ui); }
.legenda i.monumenti-pallino--assente { background: transparent; border: 1.5px dashed var(--text-muted); }
.monumenti-assente { margin-top: 4px; color: var(--text-muted); }
