:root {
  --ink: #efeaff;
  --ink-soft: rgba(239, 234, 255, 0.72);
  --ink-faint: rgba(239, 234, 255, 0.45);
  --violet: #8f7bff;
  --violet-glow: rgba(143, 123, 255, 0.45);
  --glass: rgba(14, 11, 32, 0.56);
  --glass-line: rgba(176, 160, 255, 0.2);
  --space: #04030a;
  --radius: 14px;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  /* linea del tempo in basso e ciò che sta sopra di lei */
  --tb-b: max(12px, env(safe-area-inset-bottom));
  --tb-h: 58px;
  --ev-h: 30px;
  --ln-h: 0px; /* barre delle ricerche (D33): le imposta lanes.js */
  --above-tl: calc(var(--tb-b) + var(--tb-h) + var(--ev-h) + 18px + var(--ln-h));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--space); color: var(--ink); font-family: var(--font); }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }

#stars {
  position: fixed; inset: 0;
  background:
    radial-gradient(1200px 800px at 50% 55%, rgba(60, 40, 140, 0.22), transparent 70%),
    radial-gradient(1px 1px at 12% 22%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1px 1px at 78% 14%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(1.5px 1.5px at 64% 82%, rgba(210,200,255,.6), transparent 60%),
    radial-gradient(1px 1px at 30% 70%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1px 1px at 88% 58%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(1.2px 1.2px at 46% 9%, rgba(230,220,255,.55), transparent 60%),
    radial-gradient(1px 1px at 6% 88%, rgba(255,255,255,.4), transparent 60%),
    var(--space);
}

#map { position: fixed; inset: 0; }

/* Apertura: copre la preparazione grafica e si dissolve sulla Terra già pronta */
#intro {
  position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 18px;
  background: radial-gradient(900px 600px at 50% 55%, rgba(60, 40, 140, 0.25), transparent 70%), var(--space);
  transition: opacity 0.9s ease;
}
#intro.gone { opacity: 0; pointer-events: none; }
#intro .mark { font-size: 15px; letter-spacing: 0.9em; margin-right: -0.9em; color: var(--ink-soft); font-weight: 600; }
#intro .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--violet); box-shadow: 0 0 18px var(--violet); animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.35; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { #intro .pulse { animation: none; } }
#map .maplibregl-canvas { outline: none; }
#particles, #labels { position: fixed; inset: 0; pointer-events: none; }
#labels { overflow: hidden; transition: opacity .6s ease; }
/* Nella storia i nomi sono quelli di oggi: restano come riferimento, attenuati */
#labels.riferimento { opacity: 0.68; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* --- Anno: sempre visibile, in alto al centro ------------------------------- */
#time {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: grid; justify-items: center; padding: 4px 6px; z-index: 5; max-width: calc(100vw - 20px);
}
#time .bar { display: flex; align-items: center; gap: 2px; max-width: 100%; }
/* Pannello del tempo aperto: sopra Esplora e ricerca (sul telefono si allarga sopra di loro) */
#time:has(#timeline:not([hidden])) { z-index: 8; }
#time .step:disabled { opacity: .3; cursor: default; background: transparent; }
#time .step {
  width: 36px; height: 40px; border: 0; background: transparent; border-radius: 10px;
  font-size: 26px; line-height: 1; color: var(--ink-soft); cursor: pointer;
}
#time .step:hover { color: var(--ink); background: rgba(143, 123, 255, 0.14); }
#yearValue {
  min-width: 118px; min-height: 44px; padding: 3px 10px; border: 0; background: transparent; cursor: pointer;
  display: grid; justify-items: center; align-content: center; gap: 2px; line-height: 1;
  border-radius: 10px; position: relative;
}
#yearValue .v { font-size: 32px; font-weight: 600; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; text-shadow: 0 0 18px var(--violet-glow); }
#yearValue .u { font-size: 11px; font-weight: 500; letter-spacing: 0.03em; color: var(--ink-soft); white-space: nowrap; max-width: min(56vw, 320px); overflow: hidden; text-overflow: ellipsis; }
#yearValue { min-width: 0; }
#yearValue:has(.u:not([hidden])) .v { font-size: 26px; }
#yearValue:hover { background: rgba(143, 123, 255, 0.1); }
#time.preparing #yearValue::after {
  content: ""; position: absolute; left: 22%; right: 22%; bottom: 3px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--violet), transparent);
  animation: sweep 0.9s ease-in-out infinite;
}
@keyframes sweep { 0% { opacity: .2; transform: scaleX(.3); } 50% { opacity: 1; transform: scaleX(1); } 100% { opacity: .2; transform: scaleX(.3); } }
/* Linea del tempo a cascata */
#timeline { grid-column: 1 / -1; padding: 8px 8px 8px; width: min(92vw, 580px); display: grid; gap: 9px; }
#timeline[hidden] { display: none; }
#timeCrumbs { display: flex; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--ink-faint); }
#timeCrumbs button { border: 0; background: transparent; color: var(--ink-soft); padding: 3px 6px; border-radius: 7px; cursor: pointer; font-size: 12px; }
#timeCrumbs button:hover { background: rgba(143, 123, 255, 0.14); color: var(--ink); }
#timeCrumbs button[aria-current="true"] { color: var(--ink); font-weight: 600; background: rgba(143, 123, 255, 0.14); }
#timeCrumbs button.deep { color: var(--ink-faint); }
#timeCrumbs .sep { opacity: .5; }
#timeChips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow: auto; }
#timeChips button { border: 1px solid var(--glass-line); background: rgba(255, 255, 255, 0.03); color: var(--ink-soft); border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
#timeChips button small { color: var(--ink-faint); margin-left: 6px; font-size: 11px; }
#timeChips button:hover { color: var(--ink); border-color: rgba(176, 160, 255, 0.45); }
#timeChips button[aria-pressed="true"] { background: rgba(143, 123, 255, 0.3); color: var(--ink); border-color: rgba(176, 160, 255, 0.6); }
#timeNote { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-soft); }
#timeNote:empty { display: none; }
#timeline .row { display: flex; gap: 8px; }
#timeGoForm { flex: 1; margin: 0; display: flex; gap: 6px; min-width: 0; }
#timeGoBtn { height: 34px; padding: 0 12px; border: 1px solid rgba(176, 160, 255, 0.45); background: rgba(143, 123, 255, 0.22); color: var(--ink); border-radius: 9px; cursor: pointer; font-size: 13px; white-space: nowrap; }
#timeGoBtn:hover { background: rgba(143, 123, 255, 0.36); }
#timeGo { flex: 1; min-width: 0; width: 100%; height: 34px; border: 1px solid var(--glass-line); background: rgba(255, 255, 255, 0.04); color: var(--ink); border-radius: 9px; padding: 0 10px; font-size: 13px; outline: none; }
#timeGo::placeholder { color: var(--ink-faint); }
#timeGo:focus { border-color: rgba(176, 160, 255, 0.6); }
#timeGo.err { border-color: #ff8a8a; }

/* --- Ricerca ------------------------------------------------------------------ */
#search { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; width: 250px; z-index: 5; padding: 0; }
#searchInput {
  width: 100%; height: 44px; padding: 0 14px; border: 0; background: transparent; color: var(--ink);
  font-size: 15px; outline: none; border-radius: var(--radius);
}
#searchInput::placeholder { color: var(--ink-faint); }
#searchResults { list-style: none; margin: 0; padding: 4px; border-top: 1px solid var(--glass-line); max-height: 50vh; overflow: auto; }
#searchResults li { padding: 8px 10px; border-radius: 9px; cursor: pointer; font-size: 14px; }
#searchResults li small { color: var(--ink-faint); margin-left: 6px; }
#searchResults li[aria-selected="true"], #searchResults li:hover { background: rgba(143, 123, 255, 0.18); }

/* --- Esplora ------------------------------------------------------------------ */
#explore { position: fixed; top: max(14px, env(safe-area-inset-top)); left: 14px; z-index: 5; }
#exploreBtn { height: 44px; padding: 0 18px; cursor: pointer; font-size: 15px; letter-spacing: 0.04em; }
#exploreBtn[aria-expanded="true"] { border-color: rgba(176, 160, 255, 0.5); }
#exploreBtn .burger { margin-right: 4px; opacity: .8; }

/* Menu laterale «Livelli»: tutti gli elementi del mondo per categorie, chiudibile */
#explorePanel.drawer {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 14px; bottom: max(14px, env(safe-area-inset-bottom));
  width: 310px; margin: 0; padding: 0; display: flex; flex-direction: column; z-index: 9; overflow: hidden;
}
#explorePanel[hidden] { display: none; }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 8px 16px; border-bottom: 1px solid var(--glass-line); }
.drawer h2 { margin: 0; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); font-weight: 600; }
#drawerClose { width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-soft); font-size: 17px; cursor: pointer; }
#drawerClose:hover { background: rgba(143, 123, 255, 0.15); color: var(--ink); }
#layerTree { overflow: auto; padding: 4px 8px 8px; flex: 1; overscroll-behavior: contain; }
#layerTree details { border-bottom: 1px solid rgba(176, 160, 255, 0.09); padding: 2px 0 4px; }
#layerTree summary { list-style: none; cursor: pointer; padding: 9px 8px; font-size: 13.5px; font-weight: 600; color: var(--ink); display: flex; align-items: baseline; gap: 8px; border-radius: 8px; }
#layerTree summary::-webkit-details-marker { display: none; }
#layerTree summary::before { content: "▸"; width: 10px; opacity: .55; transition: transform .2s; display: inline-block; }
#layerTree details[open] summary::before { transform: rotate(90deg); }
#layerTree summary small { font-weight: 400; color: var(--ink-faint); font-size: 11.5px; }
#layerTree summary:hover { background: rgba(143, 123, 255, 0.08); }
.sw { width: 100%; display: grid; grid-template-columns: 30px 1fr; column-gap: 10px; align-items: center; text-align: left; padding: 7px 8px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; color: var(--ink-soft); font-size: 14px; }
.sw:hover { background: rgba(143, 123, 255, 0.1); color: var(--ink); }
.sw .knob { width: 28px; height: 16px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); position: relative; transition: background .2s; }
.sw .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink-soft); transition: transform .2s; }
.sw[aria-checked="true"] { color: var(--ink); }
.sw[aria-checked="true"] .knob { background: var(--violet); }
.sw[aria-checked="true"] .knob::after { transform: translateX(12px); background: #fff; }
.sw small { grid-column: 2; color: var(--ink-faint); font-size: 11.5px; margin-top: 1px; }
.sw small.warn { color: #ffcf8a; }
.sw.sub { padding-left: 30px; font-size: 13px; }
.sw.dim { opacity: .5; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px 8px 6px; }
.seg button { border: 1px solid var(--glass-line); background: transparent; color: var(--ink-soft); border-radius: 8px; padding: 7px 8px; font-size: 13px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: rgba(143, 123, 255, 0.28); color: var(--ink); border-color: rgba(176, 160, 255, 0.55); }
.soon-item { display: flex; gap: 6px; padding: 5px 8px 5px 26px; color: var(--ink-faint); font-size: 12.5px; cursor: help; }
.soon-item b { font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.soon-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soon-item::after { content: "in arrivo"; font-size: 11px; opacity: .75; white-space: nowrap; }
.fam { padding: 8px 8px 2px 26px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); }
.look { padding: 8px 0 4px; }
.look-title { padding: 2px 8px 4px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); }

/* «+ Aggiungi» */
.add { padding: 6px 8px 8px; border-bottom: 1px solid rgba(176, 160, 255, 0.09); }
.add-btn { width: 100%; height: 38px; border: 1px dashed rgba(176, 160, 255, 0.55); border-radius: 10px; background: rgba(143, 123, 255, 0.1); color: var(--ink); font-size: 14px; cursor: pointer; }
.add-btn:hover { background: rgba(143, 123, 255, 0.2); }
#addForm { margin-top: 8px; display: grid; gap: 8px; }
#addText { width: 100%; resize: vertical; min-height: 64px; border: 1px solid var(--glass-line); background: rgba(255, 255, 255, 0.04); color: var(--ink); border-radius: 9px; padding: 8px 10px; font: inherit; font-size: 13px; outline: none; }
#addText:focus { border-color: rgba(176, 160, 255, 0.6); }
#addTitle { width: 100%; height: 32px; border: 1px solid var(--glass-line); background: rgba(255, 255, 255, 0.04); color: var(--ink); border-radius: 9px; padding: 0 10px; font: inherit; font-size: 12.5px; outline: none; }
#addTitle:focus { border-color: rgba(176, 160, 255, 0.6); }
/* Le domande specifiche di quell'anno (D30) */
.add-plan { margin: 8px 0 4px; border: 1px solid var(--glass-line); border-radius: 9px; padding: 6px 10px; background: rgba(255, 255, 255, 0.03); }
.add-plan summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.add-plan ol { margin: 6px 0 4px; padding-left: 18px; display: grid; gap: 5px; }
.add-plan li { font-size: 12px; line-height: 1.4; color: var(--ink-soft); }
.add-plan li b { display: block; font-weight: 600; color: var(--ink); }
.add-plan li.open span { color: #ffcf8a; }
.add-next { margin: 4px 0 2px; font-size: 12px; line-height: 1.4; font-weight: 600; color: #7ee2a8; }
.add-next.cerca, .add-next.rivedi { color: #ffcf8a; }
.add-next.non-esisteva { color: #8fd3ff; }
/* «Calcola vero meteo» (D31): pulsante e fotografia dichiarata (calcolata ora · registrata · ipotetica) */
#meteoVero { position: fixed; left: 14px; top: calc(max(14px, env(safe-area-inset-top)) + 54px); z-index: 5; display: grid; gap: 6px; width: min(330px, calc(100vw - 28px)); pointer-events: none; }
#meteoVeroBtn { pointer-events: auto; justify-self: start; height: 36px; padding: 0 14px; cursor: pointer; font-size: 13.5px; color: var(--ink); }
#meteoVeroBtn::before { content: "☁"; margin-right: 7px; opacity: .85; }
#meteoVeroBtn[aria-expanded="true"] { border-color: rgba(176, 160, 255, 0.6); }
#mfCard { pointer-events: auto; padding: 10px 12px; font-size: 12.5px; line-height: 1.45; max-height: 46vh; overflow: auto; }
#mfCard[hidden] { display: none; }
.mf-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.mf-head b { font-weight: 650; }
.mf-tipo { font-size: 11px; border-radius: 999px; padding: 1px 8px; border: 1px solid currentColor; white-space: nowrap; }
.mf-tipo.t-calcolato { color: #7ee2a8; } .mf-tipo.t-registrato { color: #8fd3ff; } .mf-tipo.t-ipotetico { color: #ff9aa6; }
.mf-spiega { margin: 6px 0 0; color: var(--ink-soft); }
.mf-spiega.warn { color: #ffcf8a; }
.mf-fonte { margin: 4px 0 0; color: var(--ink-faint); font-size: 11.5px; }
#mfCard .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#mfCard button { height: 30px; padding: 0 11px; border: 1px solid var(--glass-line); border-radius: 8px; background: rgba(255, 255, 255, 0.05); color: var(--ink); font-size: 12.5px; cursor: pointer; }
#mfCard button.primary { background: rgba(143, 123, 255, 0.35); border-color: rgba(176, 160, 255, 0.6); }
#mfCard .mf-off { margin-top: 8px; }
body.origini #meteoVero, body.scenario #meteoVero { display: none; }
@media (max-width: 640px) { #meteoVero { top: calc(max(14px, env(safe-area-inset-top)) + 110px); } }
.add .row { display: flex; gap: 6px; flex-wrap: wrap; }
.add .row button { height: 32px; padding: 0 12px; border: 1px solid var(--glass-line); background: transparent; color: var(--ink-soft); border-radius: 8px; cursor: pointer; font-size: 13px; }
.add .row button.primary { border-color: rgba(176, 160, 255, 0.5); background: rgba(143, 123, 255, 0.28); color: var(--ink); }
.add .row button:disabled { opacity: .6; cursor: default; }
.add-note { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--ink-faint); }
#addResult { margin-top: 10px; padding: 10px; border: 1px solid var(--glass-line); border-radius: 10px; background: rgba(255, 255, 255, 0.03); display: grid; gap: 8px; }
.add-state { font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.add-state.ok { color: #7ee2a8; } .add-state.warn { color: #ffcf8a; } .add-state.err { color: #ff9aa6; }
.add-chain { font-size: 12.5px; line-height: 1.45; color: var(--ink); }
.add-card { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 12px; }
.add-card dt { color: var(--ink-faint); }
.add-card dd { margin: 0; color: var(--ink-soft); }
.add-forms { font-size: 12px; color: var(--ink-soft); }
.req { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 26px; font-size: 12.5px; color: var(--ink-soft); }
.req span { flex: 1; }
.req button { border: 0; background: transparent; color: var(--ink-faint); cursor: pointer; font-size: 15px; }

/* Legenda universale degli strati */
#legend { max-height: calc(100vh - 170px); overflow: auto; }
#legend .lg + .lg { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--glass-line); }
#legend .cats { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 3px; font-size: 12px; color: var(--ink-soft); }
#legend .cats i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }
#legend .warn { color: #ffcf8a; }
.panel-note { margin: 0; padding: 8px 16px 12px; font-size: 11.5px; color: var(--ink-faint); line-height: 1.45; border-top: 1px solid var(--glass-line); }

/* --- Legenda ------------------------------------------------------------------ */
#legend { position: fixed; left: 14px; bottom: calc(var(--above-tl) + 26px); width: 250px; padding: 12px 14px; z-index: 4; font-size: 13px; }
#legend h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
#legend .item { margin: 8px 0; transition: opacity .5s ease; }
#legend .item .bar { height: 7px; border-radius: 4px; margin-top: 4px; }
#legend .item .range { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
#legend .sym { display: inline-block; width: 22px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
#legend .reliability { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--glass-line); font-size: 12px; color: var(--ink-soft); }
#legend .reliability b { color: #ffcf8a; font-weight: 600; }

/* --- Camera e stato ------------------------------------------------------------- */
#camera { position: fixed; right: 14px; bottom: calc(var(--above-tl) + 26px); display: grid; z-index: 4; padding: 4px; }
#camera button { width: 40px; height: 40px; border: 0; background: transparent; font-size: 20px; cursor: pointer; border-radius: 10px; color: var(--ink-soft); }
#camera button:hover { background: rgba(143, 123, 255, 0.15); color: var(--ink); }
#camera .divider { display: block; height: 1px; margin: 4px 8px; background: var(--glass-line); }
#camera button.icon { display: grid; place-items: center; }
#camera svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
#camera svg .fill { fill: currentColor; stroke: none; }
#camera button[aria-pressed="true"] { background: rgba(143, 123, 255, 0.28); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(176, 160, 255, 0.45); }

/* Dissolvenza globo ↔ carta: la foto dell'ultimo fotogramma si dissolve sulla nuova vista */
#xfade { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }

#toast {
  position: fixed; left: 50%; top: calc(max(14px, env(safe-area-inset-top)) + 64px); transform: translateX(-50%); z-index: 6;
  padding: 8px 14px; border-radius: 10px; font-size: 13px; background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: opacity .4s ease;
}

/* Avviso «grafica leggera» */
#gfxNote {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(max(14px, env(safe-area-inset-top)) + 66px); z-index: 5;
  width: min(580px, calc(100vw - 28px)); padding: 10px 40px 10px 14px; font-size: 13px; line-height: 1.5; color: var(--ink-soft);
}
#gfxNote b { color: var(--ink); }
#gfxNote i { font-style: normal; color: var(--ink); }
#gfxNote code { font-family: Consolas, ui-monospace, monospace; font-size: 12px; color: var(--ink); background: rgba(143, 123, 255, 0.18); padding: 1px 5px; border-radius: 5px; user-select: all; }
#gfxNote button { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); font-size: 18px; line-height: 1; cursor: pointer; }
#gfxNote button:hover { background: rgba(143, 123, 255, 0.15); color: var(--ink); }
@media (max-width: 640px) { #gfxNote { top: calc(max(14px, env(safe-area-inset-top)) + 124px); } }

/* Grafica leggera: senza scheda grafica anche le sfocature del «vetro» si ricalcolano a ogni fotogramma */
.grafica-leggera .glass, .grafica-leggera #toast { backdrop-filter: none; -webkit-backdrop-filter: none; --glass: rgba(14, 11, 32, 0.9); }
.grafica-leggera .atlante .glass { --glass: rgba(20, 17, 40, 0.92); }

/* --- Origini (tappa 6, D14) ------------------------------------------------------------------ */
#origins { position: fixed; inset: 0; z-index: 3; opacity: 0; transition: opacity .6s ease; background: #000; }
#origins.on { opacity: 1; }
#originsCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
body.origini #map, body.origini #labels, body.origini #particles, body.origini #legend, body.origini #camera, body.origini #status, body.origini #search { visibility: hidden; }
#oCard { position: absolute; left: 14px; top: calc(max(14px, env(safe-area-inset-top)) + 58px); width: min(360px, calc(100vw - 28px)); max-height: calc(100vh - 260px); overflow: auto; padding: 12px 16px 12px; }
#oCard h2 { margin: 2px 0; font-size: 19px; font-weight: 650; }
#oCard p { margin: 6px 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); }
.o-kicker { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); }
.o-when { font-size: 13px; color: #ffcf8a; font-variant-numeric: tabular-nums; }
.o-row { font-size: 12.5px; color: var(--ink-soft); margin: 3px 0; }
.o-aff { margin-top: 8px; padding: 6px 0 0 9px; border-top: 1px solid var(--glass-line); border-left: 3px solid #8fd3ff; font-size: 12px; line-height: 1.45; color: var(--ink-soft); }
.o-aff.aff-OSSERVATO { border-left-color: #7ee2a8; } .o-aff.aff-RICOSTRUITO { border-left-color: #8fd3ff; } .o-aff.aff-STIMATO { border-left-color: #ffcf8a; } .o-aff.aff-IPOTETICO { border-left-color: #ff9aa6; }
.o-hint { margin-top: 6px; font-size: 11.5px; color: var(--ink-faint); }
.o-hyps { margin-top: 10px; padding: 8px 10px; border: 1px dashed rgba(255, 154, 166, 0.55); border-radius: 10px; background: rgba(255, 154, 166, 0.06); }
.o-hyps-title { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #ff9aa6; }
.o-hyp { margin: 7px 0 0; }
.o-hyp b { font-size: 13px; }
.o-hyp p { margin: 2px 0 0 !important; font-size: 12.5px !important; }
.o-badge { margin-left: 6px; font-size: 10.5px; color: #ff9aa6; border: 1px solid rgba(255, 154, 166, 0.5); border-radius: 999px; padding: 0 6px; }
#oLensCard { position: absolute; right: 14px; top: calc(max(14px, env(safe-area-inset-top)) + 58px); width: min(370px, calc(100vw - 28px)); max-height: calc(100vh - 90px - var(--above-tl)); overflow: auto; padding: 12px 14px; }
/* Lente filmata (D19): il laboratorio della cella */
.lab-title { font-size: 12.5px; color: #ffcf8a; margin-top: 2px; }
.lab-canvas { display: block; width: 100%; aspect-ratio: 8 / 5; margin: 8px 0 6px; border-radius: 10px; background: #06050d; cursor: pointer; touch-action: manipulation; box-shadow: inset 0 0 0 1px rgba(255, 207, 90, 0.35); }
.lab-sel { font-size: 12.5px; line-height: 1.45; color: var(--ink-soft); min-height: 36px; }
.lab-sel b { color: var(--ink); }
.lab-intro { margin: 6px 0; font-size: 12px; line-height: 1.45; color: var(--ink-soft); }
.lab-temp { display: grid; gap: 3px; margin: 8px 0; font-size: 12px; color: var(--ink-soft); }
.lab-temp .row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.lab-temp input { width: 100%; accent-color: #ffcf5a; margin: 0; }
.lab-soglia { font-size: 11.5px; color: var(--ink-faint); }
.lab-exp { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.lab-exp-t { font-size: 11.5px; color: var(--ink-faint); }
.lab-exp button, .lab-reset { border: 1px solid rgba(255, 207, 90, 0.5); background: rgba(255, 207, 90, 0.1); color: var(--ink); border-radius: 8px; padding: 5px 9px; font-size: 12px; cursor: pointer; }
.lab-exp button:hover, .lab-reset:hover { background: rgba(255, 207, 90, 0.22); }
.lab-msg { font-size: 12.5px; line-height: 1.4; color: #ffcf8a; min-height: 18px; margin: 4px 0; }
.lab-counts { font-size: 11px; line-height: 1.4; color: var(--ink-faint); }
.lab-cell { margin: 6px 0 0; padding-left: 16px; font-size: 12px; line-height: 1.45; color: var(--ink-soft); }
#oLensCard h3 { margin: 4px 26px 6px 0; font-size: 14px; }
#oLensCard ul { margin: 0; padding-left: 16px; font-size: 12.5px; line-height: 1.5; color: var(--ink-soft); }
.o-note { margin: 6px 0 0; font-size: 11px; line-height: 1.4; color: var(--ink-faint); }
.o-close { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); font-size: 18px; cursor: pointer; }

/* --- Linea del tempo unica (D17): la barra di un filmato dal «prima del Big Bang» a oggi --------------------- */
/* Riga dei periodi (D32): pochi periodi; toccandone uno si aprono i suoi momenti. Scorre (D24). */
#events { position: fixed; left: 14px; right: 14px; bottom: calc(var(--tb-b) + var(--tb-h) + 8px + var(--ln-h)); z-index: 5; height: var(--ev-h); }
#evStrip {
  position: relative; height: 100%; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 0 32px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 30px, #000 calc(100% - 30px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 30px, #000 calc(100% - 30px), transparent);
}
#evStrip::-webkit-scrollbar { display: none; }
#evStrip.dragging { cursor: grabbing; }
#evStrip.dragging button { pointer-events: none; }
#evStrip button { flex: none; height: var(--ev-h); border: 1px solid var(--glass-line); background: rgba(14, 11, 32, 0.72); color: var(--ink-soft); border-radius: 999px; padding: 0 11px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
#evStrip button[hidden] { display: none; }
#evStrip button:hover { color: var(--ink); border-color: rgba(176, 160, 255, 0.5); }
#evStrip .per { color: var(--ink); font-weight: 600; padding-left: 9px; border-color: color-mix(in srgb, var(--c) 55%, transparent); background: linear-gradient(90deg, color-mix(in srgb, var(--c) 38%, rgba(14, 11, 32, 0.8)), rgba(14, 11, 32, 0.78)); }
#evStrip .per::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--c); vertical-align: 0; }
#evStrip .per::after { content: "▸"; margin-left: 6px; font-size: 10px; opacity: .75; }
#evStrip .per[aria-expanded="true"]::after { content: "▾"; }
#evStrip .per.here { box-shadow: 0 0 0 1px var(--c) inset, 0 0 12px color-mix(in srgb, var(--c) 45%, transparent); }
#evStrip .mom { font-size: 12px; background: rgba(14, 11, 32, 0.6); }
#evStrip .mom[aria-current="true"] { color: var(--ink); background: rgba(143, 123, 255, 0.34); border-color: rgba(176, 160, 255, 0.7); }
.ev-nav { position: absolute; top: 0; z-index: 1; width: 28px; height: var(--ev-h); padding: 0; border: 1px solid var(--glass-line); border-radius: 50%; background: rgba(14, 11, 32, 0.92); color: var(--ink); font-size: 17px; line-height: 1; cursor: pointer; }
.ev-nav.l { left: 0; } .ev-nav.r { right: 0; }
.ev-nav:hover { background: rgba(143, 123, 255, 0.3); }
/* Barre delle ricerche (D33): una per ricerca, con il suo colore, la sua durata e il titolo scelto */
#lanes { position: fixed; bottom: calc(var(--tb-b) + var(--tb-h) + 4px); z-index: 5; pointer-events: none; }
.lane { position: relative; height: 22px; }
.ln-seg { position: absolute; top: 7px; height: 8px; min-width: 8px; padding: 0; border: 0; border-radius: 4px; background: var(--c); box-shadow: 0 0 10px color-mix(in srgb, var(--c) 60%, transparent); cursor: pointer; pointer-events: auto; transform: translateX(0); }
.ln-lab { position: absolute; top: 0; display: flex; align-items: center; gap: 2px; height: 22px; max-width: 70%; padding: 0 4px 0 8px; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--c) 50%, transparent); background: rgba(14, 11, 32, 0.9); pointer-events: auto; white-space: nowrap; }
.ln-open { min-width: 0; overflow: hidden; text-overflow: ellipsis; border: 0; background: transparent; color: var(--ink); font-size: 12px; cursor: pointer; padding: 0; }
.ln-open b { color: var(--c); font-weight: 650; }
.ln-q { color: var(--ink-soft); font-style: italic; }
.ln-when { color: var(--ink-faint); }
.ln-act { flex: none; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 13px; }
.ln-act:hover { background: rgba(143, 123, 255, 0.25); color: var(--ink); }
.ln-edit { width: 220px; height: 18px; border: 1px solid var(--glass-line); border-radius: 5px; background: rgba(4, 3, 10, 0.8); color: var(--ink); font: inherit; font-size: 12px; padding: 0 5px; }
#tbSpan { position: absolute; top: 3px; height: 16px; border-radius: 5px; border: 1px solid color-mix(in srgb, var(--c) 80%, white); background: color-mix(in srgb, var(--c) 22%, transparent); pointer-events: none; }
#tbMarks i.hid { display: none; }
#tbMarks i:not(.k) { background: rgba(255, 255, 255, 0.32); height: 9px; top: 6.5px; }
#timebar { position: fixed; left: 14px; right: 14px; bottom: var(--tb-b); height: var(--tb-h); z-index: 5; display: flex; align-items: center; gap: 8px; padding: 6px 12px; }
.tb-btn { flex: none; height: 36px; min-width: 40px; padding: 0 10px; border: 1px solid var(--glass-line); background: transparent; color: var(--ink); border-radius: 9px; cursor: pointer; font-size: 13px; font-variant-numeric: tabular-nums; }
.tb-btn:hover { background: rgba(143, 123, 255, 0.14); }
.tb-btn[aria-pressed="true"] { background: rgba(143, 123, 255, 0.3); border-color: rgba(176, 160, 255, 0.6); }
#timePlay { display: grid; place-items: center; font-size: 0; }
#timePlay svg { width: 18px; height: 18px; fill: currentColor; }
#timePlay .i-pause, #timePlay[aria-pressed="true"] .i-play { display: none; }
#timePlay[aria-pressed="true"] .i-pause { display: inline; }
#oLensBtn { display: none; }
body.origini #oLensBtn { display: block; }
.tb-wrap { flex: 1; min-width: 0; position: relative; padding-bottom: 15px; }
#tbTrack { position: relative; height: 22px; cursor: pointer; touch-action: none; outline: none; }
#tbTrack::before { content: ""; position: absolute; left: 0; right: 0; top: 8px; height: 6px; border-radius: 3px; background: var(--bands); }
#tbRest { position: absolute; top: 8px; right: 0; height: 6px; border-radius: 0 3px 3px 0; background: rgba(6, 5, 16, 0.62); pointer-events: none; }
#tbMarks i { position: absolute; top: 5px; width: 2px; height: 12px; margin-left: -1px; border-radius: 1px; background: rgba(255, 255, 255, 0.5); pointer-events: none; }
#tbHandle { position: absolute; top: 3px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(143, 123, 255, 0.5), 0 0 14px rgba(143, 123, 255, 0.8); pointer-events: none; }
#tbTrack:focus-visible #tbHandle { box-shadow: 0 0 0 3px var(--violet), 0 0 18px var(--violet); }
#tbTicks { position: absolute; left: 0; right: 0; bottom: 0; height: 13px; font-size: 10.5px; color: var(--ink-faint); pointer-events: none; }
#tbTicks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
#tbTicks span.l { transform: none; }
#tbTicks span.r { transform: translateX(-100%); }
#tbHover, #tbStop { position: absolute; bottom: 26px; transform: translateX(-50%); white-space: nowrap; padding: 4px 9px; border-radius: 8px; font-size: 12px; color: var(--ink); background: rgba(14, 11, 32, 0.94); border: 1px solid var(--glass-line); pointer-events: none; }
#tbStop { bottom: 30px; color: #ffcf8a; opacity: 0; transition: opacity .35s ease; }
#tbStop.on { opacity: 1; }
#tbHover.l, #tbStop.l { transform: none; }
#tbHover.r, #tbStop.r { transform: translateX(-100%); }
/* --- Evento raccontato (D21): la linea del tempo dell'evento sostituisce quella della storia --------------------- */
body.scenario #timebar, body.scenario #events, body.scenario #lanes { display: none; }
body.scenario #yearPrev, body.scenario #yearNext { visibility: hidden; } /* nell'evento il tempo si muove con la sua linea */
#scenario[hidden] { display: none; }
#scCard { position: fixed; left: 14px; top: calc(max(14px, env(safe-area-inset-top)) + 58px); width: min(350px, calc(100vw - 28px)); max-height: calc(100vh - 100px - var(--tb-h) - var(--tb-b)); overflow: auto; padding: 12px 16px; z-index: 5; }
#scCard h2 { margin: 2px 0 4px; font-size: 19px; font-weight: 650; }
.sc-date { font-size: 22px; font-weight: 650; color: #ffcf8a; font-variant-numeric: tabular-nums; }
.sc-stop { margin: 4px 0 6px; font-size: 13px; line-height: 1.45; color: var(--ink); min-height: 38px; }
.sc-facts { margin: 6px 0; padding-left: 16px; font-size: 12.5px; line-height: 1.45; color: var(--ink-soft); }
.sc-facts li { margin: 3px 0; }
.sc-aff { display: inline-block; margin-left: 6px; font-size: 10.5px; color: var(--ink-faint); border: 1px solid var(--glass-line); border-radius: 999px; padding: 0 6px; }
.sc-aff.aff-OSSERVATO { color: #7ee2a8; } .sc-aff.aff-STIMATO { color: #ffcf8a; } .sc-aff.aff-IPOTETICO { color: #ff9aa6; } .sc-aff.aff-RICOSTRUITO { color: #8fd3ff; }
.sc-repr { margin: 6px 0; border-top: 1px solid var(--glass-line); padding-top: 6px; }
.sc-repr-t { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); padding: 0 8px 2px; }
.sc-curve { display: block; width: 100%; height: 75px; margin: 6px 0 2px; }
.sc-counts { font-size: 11.5px; line-height: 1.4; color: var(--ink-soft); }
#scBar { position: fixed; left: 14px; right: 14px; bottom: var(--tb-b); height: var(--tb-h); z-index: 5; display: flex; align-items: center; gap: 8px; padding: 6px 12px; }
#scPlay { display: grid; place-items: center; font-size: 0; }
#scPlay svg { width: 18px; height: 18px; fill: currentColor; }
#scPlay .i-pause, #scPlay[aria-pressed="true"] .i-play { display: none; }
#scPlay[aria-pressed="true"] .i-pause { display: inline; }
#scTrack { position: relative; height: 22px; cursor: pointer; touch-action: none; outline: none; }
#scTrack::before { content: ""; position: absolute; left: 0; right: 0; top: 8px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #7a2a2a, #c2582a 35%, #d9953c 70%, #8a8f5a); }
#scRest { position: absolute; top: 8px; right: 0; height: 6px; border-radius: 0 3px 3px 0; background: rgba(6, 5, 16, 0.62); pointer-events: none; }
#scMarks i { position: absolute; top: 4px; width: 3px; height: 14px; margin-left: -1.5px; border-radius: 1px; background: #ffe7a0; pointer-events: none; }
#scHandle { position: absolute; top: 3px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255, 140, 60, 0.55), 0 0 14px rgba(255, 140, 60, 0.8); pointer-events: none; }
#scTrack:focus-visible #scHandle { box-shadow: 0 0 0 3px #ffb347, 0 0 18px #ffb347; }
#scTicks { position: absolute; left: 0; right: 0; bottom: 0; height: 13px; font-size: 10.5px; color: var(--ink-faint); pointer-events: none; }
#scTicks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
#scStop { position: absolute; bottom: 30px; transform: translateX(-50%); max-width: min(70vw, 520px); white-space: normal; padding: 5px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.35; color: #ffcf8a; background: rgba(14, 11, 32, 0.95); border: 1px solid rgba(255, 207, 90, 0.4); pointer-events: none; opacity: 0; transition: opacity .35s ease; width: max-content; }
#scStop.on { opacity: 1; }
#scStop.l { transform: none; } #scStop.r { transform: translateX(-100%); }
.sc-hold { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.sc-hold input { accent-color: #ffb347; }
#scFx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
@media (max-width: 640px) {
  #scCard { top: calc(max(14px, env(safe-area-inset-top)) + 112px); max-height: 34vh; padding: 10px 12px; }
  #scCard .sc-facts, #scCard .o-note { display: none; }
  #scCard .sc-repr .sw { padding: 4px 6px; font-size: 13px; }
  #scCard .sc-repr .sw small { display: none; }
  #scCard .sc-curve { height: 54px; }
  #scBar { left: 8px; right: 8px; gap: 5px; padding: 6px 8px; }
  .sc-hold { display: none; }
}

/* Cielo del viaggio (D18): Sole, Luna, pioggia; notte e nuvole sono un livello della mappa */
#sky { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.act { display: block; width: calc(100% - 34px); margin: 4px 8px 6px 26px; height: 34px; border: 1px solid rgba(255, 207, 90, 0.5); border-radius: 9px; background: rgba(255, 207, 90, 0.1); color: var(--ink); font-size: 13px; text-align: left; padding: 0 12px; cursor: pointer; }
.act:hover { background: rgba(255, 207, 90, 0.2); }
@media (max-width: 640px) {
  #oCard { top: calc(max(14px, env(safe-area-inset-top)) + 112px); max-height: 30vh; padding: 10px 12px; }
  #oCard h2 { font-size: 16px; }
  #oLensCard { top: auto; bottom: calc(var(--above-tl) + 8px); max-height: 56vh; }
  .lab-intro, .lab-cell { display: none; }
  #timebar { left: 8px; right: 8px; gap: 5px; padding: 6px 8px; }
  #events { left: 8px; right: 8px; }
  .tb-btn { min-width: 36px; padding: 0 8px; }
  #tbTicks span:not(.m) { display: none; }
}

/* Terra bianca: etichette scure con alone chiaro */
.atlante .lbl { color: #1d1a2c; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 1px 8px rgba(255, 255, 255, 0.9); }
.atlante .lbl.country { color: rgba(40, 34, 64, 0.78); }
.atlante .lbl.city::before { background: #1d1a2c; box-shadow: none; }
.atlante .lbl .v { text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
/* Su fondo chiaro il vetro diventa più pieno, altrimenti vira al grigio */
.atlante { --glass: rgba(20, 17, 40, 0.84); }
/* La riga di stato può stare sulla carta chiara o sullo spazio scuro: una capsula la rende leggibile su entrambi */
.atlante #status { color: #1d1a2c; text-shadow: none; background: rgba(247, 246, 242, 0.86); padding: 3px 12px; border-radius: 999px; }
#status {
  position: fixed; left: 50%; bottom: calc(var(--above-tl) - 2px); transform: translateX(-50%);
  font-size: 12px; letter-spacing: .08em; color: var(--ink-soft); text-shadow: 0 1px 6px rgba(0,0,0,.8); z-index: 4; white-space: nowrap;
}
#status .sep { margin: 0 8px; opacity: .5; }

button:focus-visible, input:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

/* --- Etichette --------------------------------------------------------------------- */
.lbl {
  position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform, opacity;
  color: rgba(245, 242, 255, 0.92); text-shadow: 0 0 4px rgba(0,0,0,.9), 0 1px 10px rgba(0,0,0,.7);
  transition: opacity .35s ease; font-size: 12px;
}
.lbl.country { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: rgba(236, 232, 255, 0.78); font-weight: 600; }
.lbl.city::before { content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: #fff; margin-right: 5px; vertical-align: middle; box-shadow: 0 0 6px rgba(255,255,255,.8); }
.lbl.city.cap { font-weight: 600; font-size: 13px; }
.lbl .v { font-weight: 700; font-variant-numeric: tabular-nums; margin-left: 2px; letter-spacing: 0; }

/* --- MapLibre ------------------------------------------------------------------------ */
.maplibregl-ctrl-attrib { background: rgba(10, 8, 24, 0.55) !important; color: var(--ink-faint) !important; font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--ink-soft) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(1); }

/* --- Telefono ------------------------------------------------------------------------- */
@media (max-width: 640px) {
  #yearValue { font-size: 26px; min-width: 90px; }
  #search { top: auto; bottom: calc(var(--above-tl) + 26px); right: 64px; left: 14px; width: auto; }
  #search #searchResults { position: absolute; bottom: 48px; left: 0; right: 0; background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--radius); backdrop-filter: blur(14px); }
  #explore { top: calc(max(14px, env(safe-area-inset-top)) + 62px); }
  #exploreBtn { height: 40px; padding: 0 14px; }
  #explorePanel.drawer { left: 0; top: 0; bottom: 0; width: min(86vw, 330px); border-radius: 0 var(--radius) var(--radius) 0; }
  #legend { left: 10px; right: auto; width: min(230px, 62vw); bottom: auto; top: calc(max(14px, env(safe-area-inset-top)) + 112px); padding: 8px 12px; font-size: 12px; cursor: pointer; }
  #legend h3 { margin: 0; }
  #legend h3::after { content: " ▾"; opacity: .6; }
  #legend.open h3 { margin-bottom: 8px; }
  #legend.open h3::after { content: " ▴"; }
  #legend:not(.open) .item, #legend:not(.open) .reliability, #legend:not(.open) .cats { display: none; }
  #legend:not(.open) .lg + .lg { margin-top: 2px; padding-top: 2px; border: 0; }
  #camera { bottom: calc(var(--above-tl) + 26px); right: 10px; }
  #status { display: none; }
  /* crediti in alto a destra: in basso ci sono ricerca e camera */
  .maplibregl-ctrl-bottom-right { top: calc(max(14px, env(safe-area-inset-top)) + 62px); bottom: auto; }
}

/* Quando i dati di un elemento non valgono per l'anno guardato, si propone ciò che di quell'anno c'è davvero. */
.alt-epoca { display: block; width: calc(100% - 34px); margin: 2px 8px 6px 26px; padding: 5px 8px; text-align: left; font-size: 12px; color: var(--ink-soft); background: rgba(124,108,242,.16); border: 1px solid rgba(124,108,242,.35); border-radius: 8px; cursor: pointer; }
.alt-epoca:hover { background: rgba(124,108,242,.28); }

/* Permesso per i voli di adesso: servizio esterno, si dice che cosa riceve prima di chiederglielo. */
.voli-consenso { margin: 2px 8px 8px 26px; padding: 8px 10px; font-size: 12px; color: var(--ink-soft); background: rgba(124,108,242,.12); border: 1px solid rgba(124,108,242,.3); border-radius: 8px; }
.voli-consenso p { margin: 0 0 6px; }
.voli-consenso .row { display: flex; gap: 6px; }

/* Mini editor della mappa: colora i pezzi, dai un nome ai gruppi (chiesto da Marco il 2026-09-12). */
.editor-mappa { position: absolute; top: 92px; right: 16px; width: 300px; max-height: calc(100% - 190px); overflow-y: auto; z-index: 7; padding: 12px; border-radius: 14px; background: rgba(16,14,32,.92); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(10px); color: var(--ink); font-size: 13px; }
.editor-mappa .ed-testa { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.editor-mappa .ed-riga { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.editor-mappa select { flex: 1; padding: 4px 6px; border-radius: 8px; background: rgba(255,255,255,.08); color: var(--ink); border: 1px solid rgba(255,255,255,.15); }
.editor-mappa .ed-gruppo { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.editor-mappa .ed-gruppo.attivo { background: rgba(124,108,242,.16); border-radius: 8px; padding: 4px 6px; }
.editor-mappa .ed-colore { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.editor-mappa .ed-gruppo input { flex: 1; min-width: 0; padding: 3px 6px; border-radius: 6px; background: rgba(255,255,255,.07); color: var(--ink); border: 1px solid rgba(255,255,255,.12); }
.editor-mappa .ed-quanti { opacity: .7; min-width: 18px; text-align: right; }
.editor-mappa .ed-usa, .editor-mappa .ed-x { padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.08); color: var(--ink-soft); border: 1px solid rgba(255,255,255,.12); cursor: pointer; font-size: 11.5px; }
.editor-mappa .ed-azioni { display: flex; gap: 6px; margin-top: 8px; }
.editor-mappa .ed-aiuto, .editor-mappa .ed-avviso { margin: 8px 0 0; font-size: 12px; color: var(--ink-faint); }
.editor-mappa .ed-avviso { color: var(--warn, #ffcf5a); }
@media (max-width: 640px) { .editor-mappa { right: 8px; left: 8px; width: auto; top: 84px; } }
.editor-mappa .ed-azioni button { flex: 1; padding: 6px 8px; border-radius: 8px; font-size: 12px; cursor: pointer; background: rgba(255,255,255,.08); color: var(--ink-soft); border: 1px solid rgba(255,255,255,.14); }
.editor-mappa .ed-azioni button.primary { background: rgba(124,108,242,.35); color: var(--ink); border-color: rgba(124,108,242,.6); }
.editor-mappa .ed-azioni button:hover { background: rgba(255,255,255,.14); }
/* Pannello «Colora il mondo»: campi scuri e leggibili (prima select e caselle uscivano bianche di sistema). */
.editor-mappa select, .editor-mappa select option, .editor-mappa .ed-gruppo input, .editor-mappa .ed-chiedi input {
  background: #1b1733; color: #eceaff; border: 1px solid rgba(255,255,255,.18);
}
.editor-mappa select { padding: 5px 6px; border-radius: 8px; font-size: 12.5px; }
.editor-mappa .ed-gruppo { gap: 8px; padding: 6px 4px; border-radius: 8px; }
.editor-mappa .ed-gruppo:hover { background: rgba(255,255,255,.05); }
.editor-mappa .ed-colore { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(255,255,255,.3); cursor: pointer; }
.editor-mappa .ed-pezzi { margin: 0 0 6px 26px; font-size: 11.5px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-mappa .ed-tavolozza { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px 26px; }
.editor-mappa .ed-tavolozza button { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(255,255,255,.25); cursor: pointer; }
.editor-mappa .ed-chiedi { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.12); }
.editor-mappa .ed-chiedi input { width: 100%; padding: 6px 8px; border-radius: 8px; font-size: 12.5px; }
.editor-mappa .ed-chiedi .row { display: flex; gap: 6px; margin-top: 6px; }
.editor-mappa .ed-risposta { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); }
.editor-mappa .ed-chiedi button { padding: 6px 12px; border-radius: 8px; font-size: 12.5px; cursor: pointer; background: rgba(124,108,242,.35); color: var(--ink); border: 1px solid rgba(124,108,242,.6); }
.editor-mappa .ed-chiedi button:hover { background: rgba(124,108,242,.5); }
.editor-mappa .ed-chiedi button:disabled { opacity: .6; cursor: progress; }
/* stato dell'AI locale: deve essere leggibile ma discreto, e dire la verità anche quando non c'è */
.editor-mappa .ed-ai { margin: 6px 0 0; font-size: 11.5px; color: var(--ink-faint); line-height: 1.35; }
.editor-mappa .ed-permesso { margin: 8px 0 0; padding: 8px 10px; font-size: 12px; color: var(--ink-soft); background: rgba(124,108,242,.12); border: 1px solid rgba(124,108,242,.3); border-radius: 8px; }
.editor-mappa .ed-permesso p { margin: 0 0 6px; }
.editor-mappa .ed-permesso .row { display: flex; gap: 6px; }
.editor-mappa .ed-chiedi button.ed-ai-btn { background: rgba(63,191,143,.28); border-color: rgba(63,191,143,.55); }
.editor-mappa .ed-chiedi button.ed-ai-btn:hover { background: rgba(63,191,143,.42); }
