/* ==========================================================================
   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;
  --z-finestra: 1000;
  --z-velo: 1200;
  --z-tooltip-grafico: 10000;

  /* 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 */
/* colore di terra di positron: finché stile e tile non arrivano dalla rete la mappa non resta bianca */
#mappa { position: absolute; inset: 0; background: #f2f3f0; }
:root[data-tema="scuro"] #mappa { background: var(--surface); }
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, .scheda-evento-scelta, #pannello-filtri select, #cerca-particella input, .strato-cerca, .strato-tema select, .gi-campo select, .agg-campo input, .terremoti-filtro 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); }
#avvisi .avviso-attesa { align-items: center; padding: 6px 10px; }
#avvisi .avviso-attesa::before { content: ''; flex: none; width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--text-muted); border-radius: 50%; animation: giro-attesa .8s linear infinite; }
@keyframes giro-attesa { to { transform: rotate(360deg); } }

/* grafica unica per tutti i popup e i tooltip della mappa: scheda a vetro che segue il tema */
.maplibregl-popup-content {
  background: color-mix(in srgb, var(--surface) 94%, transparent); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: 0 8px 28px rgba(0, 0, 0, .28); backdrop-filter: blur(8px);
}
.maplibregl-popup-anchor-top .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left .maplibregl-popup-tip, .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--surface); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface); }
.maplibregl-popup-close-button { color: var(--text-muted); }

/* tooltip sulla mappa: uno solo (core/tooltip.js), con una sezione per fonte (trasporto, sicurezza, confini) */
.mappa-tooltip .maplibregl-popup-content { padding: 10px 14px 12px; font-size: var(--fs-sm); pointer-events: none; }
.mappa-tooltip-corpo > .mappa-tooltip-sezione > div > strong:first-child { font-size: var(--fs-base); font-weight: 700; color: var(--text); }
.mappa-tooltip .tooltip-riga { border-bottom-color: var(--border); font-size: var(--fs-xs); }
.mappa-tooltip .tooltip-riga > span { font-family: ui-monospace, monospace; }
.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); }

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 del progetto: 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, .sotto-pannello h4.gruppo-sottosezione { margin: 10px 0 6px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text); }
.sotto-pannello h4.gruppo-sottosezione { margin-left: 14px; }
.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); }
/* durante la riproduzione della timeline la barra di ricerca cede il posto ad anno e date della finestra */
@media (min-width: 721px) and (not ((pointer: coarse) and (max-height: 500px))) { body.timeline-in-corso #cerca, body.timeline-in-corso #cerca-pannello { display: none; } }
.cerca-tempo { display: flex; flex-direction: column; gap: 8px; padding: 10px 18px 12px; background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-lg, 20px); box-shadow: var(--ombra); }
.cerca-tempo[hidden] { display: none; }
@media (min-width: 721px) {
  body.timeline-in-corso #area-ricerca { width: clamp(340px, calc(100vw - var(--scheda-l) - var(--sx) - 150px), 640px); } /* più larga della ricerca: comandi, anno e date stanno su un rigo */
}
#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; }
.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; }
/* Popup di aerei e navi: scheda a vetro che segue il tema. Il «tip» di MapLibre diventa la linea di richiamo: un tratto verticale lungo
   dal mezzo (con un punto) e uno orizzontale corto che entra nel bordo della scheda all'altezza dell'intestazione. L'altezza della
   scheda (--traffico-h) la scrive popup-traffico.js dopo averla misurata. */
.traffico-popup-box { --traffico-orizz: 28px; --traffico-gancio: 24px; z-index: 5; }
.traffico-popup-box.geologia-popup { z-index: 3; } /* sopra la legenda e i pulsanti della mappa (z-index 2), così il suo collegamento si tocca */
body:has(#scheda:not([hidden])) .traffico-popup-box { z-index: 1; } /* ma sotto la scheda del luogo aperta (z-index 2, a tutto schermo 4): in mobile la scheda è un foglio sopra la mappa */
.traffico-popup-box .maplibregl-popup-content { padding: 0; background: color-mix(in srgb, var(--surface) 94%, transparent); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: 0 8px 28px rgba(0, 0, 0, .28); backdrop-filter: blur(8px); overflow: visible; }
.traffico-popup-box .maplibregl-popup-tip { position: absolute; width: 2px; height: calc(var(--traffico-h, 300px) + 3px); margin: 0; border: 0; background: var(--traffico-colore, var(--text-muted)); }
.traffico-popup-box .maplibregl-popup-tip::before { content: ''; position: absolute; width: var(--traffico-orizz); height: 2px; background: var(--traffico-colore, var(--text-muted)); }
.traffico-popup-box .maplibregl-popup-tip::after { content: ''; position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--traffico-colore, var(--text-muted)); border: 2px solid var(--surface); box-sizing: border-box; }
.traffico-popup-box[class*="anchor-top"] .maplibregl-popup-tip { top: var(--traffico-gancio); }
.traffico-popup-box[class*="anchor-top"] .maplibregl-popup-tip::before { top: 0; }
.traffico-popup-box[class*="anchor-top"] .maplibregl-popup-tip::after { bottom: -5px; }
.traffico-popup-box[class*="anchor-bottom"] .maplibregl-popup-tip { bottom: var(--traffico-gancio); }
.traffico-popup-box[class*="anchor-bottom"] .maplibregl-popup-tip::before { bottom: 0; }
.traffico-popup-box[class*="anchor-bottom"] .maplibregl-popup-tip::after { top: -5px; }
.traffico-popup-box[class$="-left"] .maplibregl-popup-tip { left: calc(-1 * var(--traffico-orizz)); }
.traffico-popup-box[class$="-left"] .maplibregl-popup-tip::before { left: 0; }
.traffico-popup-box[class$="-left"] .maplibregl-popup-tip::after { left: -4px; }
.traffico-popup-box[class$="-right"] .maplibregl-popup-tip { right: calc(-1 * var(--traffico-orizz)); }
.traffico-popup-box[class$="-right"] .maplibregl-popup-tip::before { right: 0; }
.traffico-popup-box[class$="-right"] .maplibregl-popup-tip::after { right: -4px; }
.traffico-popup { padding: 10px 14px 12px; font-size: var(--fs-sm); }
.traffico-testa { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.traffico-marchio { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; background: var(--traffico-colore); color: #fff; }
.traffico-sezione { flex: 1; font: 600 var(--fs-xs) ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }
.traffico-chiudi { width: 24px; height: 24px; border: 1px solid var(--border); border-radius: 50%; background: transparent; color: inherit; font-size: 16px; line-height: 1; cursor: pointer; }
.traffico-chiudi:hover { background: var(--surface-hover); }
.traffico-titolo { margin: 0 0 2px; font-size: var(--fs-lg, 1.15rem); font-weight: 700; color: var(--text); }
.traffico-riga-stato { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 6px; }
.traffico-riga-stato .traffico-stato { margin: 0; }
.traffico-riga-stato .tooltip-badge { margin-top: 0; }
.traffico-azione { flex: none; margin-top: 0; text-decoration: none; cursor: pointer; white-space: nowrap; }
.traffico-azione:hover { background: color-mix(in srgb, var(--colore) 26%, transparent); }
.traffico-stato { margin: 0 0 6px; font-size: var(--fs-xs); font-weight: 700; color: color-mix(in srgb, var(--traffico-colore) 75%, var(--text)); }
.traffico-righe { display: grid; grid-template-columns: auto 1fr; margin: 0; }
.traffico-righe dt, .traffico-righe dd { margin: 0; padding: 5px 0; border-top: 1px solid var(--border); }
.traffico-righe dt { padding-right: 14px; font: var(--fs-xs) ui-monospace, monospace; color: var(--text-muted); }
.traffico-righe dd { text-align: right; font-weight: 600; color: var(--text); }
.traffico-corpo { margin: 0 0 6px; }
.traffico-corpo .monumento-foto { max-height: 110px; margin-bottom: 6px; border-radius: var(--r-sm); }
.traffico-corpo .monumento-desc, .traffico-corpo .monumento-cat, .traffico-corpo .monumento-fonte, .traffico-corpo .monumento-scomparso { margin-left: 0; margin-right: 0; }
.traffico-corpo .monumento-cat { color: var(--text-muted); }
.traffico-corpo .monumento-link { margin: 8px 0 4px; }
.traffico-etichette { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.traffico-etichette .tooltip-badge { margin-top: 0; }
.traffico-coordinate { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--border); font: var(--fs-xs) ui-monospace, monospace; color: var(--text-muted); }

.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: var(--fs-xs); 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; }
.legenda-omi .omi-zone { margin: 0 0 6px 20px; font-size: var(--fs-2xs); color: var(--text-muted); }
.legenda-omi .omi-zone summary { cursor: pointer; }
.legenda-omi .omi-zone div { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 3px; }
.legenda-omi .omi-zone label { display: inline-flex; align-items: center; gap: 3px; }
.legenda-omi .omi-zone i { width: 10px; height: 10px; }
.legenda-esterna-corpo { max-height: 40vh; overflow: auto; }
.legenda-esterna-origine { display: block; margin-bottom: 4px; color: var(--text-muted); font-size: var(--fs-2xs); overflow-wrap: anywhere; }
.tooltip-origine { display: block; margin-top: 2px; color: var(--text-muted); font-size: var(--fs-2xs); }
.legenda-esterna-img { display: block; max-width: 100%; height: auto; }
.legenda-esterna-voce small { color: var(--text-muted); }
.legenda-esterna-classe { display: flex; align-items: center; gap: 6px; }
.legenda-esterna-classe .legenda-esterna-img { flex: none; }
.legenda-esterna-gruppo { margin-top: 4px; font-size: var(--fs-2xs); }
.mappa-tooltip .legenda { max-width: 260px; }
.mappa-tooltip .tooltip-campione { display: inline-flex; vertical-align: middle; margin-right: 6px; max-height: none; overflow: visible; }
.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, #storico-pannello, #confronto-pannello, #mappe-pannello {
  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], #storico-pannello[hidden], #confronto-pannello[hidden], #mappe-pannello[hidden] { display: none; }
#scheda h2, #storico-pannello h2, #confronto-pannello h2, #mappe-pannello 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, #storico-pannello .scheda-intestazione h2, #confronto-pannello .scheda-intestazione h2, #mappe-pannello .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--evidenziabile { cursor: pointer; border-radius: var(--r-sm); outline: 2px solid transparent; outline-offset: 2px; }
.scheda-gruppo--evidenziabile:hover, .scheda-gruppo--evidenziabile:focus-visible { outline-color: color-mix(in srgb, var(--evidenza) 50%, transparent); }
.scheda-gruppo--evidenziabile[aria-pressed="true"] { outline-color: var(--evidenza); }
.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-badge-tinta { justify-self: end; padding: 1px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; color: color-mix(in srgb, var(--tinta) 55%, var(--text)); background: color-mix(in srgb, var(--tinta) 14%, transparent); border: 1px solid color-mix(in srgb, var(--tinta) 53%, transparent); }
.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); }
.peba-barra { height: 8px; margin: 6px 0 10px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.peba-barra-riempi { height: 100%; border-radius: inherit; }
.peba-criticita h4, .peba-foto-sez h4 { margin: 10px 0 6px; font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.peba-criticita ul { margin: 0; padding-left: 18px; }
.peba-foto-griglia { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.peba-foto { display: block; aspect-ratio: 1; overflow: hidden; border-radius: var(--r-sm); background: var(--accent-soft); }
.peba-foto:first-child { grid-column: span 3; aspect-ratio: 16 / 10; }
.peba-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scheda-link { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; padding: 7px 10px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--link); text-decoration: none; font-weight: 600; transition: background var(--t-rapida), border-color var(--t-rapida); }
.scheda-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.scheda-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.scheda-link-et { padding: 1px 8px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--link) 12%, 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, #storico-pannello, #confronto-pannello, #mappe-pannello {
    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), #chatbot-pannello:not([hidden]):not(.collassato), #storico-pannello:not([hidden]):not(.collassato), #confronto-pannello:not([hidden]):not(.collassato), #mappe-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-pc i.pc-campione, .lg-pc i.pc-campione { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 14px; border: 1px solid #929290; vertical-align: -3px; background: repeating-linear-gradient(135deg, var(--pc-colore) 0 2px, transparent 2px 5px); }
.pc-campione .pc-icona { width: 12px; height: 12px; }
.legenda-incendi i.incendi-campione { width: 14px; height: 10px; border: 1.5px solid; border-radius: 2px; }
.lg-allerte i.incendi-campione, .lg-radar i.incendi-campione { display: inline-block; width: 14px; height: 10px; border: 1.5px solid rgba(0, 0, 0, .35); border-radius: 2px; vertical-align: -1px; }
.lg-allerte .allerta-riga { margin: 4px 0; font-size: 12px; }
.lg-allerte .allerta-giorni { display: flex; gap: 6px; margin: 6px 0; }
.lg-allerte .allerta-giorno { flex: 1; padding: 3px 8px; border: 1px solid currentColor; border-radius: 12px; background: transparent; color: inherit; font-size: 12px; cursor: pointer; }
.lg-allerte .allerta-giorno[aria-pressed="true"] { background: var(--accent, #e8590c); border-color: var(--accent, #e8590c); color: #fff; }
.lg-radar .radar-scala { height: 8px; border-radius: 4px; margin: 6px 0 2px; background: linear-gradient(90deg, #9bd5f2, #2f7ed8, #2fb344, #f7e12e, #f08c00, #e03131, #9c36b5); }
.lg-radar .radar-scala-testo { display: flex; justify-content: space-between; margin: 0 0 6px; }
.lg-radar .radar-riga { display: flex; align-items: center; gap: 8px; }
.lg-radar .radar-cursore { flex: 1; min-width: 0; }
.lg-radar .radar-bottone { width: 28px; height: 28px; border: 1px solid currentColor; border-radius: 50%; background: transparent; color: inherit; font-size: 11px; cursor: pointer; }
.lg-radar .radar-ora { min-width: 4.5em; font-size: 12px; font-variant-numeric: tabular-nums; }
.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; }
.legenda-peba i.mef-campione { display: inline-block; width: 14px; height: 10px; margin-right: 6px; border-radius: 2px; border: 1px solid rgb(0 0 0 / .35); flex: none; vertical-align: middle; }
.legenda .peba-famiglia { flex-direction: column; align-items: stretch; gap: 0; margin-top: 6px; }
.legenda-peba { max-height: 60vh; overflow-y: auto; }
.tooltip-elenco { margin-top: 4px; font-size: var(--fs-xs); font-weight: 400; }
.tooltip-suggerimento { margin-top: 6px; font-size: var(--fs-xs); font-weight: 400; font-style: italic; color: var(--text-muted); }
.tooltip-elenco > div { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* cerchietto che gira per le attese (tooltip dei comuni, scheda): la stessa animazione degli avvisi di attesa */
.gira-attesa { display: inline-block; flex: none; width: 10px; height: 10px; margin-left: 5px; border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; border-radius: 50%; vertical-align: -1px; animation: giro-attesa .8s linear infinite; }
.comuni-gira { color: #c27c0e; }
/* valore o voce di un grafico che fa da filtro della mappa: si presenta come un collegamento */
.scheda-filtro { padding: 0; border: 0; background: none; font: inherit; color: var(--accent); text-align: left; text-decoration: underline dotted; cursor: pointer; }
.scheda-filtro:hover, .scheda-filtro:focus-visible { text-decoration: underline; }
.peba-legenda-titolo { display: block; margin-bottom: 2px; font-size: var(--fs-xs); font-style: normal; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.peba-modo { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: var(--fs-xs); color: var(--text-muted); }
.peba-modo button { padding: 2px 10px; border: 1px solid var(--border-ui); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.peba-modo button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-strong); font-weight: 600; }
.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); }
/* Ex Noviziato dei Crociferi in 3D: esploso dei piani, piani con la vista in pianta, elementi */
.legenda-crociferi .ic-etichetta { display: block; margin: 8px 0 4px; font-size: var(--fs-3xs); text-transform: uppercase; color: var(--text-muted); }
.legenda-crociferi .cr-esploso input { display: block; width: 80%; margin-top: 6px; accent-color: var(--accent-strong); }
.legenda-crociferi .cr-esploso output { font-variant-numeric: tabular-nums; text-transform: none; }
.legenda-crociferi i.cr-vuoto { display: none; }
.legenda-crociferi .cr-pianta { margin-left: auto; padding: 1px 6px; border: 1px solid var(--border-ui); border-radius: var(--r-xs); background: var(--surface-alt); color: var(--text-muted); font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.legenda-crociferi .cr-pianta:hover, .legenda-crociferi .cr-pianta[aria-pressed="true"] { border-color: var(--accent-strong); color: var(--text); }
.legenda-crociferi .cr-pianta[aria-pressed="true"] { background: var(--accent-strong); color: var(--accent-strong-ink); }
.legenda-crociferi .cr-tutti { margin: 8px 0 6px; padding: 4px 10px; border: 1.5px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface-alt); color: var(--text); font: inherit; font-size: var(--fs-2xs); font-weight: 600; cursor: pointer; }
.legenda-crociferi .cr-tutti:hover { border-color: var(--accent-strong); }


/* ==========================================================================
   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); }
#barra-strumenti #btn-tabella:not([aria-pressed="true"]) { width: auto; min-width: 32px; padding: 0 10px; gap: 6px; border-radius: 16px; border-color: var(--accent); background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 3px var(--accent-soft); animation: tabella-pulsa 2.4s ease-in-out infinite; } /* in evidenza: la Lista Terremoti è il percorso principale */
#barra-strumenti #btn-tabella:not([aria-pressed="true"])::after { content: attr(title); font-size: var(--fs-xs); font-weight: 700; }
#barra-strumenti #btn-tabella:not([aria-pressed="true"]):hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-strong-ink); }
@keyframes tabella-pulsa { 50% { box-shadow: 0 0 0 6px transparent; } }
@media (prefers-reduced-motion: reduce) { #barra-strumenti #btn-tabella { animation: none !important; } }
@media (pointer: coarse) { #barra-strumenti button { width: 44px; height: 44px; } }


#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]):not(.legenda-vuota))) { 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, #legende-box.ridotta #legende-raggio, #legende-box.ridotta .legenda-avviso { display: none; }
#legende-raggio { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px 8px; border-top: 1px solid var(--border-ui); font-size: var(--fs-xs); color: var(--text); }
#legende-raggio:empty { display: none; }
/* avviso sulle fonti, in fondo alla legenda sotto l'interruttore di Live Zoom */
.legenda-avviso { margin: 0; padding: 0 10px 8px; font-size: var(--fs-3xs); line-height: 1.4; color: var(--text-muted); }
#legende-raggio input[type=range] { width: 100%; }
.legende-raggio-forma { display: flex; gap: 4px; margin-top: 4px; }
.legende-raggio-forma button, .legende-raggio-poligono button { flex: 1; padding: 4px 8px; border: 1px solid var(--border-ui); border-radius: var(--r-md); background: transparent; color: inherit; font: inherit; cursor: pointer; }
.legende-raggio-forma button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.legende-raggio-forma button:focus-visible, .legende-raggio-poligono button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.legende-raggio-poligono { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.legende-raggio-poligono[hidden] { display: none; }
.legende-raggio-cerchio[hidden] { display: none; }
.legende-raggio-cerchio { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; cursor: pointer; }
.legende-raggio-cerchio input { appearance: none; flex: none; position: relative; width: 34px; height: 18px; margin: 0; border: 1px solid var(--border-ui); border-radius: var(--r-pill); background: var(--surface-alt); cursor: pointer; transition: background var(--t-rapida), border-color var(--t-rapida); }
.legende-raggio-cerchio input::after { content: ''; position: absolute; top: 1px; left: 1px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border-ui); box-sizing: border-box; box-shadow: var(--ombra); transition: transform var(--t-rapida); }
.legende-raggio-cerchio input:checked { background: var(--accent); border-color: var(--accent); }
.legende-raggio-cerchio input:checked::after { transform: translateX(16px); }
.live-zoom-legenda { margin: 0 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border-ui); }
.legende-raggio-cerchio input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* in evidenza: la ricerca attorno a un punto è un percorso principale; spento, la riga si fa notare, acceso torna quieta */
.legende-raggio-attivo { margin-top: 2px; padding: 6px 8px; border: 1px solid var(--accent); border-radius: var(--r-md); background: var(--accent-soft); font-weight: 700; color: var(--accent-strong); }
.legende-raggio-attivo:has(input:not(:checked)) { box-shadow: 0 0 0 3px var(--accent-soft); animation: tabella-pulsa 2.4s ease-in-out infinite; }
.legende-raggio-attivo:has(input:checked) { animation: none; }
/* ricerca attorno a un punto accesa: crocicchio su tutta la mappa, anche sopra gli eventi (che altrimenti mostrano la manina) */
body.raggio-attivo .maplibregl-canvas, body.raggio-attivo .maplibregl-canvas:active { cursor: crosshair !important; }
/* numero di eventi al centro del cerchio, a scheda chiusa */
.cerchio-etichetta { padding: 5px 12px; border: 2px solid var(--accent); border-radius: var(--r-pill); background: var(--surface); color: var(--accent-strong); font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; box-shadow: var(--ombra); pointer-events: none; }
#legende-raggio .legende-raggio-filtri { grid-template-columns: 1fr; gap: 6px; margin: 4px 0 0; padding-top: 6px; border-top: 1px solid var(--border-ui); }
@media (prefers-reduced-motion: reduce) { .legende-raggio-attivo { animation: none !important; } }
#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; }
/* Il blocco della magnitudo vale per tutti gli strati dei terremoti: in mappa sta in cima alle legende */
#legende > .legenda-magnitudo { order: -1; }

/* Tema magnitudo (js/core/tema-magnitudo.js): le classi al posto delle fasce d'età nella legenda dei terremoti.
   `.legenda div` disporrebbe le righe in fila: il contenitore resta un blocco, una riga per classe. */
.legenda .legenda-fasce, .legenda .legenda-magnitudo-classi { display: block; }
.legenda [hidden] { display: none; }
.legenda-magnitudo-riga { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: var(--fs-xs); cursor: pointer; }
.legenda-magnitudo-riga input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.legenda-magnitudo-riga:has(input:not(:checked)) { opacity: .4; }
.legenda-magnitudo-riga:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: var(--r-sm); }
.legenda-magnitudo-casella { flex: none; display: flex; align-items: center; justify-content: center; width: 30px; }
.legenda-magnitudo-cerchio { display: block; box-sizing: border-box; border: 1.5px solid currentColor; border-radius: 50%; background: color-mix(in srgb, currentColor 55%, transparent); }
.legenda-magnitudo-cerchio-pieno { background: currentColor; border-color: rgba(255, 255, 255, 0.8); }
.legenda-magnitudo-nota { margin: 2px 0 0; color: var(--text-muted); font-size: var(--fs-3xs); line-height: 1.35; }

/* Slider della magnitudo (js/layers/slider-magnitudo.js): due maniglie sullo stesso binario, i numeri a fianco e le
   tacche con i cerchi delle classi. Sta in un solo blocco per tutti gli strati dei terremoti (legenda-magnitudo.js). */
.legenda .slider-mag { display: flex; flex-direction: column; align-items: stretch; gap: 2px; margin: 6px 0 4px; }
.legenda .slider-mag-testa { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.slider-mag-titolo { font-size: var(--fs-3xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.slider-mag-numeri { display: flex; align-items: center; gap: 3px; }
.slider-mag-numero { box-sizing: border-box; width: 40px; min-height: 24px; padding: 2px; border: 1px solid var(--border-ui); border-radius: var(--r-xs); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-xs); text-align: center; font-variant-numeric: tabular-nums; }
.slider-mag-numero:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--accent); }
.slider-mag-trattino { color: var(--text-muted); }
.legenda .slider-mag-pista { position: relative; display: block; height: 24px; }
.legenda .slider-mag-pista input { position: absolute; left: 0; top: 0; width: 100%; height: 24px; margin: 0; padding: 0; border: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.legenda .slider-mag-pista input::-webkit-slider-runnable-track { height: 3px; background: var(--border); border-radius: 2px; }
.legenda .slider-mag-pista input::-moz-range-track { height: 3px; background: var(--border); border-radius: 2px; }
.legenda .slider-mag-pista input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; box-sizing: border-box; width: 16px; height: 16px; margin-top: -6.5px; border-radius: 50%; border: 2px solid var(--accent-strong, var(--accent)); background: var(--surface); cursor: ew-resize; }
.legenda .slider-mag-pista input::-moz-range-thumb { pointer-events: auto; box-sizing: border-box; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-strong, var(--accent)); background: var(--surface); cursor: ew-resize; }
.legenda .slider-mag-pista input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.legenda .slider-mag-pista input:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.slider-mag-tratta { position: absolute; top: 10.5px; height: 3px; border-radius: 2px; background: var(--accent-strong, var(--accent)); pointer-events: none; }
/* le tacche occupano tutta la riga e crescono dal basso: i cerchi appoggiati sulla stessa linea e i numeri allineati sotto */
.legenda .slider-mag-tacche { position: relative; display: block; height: 34px; }
.legenda .slider-mag-tacca { position: absolute; top: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; transform: translateX(-50%); }
.slider-mag-cerchio { display: block; flex: none; box-sizing: border-box; border: 1.5px solid var(--text-muted); border-radius: 50%; background: color-mix(in srgb, var(--text-muted) 18%, transparent); }
.slider-mag-valore { font-size: var(--fs-3xs); line-height: 1; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.slider-mag-nota { margin: 6px 0 2px; color: var(--text-muted); font-size: var(--fs-3xs); line-height: 1.35; }
.slider-mag[data-attivo="true"] .slider-mag-titolo { color: var(--text); }
.slider-mag[data-attivo="true"] .slider-mag-tratta { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }

/* Legenda sotto lo strato, nel pannello Layer (js/core/legenda-pannello.js) */
.legenda-sostituita, .legenda-vuota { display: none; }
.legenda-in-pannello { margin: 0 0 8px 38px; padding: 4px 8px 6px; border-left: 2px solid var(--border-ui); font-size: var(--fs-xs); }
.legenda-in-pannello:has(> .legenda[hidden]), .legenda-in-pannello:has(> .legenda-sostituita) { display: none; }
.legenda-in-pannello > summary { cursor: pointer; font-weight: 700; color: var(--text-muted); list-style: none; }
.legenda-in-pannello > summary::-webkit-details-marker { display: none; }
.legenda-in-pannello > summary::before { content: '▸ '; }
.legenda-in-pannello[open] > summary::before { content: '▾ '; }
.legenda-in-pannello > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.legenda-in-pannello > .legenda { margin-top: 4px; max-height: 260px; overflow-y: auto; }
.legenda-in-pannello .legenda-esterna > strong { display: none; } /* il nome del layer è già nella riga sopra */

.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: 1099px) { #legende-box { --legende-bottom: 100px; bottom: 100px; } }
@media (max-height: 500px) { #legende-box { --legende-alto: 64px; } } /* telefono ruotato: lo spazio sopra la legenda è solo la fila dei pulsanti, il resto serve alla legenda (che scorre) */

@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; }
  #pannello-filtri label > span { flex: 0 0 8.5em; } /* etichette della stessa larghezza: le tendine partono dallo stesso punto e hanno la stessa lunghezza */
  #pannello-filtri label select { flex: 1; min-width: 0; width: auto; }
  .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: 260px; 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; }
.shakemap-chip { max-width: 340px; }
.lg-shakemap .shakemap-righe { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.lg-shakemap .shakemap-righe .allerta-riga { margin: 1px 0; }
.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; }
  #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 (dal progetto di origine) */
.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; }
.gruppo-sezione[role="button"], .gruppo-sottosezione[role="button"] { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.gruppo-sezione[role="button"]::before, .gruppo-sottosezione[role="button"]::before { content: "▾"; flex: none; width: 1em; font-size: .9em; color: var(--text-muted); transition: transform .15s; }
.gruppo-sezione[role="button"][aria-expanded="false"]::before, .gruppo-sottosezione[role="button"][aria-expanded="false"]::before { transform: rotate(-90deg); }
.gruppo-sezione[role="button"]:focus-visible, .gruppo-sottosezione[role="button"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.sotto-chiuso { display: none !important; }

/* 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; }
.scheda-vuoto-storico { display: flex; flex-direction: column; gap: 12px; margin: 16px 14px; padding: 16px 14px; border: 1px dashed var(--border-ui); border-radius: var(--r-md); background: var(--surface-alt); }
.scheda-vuoto-storico .scheda-nota { margin: 0; text-align: left; }
.scheda-vuoto-storico .scheda-filtro { align-self: flex-start; font-weight: 600; }
.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, #chatbot-pannello.collassato, #storico-pannello.collassato, #confronto-pannello.collassato, #mappe-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, #chatbot-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], #chatbot-pannello[hidden] { display: none; }
@media (min-width: 721px) { #geoimage-pannello, #tema-ui-pannello, #chatbot-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; display: flex; align-items: center; gap: 8px; margin: 0; padding: 6px 12px; font-size: var(--fs-sm); background: var(--accent-soft); border-bottom: 1px solid var(--border); }
.gi-stato-testo { flex: 1; min-width: 0; }
.gi-stato .gi-btn { flex: none; }
.gi-stato .gi-btn[hidden] { display: none; }
.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 { margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--border-ui); }
.tui-avanzati > summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); padding: 4px 0; }
.tui-avanzati[open] { display: grid; gap: 8px; }
.tui-avanzati[open] > :not(summary) { margin: 0; }
.tui-avanzati > .gi-btn { justify-self: start; }
.tui-avanzati > .gi-btn[hidden] { display: none; }
.tui-nome { display: grid; gap: 1px; min-width: 0; }
.tui-suggerimento { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.3; }
.tui-anteprima.tui-anteprima-grande { width: 100%; height: 64px; gap: 6px; padding: 10px; }
.tui-anteprima.tui-anteprima-grande i { height: 6px; }
.tui-anteprima.tui-anteprima-grande .tui-barra { height: 10px; }
.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-gruppo { display: grid; gap: 6px; }
.tui-gruppo + .tui-gruppo { margin-top: 6px; }
.tui-gruppo h4 { margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.tui-altri { justify-self: start; border-style: dashed; }
.tui-preset .gi-btn[hidden] { display: none; }
.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: 36px minmax(0, 1fr) 9ch; align-items: center; gap: 10px; }
.tui-colore input[type="color"] { width: 36px; height: 36px; padding: 2px; box-sizing: border-box; border-radius: var(--r-sm); cursor: pointer; }
.tui-colore input[aria-invalid="true"][type="color"] { outline: 2px solid var(--pericolo); outline-offset: 1px; }
.tui-hex { width: 100%; min-height: 32px; padding: 2px 6px; box-sizing: border-box; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.tui-hex[aria-invalid="true"] { border-color: var(--pericolo); }
.tui-hex:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.tui-blocco { display: grid; gap: 4px; }
.tui-avviso { display: flex; align-items: center; gap: 8px; margin: 0 0 0 46px; font-size: var(--fs-sm); color: var(--pericolo); }
.tui-avviso[hidden] { display: none; }
.tui-avviso span { flex: 1; min-width: 0; }
.tui-avviso .gi-btn { flex: none; }
@media (pointer: coarse), (max-width: 720px) { .tui-colore input[type="color"] { width: 44px; height: 44px; } .gi-campo.tui-colore { grid-template-columns: 44px minmax(0, 1fr) 9ch; } .tui-hex, .tui-avviso .gi-btn { min-height: 44px; } .tui-avviso { margin-left: 54px; } }
.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 */
}

/* invito a installare l'app: solo telefono, sopra la barra dei tab */
.invito-installa {
  position: fixed; z-index: var(--z-header); left: 12px; right: 12px; bottom: calc(var(--tab-h, 60px) + var(--footer-h, 0px) + 8px);
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 2px solid var(--bianco); border-radius: var(--r-md);
  background: var(--invito-bg-hover); color: var(--bianco); font-size: var(--fs-sm); box-shadow: var(--ombra);
}
.invito-installa p { margin: 0; }
.invito-installa div { display: flex; gap: 8px; justify-content: flex-end; }
.invito-installa button { cursor: pointer; padding: 6px 16px; border: 2px solid var(--bianco); border-radius: var(--r-pill); font: inherit; font-weight: 600; }
.invito-installa-si { background: var(--accent-strong); color: var(--accent-strong-ink); }
.invito-installa-no { background: transparent; color: var(--bianco); }
body:has(#dt-consenso) .invito-installa { display: none; } /* prima la scelta sui cookie */

/* 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: var(--fs-xs); 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: var(--fs-xs); 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: 10px; 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: la mappa occupa tutta la finestra (la pagina non scorre mai)
   ========================================================================== */
body { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100dvh; }
/* contain: layout fa di #corpo il riferimento di tutti gli elementi fixed dell'interfaccia: restano dentro la mappa */
/* posizione esplicita: un elemento estraneo nel body (estensioni del browser, tooltip) non deve spostare la mappa */
#corpo { grid-area: 1 / 1; position: relative; min-height: 0; overflow: hidden; contain: layout; }
body { grid-auto-rows: 0; } /* righe in più, se ce ne sono, non rubano spazio */

#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 a[data-scheda="emergenza"], #menu-info a[data-scheda="emergenza"]:hover { background: var(--emergenza, #d7263d); color: #fff; font-weight: 700; } /* voce «Modalità emergenza»: sfondo nel rosso dell'emergenza */
#menu-info a[data-scheda="emergenza"]:hover { filter: brightness(.92); }
#menu-info button[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
/* «Guida generale» e «About» sono voci vere; la freccia accanto apre le altre (Plugin RNDT e Geoimage; Presentazione e Privacy) */
.menu-tendina { position: relative; }
.menu-tendina-toggle::after { content: " ▾"; font-size: .75em; }
.menu-tendina-toggle[aria-expanded="true"], .menu-tendina-toggle.attiva { color: var(--text); }
#menu-info .menu-tendina-toggle.attiva { border-bottom-color: var(--accent); }
.menu-tendina-lista { display: none; position: absolute; top: 100%; left: 0; white-space: nowrap; z-index: calc(var(--z-header) + 1); min-width: 100%; padding: 6px 0; background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-md); box-shadow: var(--ombra); }
.menu-tendina.aperta .menu-tendina-lista { display: block; }
#menu-altro .menu-tendina-lista { left: auto; right: 0; }
.menu-diviso { display: flex; align-items: center; }
#menu-info .menu-diviso .menu-tendina-toggle { padding-left: 4px; padding-right: 8px; }
.menu-diviso .menu-tendina-toggle::after { content: "▾"; }
.menu-solo-stretto { display: none; }
.menu-icona { display: none; }
@media (min-width: 1181px) {
  #menu-info .menu-tendina-lista :is(button, a) { width: 100%; text-align: left; border-radius: 0; border-bottom: 0; }
  #menu-info .menu-tendina-lista :is(button, a)[aria-current="page"] { background: var(--surface-hover); }
}
@media (max-width: 1180px) {
  #menu-info .menu-gruppo { display: none; }
  #menu-info .menu-tendina-toggle { width: 100%; }
  #menu-info .menu-tendina-lista { position: static; min-width: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: var(--surface-alt); }
  #menu-info .menu-tendina-lista :is(button, a) { width: 100%; padding-right: 32px; font-weight: 500; }
  #menu-altro .menu-tendina-lista { right: auto; }
  .menu-diviso { flex-wrap: wrap; }
  #menu-info .menu-diviso > [data-scheda] { flex: 1; width: auto; }
  /* tutta la riga apre la lista (la pagina principale è la prima sottovoce); la freccia sta a sinistra, i testi restano a filo a destra */
  #menu-info .menu-diviso .menu-tendina-toggle { position: absolute; top: 0; left: 0; width: 100%; height: 44px; min-height: 0; padding: 0 16px; text-align: left; z-index: 1; }
  #menu-info .menu-diviso .menu-tendina-toggle, #menu-info .menu-diviso .menu-tendina-toggle:hover { background: none; } /* resta trasparente: il testo della voce deve vedersi */
  #menu-info .menu-diviso:has(.menu-tendina-toggle:hover) > :first-child { background: var(--surface-hover); color: var(--text); }
  #menu-info .menu-diviso .menu-tendina-toggle::after { font-size: 1rem; display: inline-block; transition: transform .15s; }
  #menu-info .menu-diviso .menu-tendina-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }
  #menu-info .menu-solo-stretto { display: block; }
  #menu-info .menu-diviso .menu-tendina-lista { flex-basis: 100%; }
}
#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); }
/* lingua IT/EN nella barra degli strumenti: tondo come le altre icone, globo con la sigla sotto */
#barra-strumenti > #switch-lingua { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; width: 36px; min-width: 0; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); box-shadow: var(--ombra); color: var(--text); font: inherit; cursor: pointer; }
#barra-strumenti > #switch-lingua .lingua-sigla { font-size: .5625rem; font-weight: 700; line-height: 1; letter-spacing: .02em; }
#barra-strumenti > #switch-lingua svg { width: 15px; height: 15px; }
#barra-strumenti > #switch-lingua:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
#barra-strumenti > #switch-lingua:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#barra-strumenti > #switch-lingua svg { flex: none; }
/* 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: 44px; padding: 10px 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-tendina-lista :is(button, a) { padding-right: 16px; }
  #menu-info #link-home { order: -1; } #menu-info [data-scheda="mappa"] { order: 0; } #menu-info [data-scheda="digitaltwin"] { order: 1; } #menu-info #menu-guide { order: 3; }
  #menu-info [data-scheda="fonti"] { order: 4; } #menu-info #menu-altro { order: 5; }
}

#piede-coord { margin-left: auto; flex: none; font-family: ui-monospace, Consolas, monospace; font-weight: 500; }
#logo-ods { flex: none; display: block; line-height: 0; }
#logo-ods img { display: block; height: 24px; width: auto; }

/* 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; }
}

/* pannello «Stampa»: scelta di area, formato ed elementi; il riquadro trascinabile sulla mappa è l'area che si stampa */
#gruppo-stampa:not([hidden]) { display: flex; flex-direction: column; gap: 8px; }
#gruppo-stampa .stampa-anteprima { width: 100%; height: auto; border: 1px solid var(--border-ui); border-radius: var(--r-sm, 4px); background: var(--surface-alt); }
#gruppo-stampa .stampa-nota { margin: 0; font-size: var(--fs-xs); color: var(--text-soft, var(--text)); }
#gruppo-stampa .stampa-campo { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; padding: 0; }
#gruppo-stampa .stampa-campo[hidden], #gruppo-stampa fieldset[hidden] { display: none; }
#gruppo-stampa .stampa-riga { display: flex; gap: 8px; }
#gruppo-stampa input[type="text"], #gruppo-stampa select { width: 100%; margin: 0; padding: 5px 8px; font: inherit; }
#gruppo-stampa .stampa-elementi { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 0; padding: 6px 10px 8px; border: 1px solid var(--border-ui); border-radius: var(--r-sm, 4px); }
#gruppo-stampa .stampa-shakemap { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 6px 10px 8px; border: 1px solid var(--border-ui); border-radius: var(--r-sm, 4px); }
#gruppo-stampa .stampa-elementi label { display: flex; align-items: center; gap: 6px; padding: 0; }
#gruppo-stampa .stampa-elementi .stampa-nota { grid-column: 1 / -1; }
#gruppo-stampa .stampa-non-disponibile { opacity: .45; }
#gruppo-stampa .stampa-azioni { position: sticky; bottom: -10px; display: flex; justify-content: space-between; gap: 8px; margin: 0 -14px -10px; padding: 8px 14px 10px; background: var(--surface); border-top: 1px solid var(--border-ui); }
#gruppo-stampa button.stampa-esporta { padding: 6px 16px; font: inherit; font-weight: 600; color: var(--accent-ink); background: var(--accent); border: 1px solid var(--accent); border-radius: var(--r-sm, 4px); cursor: pointer; }
#gruppo-stampa .stampa-adatta-pagina { display: flex; gap: 8px; align-items: center; cursor: pointer; }
#gruppo-stampa button.stampa-adatta, #gruppo-stampa button.stampa-centra { padding: 6px 12px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-sm, 4px); cursor: pointer; }
#gruppo-stampa button:disabled { opacity: .6; cursor: wait; }
#stampa-riquadro { position: fixed; z-index: var(--z-mappa-ui); box-sizing: border-box; border: 2px solid var(--accent); box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0, 0, 0, .5); cursor: move; touch-action: none; }
#stampa-riquadro[hidden] { display: none; }
#stampa-riquadro.a-scala .stampa-maniglia { display: none; } /* a scala fissa l'estensione la decide la scala */
#stampa-riquadro .stampa-maniglia { position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; background: var(--accent); border: 2px solid #fff; border-radius: 50%; cursor: nwse-resize; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
#gruppo-stampa .stampa-anteprima { cursor: zoom-in; }
@media (max-width: 720px) {
  #gruppo-stampa .stampa-anteprima { max-height: 120px; object-fit: contain; }
}
/* anteprima ingrandita del pannello «Stampa» */
.stampa-anteprima-grande { padding: 0; border: 0; background: transparent; max-width: 96vw; max-height: 94vh; overflow: visible; }
.stampa-anteprima-grande::backdrop { background: rgb(0 0 0 / .72); }
.stampa-anteprima-tela { display: block; max-width: 96vw; max-height: 94vh; width: auto; height: auto; object-fit: contain; border-radius: var(--r-sm, 4px); background: #fff; box-shadow: 0 10px 40px rgb(0 0 0 / .5); cursor: zoom-out; }
.stampa-anteprima-chiudi { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgb(15 23 42 / .75); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }

#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), #chatbot-pannello:not([hidden]):not(.collassato), #storico-pannello:not([hidden]):not(.collassato), #confronto-pannello:not([hidden]):not(.collassato), #mappe-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: 64px; --footer-h: 0px; --emergenza: #d7263d; } /* rosso dell'emergenza: barra in modalità emergenza, badge «Emergenza» e scheda del percorso nella home */
#barra-tab, .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; padding: 0 6px; box-sizing: border-box;
    background: color-mix(in srgb, var(--surface) 96%, transparent); border-top: 1px solid var(--border-ui); box-shadow: 0 -6px 18px rgb(0 0 0 / .08);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
  #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: 0 solid transparent; background: none; color: var(--text-muted); font: inherit; font-size: .6875rem; font-weight: 600; letter-spacing: .01em;
    -webkit-tap-highlight-color: transparent; cursor: pointer;
  }
  /* l'icona sta su una pillola: vuota a riposo, colorata sul tab attivo */
  #barra-tab button svg { box-sizing: content-box; padding: 4px 18px; border-radius: var(--r-pill); transition: background var(--t-rapida), color var(--t-rapida); }
  #barra-tab button[aria-pressed="true"] { color: var(--text); font-weight: 700; }
  #barra-tab button[aria-pressed="true"] svg { background: color-mix(in srgb, var(--accent) 24%, transparent); color: var(--text); }
  #barra-tab button:active svg { background: var(--surface-hover); }
  #barra-tab button:focus-visible { outline: 3px solid var(--focus); outline-offset: -4px; border-radius: 14px; }
  #barra-tab .conta-strati {
    position: absolute; top: 4px; left: calc(50% + 10px); 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; }


  /* 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; il catalogo RNDT sta nei tab */
  #barra-strumenti { top: 68px; right: 12px; left: auto; flex-direction: column; align-items: center; gap: 8px; }
  #barra-strumenti > #btn-rndt { display: none; }
  #barra-strumenti > #switch-lingua { width: 44px; height: 44px; }
  #barra-strumenti > #switch-lingua svg { width: 18px; height: 18px; }
  #barra-strumenti > #switch-lingua .lingua-sigla { font-size: .625rem; }

  /* modalità emergenza (Piano di emergenza acceso): barra con Mappa, Home, GPS, Talia ed Esci, nessuno strumento sulla mappa, solo la scheda dell'area */
  #barra-tab button:is([data-tab="home"], [data-tab="gps"], [data-tab="condividi"], [data-tab="talia"], [data-tab="esci"]) { display: none; }
  body.modo-emergenza #barra-tab button:is([data-tab="home"], [data-tab="gps"], [data-tab="condividi"], [data-tab="talia"], [data-tab="esci"]) { display: flex; }
  body.modo-emergenza #barra-tab button:not([data-tab="mappa"], [data-tab="home"], [data-tab="gps"], [data-tab="condividi"], [data-tab="talia"], [data-tab="esci"]),
  body.modo-emergenza #barra-strumenti, body.modo-emergenza #legende-raggio, body.modo-emergenza .invito-clic, body.modo-emergenza #zoom-box,
  body.modo-emergenza #barra-strati, body.modo-emergenza #pannello { display: none; }
  body.modo-emergenza #pannello:has(#gruppo-filtri:not([hidden])) { display: block; } /* il tasto Filtri della ricerca riapre solo il pannello dei filtri */
  body.modo-emergenza #pannello-filtri .filtri-ordinari { display: none; } /* in emergenza restano i filtri di zona (territorio): via trasporto, incidenti e catasto */
  body.modo-emergenza #barra-tab { background: var(--emergenza); border-top-color: rgba(0, 0, 0, .3); box-shadow: 0 -2px 8px rgba(0, 0, 0, .3); }
  body.modo-emergenza #barra-tab button svg, body.modo-emergenza #barra-tab button[aria-pressed="true"] svg { background: none; padding-inline: 0; }
  body.modo-emergenza #barra-tab button, body.modo-emergenza #barra-tab button[aria-pressed="true"] { color: #fff; font-weight: 700; border-top-color: transparent; } /* tutti i tab uguali, anche l'attivo */

  /* 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); z-index: var(--z-foglio); } /* la scheda sta sopra la colonna degli strumenti */
  #rndt-pannello, #geoimage-pannello, #tema-ui-pannello, #chatbot-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»: pannello a tutta larghezza sopra la barra a tab, voci grandi a sinistra, sfondo oscurato */
  body.info-aperto::after { content: ""; position: fixed; inset: 0 0 var(--tab-h); z-index: calc(var(--z-header) - 1); background: color-mix(in srgb, var(--accent) 35%, transparent); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
  body.info-aperto #menu-info {
    display: flex; position: fixed; top: auto; left: 8px; right: 8px; bottom: calc(var(--tab-h) + var(--footer-h) + 8px); width: auto; min-width: 0; max-height: 72dvh; overflow-y: auto;
    flex-direction: column; align-items: stretch; gap: 8px; margin: 0; padding: 10px; z-index: calc(var(--z-header) + 1); text-align: left;
    background: none; border: 0; border-radius: 0; box-shadow: none;
  }
  #menu-info button, #menu-info a { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 12px 16px; text-align: left; color: var(--text); font-size: 1rem; font-weight: 600; border: 0; border-radius: 16px; background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 12px rgb(0 0 0 / .06); }
  #menu-info button[aria-current="page"], #menu-info a[aria-current="page"] { background: var(--surface); box-shadow: inset 0 0 0 2px var(--text); color: var(--text); font-weight: 700; }
  #menu-info a, #menu-info .menu-solo-stretto { justify-content: flex-start; gap: 14px; }
  #menu-info .menu-tendina-lista .menu-solo-stretto { display: flex; }
  #menu-info .menu-icona { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--text); }
  #menu-info .menu-tendina-lista .menu-icona { width: 32px; height: 32px; }
  :root[data-tema="scuro"] #menu-info .menu-icona { background: var(--accent); color: var(--accent-ink); } /* scuro: tessera arancione piena, icona ben visibile */
  :root[data-tema="scuro"] #menu-info a[data-scheda="emergenza"] .menu-icona { background: rgb(255 255 255 / .22); color: #fff; }
  #menu-info a[data-scheda="emergenza"] .menu-icona { background: rgb(255 255 255 / .22); color: #fff; }
  #menu-info .menu-diviso:has(.menu-tendina-toggle[aria-expanded="true"], .menu-tendina-toggle:hover) > a .menu-icona { background: rgb(255 255 255 / .45); }
  #menu-info .menu-tendina-toggle::after { content: ""; width: 9px; height: 9px; margin-left: auto; border: solid currentColor; border-width: 0 2.4px 2.4px 0; rotate: 45deg; translate: 0 -2px; opacity: .55; transition: rotate .15s; }
  #menu-info .menu-tendina-toggle[aria-expanded="true"]::after { rotate: -135deg; translate: 0 2px; }
  #menu-info .menu-tendina-lista { display: none; margin: 8px 0 0; padding: 0; border: 0; background: none; gap: 8px; flex-direction: column; }
  #menu-info .menu-tendina.aperta .menu-tendina-lista { display: flex; }
  #menu-info .menu-diviso { display: flex; flex-wrap: wrap; align-items: stretch; }
  #menu-info .menu-diviso .menu-tendina-toggle { height: 54px; box-shadow: none; background: none; }
  #menu-info .menu-diviso:has(.menu-tendina-toggle[aria-expanded="true"], .menu-tendina-toggle:hover) > a, #menu-info .menu-tendina-toggle[aria-expanded="true"]:not(.menu-diviso *) { background: var(--accent); color: var(--accent-ink); }
  #menu-info .menu-diviso > a { flex: 1; }
  #menu-info .menu-tendina-lista :is(button, a) { min-height: 46px; padding: 10px 16px; font-size: .9375rem; font-weight: 500; color: var(--text-muted); box-shadow: none; border: 1px solid var(--border-ui); }
  #menu-info .menu-tendina-lista a[data-scheda="emergenza"] { color: #fff; font-weight: 700; border-color: transparent; }
  #menu-info [data-scheda="mappa"] { display: none; }
  #menu-info #link-home { order: -1; } #menu-info [data-scheda="digitaltwin"] { order: 1; } #menu-info #menu-guide { order: 3; } #menu-info [data-scheda="fonti"] { order: 4; } #menu-info #menu-altro { order: 5; }
}
/* modalità emergenza a telefono ruotato (touch, altezza fino a 500 px, oltre 720 px di larghezza): la stessa barra rossa in basso e la scheda dell'area a destra sopra la barra; niente testata, piede, barra dei pannelli né strumenti. Il resto dell'app, ruotato, resta quello desktop */
@media (min-width: 721px) and (pointer: coarse) and (max-height: 500px) {
  body.modo-emergenza #rail-pannelli, body.modo-emergenza #barra-strumenti,
  body.modo-emergenza #legende-raggio, body.modo-emergenza .invito-clic, body.modo-emergenza #zoom-box, body.modo-emergenza #barra-strati, body.modo-emergenza #pannello,
  body.modo-emergenza #barra-tab button:not([data-tab="mappa"], [data-tab="home"], [data-tab="gps"], [data-tab="condividi"], [data-tab="talia"], [data-tab="esci"]) { display: none; }
  body.modo-emergenza #pannello-filtri .filtri-ordinari { display: none; }
  body.modo-emergenza #pannello:has(#gruppo-filtri:not([hidden])) { display: block; }
  body.modo-emergenza #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(--emergenza); border-top: 1px solid rgba(0, 0, 0, .3); box-shadow: 0 -2px 8px rgba(0, 0, 0, .3);
  }
  body.modo-emergenza #barra-tab button, body.modo-emergenza #barra-tab button[aria-pressed="true"] {
    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: #fff; font: inherit; font-size: var(--fs-xs); font-weight: 700;
  }
  body.modo-emergenza #area-ricerca { top: 8px; bottom: auto; left: 8px; right: auto; width: min(360px, calc(100% - var(--scheda-w) - 24px)); transform: none; }
  body.modo-emergenza #cerca-risultati { bottom: auto; top: calc(100% + 8px); }
  body.modo-emergenza #scheda { top: 0; right: 0; bottom: var(--tab-h); width: min(var(--scheda-w), 55%); z-index: var(--z-foglio); }
  body.modo-emergenza :is(#rndt-pannello, #geoimage-pannello, #tema-ui-pannello, #chatbot-pannello) { right: 0; bottom: var(--tab-h); width: min(var(--scheda-w), 55%); }
  body.modo-emergenza #legende-box { --legende-bottom: calc(var(--tab-h) + 12px); bottom: calc(var(--tab-h) + 12px); left: 8px; }
}
.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; }
.tooltip-pallino { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; border: 1px solid rgb(0 0 0 / .25); }
.tooltip-badge { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; color: var(--colore); background: color-mix(in srgb, var(--colore) 14%, transparent); border: 1px solid color-mix(in srgb, var(--colore) 53%, transparent); }
.strati-tooltip-altre { color: var(--text-muted); }
/* voce del tooltip organizzata come la scheda: titolo con filetto, poi righe etichetta (attenuata) / valore (grassetto, a destra) */
.strati-tooltip-corpo > div > strong { display: block; padding-bottom: 3px; border-bottom: 1px solid var(--tooltip-bordo); }
.strati-tooltip-corpo > div > strong { color: var(--accent-strong); }
.tooltip-icona { display: inline-flex; vertical-align: -.2em; margin-right: 6px; }
.tooltip-riga { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 2px 0; border-bottom: 1px solid var(--tooltip-bordo); }
.tooltip-riga:last-child { border-bottom: 0; }
.tooltip-riga > span { flex: none; color: var(--text-muted); }
.tooltip-riga > b { min-width: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* 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; } }
.maplibregl-ctrl-bottom-right .logo-pahub { display: block; margin: 0 10px 20px 0; line-height: 0; }
.logo-pahub img { display: block; width: 110px; height: auto; }
@media (min-width: 721px) { .maplibregl-ctrl-bottom-right .logo-pahub { margin-right: 68px; } }
#barra-strumenti button[hidden] { display: none; }

/* Street View: finestra flottante, spostabile e ridimensionabile */
dialog.streetview-finestra { position: fixed; margin: 0; inset: auto; z-index: var(--z-finestra); 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 in fondo alla finestra 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, 0px);
  box-sizing: border-box; display: flex; flex-direction: column; min-height: 160px; max-height: calc(100dvh - var(--footer-h, 0px) - 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 - 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), #chatbot-pannello:not([hidden]):not(.collassato), #storico-pannello:not([hidden]):not(.collassato), #confronto-pannello:not([hidden]):not(.collassato), #mappe-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), #chatbot-pannello:not([hidden]):not(.collassato), #storico-pannello:not([hidden]):not(.collassato), #confronto-pannello:not([hidden]):not(.collassato), #mappe-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), #chatbot-pannello:not([hidden]):not(.collassato), #storico-pannello:not([hidden]):not(.collassato), #confronto-pannello:not([hidden]):not(.collassato), #mappe-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 { display: block; 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); }

.peba-visore { position: fixed; inset: 0; z-index: calc(var(--z-viewer) + 100); background: rgb(10 14 30 / .9); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.peba-visore[hidden] { display: none; }
.peba-visore-palco { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.peba-visore-img { max-width: 88vw; max-height: 74vh; object-fit: contain; border-radius: 4px; transition: transform .2s ease; }
.peba-visore-miniature { flex: 0 0 auto; display: flex; gap: 8px; overflow-x: auto; max-width: 92vw; padding: 10px 6px 4px; margin-bottom: 6px; }
.peba-visore-mini { flex: 0 0 auto; width: 64px; height: 64px; padding: 0; overflow: hidden; border-radius: 6px; cursor: pointer; border: 2px solid transparent; opacity: .55; background: none; transition: opacity .15s, border-color .15s; }
.peba-visore-mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.peba-visore-mini:hover { opacity: .85; }
.peba-visore-mini.attiva { opacity: 1; border-color: #fff; }
.peba-visore-chiudi, .peba-visore-nav, .peba-visore-tondo { position: absolute; background: rgb(255 255 255 / .12); color: #fff; border: 0; border-radius: 50%; cursor: pointer; line-height: 1; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.peba-visore-chiudi:hover, .peba-visore-nav:hover, .peba-visore-tondo:hover { background: rgb(255 255 255 / .25); }
.peba-visore-chiudi:focus-visible, .peba-visore-nav:focus-visible, .peba-visore-tondo:focus-visible, .peba-visore-mini:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.peba-visore-chiudi { top: 16px; right: 16px; width: 40px; height: 40px; font-size: 18px; }
.peba-visore-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; font-size: 30px; }
.peba-visore-prec { left: 16px; }
.peba-visore-succ { right: 16px; }
.peba-visore-contatore { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 13px; background: rgb(0 0 0 / .4); padding: 4px 12px; border-radius: 12px; }
.peba-visore-strumenti { position: absolute; bottom: 16px; right: 16px; display: flex; gap: 8px; }
.peba-visore-tondo { position: static; width: 40px; height: 40px; font-size: 18px; }
@media (max-width: 640px) { .peba-visore-nav { width: 40px; height: 40px; font-size: 24px; } .peba-visore-img { max-width: 96vw; max-height: 60vh; } }

.peba-nota { margin-top: 12px; border-radius: var(--r-sm); background: var(--avviso-scheda); border-left: 3px solid var(--accent-strong); color: var(--avviso-scheda-ink); font-size: var(--fs-xs); }
.peba-nota summary { cursor: pointer; padding: 8px 10px; font-weight: 700; list-style: none; }
.peba-nota summary::-webkit-details-marker { display: none; }
.peba-nota summary::before { content: "▸"; display: inline-block; width: 1em; transition: transform .15s; }
.peba-nota[open] summary::before { transform: rotate(90deg); }
.peba-nota summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.peba-nota p { margin: 0; padding: 0 10px 10px; line-height: 1.4; }

/* pendolarismo: riquadri, numeri e classifiche della scheda, come nel pannello della mappa originale */
.pend-riquadri, .pend-numeri { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.pend-riquadro, .pend-numero { padding: 8px 6px; border-radius: var(--r-sm); background: var(--accent-soft); text-align: center; }
.pend-riquadro .pend-val { font-size: var(--fs-md); font-weight: 700; }
.pend-numero { background: transparent; border: 1px solid var(--border-ui); }
.pend-numero .pend-val { font-weight: 700; }
.pend-et { font-size: var(--fs-xs); color: var(--text-muted); overflow-wrap: anywhere; }
.pend-pos { color: #3d7fff; }
.pend-neg { color: #ff4400; }
.pend-classifica h4 { margin: 12px 0 6px; font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.pend-riga { margin-bottom: 6px; }
.pend-riga-testa { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); }
.pend-riga-val { color: var(--text-muted); white-space: nowrap; }
.pend-barra { height: 6px; margin-top: 2px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.pend-barra i { display: block; height: 100%; border-radius: inherit; }
.legenda-pendolarismo i.pend-linea { display: inline-block; width: 18px; height: 4px; margin-right: 6px; border-radius: 2px; flex: none; vertical-align: middle; }
.scheda-sunto-titolo { margin: 12px 0 0; font-size: var(--fs-sm); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.scheda-sunto-titolo + .scheda-sunto { margin-top: 6px; }
.interruttore-tip { margin: 0 0 8px; }
/* legende del PRG 2004: simbolo 16×16 e testo che va a capo */
.legenda-prg strong { display: block; margin-bottom: 4px; font-size: var(--fs-xs); }
.prg-voce { display: flex; align-items: flex-start; gap: 6px; padding: 2px 0; font-size: var(--fs-xs); line-height: 1.3; }
.prg-voce img { flex: none; width: 16px; height: 16px; margin-top: 1px; image-rendering: pixelated; }
.prg-voce span { min-width: 0; overflow-wrap: anywhere; }
.prg-voce-titolo { margin-top: 6px; font-weight: 600; }
.prg-sezione { margin: 6px 0 2px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.prg-ppe { margin-top: 8px; font-size: var(--fs-sm); color: var(--text); }
.prg-gruppo { margin-left: 8px; color: var(--text); }
.prg-voce-sotto { margin-left: 18px; }
/* menu «Overlay informativi»: tooltip e legende sulla mappa */
.opzioni-overlay { margin: 0 0 8px; border-top: 0; }
.opzioni-overlay > summary h2 { font-size: var(--fs-sm); }
.opzioni-overlay .interruttore-tip { margin: 0 0 2px; }
.filtri-nota { margin: 12px 0 0; color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.4; }

/* trend della popolazione: scelta del livello, rampa di colore e grafico della scheda */
.trend-livelli { display: flex; flex-wrap: nowrap; gap: 4px; margin: 6px 0; }
.trend-livello { display: inline-flex; align-items: center; padding: 3px 7px; white-space: nowrap; min-width: 0; border: 1px solid var(--border-ui); border-radius: var(--r-pill); font-size: var(--fs-xs); color: var(--text-muted); cursor: pointer; }
.trend-livello input { position: absolute; opacity: 0; pointer-events: none; }
.trend-livello:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 700; }
.trend-livello:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.trend-rampa { height: 10px; border-radius: 5px; border: 1px solid var(--border-ui); }
.trend-rampa-estremi { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-muted); }
.trend-grafico { width: 100%; height: auto; color: var(--text-muted); }
.trend-livello-dettaglio { margin-top: 8px; }
.trend-livello-dettaglio + .trend-livello-dettaglio { padding-top: 8px; border-top: 1px solid var(--border-ui); } /* filo sottile tra un grafico e il successivo */
.strati-tooltip-corpo > div:has(.trend-grafico-tip) + div:has(.trend-grafico-tip) { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-ui); }
.trend-livello-dettaglio > summary { cursor: pointer; font-weight: 700; font-size: var(--fs-sm); }
.trend-grafico-tip { width: 260px; max-width: 100%; margin-top: 4px; }
a.scheda-badge-tinta { text-decoration: none; }
a.scheda-badge-tinta:hover, a.scheda-badge-tinta:focus-visible { background: color-mix(in srgb, var(--tinta) 26%, transparent); }

/* Chat bot: pannello a destra con la conversazione */
.cb-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.cb-msg { max-width: 92%; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: var(--fs-md, 14px); line-height: 1.45; overflow-wrap: anywhere; }
.cb-utente { align-self: flex-end; background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.cb-bot { align-self: flex-start; }
.cb-msg p { margin: 0 0 8px; }
.cb-msg p:last-child, .cb-msg ul:last-child { margin-bottom: 0; }
.cb-msg ul { margin: 0 0 8px; padding-left: 20px; }
.cb-sunto { flex: none; max-height: 40%; overflow-y: auto; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--surface); font-size: var(--fs-md, 14px); line-height: 1.4; }
.cb-divisore { flex: none; position: relative; height: 10px; margin: -5px 0; z-index: 1; cursor: row-resize; touch-action: none; }
.cb-divisore::after { content: ""; position: absolute; left: 50%; top: 3px; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--border-ui); }
.cb-divisore:hover::after, .cb-divisore:focus-visible::after { background: var(--accent); }
.cb-divisore:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cb-sunto > summary { cursor: pointer; font-weight: 600; color: var(--text); }
.cb-sunto-tab { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; color: var(--text); }
.cb-sunto-apri { padding: 2px 10px; border: 1px solid var(--accent); border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent-strong); font: inherit; font-size: var(--fs-sm, 12px); cursor: pointer; }
.cb-sunto-voci { margin: 4px 0 0; padding-left: 18px; color: var(--text); }
.cb-sunto-voci li { margin-bottom: 3px; overflow-wrap: anywhere; }
.cb-sunto-voce { padding: 0; border: 0; background: none; color: var(--accent-strong); font: inherit; font-weight: 600; text-align: left; text-decoration: underline; cursor: pointer; }
.cb-nota { color: var(--text-muted); font-size: var(--fs-sm, 12px); }
.cb-domande { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cb-domanda, .cb-altro { text-align: left; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--accent-strong); font: inherit; cursor: pointer; }
.cb-domanda:hover, .cb-altro:hover { background: var(--surface-hover); }
.cb-altro { margin-top: 8px; padding: 4px 10px; }
.cb-form { flex: none; display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface); }
.cb-campo { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; }
.cb-azioni { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cb-oggetto, .cb-layer, .cb-guida, .cb-filtro, .cb-percorso { padding: 6px 10px; border: 1px solid var(--accent); border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent-strong); font: inherit; cursor: pointer; }
.cb-filtri { margin-top: 10px; }
.cb-filtro-consigliato { font-weight: 600; box-shadow: 0 0 0 2px var(--accent-soft); }
.cb-filtri-stato { margin: 6px 0 0; font-weight: 600; color: var(--accent-strong); }
.cb-filtro-tutte { background: var(--surface); }
.cb-layer[aria-pressed="true"], .cb-filtro[aria-pressed="true"], .cb-percorso[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.cb-pulisci { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-muted); cursor: pointer; }
.cb-pulisci:hover { background: var(--surface-hover); color: var(--text); }

/* Cambio pagina senza sfarfallio: il browser (Chrome/Edge) tiene a schermo la pagina vecchia finché la nuova non è pronta,
   poi il contenuto sfuma nella nuova in dissolvenza veloce. */
@view-transition { navigation: auto; }
::view-transition-group(root) { animation-duration: .15s; }
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*) { animation: none; } }

/* Talia: «Come chiedere» (punto interrogativo nella testata) */
.pannello-aiuto { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--accent-strong); font: inherit; font-weight: 700; cursor: pointer; }
.pannello-aiuto:hover, .pannello-aiuto[aria-expanded='true'] { border-color: var(--accent); background: var(--accent-soft); }
.cb-aiuto { padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); max-height: 45%; overflow-y: auto; }
.cb-aiuto h3 { margin: 0 0 4px; font-size: var(--fs-md, 14px); }
.cb-aiuto h4 { margin: 10px 0 4px; font-size: var(--fs-sm, 12px); text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.cb-aiuto .cb-azioni { display: flex; flex-wrap: wrap; gap: 6px; }
.cb-aiuto[hidden] { display: none; }

/* Talia racconta il luogo (messaggio al pannello del chat bot) */
.cb-parole-tab { margin: 10px 0 4px; font-size: var(--fs-sm, 12px); text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.cb-parole { margin: 0 0 6px; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.cb-parole-regola { font: inherit; font-size: var(--fs-sm, 12px); color: var(--accent-strong); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.cb-parole-spiega { display: block; margin-top: 2px; color: var(--text-muted); font-family: var(--mono, ui-monospace, monospace); }
.terremoti-filtri { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0; }
.terremoti-filtro { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 0; font-size: var(--fs-xs); color: var(--text-muted); }
.terremoti-filtro select { margin: 0; padding: 5px; }
.terremoti-filtro.terremoti-casella { flex-direction: row; align-items: center; gap: 6px; grid-column: 1 / -1; }
.terremoti-periodo-nota { display: block; font-size: var(--fs-xs); line-height: 1.2; color: var(--text-muted); white-space: normal; }
.terremoti-periodo-nota[hidden] { display: none; }
.terremoti-filtri > .terremoti-filtro-unita { grid-column: 1 / -1; }
.terremoti-pf-sezione-tempo[hidden] { display: none; }
.terremoti-periodo-dialog { width: min(92vw, 380px); padding: 0; border: 1px solid var(--border-ui); border-radius: var(--r-md); background: var(--surface); color: var(--text); box-shadow: var(--ombra); }
.terremoti-periodo-dialog::backdrop { background: rgb(0 0 0 / .35); }
.terremoti-periodo-dialog form { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.terremoti-periodo-dialog h2 { margin: 0; font-size: var(--fs-md); }
.terremoti-periodo-campi { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.terremoti-periodo-campi label { display: flex; flex-direction: column; gap: 3px; font-size: var(--fs-xs); color: var(--text-muted); }
.terremoti-periodo-campi input { width: 100%; min-width: 0; padding: 7px 6px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; }
.terremoti-periodo-errore { margin: 0; color: #c92a2a; font-size: var(--fs-xs); }
.terremoti-periodo-azioni { display: flex; justify-content: flex-end; gap: 8px; }
.terremoti-periodo-azioni button { padding: 8px 14px; border-radius: var(--r-sm); font: inherit; cursor: pointer; }
.terremoti-periodo-azioni .primario { border: 1px solid var(--accent); background: var(--accent); color: #1f1300; font-weight: 700; }
.terremoti-periodo-azioni .secondario { border: 1px solid var(--border-ui); background: var(--surface); color: var(--text); }
.terremoti-barre { display: flex; align-items: flex-end; gap: 2px; height: 110px; margin: 8px 0 2px; }
.terremoti-barra { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.terremoti-barra i { display: block; width: 100%; border-radius: 2px 2px 0 0; background: var(--accent); opacity: .7; }
.terremoti-barra i.sciame { background: #e03131; opacity: 1; }
.terremoti-barra span { height: 14px; font-size: var(--fs-xs); line-height: 14px; color: var(--text-muted); white-space: nowrap; overflow: visible; }
.terremoti-sintesi { margin: 4px 0 8px; font-size: var(--fs-sm); line-height: 1.4; color: var(--text); }
.terremoti-vista { display: inline-flex; margin: 2px 0 6px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); overflow: hidden; }
.terremoti-vista button { padding: 3px 10px; border: 0; background: var(--surface); color: var(--text-muted); font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.terremoti-vista button + button { border-left: 1px solid var(--border-ui); }
.terremoti-vista button.attivo { background: var(--accent); color: #1f1300; font-weight: 700; }
.terremoti-sequenza-punti .pt-classe { stroke: rgba(0, 0, 0, .35); stroke-width: .5; fill-opacity: .9; }
.terremoti-sequenza-punti .evento:hover .pt-classe, .terremoti-sequenza-punti .evento:focus .pt-classe { stroke: var(--text); stroke-width: 1.5; }
.terremoti-quote-legenda { display: flex; gap: 14px; margin: 4px 0 6px; font-size: var(--fs-xs); color: var(--text-muted); }
.terremoti-quote-legenda span::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 2px; background: var(--text-muted); opacity: .55; }
.terremoti-quote-legenda .en::before { background: var(--accent); opacity: 1; }
.terremoti-quote-riga { display: grid; grid-template-columns: 34px 1fr; gap: 1px 8px; align-items: center; margin-bottom: 8px; }
.terremoti-quote-riga b { grid-row: 1 / span 2; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.terremoti-quote-barra { display: flex; align-items: center; gap: 6px; height: 11px; }
.terremoti-quote-barra i { display: block; height: 100%; border-radius: 0 2px 2px 0; }
.terremoti-quote-barra.ev i { background: var(--text-muted); opacity: .55; }
.terremoti-quote-barra.en i { background: var(--accent); }
.terremoti-quote-barra span { font-size: var(--fs-xs); line-height: 1; color: var(--text); white-space: nowrap; }
.terremoti-pf-scala { display: flex; align-items: center; gap: 6px; margin: 4px 0; font-size: var(--fs-xs); color: var(--text-muted); cursor: pointer; }
.terremoti-serie { margin: 14px 0; padding: 4px 12px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface, rgba(127,127,127,.05)); }
.terremoti-serie .scheda-nota { margin: 6px 0 0; }
.terremoti-titolo { margin: 10px 0 4px; font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.terremoti-mt { display: block; width: 100%; height: auto; }
.terremoti-mt .asse { stroke: var(--border); stroke-width: 1; }
.terremoti-mt .et { fill: var(--text-muted); font-size: 10px; }
.terremoti-mt .et.forte { fill: #e03131; font-weight: 700; }
.terremoti-mt .evento line { stroke: var(--accent); stroke-width: 1; opacity: .6; }
.terremoti-mt .evento circle { fill: var(--accent); }
.terremoti-mt .apribile { cursor: pointer; outline: none; }
.terremoti-mt .apribile .zona { stroke: transparent; stroke-width: 8; pointer-events: stroke; }
.terremoti-mt .apribile:hover circle:not(.pt):not(.zona-punto), .terremoti-mt .apribile:focus-visible circle:not(.pt):not(.zona-punto) { r: 5; stroke: var(--text, #222); stroke-width: 1.5; }
.terremoti-mt .forte line { stroke: #e03131; stroke-width: 1.5; }
.terremoti-mt .forte circle { fill: #e03131; }
.terremoti-mt .asse.fine { stroke-opacity: .45; stroke-dasharray: 2 3; }
.terremoti-mt .marca-forte { stroke: #e03131; stroke-width: 1; stroke-dasharray: 4 3; opacity: .7; }
.terremoti-mt .asse-titolo { font-weight: 600; letter-spacing: .02em; }
.terremoti-mt.grande .et { font-size: 12px; }
.terremoti-cum .area { fill: var(--accent); opacity: .15; }
.terremoti-cum .curva { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; }
.terremoti-st .pt { fill: var(--accent); opacity: .55; stroke: var(--accent); stroke-width: .5; }
.terremoti-st .forte .pt { fill: #e03131; stroke: #e03131; opacity: 1; }
.terremoti-st .apribile { cursor: pointer; outline: none; }
.terremoti-st .apribile:hover .pt, .terremoti-st .apribile:focus-visible .pt { opacity: 1; stroke-width: 1.5; }
.terremoti-omori .punto { fill: var(--accent); }
.terremoti-omori .fit { stroke: #e03131; stroke-width: 1.5; stroke-dasharray: 4 3; }
.terremoti-sequenze h4 { margin: 12px 0 6px; font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.terremoti-sequenza { display: flex; flex-direction: column; gap: 1px; padding: 5px 0; border-top: 1px solid var(--border); font-size: var(--fs-xs); }
.terremoti-sequenza span { color: var(--text-muted); }
.scheda-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; }
.scheda-nav[hidden] { display: none; }
.scheda-nav-conta { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.scheda-nav-freccia { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border, #c9ced6); background: transparent; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; }
.scheda-nav-freccia:hover:not(:disabled) { background: rgb(128 128 128 / .15); }
.scheda-nav-freccia:disabled { opacity: .35; cursor: default; }
.scheda-mini { position: relative; display: block; width: auto; height: var(--alt); margin: 8px 0 4px; overflow: hidden; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface-alt); }
.scheda-mini-tele { position: absolute; left: 50%; top: 0; height: 100%; }
.scheda-mini img { position: absolute; width: 256px; height: 256px; max-width: none; }
.scheda-mini-punto { position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #e03131; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.scheda-mini-attr { position: absolute; right: 0; bottom: 0; padding: 0 3px; font-size: 9px; background: rgba(255, 255, 255, .8); color: #333; }
.scheda-mini:hover, .scheda-mini:focus-visible { border-color: var(--accent); }
.legenda .terremoti-pannello, #confronto-pannello .terremoti-pannello, #mappe-pannello .terremoti-pannello { display: flex; flex-direction: column; align-items: stretch; gap: 4px; margin: 6px 0; }
.legenda .terremoti-pannello p, #confronto-pannello .terremoti-pannello p, #mappe-pannello .terremoti-pannello p { margin: 0; text-align: left; }
.terremoti-pf-et { margin-top: 4px; font-size: var(--fs-xs); color: var(--text-muted); }
.legenda .terremoti-pf-barre { display: flex; align-items: flex-end; gap: 1px; height: 44px; width: 100%; }
.legenda .terremoti-pannello .terremoti-pf-sezione-tempo { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.legenda .terremoti-pf-barre i { flex: 1 1 0; min-width: 0; width: auto; height: 0; border: 0; border-radius: 1px 1px 0 0; background: var(--accent); opacity: .85; }
.legenda .terremoti-pf-barre i.fuori { opacity: .2; }
.legenda .terremoti-pf-slider { position: relative; display: block; height: 22px; }
.legenda .terremoti-pf-slider input { position: absolute; left: 0; top: 0; width: 100%; height: 22px; margin: 0; padding: 0; border: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.terremoti-pf-slider input::-webkit-slider-runnable-track { height: 3px; background: var(--border); border-radius: 2px; }
.terremoti-pf-slider input::-moz-range-track { height: 3px; background: var(--border); border-radius: 2px; }
.terremoti-pf-slider input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 14px; height: 14px; margin-top: -5.5px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface, #fff); cursor: ew-resize; }
.terremoti-pf-slider input::-moz-range-thumb { pointer-events: auto; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface, #fff); cursor: ew-resize; }
.legenda .terremoti-pannello .terremoti-pf-intervallo { font-size: var(--fs-xs); color: var(--text-muted); }
.legenda .terremoti-pf-testa { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.legenda .terremoti-pannello .terremoti-pf-testa strong { margin: 0; }
.legenda .terremoti-pf-comandi { display: flex; justify-content: flex-end; gap: 4px; }
.legenda .terremoti-pf-icona.aperto { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.legenda .terremoti-pf-corpo { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.legenda .terremoti-pf-corpo[hidden] { display: none; }
.legenda .terremoti-pf-comandi button[hidden] { display: none; }
.legenda .terremoti-pf-istogramma { display: flex; align-items: flex-end; justify-content: stretch; gap: 6px; height: 64px; }
.terremoti-pf-istogramma button { flex: 1 1 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; padding: 0; background: none; border: 0; cursor: pointer; font-size: var(--fs-xs); color: var(--text-muted); }
.legenda .terremoti-pf-istogramma button i { display: block; width: 100%; height: 0; border: 0; border-radius: 2px 2px 0 0; background: var(--accent); }
.terremoti-pf-istogramma button.spenta i { opacity: .2; }
.terremoti-pf-istogramma button b { font-weight: 600; color: var(--text); }
.legenda .terremoti-pf-icona { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: var(--r-xs, 4px); background: var(--surface, #fff); color: var(--accent-strong, var(--accent)); cursor: pointer; }
.legenda .terremoti-pf-icona:hover, .legenda .terremoti-pf-icona:focus-visible { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.legenda .terremoti-pf-icona svg { display: block; }
.legenda .terremoti-pf-velocita { width: auto; white-space: nowrap; min-width: 34px; padding: 0 6px; font: inherit; font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Timeline dei terremoti (timetile): intervallo in grande, preset, comandi, istogramma impilato con finestra trascinabile, legenda a classi */
.cerca-tempo.timetile { gap: 10px; padding: 12px 14px; }
.cerca-tempo.timetile.ridotta { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 8px 14px; }
.cerca-tempo.timetile.ridotta .tt-intervallo { font-size: 1.5rem; }
.cerca-tempo.timetile.ridotta .tt-riga2 { flex: 0 0 auto; }
.cerca-tempo.timetile p { margin: 0; text-align: left; }
.timetile .tt-testa { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.timetile .tt-titolo { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.timetile .tt-riga { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.timetile .tt-intervallo { font-family: var(--font-ui, 'Montserrat', system-ui, sans-serif); font-size: 2.1rem; line-height: 1.1; font-weight: 800; color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.timetile .tt-anno { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.timetile .tt-sotto { font-size: var(--fs-sm); color: var(--text-muted); }
.timetile .tt-preset { display: flex; flex-wrap: wrap; gap: 6px; }
.timetile .tt-preset[hidden], .timetile .tt-corpo[hidden] { display: none; }
.timetile .tt-chip, .timetile .tt-btn, .timetile .tt-riduci, .timetile .tt-velocita { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 9px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.timetile .tt-btn { white-space: nowrap; }
.timetile .tt-chip { min-width: 44px; border-radius: var(--r-pill); }
.timetile .tt-chip.attivo { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.timetile .tt-chip:hover, .timetile .tt-btn:hover, .timetile .tt-riduci:hover { background: var(--surface-hover); }
.timetile .tt-chip.attivo:hover { background: var(--accent); filter: brightness(1.08); }
.timetile .tt-chip:focus-visible, .timetile .tt-btn:focus-visible, .timetile .tt-riduci:focus-visible, .timetile .tt-velocita:focus-visible, .timetile .tt-voce:focus-visible, .timetile .tt-finestra:focus-visible, .timetile .tt-maniglia:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.timetile .tt-punto { width: 8px; height: 8px; border: 0; border-radius: 50%; background: #e03131; }
.timetile .tt-riduci { margin-left: auto; font-weight: 500; color: var(--text-muted); }
.timetile .tt-corpo { display: flex; flex-direction: column; gap: 10px; }
.timetile .tt-comandi { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.timetile .tt-avvia[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.timetile .tt-etichetta-vel { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-muted); }
.timetile .tt-velocita { padding: 0 8px; }
.timetile .tt-grafico { position: relative; height: 92px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--border) 45%, transparent); overflow: hidden; touch-action: none; }
.timetile .tt-barre { position: absolute; inset: 4px 2px 0; display: flex; align-items: flex-end; gap: 1px; }
.timetile .tt-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column-reverse; justify-content: flex-start; }
.timetile .tt-col i { display: block; width: 100%; min-height: 0; border: 0; flex: 0 0 auto; }
.timetile .tt-col i.alta { min-height: 3px; }
.timetile .tt-barre.spenta-0 i[data-c="0"], .timetile .tt-barre.spenta-1 i[data-c="1"], .timetile .tt-barre.spenta-2 i[data-c="2"], .timetile .tt-barre.spenta-3 i[data-c="3"], .timetile .tt-barre.spenta-4 i[data-c="4"] { opacity: .15; }
.timetile .tt-finestra { position: absolute; top: 0; bottom: 0; display: block; box-sizing: border-box; min-width: 28px; border: 2px solid var(--accent-strong); border-radius: var(--r-sm); background: color-mix(in srgb, var(--accent) 16%, transparent); cursor: grab; touch-action: none; }
.timetile .tt-finestra:active { cursor: grabbing; }
.timetile .tt-maniglia { position: absolute; top: 0; bottom: 0; width: 14px; display: flex; align-items: center; justify-content: center; cursor: ew-resize; touch-action: none; background: var(--accent-strong); }
.timetile .tt-maniglia.sx { left: -2px; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.timetile .tt-maniglia.dx { right: -2px; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.timetile .tt-maniglia i { width: 2px; height: 16px; border: 0; border-radius: 1px; background: var(--accent-strong-ink); box-shadow: 4px 0 0 var(--accent-strong-ink); transform: translateX(-2px); }
.timetile .tt-asse { position: relative; height: 14px; font-size: var(--fs-xs); line-height: 14px; color: var(--text-muted); }
.timetile .tt-asse span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }
.timetile .tt-legenda { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.timetile .tt-voce { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 0 8px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text-muted); font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.timetile .tt-voce:hover { background: var(--surface-hover); }
.timetile .tt-voce b { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.timetile .tt-voce.spenta { opacity: .45; }
.timetile .tt-pallino { width: 10px; height: 10px; border: 1px solid color-mix(in srgb, var(--text) 25%, transparent); border-radius: 3px; }
.timetile .tt-chiudi { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; padding: 0; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--text-muted); font: inherit; font-size: 1rem; cursor: pointer; }
.timetile .tt-chiudi:hover { background: var(--surface-hover); color: var(--text); }
.timetile .tt-chiudi:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.timetile .tt-destra { display: flex; align-items: center; gap: 6px; }
.timetile .tt-semplifica { min-width: 36px; padding: 0; font-size: 1.1rem; }
.timetile .tt-riga2 { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 6px; }
.timetile .tt-comandi[hidden] { display: none; }
.timetile .tt-azioni { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.timetile .tt-azioni .tt-riduci { margin-left: 0; }
.timetile .tt-semplifica { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 9px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--text-muted); font: inherit; font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.timetile .tt-semplifica:hover { background: var(--surface-hover); }
.timetile .tt-semplifica:focus-visible, .timetile .tt-sposta:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.timetile .tt-sposta { display: inline-flex; align-items: center; justify-content: center; width: 28px; min-height: 36px; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--text-muted); font-size: 1.1rem; line-height: 1; cursor: grab; touch-action: none; }
.timetile .tt-sposta:hover { background: var(--surface-hover); }
.timetile .tt-sposta:active { cursor: grabbing; }
.cerca-tempo.timetile.libera { position: fixed; z-index: var(--z-barra, 20); width: min(640px, calc(100vw - 16px)); max-width: calc(100vw - 16px); right: auto; bottom: auto; transform: none; margin: 0; }
.cerca-tempo.timetile.libera.semplice { width: min(380px, calc(100vw - 16px)); }
.cerca-tempo.timetile.semplice { gap: 8px; padding: 8px 12px; }
.timetile.semplice .tt-preset, .timetile.semplice .tt-etichetta-vel, .timetile.semplice .tt-reset, .timetile.semplice .tt-asse, .timetile.semplice .tt-legenda { display: none; }
.timetile.semplice .tt-grafico { height: 52px; }
.timetile.semplice .tt-intervallo { font-size: 1.6rem; }
.timetile.semplice .tt-corpo { gap: 8px; }
.timetile.semplice .tt-comandi { flex-wrap: nowrap; }
.timetile.semplice .tt-comandi .tt-btn { padding: 0 8px; }
.timetile.semplice .tt-semplifica, .timetile.semplice .tt-riduci { min-width: 36px; padding: 0; font-size: 1.1rem; }
.timetile.semplice .tt-azioni { gap: 4px; }
.timetile.semplice .tt-sposta { width: 24px; }
.timetile.ridotta .tt-semplifica { display: none; }
/* versione completa più compatta: su mouse pulsanti e legenda più bassi, sul touch restano da 36 px */
.cerca-tempo.timetile:not(.semplice) { gap: 6px; padding: 8px 14px 10px; }
.timetile:not(.semplice) .tt-corpo { gap: 4px; }
.timetile:not(.semplice) .tt-intervallo { font-size: 1.9rem; }
.timetile:not(.semplice) .tt-sotto { line-height: 1.2; }
.timetile:not(.semplice) .tt-grafico { height: 64px; }
.timetile:not(.semplice) .tt-asse { height: 12px; line-height: 12px; }
@media (pointer: fine) {
  .timetile:not(.semplice) .tt-chip, .timetile:not(.semplice) .tt-btn, .timetile:not(.semplice) .tt-riduci, .timetile:not(.semplice) .tt-velocita, .timetile:not(.semplice) .tt-semplifica, .timetile:not(.semplice) .tt-chiudi, .timetile:not(.semplice) .tt-sposta { min-height: 30px; }
  .timetile:not(.semplice) .tt-semplifica, .timetile:not(.semplice) .tt-chiudi { min-width: 30px; }
  .timetile:not(.semplice) .tt-voce { min-height: 26px; }
}
@media (max-width: 480px) { .timetile .tt-etichetta-vel { flex: 1 1 100%; } .timetile .tt-velocita { flex: 1; } .timetile .tt-intervallo { font-size: 1.7rem; } }
@media (prefers-reduced-motion: reduce) { .timetile .tt-chip, .timetile .tt-btn { transition: none; } }

/* punto «La mia posizione» */
.mia-posizione { width: 16px; height: 16px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(26,115,232,.35), 0 1px 4px rgba(0,0,0,.4); }

/* sezione cercata dal clic (peso 1, es. area del Piano di emergenza): intestazione in evidenza */
details.scheda-sez[data-peso="1"] > summary { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: var(--r-sm); padding-left: 8px; padding-right: 8px; }

/* badge a tinta piena (es. «Percorso» del Piano di emergenza): verde delle vie di fuga, testo bianco, ben visibile anche a chi è agitato */
a.scheda-badge-tinta.scheda-badge-pieno { background: var(--tinta); border-color: var(--tinta); color: #fff; padding: 6px 16px; font-size: var(--fs-base); font-weight: 700; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
a.scheda-badge-tinta.scheda-badge-pieno:hover, a.scheda-badge-tinta.scheda-badge-pieno:focus-visible { background: color-mix(in srgb, var(--tinta) 82%, #000); }
/* numeri di telefono: pieno anche quando non sono chiamabili (computer); sul telefono area di tocco da 44px */
.scheda-tel { background: var(--tinta, var(--emergenza, #d7263d)); border-color: var(--tinta, var(--emergenza, #d7263d)); color: #fff; padding: 6px 16px; font-size: var(--fs-base); font-weight: 700; letter-spacing: .02em; text-decoration: none; white-space: nowrap; }
a.scheda-tel { min-height: 44px; display: inline-flex; align-items: center; box-sizing: border-box; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }

/* riquadro con la mappa delle aree di emergenza nella scheda */
.pc-mini { margin: 8px 0 4px; }
.pc-mini-tela { position: relative; width: 100%; overflow: hidden; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface-alt); }
.pc-mini-nota { margin: 4px 2px 0; font-size: var(--fs-xs); color: var(--text-muted); }
/* righe con pulsante a pieno (telefono, percorso): etichetta e pulsante sulla stessa linea centrale */
.scheda-riga:has(.scheda-badge-pieno) { align-items: center; }
.scheda-tel { justify-content: center; min-width: 76px; text-align: center; }
a.scheda-tel { min-height: 40px; }

/* ---- ingranaggio delle impostazioni (telefono): tema, lingua e condividi in un pannello; usato da home, pagine a fasce e mappa (js/core/impostazioni-mobile.js) ---- */
#home-imp-apri, .home-impostazioni { display: none; }
@media (max-width: 720px), (pointer: coarse) and (max-height: 500px) {
  #home-imp-apri:not([hidden]) { display: flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text-muted); cursor: pointer; }
  #home-imp-apri:hover { background: var(--surface-hover); color: var(--text); }
  .home-impostazioni:not([hidden]) { position: fixed; inset: 0; z-index: calc(var(--z-header) + 5); display: flex; align-items: flex-start; justify-content: center; padding: calc(var(--home-header, 64px) + 8px) 16px 16px; background: rgb(0 0 0 / .45); }
  .home-imp-scheda { width: min(360px, 100%); box-sizing: border-box; padding: 14px 16px 16px; border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: var(--ombra); }
  .home-imp-testa { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
  .home-imp-testa h2 { margin: 0; font-size: var(--fs-md); }
  #home-imp-chiudi { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text-muted); cursor: pointer; }
  #home-imp-chiudi:hover { background: var(--surface-hover); color: var(--text); }
  .home-imp-voci { margin: 0; padding: 0; list-style: none; }
  .home-imp-voci li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-top: 1px solid var(--border-ui); }
  .home-imp-voci li:first-child { border-top: 0; }
  .home-imp-voci #btn-condividi { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; color: var(--text); background: var(--surface-alt); border: 1px solid var(--border-ui); border-radius: 50%; cursor: pointer; }
  .home-imp-voci #btn-condividi svg { width: 18px; height: 18px; }
  .home-imp-voci #switch-tema { display: flex; align-items: center; margin-left: auto; width: 64px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; }
  .home-imp-voci #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); }
  .home-imp-voci #switch-tema .switch-sole, .home-imp-voci #switch-tema .switch-luna { position: absolute; top: 6px; color: var(--text-muted); }
  .home-imp-voci #switch-tema .switch-sole { left: 7px; }
  .home-imp-voci #switch-tema .switch-luna { right: 7px; }
  .home-imp-voci #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); }
  .home-imp-voci #switch-tema[aria-checked="true"] .switch-pista { background: var(--accent); border-color: var(--accent); }
  .home-imp-voci #switch-tema[aria-checked="true"] .switch-sole, .home-imp-voci #switch-tema[aria-checked="true"] .switch-luna { color: var(--accent-ink); }
  .home-imp-voci #switch-tema[aria-checked="true"] .switch-manopola { transform: translateX(28px); }
  .home-imp-voci #switch-tema:focus-visible .switch-pista { outline: 2px solid var(--focus); outline-offset: 2px; }
}
@media (max-width: 720px), (pointer: coarse) and (max-height: 500px) { #app-header > #home-imp-apri { margin-left: auto; } }

/* tooltip: intestazione come quella del popup (marchio colorato e nome della sezione) */
.tooltip-testa { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tooltip-marchio { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; color: #fff; }
.tooltip-sezione { font: 600 var(--fs-xs) ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }
.mappa-tooltip.traffico-popup-box .maplibregl-popup-tip { display: block; }
.mappa-tooltip.traffico-popup-box .maplibregl-popup-content { padding: 10px 14px 12px; }

/* pulsante «ingrandisci» e popup grande dei grafici: solo desktop */
.ingrandisci-grafico { display: none; flex: none; width: 18px; height: 18px; padding: 0; border: 1px solid var(--text-muted); border-radius: 4px; background: transparent; color: var(--text-muted); cursor: pointer; place-items: center; }
.ingrandisci-grafico:hover, .ingrandisci-grafico:focus-visible { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (min-width: 1000px) and (hover: hover) { .ingrandisci-grafico { display: inline-grid; } }
.grafico-grande-popup { width: min(1000px, calc(100vw - 48px)); max-width: none; max-height: 90vh; padding: 8px 18px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(0, 0, 0, .35); overflow-y: auto; }
.grafico-grande-popup::backdrop { background: rgba(0, 0, 0, .5); }
.grafico-grande-popup .terremoti-serie { margin: 8px 0; padding: 4px 16px 14px; }
.grafico-grande-popup .scheda-nota { font-size: var(--fs-sm, 13px); }
.grafico-grande-popup .terremoti-titolo { font-size: var(--fs-sm, 13px); }
.terremoti-cum .evento circle, .terremoti-cum .forte circle { stroke: var(--surface, #fff); stroke-width: 1; }
.terremoti-omori.grande .punto { transition: r .1s; }
.terremoti-omori.grande .punto:hover { r: 6; stroke: var(--text, #222); stroke-width: 1.5; }
.terremoti-barre.grande .terremoti-barra:hover i { opacity: 1; }
.terremoti-barre.grande .terremoti-barra:hover { background: rgba(127, 127, 127, .12); }
.terremoti-mt .brush { fill: var(--accent); opacity: .22; stroke: var(--accent); stroke-width: 1; pointer-events: none; }
.terremoti-mt.grande { cursor: crosshair; user-select: none; touch-action: none; }
.terremoti-mt.grande .apribile { cursor: pointer; }
.terremoti-mt.grande.zoomato { cursor: grab; }
.zoom-aiuto { margin: 0 0 4px; }
.zoom-riga { display: flex; align-items: center; gap: 8px; margin: 2px 0 6px; }
.zoom-riga .scheda-nota { margin: 0; }
/* minimappa accanto al grafico (popup grande) */
.grafico-grande-popup:has(.con-mappa) { width: min(1760px, calc(100vw - 24px)); height: 690px; max-height: 95vh; padding: 8px 14px 14px; overflow: auto; } /* altezza fissa, qualunque sia il monitor; più in basso si scorre, sotto ~1250 px di larghezza anche in orizzontale */
/* tre riquadri alti uguali, ognuno con una riga di testo sopra e una sotto: grafico | minimappa | scheda dell'evento */
.terremoti-serie.con-mappa { display: grid; grid-template-columns: minmax(520px, 1fr) 300px 320px; grid-template-rows: auto auto var(--alt-grafico) auto auto; column-gap: 14px; min-width: 1200px; }
.terremoti-serie.con-mappa > .terremoti-titolo { grid-column: 1 / -1; grid-row: 1; }
.terremoti-serie.con-mappa > .zoom-aiuto, .terremoti-serie.con-mappa > .zoom-riga { grid-column: 1; grid-row: 2; align-self: end; }
.terremoti-serie.con-mappa > .minimappa-aiuto { grid-column: 2; grid-row: 2; align-self: end; margin: 0 0 4px; }
.terremoti-serie.con-mappa > .minimappa-apri { grid-column: 3; grid-row: 2; align-self: end; margin: 0 0 4px; }
.terremoti-serie.con-mappa > svg.terremoti-mt { grid-column: 1; grid-row: 3; height: var(--alt-grafico); border: 1px solid var(--border-ui); border-radius: var(--r-sm); }
.terremoti-serie.con-mappa > .minimappa-quadro { grid-column: 2; grid-row: 3; }
.terremoti-serie.con-mappa > .minimappa-dettaglio { grid-column: 3; grid-row: 3; }
.terremoti-serie.con-mappa > p.scheda-nota:not(.zoom-aiuto):not(.minimappa-aiuto) { grid-column: 1; grid-row: 4; }
.terremoti-serie.con-mappa > .minimappa-scheda { grid-column: 2; grid-row: 4; }
.minimappa-quadro { position: relative; width: 300px; overflow: hidden; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface-alt); }
.minimappa-quadro img { position: absolute; width: 256px; height: 256px; max-width: none; }
.minimappa-vista { position: absolute; inset: 0; }
.minimappa-punti { position: absolute; inset: 0; width: 100%; height: 100%; }
.minimappa-punti .evento circle { fill: var(--accent); fill-opacity: .55; stroke: #fff; stroke-width: 1; cursor: pointer; }
.minimappa-punti .forte circle { fill: #e03131; fill-opacity: .85; stroke: #fff; stroke-width: 1.2; cursor: pointer; }
.minimappa-punti .sel circle { fill-opacity: 1; stroke: #111; stroke-width: 2; r: 8; }
.minimappa-punti .fissato circle { stroke: #f08c00; stroke-width: 3; }
.terremoti-mt .sel circle:not(.zona-punto) { stroke: var(--text, #222); stroke-width: 2; opacity: 1; }
.terremoti-mt .sel circle:not(.pt):not(.zona-punto) { r: 6; } /* i cerchi del diagramma spazio-tempo (.pt) tengono il loro raggio: cambiarlo sotto il mouse faceva uscire e rientrare il puntatore (sfarfallio) */
.zoom-icona { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text); cursor: pointer; vertical-align: middle; }
.zoom-icona svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.zoom-icona:hover, .zoom-icona:focus-visible { color: var(--accent); background: rgba(127, 127, 127, .15); }
.terremoti-serie:has(> .zoom-freccia) { position: relative; }
.terremoti-serie > .zoom-freccia { position: absolute; top: 50%; z-index: 3; width: 30px; height: 30px; padding: 0 0 2px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .45); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; opacity: .75; }
.terremoti-serie > .zoom-freccia:hover, .terremoti-serie > .zoom-freccia:focus-visible { opacity: 1; background: rgba(0, 0, 0, .7); }
.terremoti-serie > .zoom-freccia.sx { left: 6px; }
.terremoti-serie > .zoom-freccia.dx { right: 6px; }
.terremoti-serie.con-mappa > .zoom-freccia { position: static; grid-column: 1; grid-row: 3; align-self: center; margin: 0 6px; }
.terremoti-serie.con-mappa > .zoom-freccia.sx { justify-self: start; }
.terremoti-serie.con-mappa > .zoom-freccia.dx { justify-self: end; }
.terremoti-mt .sel line:not(.zona) { stroke-width: 2.5; opacity: 1; }
.terremoti-mt .fissato circle:not(.zona-punto) { stroke: #f08c00; stroke-width: 3; }
/* sezione verticale nel popup con minimappa e scheda: stessa griglia, il grafico è un svg.grafico-zoom e la legenda va sotto */
.terremoti-serie.con-mappa > svg.grafico-zoom { grid-column: 1; grid-row: 3; width: 100%; height: var(--alt-grafico); margin: 0; border: 1px solid var(--border-ui); border-radius: var(--r-sm); }
.grafico-grande-popup .terremoti-serie.con-mappa.terremoti-confronto-grafico.grande > svg { width: 100%; margin: 0; }
.terremoti-serie.con-mappa > .terremoti-confronto-chiave { grid-column: 1; grid-row: 5; }
.punto-sezione { transition: opacity .1s; }
.evento.sel .punto-sezione { stroke: var(--text, #222); stroke-width: 2.5; opacity: 1; }
.evento.fissato .punto-sezione { stroke: #f08c00; stroke-width: 3; opacity: 1; }
/* grafici molto fitti (unità «anno»): un solo tracciato per gli steli, e un unico rilevatore del puntatore */
.terremoti-mt .steli { stroke: var(--accent); stroke-width: 1; opacity: .6; fill: none; }
.terremoti-mt .stelo-forte { stroke: #e03131; stroke-width: 1.5; }
.terremoti-mt .punto-forte { fill: #e03131; }
.terremoti-st .pt.forte { fill: #e03131; stroke: #e03131; opacity: 1; }
.terremoti-mt.punti-interattivi { cursor: crosshair; }
/* zone invisibili ma larghe: rendono toccabili anche i punti più piccoli (marche della curva, spazio-tempo, Omori) */
.terremoti-mt .apribile > .zona-punto, .terremoti-mt .punto-giorno > .zona-punto { fill: transparent; stroke: none; pointer-events: all; }
.terremoti-mt .zona-punto { cursor: crosshair; }
/* Omori: ogni punto è un giorno di repliche; sotto il mouse si accende quel gruppo in mappa */
.terremoti-omori .punto-giorno { cursor: crosshair; outline: none; }
.terremoti-omori .punto-giorno:hover .punto, .terremoti-omori .punto-giorno:focus-visible .punto { r: 6; stroke: var(--text, #222); stroke-width: 1.5; }
/* barre e sequenze: gruppi di eventi; il passaggio del mouse li evidenzia in mappa */
.terremoti-barra.interattivo, .terremoti-sequenza.interattivo { cursor: crosshair; outline: none; }
.terremoti-barra.interattivo:hover, .terremoti-barra.interattivo:focus-visible,
.terremoti-sequenza.interattivo:hover, .terremoti-sequenza.interattivo:focus-visible { background: rgba(127, 127, 127, .12); border-radius: 3px; }
.terremoti-barra.interattivo:hover i, .terremoti-barra.interattivo:focus-visible i { opacity: 1; }
.terremoti-barra.interattivo:focus-visible, .terremoti-sequenza.interattivo:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.terremoti-grafici-aiuto { margin: 2px 0 8px; }
.minimappa-attr { position: absolute; right: 0; bottom: 0; padding: 0 3px; font-size: 9px; background: rgba(255, 255, 255, .8); color: #333; }
.minimappa-scheda { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; font-size: var(--fs-sm, 13px); }
.minimappa-scheda span { color: var(--text-muted); }
.minimappa-dettaglio { display: flex; flex-direction: column; box-sizing: border-box; border: 1px solid var(--border-ui); border-radius: var(--r-sm); overflow-y: auto; } /* la cornice resta ferma, scorre il contenuto */
.minimappa-dettaglio .scheda-sez { margin: 0; flex: none; border: 0; }
/* blocco «Nella sequenza» nella scheda dell'evento */
.seq-blocco { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: var(--fs-sm, 13px); }
.seq-titolo { margin: 0 0 4px; font-size: var(--fs-sm, 13px); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.seq-riga { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.seq-riga span { color: var(--text-muted); }
.seq-riga strong { text-align: right; }
.seq-sottotitolo { margin: 6px 0 2px; color: var(--text-muted); }
.seq-vicino { display: block; width: 100%; margin: 2px 0; padding: 4px 8px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: transparent; color: var(--link); font: inherit; text-align: left; cursor: pointer; }
.seq-vicino:hover, .seq-vicino:focus-visible { background: var(--surface-hover); }
.seq-profondita { display: block; width: 100%; height: 26px; }
.seq-profondita .asse { stroke: var(--border-ui); stroke-width: 1; }
.seq-profondita .altro { fill: var(--accent); fill-opacity: .35; }
.seq-profondita .scelto { fill: var(--accent); stroke: var(--text); stroke-width: 1.5; }
.terremoti-barre.grande { height: 280px; margin-top: 18px; padding-top: 30px; gap: 4px; }
.terremoti-barre.grande .terremoti-barra b { height: 14px; font-size: var(--fs-xs); line-height: 14px; font-weight: 600; color: var(--text); }
.terremoti-barre.grande .terremoti-barra span { font-size: var(--fs-xs); }
.grafico-grande-popup .terremoti-sequenza { font-size: var(--fs-sm, 13px); }
/* icona «i» dei grafici e popup di spiegazione (js/core/info-grafico.js) */
.titolo-con-info { display: flex; align-items: center; gap: 6px; }
.info-grafico { flex: none; width: 18px; height: 18px; padding: 0; border: 1px solid var(--text-muted); border-radius: 50%; background: transparent; color: var(--text-muted); font: italic 700 11px/1 Georgia, serif; text-transform: none; letter-spacing: 0; cursor: pointer; }
.info-grafico:hover, .info-grafico:focus-visible { background: var(--accent); border-color: var(--accent); color: #fff; }
.info-grafico-popup { max-width: min(440px, calc(100vw - 32px)); max-height: 80vh; padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-size: var(--fs-sm, 13px); line-height: 1.45; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); overflow-y: auto; }
.info-grafico-popup::backdrop { background: rgba(0, 0, 0, .4); }
.info-grafico-popup h3 { margin: 0 0 8px; font-size: var(--fs-md, 15px); }
.info-grafico-popup p { margin: 0 0 10px; }
.info-grafico-popup strong { color: var(--accent-strong); }
.info-grafico-chiudi { display: block; margin: 4px 0 0 auto; padding: 6px 16px; border: 0; border-radius: var(--r-pill); background: var(--accent-strong); color: var(--accent-strong-ink); font: inherit; font-weight: 600; cursor: pointer; }

/* scheda dell'evento sismico sul modello di quella dell'INGV */
.scheda-evento { margin: 8px 0 4px; }
.scheda-evento-titolo { margin: 0; font-size: var(--fs-xl, 1.4rem); font-weight: 800; letter-spacing: .01em; text-transform: uppercase; color: #e8590c; line-height: 1.1; }
.scheda-evento-luogo { margin: 2px 0 4px; font-weight: 400; font-size: var(--fs-sm); color: var(--text-soft, var(--text)); }
.scheda-evento-campi { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 16px 0 14px; }
.scheda-evento-campo { display: flex; flex-direction: column; min-width: 0; }
.scheda-evento-chiave { font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; color: #e8590c; }
.scheda-evento-chiave small { font-weight: 400; text-transform: none; color: var(--text-soft, var(--text)); }
.scheda-evento-scelta { margin: 4px 0 0; padding: 5px; font-size: var(--fs-sm); cursor: pointer; }
a.scheda-evento-valore { color: inherit; text-decoration: underline; }
.scheda-evento-valore { font-size: var(--fs-base); font-weight: 600; }
.scheda-evento-legende { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin: 10px 0; }
.scheda-evento-legenda strong { display: block; margin-bottom: 4px; font-size: var(--fs-xs); text-transform: uppercase; }
.scheda-evento-voce { display: flex; align-items: center; gap: 6px; min-height: 30px; font-size: var(--fs-xs); opacity: .65; }
.scheda-evento-voce.is-on { opacity: 1; font-weight: 700; }
.scheda-evento-casella { flex: none; display: flex; align-items: center; justify-content: center; width: 32px; }
.scheda-evento-cerchio, .scheda-evento-punto { display: block; border-radius: 50%; box-sizing: border-box; }
.scheda-evento-cerchio { border: 1.5px solid currentColor; }
.scheda-evento-punto { width: 16px; height: 16px; }
.scheda-evento-voce.is-on .scheda-evento-punto { box-shadow: 0 0 0 2px var(--surface, #fff), 0 0 0 3.5px currentColor; }
.scheda-evento-voce.is-on .scheda-evento-cerchio { border-width: 2.5px; }
/* badge della magnitudo di un evento: tinta della sua classe (js/core/badge-magnitudo.js) */
.badge-mag { display: inline-block; padding: 0 8px; border-radius: var(--r-pill, 999px); font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--testo-tinta, #fff); background: var(--tinta); border: 1px solid color-mix(in srgb, var(--tinta) 70%, #000); }
.scheda-tipo-nome .badge-mag, .scheda-tipo > summary .badge-mag { margin-right: 6px; }
.scheda-evento-campo > .badge-mag { align-self: flex-start; padding: 0 6px; font-size: var(--fs-3xs); line-height: 1.5; }
.scheda-evento-badge { padding: 1px 10px; border-radius: var(--r-pill, 999px); font-size: var(--fs-xs); font-weight: 700; color: color-mix(in srgb, var(--tinta) 45%, var(--text)); background: color-mix(in srgb, var(--tinta) 22%, transparent); border: 1px solid color-mix(in srgb, var(--tinta) 60%, transparent); }
details.scheda-sez-evento > summary > h3 { display: flex; flex-wrap: wrap; align-items: center; column-gap: 6px; line-height: 1.1; }
details.scheda-sez-evento .scheda-sez-testo { display: contents; }
.scheda-sez-testo .scheda-evento-luogo { flex: 0 0 100%; }
.traffico-popup .scheda-evento-legende { margin: 8px 0 4px; font-size: var(--fs-xs); }
/* sezione evidenziata (allerta in corso): bordo e titolo rossi */
.scheda-sez-tinta { border-color: var(--tinta); background: color-mix(in srgb, var(--tinta) 8%, transparent); }
.scheda-sez-tinta > summary h3 { color: var(--tinta); }
.scheda-sez-tinta .scheda-tag { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.traffico-popup .scheda-evento-casella { width: 28px; }
.traffico-popup .scheda-evento-voce { gap: 4px; white-space: nowrap; }

/* titolo e coordinate: sulla mappa, a destra, a sinistra della colonna di zoom e scala; seguono il pannello laterale come gli altri oggetti */
#mappa-info { position: fixed; z-index: var(--z-mappa-ui); right: calc(var(--scheda-l) + 68px); bottom: calc(var(--footer-h, 0px) + 56px); display: flex; flex-direction: column; align-items: flex-end; gap: 2px; padding: 6px 10px; background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--border-ui); border-radius: var(--r-md); box-shadow: var(--ombra); font-size: var(--fs-xs); color: var(--text-muted); pointer-events: none; transition: right var(--t-rapida); }
#mappa-info #app-logo { font-size: var(--fs-sm); font-weight: 700; line-height: 1.2; color: var(--text); }
#mappa-info #piede-coord { margin: 0; }
@media (max-width: 720px) { #mappa-info { right: 8px; bottom: calc(var(--tab-h, 60px) + var(--footer-h, 0px) + 8px); } }

#mappa-info { flex-direction: row; align-items: center; gap: 10px; pointer-events: auto; }
#mappa-info .mappa-info-testi { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; pointer-events: none; }
#mappa-info #logo-ods img { display: block; height: 40px; width: auto; }
:root[data-tema="scuro"] #mappa-info #logo-ods img { filter: invert(1); }
.scheda-allerta-fissa { margin: 8px 0 0; }
.scheda-allerta-fissa .scheda-sez { margin-top: 0; }
.scheda-allerta-fissa .scheda-sez[open] { max-height: 40dvh; overflow-y: auto; }
.tooltip-magnitudo { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-right: 6px; vertical-align: middle; flex: none; }
.tooltip-magnitudo i { display: block; border: 1.5px solid; border-radius: 50%; box-sizing: border-box; }
.traffico-righe dt .tooltip-magnitudo { margin-right: 6px; }

/* Archivio storico dei terremoti: scelta del periodo, confronto tra due anni */
.terremoti-archivio-esito { display: flex; flex-direction: column; gap: 4px; }
.terremoti-archivio-tabella { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.terremoti-archivio-tabella th, .terremoti-archivio-tabella td { padding: 2px 4px; text-align: right; font-weight: 400; }
.terremoti-archivio-tabella th:first-child { text-align: left; color: var(--text-muted); }
.terremoti-archivio-tabella tr:first-child th { font-weight: 600; color: var(--text); }
.terremoti-archivio-avviso { padding: 4px 6px; border-left: 3px solid var(--accent); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.terremoti-confronto-grafici { display: flex; flex-direction: column; gap: 10px; }
.terremoti-confronto-grafico { margin: 0; }
.terremoti-confronto-grafico .terremoti-titolo { margin: 0 0 2px; }
.terremoti-confronto-grafico > svg { display: block; width: 100%; height: auto; overflow: visible; }
.grafico-grande-popup .terremoti-confronto-grafico.grande > svg { width: calc(100% - 80px); margin: 0 40px; }
.terremoti-confronto-grafico text { font-size: 10px; fill: var(--text-muted); }
.terremoti-confronto-grafico .asse-titolo { font-weight: 600; letter-spacing: .02em; }
.terremoti-confronto-grafico.grande text { font-size: 12px; }
.terremoti-confronto-grafico .barra-anno { fill: var(--text-muted); opacity: .55; }
.terremoti-confronto-grafico .barra-a { fill: #0ea5e9; }
.terremoti-confronto-grafico .barra-b { fill: #f97316; }
.terremoti-confronto-grafico .linea-mag { fill: none; stroke: var(--text); stroke-width: 1.3; }
.terremoti-confronto-grafico .punto-mag { fill: var(--text); }
.terremoti-confronto-grafico .linea-mediana { fill: none; stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 3; }
.terremoti-confronto-grafico .et-mediana { paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.terremoti-classi-comandi { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.terremoti-confronto-grafico .linea-a { fill: none; stroke: #0ea5e9; stroke-width: 2; }
.terremoti-confronto-grafico .linea-b { fill: none; stroke: #f97316; stroke-width: 2; }
.terremoti-confronto-grafico .griglia { stroke: var(--border-ui); stroke-width: .6; opacity: .55; }
.terremoti-confronto-grafico .asse { stroke: var(--border-ui); stroke-width: 1; }
.terremoti-confronto-grafico .punto-hit { fill: transparent; pointer-events: all; }
/* grafici del confronto: barre e punti sono gruppi di eventi, come nei grafici della scheda */
.terremoti-confronto-grafico .interattivo { cursor: crosshair; outline: none; }
.terremoti-confronto-grafico .interattivo:hover { filter: brightness(1.1); }
.terremoti-confronto-grafico .interattivo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.terremoti-archivio-istogramma i.interattivo { cursor: crosshair; outline: none; }
.terremoti-archivio-istogramma i.interattivo:hover { filter: brightness(1.12); box-shadow: 0 0 0 2px var(--accent); }
.terremoti-archivio-tabella td.interattivo { cursor: crosshair; outline: none; }
.terremoti-archivio-tabella td.interattivo:hover, .terremoti-archivio-tabella td.interattivo:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.terremoti-archivio-istogramma i.interattivo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.terremoti-confronto-grafico .griglia,
.terremoti-confronto-grafico .asse,
.terremoti-confronto-grafico text,
.terremoti-confronto-grafico .linea-mag,
.terremoti-confronto-grafico .linea-a,
.terremoti-confronto-grafico .linea-b { pointer-events: none; }
/* tooltip dei grafici: riquadro che segue il puntatore, sopra la scheda o il popup grande */
.grafico-tooltip { position: fixed; z-index: var(--z-tooltip-grafico); max-width: 280px; padding: 6px 10px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font-size: var(--fs-xs); line-height: 1.35; font-variant-numeric: tabular-nums; box-shadow: var(--ombra); pointer-events: none; }
.grafico-tooltip[hidden] { display: none; }
.terremoti-confronto-grafico.grande svg.grafico-zoom { cursor: crosshair; user-select: none; touch-action: none; }
.terremoti-confronto-grafico.grande svg.grafico-zoom.zoomato { cursor: grab; }
.terremoti-confronto-grafico.grande .brush { fill: var(--accent); opacity: .22; stroke: var(--accent); stroke-width: 1; pointer-events: none; }
.terremoti-confronto-grafico.grande rect { transition: opacity .12s; }
.terremoti-confronto-grafico.grande rect:hover { opacity: 1; }
.terremoti-archivio-griglia { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text); cursor: pointer; }
.terremoti-archivio-classi { margin: 10px 0 0; }
.terremoti-archivio-classi .terremoti-titolo { margin: 0 0 4px; }
.terremoti-archivio-istogramma { display: flex; gap: 6px; font-size: var(--fs-xs); color: var(--text-muted); text-align: center; }
.terremoti-archivio-istogramma > div { flex: 1 1 0; display: flex; flex-direction: column; gap: 2px; }
.terremoti-archivio-barre { display: flex; align-items: flex-end; gap: 2px; height: 56px; }
.terremoti-archivio-barre i { flex: 1 1 0; display: block; min-width: 0; border-radius: 2px 2px 0 0; }
.terremoti-archivio-colonna { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.terremoti-archivio-colonna i { position: relative; flex: none; display: block; width: 100%; min-width: 0; border-radius: 2px 2px 0 0; }
.terremoti-archivio-classi .terremoti-confronto-chiave { margin-bottom: 4px; }
.terremoti-archivio-classi.grande .terremoti-archivio-barre { height: 300px; padding-top: 20px; box-sizing: border-box; gap: 6px; }
.terremoti-archivio-conteggio { position: absolute; bottom: 100%; left: 0; right: 0; padding-bottom: 2px; font-size: 12px; line-height: 1; font-weight: 600; text-align: center; color: var(--text); }
.terremoti-archivio-classi.grande .terremoti-archivio-istogramma { gap: 12px; font-size: 12px; }
.terremoti-archivio-a { background: #0ea5e9; }
.terremoti-archivio-b { background: #f97316; }
.terremoti-confronto-chiave { display: flex; gap: 12px; font-size: var(--fs-xs); }
.terremoti-confronto-chiave > span { display: inline-flex; align-items: center; gap: 5px; }
.terremoti-confronto-chiave i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.terremoti-archivio .terremoti-archivio-larga { grid-column: 1 / -1; }
.terremoti-archivio select { width: 100%; min-width: 0; padding-inline: 4px; }
.legenda .terremoti-archivio .terremoti-filtri { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
#legende-raggio > .live-zoom-legenda:only-child { margin: 0; padding: 0; border: 0; }

/* Comandi dell'archivio: pulsanti veri, ben visibili in chiaro e in scuro */
.legenda .terremoti-archivio-btn { padding: 7px 12px; border: 1px solid var(--accent); border-radius: var(--r-sm); background: var(--accent); color: #1f1300; font: inherit; font-weight: 700; text-align: center; cursor: pointer; }
.legenda .terremoti-archivio-btn:hover, .legenda .terremoti-archivio-btn:focus-visible { filter: brightness(1.08); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.legenda .terremoti-archivio-btn.secondario { background: var(--surface); color: var(--text); border-color: var(--border-ui); }
.legenda .terremoti-archivio-btn.secondario:hover, .legenda .terremoti-archivio-btn.secondario:focus-visible { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: var(--accent); }
.legenda .terremoti-archivio-btn:disabled { opacity: .55; cursor: progress; filter: none; box-shadow: none; }
.legenda .terremoti-archivio-btn:active { transform: translateY(1px); }
.legenda .terremoti-archivio > .terremoti-archivio-btn { width: 100%; }
.legenda .terremoti-archivio > strong { margin-top: 4px; }
.scheda-sez-testo .tooltip-badge { align-self: flex-start; margin: 0 0 4px; }

/* Comune cliccato in mappa: conteggi dei terremoti e serie anno per anno */
.comune-sismico { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-ui); }
.comune-sismico-riga { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0; font-size: var(--fs-xs); }
.comune-sismico-etichetta { color: var(--text-muted); }
.comune-sismico-riga strong { text-align: right; font-weight: 600; }
.comune-sismico-dove { margin: -3px 0 0; }
.comune-sismico-titolo { margin: 10px 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.comune-sismico-serie { display: flex; align-items: flex-end; gap: 1px; height: 56px; }
.comune-sismico-serie i { flex: 1 1 0; min-width: 0; background: var(--accent); border-radius: 1px 1px 0 0; }
.comune-sismico-serie i.oggi { background: #d7263d; }
.comune-sismico-anni { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-muted); }
.comune-sismico-link { font-size: var(--fs-xs); }
.comune-sismico-altri { align-self: flex-start; font: inherit; font-size: var(--fs-xs); background: none; border: 1px solid var(--border-ui); border-radius: 999px; padding: 2px 10px; cursor: pointer; color: inherit; }
.comune-sismico-altri[hidden] { display: none; }

/* Ricerca per area: suggerimenti con tipo e contesto, pannello dei filtri a cascata sopra la barra */
#cerca-risultati li { list-style: none; }
#cerca-risultati button { display: flex; flex-direction: column; gap: 1px; }
#cerca-risultati button[aria-selected="true"] { background: var(--surface-hover); }
.cerca-tipo { font-size: var(--fs-2xs); color: var(--text-muted); }
#cerca-pannello { padding: 10px 14px 12px; background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--r-md); box-shadow: var(--ombra); max-height: min(70vh, 520px); overflow-y: auto; overscroll-behavior: contain; }
#cerca-pannello[hidden] { display: none; }
#cerca-pannello h2 { margin: 0 0 6px; font-size: var(--fs-sm); }
#cerca-pannello select { background: var(--surface); color: var(--text); border: 1px solid var(--border-ui); border-radius: var(--r-sm); }
.cerca-solo-eventi { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: var(--fs-xs); color: var(--text); }
.cerca-solo-eventi[hidden] { display: none; }
#cerca-pannello .terremoti-filtro { margin-top: 8px; }
#cerca-pannello label { display: block; font-size: var(--fs-xs); color: var(--text-muted); }
#cerca-pannello select { width: 100%; margin: 2px 0 8px; padding: 6px; }

/* Legenda terremoti: `.legenda div` impone il flex, il filtro si adatta alle colonne (due nella legenda, dove la
   magnitudo ha lo slider a due maniglie, tre nella scheda) e l'etichetta non sborda in quella accanto */
.legenda .terremoti-filtri { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); align-items: start; gap: 8px; }
.legenda .terremoti-filtro > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.terremoti-serie.con-mappa > .terremoti-testa { grid-column: 1 / -1; grid-row: 1; }

/* Sezione verticale: azioni, grafico profondità/distanza e legenda delle profondità */
.legenda .terremoti-sezione-azioni { display: flex; flex-wrap: nowrap; gap: 4px; margin: 6px 0; }
.legenda .terremoti-sezione-azioni .terremoti-archivio-btn { flex: 1 1 auto; min-width: 0; padding: 7px 6px; font-size: .85em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* i cerchi del grafico: bordo del colore dello sfondo, così restano distinti dove si sovrappongono */
.terremoti-confronto-grafico .punto-sezione { fill-opacity: .72; stroke: var(--surface); stroke-width: .5; }

/* Rampa di colori delle mappe di densità e per territorio */
.terremoti-rampa { margin: 8px 0 0; }
.terremoti-rampa-barra { display: block; height: 10px; border-radius: 5px; border: 1px solid var(--border-ui); }
.terremoti-rampa-estremi { display: block; margin-top: 2px; font-size: .85em; color: var(--text-muted); text-align: right; }

/* Pannello «Mappe»: un tab per mappa sotto il titolo */
.mappe-tab { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.mappe-tempo-reale { border-style: dashed; }
.mappe-tempo-reale[aria-pressed="true"] { border-style: solid; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); font-weight: 700; }
.mappe-tab-btn { padding: 4px 10px; border: 1px solid var(--border-ui); border-radius: 999px; background: none; color: var(--text-muted); font: inherit; font-size: var(--fs-sm, .85em); cursor: pointer; }
.mappe-tab-btn[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #1f1300; font-weight: 700; }
#mappe-pannello .terremoti-filtri { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
#mappe-pannello .terremoti-archivio-btn { padding: 7px 12px; border: 1px solid var(--accent); border-radius: var(--r-sm); background: var(--accent); color: #1f1300; font: inherit; font-weight: 700; text-align: center; cursor: pointer; }
#mappe-pannello .terremoti-archivio-btn.secondario { background: none; color: var(--text); border-color: var(--border-ui); }
#mappe-pannello .terremoti-sezione-azioni { display: flex; flex-wrap: nowrap; gap: 4px; margin: 6px 0; }
#mappe-pannello .terremoti-sezione-azioni .terremoti-archivio-btn { flex: 1 1 auto; min-width: 0; padding: 7px 6px; font-size: .85em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mappe-pannello .terremoti-pannello[hidden] { display: none; }
.terremoti-sezione-prof, .legenda .terremoti-sezione-prof { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; margin: 6px 0 0; font-size: .85em; }
.terremoti-sezione-prof > div, .legenda .terremoti-sezione-prof > div { display: flex; align-items: center; justify-content: flex-start; gap: 6px; }
.terremoti-legenda-esagoni, .legenda .terremoti-legenda-esagoni { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; margin: 6px 0 0; font-size: .85em; }
.terremoti-legenda-esagoni > div { display: flex; align-items: center; gap: 6px; }
.terremoti-anim-comandi { display: flex; gap: 6px; margin: 6px 0; }
.terremoti-anim-comandi button { flex: 1; min-width: 0; padding: 6px 4px; }
.esagono-popup .maplibregl-popup-content { min-width: 250px; padding: 12px 14px; }
.esagono-scheda { display: flex; flex-direction: column; gap: 6px; font-size: .88em; }
.esagono-eventi { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.esagono-eventi li { display: flex; align-items: baseline; gap: 6px; }
.terremoti-legenda-esagoni i.incendi-campione { display: inline-block; flex: none; width: 14px; height: 10px; border: 1.5px solid rgba(0, 0, 0, .35); border-radius: 2px; }
/* nelle legende in mappa `.legenda div` e `.legenda i` renderebbero la rampa una riga con un quadratino */
.legenda .terremoti-rampa { display: block; min-width: 150px; margin: 4px 0 0; }
.legenda .terremoti-rampa-barra { display: block; width: 100%; height: 12px; border-radius: 6px; }
.legenda .terremoti-rampa-estremi { display: block; }

/* vista 3D della sezione verticale (popup): il canvas sta nella cella dell'svg */
.terremoti-serie.con-mappa > canvas.grafico-3d { grid-column: 1; grid-row: 3; width: 100%; height: var(--alt-grafico); border: 1px solid var(--border-ui); border-radius: var(--r-sm); cursor: grab; touch-action: none; user-select: none; }
canvas.grafico-3d.trascina { cursor: grabbing; }
.terremoti-serie.con-mappa > canvas.grafico-3d[hidden] { display: none; }
.grafico-3d-tip { position: absolute; z-index: 3; max-width: 240px; padding: 4px 8px; font-size: 12px; background: var(--bg-elev, #fff); color: var(--text, #111); border: 1px solid var(--border-ui); border-radius: var(--r-sm); pointer-events: none; }
.grafico-3d-comandi { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-left: 12px; font-size: 12px; }
.grafico-3d-comandi[hidden] { display: none; }
.grafico-3d-interruttore, .grafico-3d-comandi button { font: inherit; font-size: 12px; padding: 2px 10px; cursor: pointer; background: var(--bg-elev, transparent); color: inherit; border: 1px solid var(--border-ui); border-radius: var(--r-sm); }
.grafico-3d-interruttore { margin-left: 12px; }
.terremoti-serie.vista-3d .zoom-aiuto, .terremoti-serie.vista-3d .zoom-riga { display: none; }
.grafico-3d-interruttore { white-space: nowrap; align-self: center; }
.grafico-3d-comandi label { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
/* vista 3D nel grafico piccolo della scheda: stessa proporzione dell'svg (400 × 210) */
.terremoti-confronto-grafico { position: relative; }
.terremoti-confronto-grafico:not(.grande) canvas.grafico-3d { display: block; width: 100%; aspect-ratio: 400 / 210; border: 1px solid var(--border-ui); border-radius: var(--r-sm); cursor: grab; touch-action: none; user-select: none; }
.terremoti-confronto-grafico:not(.grande) canvas.grafico-3d[hidden] { display: none; }
.terremoti-confronto-grafico:not(.grande) .grafico-3d-comandi { display: flex; margin: 4px 0 0; }
.terremoti-confronto-grafico:not(.grande) .grafico-3d-comandi[hidden] { display: none; }
.terremoti-confronto-grafico:not(.grande) .grafico-3d-interruttore { margin: 0 0 0 8px; }

/* Popup «Come si disegna la sezione»: disegno in tre passi, aperto quando si accende la sezione verticale */
.sezione-guida-velo { position: fixed; inset: 0; z-index: var(--z-velo); display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .45); }
.sezione-guida { width: min(620px, 100%); max-height: 100%; overflow: auto; padding: 12px 16px 16px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--ombra); font-size: var(--fs-base); }
.sezione-guida-testata { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sezione-guida-testata strong { font-size: var(--fs-md); }
.sezione-guida-x { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text-muted); cursor: pointer; }
.sezione-guida-x:hover { color: var(--accent-strong); background: var(--surface-hover); }
.sezione-guida-x:focus-visible, .sezione-guida-ok:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sezione-guida p { margin: 8px 0; color: var(--text-muted); font-size: var(--fs-sm); }
.sezione-guida-figura { margin: 8px 0 12px; }
.sezione-guida-svg { display: block; width: 100%; height: auto; }
.sezione-guida-svg .sg-mappa { fill: var(--surface-alt); stroke: var(--border); }
.sezione-guida-svg .sg-costa { fill: var(--surface-hover); }
.sezione-guida-svg .sg-fascia { fill: #0ea5e9; fill-opacity: .18; stroke: #0369a1; stroke-width: 1; }
.sezione-guida-svg .sg-linea { stroke: #0369a1; stroke-width: 2.5; stroke-dasharray: 5 4; stroke-linecap: round; }
.sezione-guida-svg .sg-punto { fill: #0369a1; stroke: #fff; stroke-width: 1.5; }
.sezione-guida-svg .sg-lettera { fill: #fff; font-family: inherit; font-weight: 700; font-size: 9px; }
.sezione-guida-svg .sg-lettera-sm { fill: #0369a1; font-family: inherit; font-weight: 700; font-size: 10px; }
.sezione-guida-svg .sg-mano { fill: var(--text); stroke: var(--surface); stroke-width: 1; }
.sezione-guida-svg .sg-freccia { fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sezione-guida-svg .sg-asse { stroke: var(--text-muted); stroke-width: 1; }
.sezione-guida-svg .sg-evento { stroke: #fff; stroke-width: .5; fill-opacity: .85; }
.sezione-guida-svg .sg-p0 { fill: #f4a300; } .sezione-guida-svg .sg-p1 { fill: #d9480f; } .sezione-guida-svg .sg-p2 { fill: #7b2cbf; }
.sezione-guida-svg .sg-num { fill: var(--accent-strong); }
.sezione-guida-svg .sg-num-t { fill: var(--accent-strong-ink); font-family: inherit; font-weight: 700; font-size: 12px; }
.sezione-guida-svg .sg-didascalia { fill: var(--text); font-family: inherit; font-weight: 600; font-size: 12px; }
.sezione-guida-piede { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.sezione-guida-piede label { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--text-muted); cursor: pointer; }
.sezione-guida-piede input { accent-color: var(--accent-strong); }
.sezione-guida-ok { padding: 7px 16px; border: 1px solid var(--accent); border-radius: var(--r-sm); background: var(--accent); color: #1f1300; font: inherit; font-weight: 700; cursor: pointer; }
.sezione-guida-ok:hover { filter: brightness(1.08); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.sezione-guida .sezione-guida-dove { margin: 0 0 4px; color: var(--text); font-weight: 600; }
.sezione-guida-comandi { margin: 0 0 12px; padding-left: 18px; font-size: var(--fs-sm); color: var(--text-muted); }

/* Legenda dei terremoti: evento più recente, un clic apre la scheda */
.ultimo-evento { display: flex; align-items: center; gap: 8px; width: 100%; margin: 6px 0; padding: 6px 8px; border: 1px solid var(--border-ui); border-radius: var(--r-sm); background: var(--surface-alt); color: var(--text); font: inherit; font-size: var(--fs-xs); text-align: left; cursor: pointer; }
.ultimo-evento:hover { border-color: var(--accent); background: var(--accent-soft); }
.ultimo-evento[hidden] { display: none; }
.ultimo-evento-testi { display: flex; flex-direction: column; min-width: 0; }
.ultimo-evento-luogo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ultimo-evento-quando { color: var(--text-muted); }
/* telefono: la legenda ridotta è solo la barra «Legenda», stretta così non tocca il riquadro titolo/coordinate a destra */
@media (max-width: 720px) { #legende-box.ridotta { width: 128px; } }
.opzioni-overlay .tema-colora-per { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 2px; padding: 4px 8px; font-size: var(--fs-sm); }
.opzioni-overlay .tema-colora-per select { max-width: 55%; font: inherit; font-size: var(--fs-xs); }

/* PDF della scheda: pagine A4 (794×1123 px a 96 dpi) costruite fuori schermo e rasterizzate; sempre chiare, a prescindere dal tema */
.pdf-radice { position: fixed; left: -10000px; top: 0; width: 794px; z-index: -1; pointer-events: none; background: #fff; color: #1b1f24; font-family: inherit; }
.pdf-pagina { display: flex; flex-direction: column; box-sizing: border-box; overflow: hidden; background: #fff; }
.pdf-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; box-sizing: border-box; padding: 0 40px; background: #0b4f7a; color: #fff; }
.pdf-banner h1 { margin: 0; font-size: 22px; line-height: 1.2; }
.pdf-banner p { margin: 3px 0 0; font-size: 13px; }
.pdf-banner-ridotto h1 { font-size: 15px; }
.pdf-banner-data { flex: none; font-size: 13px; }
.pdf-corpo { box-sizing: content-box; padding: 14px 40px; overflow: hidden; }
.pdf-riga { display: grid; grid-template-columns: 349px 349px; column-gap: 16px; align-items: start; margin-bottom: 14px; }
.pdf-riga-piena { display: block; }
.pdf-blocco { box-sizing: border-box; }
.pdf-stralcio { margin: 0; }
.pdf-stralcio img { display: block; width: 100%; border: 1px solid #999; }
.pdf-dati { margin: 0; font-size: 13px; }
.pdf-dati dt { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #0b4f7a; }
.pdf-dati dd { margin: 0 0 10px; }
.pdf-radice .scheda-sez { border: 0; box-shadow: none; }
.pdf-radice summary { list-style: none; }
.pdf-radice summary::-webkit-details-marker { display: none; }
.pdf-piede { display: flex; align-items: center; gap: 14px; box-sizing: border-box; padding: 0 40px; border-top: 3px solid #0b4f7a; color: #333; }
.pdf-logo { flex: none; height: 36px; width: auto; }
.pdf-piede-testo { flex: 1; min-width: 0; }
.pdf-link { margin: 0 0 3px; font-size: 11px; font-weight: 600; color: #0b4f7a; }
.pdf-disclaimer { margin: 0; font-size: 10px; line-height: 1.3; }
.pdf-pagina-n { flex: none; font-size: 11px; white-space: nowrap; }
.pdf-h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 15px; line-height: 1.3; color: #0b4f7a; }
