:root {
  --bg: #eef4fb;
  --bg-panel: #ffffff;
  --text: #10202f;
  --text-muted: #5b6b78;
  --accent: #1b6ec2;
  --accent-2: #ff9d3d;
  --border: #dbe6f0;
  --shadow: 0 2px 10px rgba(20, 40, 70, .08);
  --radius: 16px;
  --danger: #e15656;
  --success: #2fa96b;
}

[data-theme="dark"] {
  --bg: #0d1524;
  --bg-panel: #16213a;
  --text: #eaf1fb;
  --text-muted: #9db1c7;
  --accent: #4a9eff;
  --accent-2: #ffb15c;
  --border: #223252;
  --shadow: 0 2px 14px rgba(0, 0, 0, .35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1524;
    --bg-panel: #16213a;
    --text: #eaf1fb;
    --text-muted: #9db1c7;
    --accent: #4a9eff;
    --accent-2: #ffb15c;
    --border: #223252;
    --shadow: 0 2px 14px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background .25s ease, color .25s ease;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
}
.logo { font-weight: 700; font-size: 1.15rem; color: var(--text); white-space: nowrap; }
.search-wrap { position: relative; flex: 1; min-width: 120px; }
.search-wrap input {
  width: 100%; padding: 10px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: .95rem;
}
.search-results {
  position: absolute; top: 110%; left: 0; right: 0;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); max-height: 320px;
  overflow-y: auto; z-index: 60;
}
.search-results .result-item {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.search-results .result-item:hover { background: var(--bg); }
.search-results .result-item small { color: var(--text-muted); }
.hidden { display: none !important; }

.icon-btn {
  background: none; border: none; font-size: 1.2rem; cursor: pointer;
  color: var(--text); padding: 6px 8px; border-radius: 10px;
}
.icon-btn:hover { background: var(--bg); }
.lang-select select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px;
}
.user-chip { font-size: .85rem; color: var(--text-muted); white-space: nowrap; }
.text-link { font-size: .9rem; white-space: nowrap; }

.container { max-width: 1100px; margin: 0 auto; padding: 18px 16px 60px; display: flex; flex-direction: column; gap: 18px; }

.panel {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px;
}
.panel h2 { margin: 0 0 12px; font-size: 1.05rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; min-width: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; min-width: 0; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
.panel { min-width: 0; overflow: hidden; }
.panel canvas { max-width: 100% !important; }
.hourly-scroll { min-width: 0; }
@media (max-width: 820px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; }
}

.current-card {
  background: linear-gradient(160deg, #0057a3 0%, #0f7fd6 55%, #3fa9f5 100%);
  color: #fff; border-radius: var(--radius); padding: 26px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
[data-theme="dark"] .current-card { background: linear-gradient(160deg, #022340, #08427a 55%, #0d5fa8); }
.current-details span { color: #cfe8ff; }
[data-theme="dark"] .current-details span { color: #8fc4ee; }
.current-loading { text-align: center; padding: 30px; opacity: .85; }

.current-main { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.current-temp { font-size: 3.4rem; font-weight: 700; }
.current-icon { font-size: 3.6rem; }
.current-details { display: flex; flex-wrap: wrap; gap: 14px 26px; margin-top: 18px; font-size: .92rem; }
.current-details div span { display: block; opacity: .8; font-size: .78rem; }

.hourly-scroll { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.hour-item { flex: 0 0 auto; text-align: center; min-width: 62px; }
.hour-item .h-time { font-size: .78rem; color: var(--text-muted); }
.hour-item .h-icon { font-size: 1.5rem; margin: 4px 0; }
.hour-item .h-temp { font-weight: 600; }

.daily-list { display: flex; flex-direction: column; gap: 8px; }
.daily-item {
  display: grid; grid-template-columns: minmax(118px, 1.3fr) 34px 1fr 84px 18px; align-items: center; gap: 8px;
  padding: 12px 8px; border-bottom: 1px solid var(--border); min-width: 0;
  cursor: pointer; border-radius: 8px; transition: background .15s ease;
}
.daily-item:hover { background: var(--bg); }
.daily-item:last-child { border-bottom: none; }
.daily-item .day-name { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.daily-item .day-today-tag { font-weight: 600; color: var(--accent); font-size: .74rem; white-space: nowrap; }
.daily-chevron { transition: transform .2s ease; color: var(--text-muted); text-align: center; }
.daily-item.expanded .daily-chevron { transform: rotate(180deg); }
.daily-bar-track { height: 6px; background: var(--border); border-radius: 4px; position: relative; }
.daily-bar-fill { position: absolute; top: 0; height: 6px; border-radius: 4px; background: linear-gradient(90deg, #6fb1ff, var(--accent-2)); }
.daily-temps { text-align: right; font-size: .95rem; white-space: nowrap; }
.daily-temps .tmin { color: var(--text-muted); }

@media (max-width: 480px) {
  .daily-item { grid-template-columns: minmax(92px, 1.15fr) 26px 1fr 66px 16px; gap: 5px; padding: 11px 4px; }
  .daily-item .day-name { font-size: .8rem; }
  .daily-item .day-today-tag { font-size: .66rem; display: block; }
  .daily-temps { font-size: .84rem; }
}

.panel-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.panel-header-row h2 { margin: 0; }
.days-selector { display: flex; gap: 4px; background: var(--bg); border-radius: 10px; padding: 3px; border: 1px solid var(--border); }
.days-btn { background: none; border: none; color: var(--text-muted); padding: 6px 12px; border-radius: 8px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.days-btn.active { background: var(--accent); color: #fff; }

.hourly-day-panel { padding: 8px 4px 10px; display: flex; flex-direction: column; gap: 6px; }
.hourly-day-row {
  display: grid; grid-template-columns: 60px 34px 1fr 60px 60px; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px; background: var(--bg); font-size: .85rem;
}
.hourly-day-row .hd-temp { font-weight: 700; text-align: right; }
.hourly-day-row .hd-precip { color: var(--text-muted); font-size: .78rem; text-align: right; }

.small-panel { text-align: center; }

/* ===== Riepilogo settimanale "a schema triplo" (home) ===== */
.text-link-btn { background: none; border: none; color: var(--accent); font-size: .82rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.week-summary-loading { grid-column: 1 / -1; text-align: center; opacity: .7; padding: 10px; }
.week-summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; align-items: stretch; }
.week-summary-grid > * { min-width: 0; }
.week-summary-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 10px; text-align: center; cursor: pointer; position: relative; min-width: 0;
  min-height: 128px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  transition: border-color .15s ease, transform .15s ease;
}
.week-summary-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.week-summary-card .wsc-day-tag {
  position: absolute; top: 8px; right: 8px; font-size: .62rem; font-weight: 700; color: #fff;
  background: var(--accent); padding: 3px 8px; border-radius: 999px; letter-spacing: .02em;
}
.week-summary-card .wsc-day { font-size: .92rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.week-summary-card .wsc-icon { font-size: 2rem; line-height: 1; }
.week-summary-card .wsc-temps { font-size: .95rem; }
.week-summary-card .wsc-temps .wsc-min { color: var(--text-muted); }

@media (max-width: 480px) {
  .week-summary-card { min-height: 112px; padding: 12px 6px; gap: 4px; }
  .week-summary-card .wsc-day { font-size: .78rem; }
  .week-summary-card .wsc-icon { font-size: 1.7rem; }
  .week-summary-card .wsc-temps { font-size: .86rem; }
  .week-summary-card .wsc-day-tag { font-size: .58rem; padding: 2px 6px; }
}

/* ===== Cartina Italia (home) ===== */
.italy-map-wrap { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); contain: paint; isolation: isolate; z-index: 1; }
#italyMap { height: 460px; width: 100%; background: #dfe9f2; }
[data-theme="dark"] #italyMap { background: #0d1524; }
.italy-city-marker {
  display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer;
  font-size: .72rem; font-weight: 700; color: var(--text); text-shadow: 0 1px 3px rgba(255,255,255,.8);
  transform: translate(-50%, -100%);
}
[data-theme="dark"] .italy-city-marker { text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.italy-city-marker .icm-icon { font-size: 1.3rem; line-height: 1; }
.italy-city-marker .icm-name { font-size: .62rem; font-weight: 600; white-space: nowrap; }
.italy-city-marker .icm-temp { font-size: .74rem; }
.aqi-badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 600; color: #fff; margin-top: 6px; }
.moon-emoji { font-size: 2.6rem; }

/* Qualità dell'aria estesa */
.pollutant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 12px; }
.pollutant-item { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; text-align: center; }
.pollutant-item .p-val { font-weight: 700; font-size: 1.05rem; }
.pollutant-item .p-label { font-size: .68rem; color: var(--text-muted); margin-top: 2px; }
.aq-recommendation { font-size: .82rem; margin-top: 10px; padding: 8px 10px; background: var(--bg); border-radius: 8px; }

/* Fase lunare estesa */
.moon-layout { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; text-align: left; }
.moon-main { text-align: center; min-width: 90px; }
.moon-details { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 6px; font-size: .85rem; }
.moon-details .m-row { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--border); padding-bottom: 4px; }
.moon-details .m-label { color: var(--text-muted); }
.moon-folklore { margin-top: 10px; padding: 8px 10px; background: var(--bg); border-radius: 8px; font-size: .8rem; }
.moon-folklore .folklore-note { color: var(--text-muted); font-size: .72rem; margin-top: 4px; }

/* Traffico */
.traffic-verdict { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.traffic-gauge { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 1rem; flex-shrink: 0; }
.traffic-speeds { font-size: .85rem; color: var(--text-muted); }
.traffic-forecast { display: flex; gap: 10px; overflow-x: auto; margin-top: 14px; padding-bottom: 4px; }
.traffic-forecast-item { flex: 0 0 auto; text-align: center; min-width: 54px; }
.traffic-forecast-item .tf-hour { font-size: .74rem; color: var(--text-muted); }
.traffic-forecast-item .tf-bar-track { width: 18px; height: 46px; background: var(--border); border-radius: 6px; margin: 4px auto; position: relative; overflow: hidden; display: flex; align-items: flex-end; }
.traffic-forecast-item .tf-bar-fill { width: 100%; border-radius: 6px; }
.traffic-forecast-note { font-size: .72rem; color: var(--text-muted); margin-top: 8px; }

.history-summary { display: flex; gap: 20px; margin-top: 10px; flex-wrap: wrap; font-size: .9rem; color: var(--text-muted); }

.favorites-bar h3 { margin: 0 0 8px; font-size: .95rem; color: var(--text-muted); }
.favorites-list { display: flex; gap: 10px; flex-wrap: wrap; }
.fav-toggle-btn.is-favorite { background: rgba(255, 209, 102, .25); color: #fff; border-color: rgba(255, 209, 102, .6); }
.fav-toggle-btn .fav-star { color: #ffd166; }
.fav-chip {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; font-size: .88rem; display: flex; align-items: center; gap: 6px;
}
.fav-chip:hover { border-color: var(--accent); }
.fav-remove { opacity: .5; }
.fav-remove:hover { opacity: 1; color: var(--danger); }

.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 10px 16px; cursor: pointer; font-size: .9rem; font-weight: 600;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }

.cloud-scan-ui { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.cloud-scan-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
#cloudPreview { max-width: 100%; border-radius: 12px; border: 1px solid var(--border); background: #000; }
#cloudVideo { max-width: 100%; border-radius: 12px; }
.cloud-scan-result {
  padding: 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); width: 100%;
}
.cloud-scan-result.worsening { border-color: var(--danger); }
.cloud-scan-result.improving { border-color: var(--success); }

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); color: var(--text); }
.auth-card {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 30px; width: 100%; max-width: 360px;
}
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.auth-card label { font-size: .85rem; color: var(--text-muted); display: flex; flex-direction: column; gap: 4px; }
.auth-card input {
  padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.auth-error { color: var(--danger); font-size: .9rem; }

/* ===== Radar meteo (RainViewer + Leaflet) ===== */
.radar-wrap { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); contain: paint; isolation: isolate; z-index: 1; }
#radarMap { height: 420px; width: 100%; background: #dfe9f2; contain: paint; }
[data-theme="dark"] #radarMap { background: #0d1524; }
.radar-controls { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.radar-time { font-size: .85rem; color: var(--text-muted); min-width: 150px; }
.radar-slider { flex: 1; min-width: 140px; accent-color: var(--accent); }
.radar-legend { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--text-muted); margin-top: 8px; }
.radar-legend-bar { height: 8px; flex: 1; border-radius: 4px; background: linear-gradient(90deg, #7dd3fc, #22c55e, #eab308, #ef4444, #a855f7); }

/* ===== Menu app in basso — icone minimal stile app ===== */
.container { padding-bottom: 110px; scroll-behavior: smooth; }
section[id] { scroll-margin-top: 78px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5000;
  background: var(--bg-panel); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 18px rgba(10, 30, 60, .12);
  display: flex; justify-content: space-around; align-items: center;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
[data-theme="dark"] .bottom-nav { box-shadow: 0 -4px 18px rgba(0, 0, 0, .45); }
.nav-item {
  appearance: none; background: none; border: none; cursor: pointer; flex: 1; max-width: 84px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px;
  font-family: inherit; font-size: .62rem; font-weight: 600; color: var(--text-muted); letter-spacing: .01em;
  transition: color .15s ease;
}
.nav-icon-3d {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  color: inherit; transition: transform .15s cubic-bezier(.34,1.56,.64,1);
}
.nav-icon-3d svg { width: 23px; height: 23px; stroke-width: 1.9; }
.nav-item.active { color: var(--accent); }
.nav-item.active .nav-icon-3d { transform: translateY(-2px) scale(1.08); }
.nav-item.active .nav-icon-3d svg { stroke-width: 2.2; }
.nav-item:active .nav-icon-3d { transform: scale(.9); }

@media (max-width: 480px) {
  .nav-item { min-width: 56px; font-size: .58rem; }
  .nav-icon-3d { width: 24px; height: 24px; }
  .nav-icon-3d svg { width: 21px; height: 21px; }
}

/* ===== Pagine dell'app (una sezione visibile alla volta) ===== */
.app-page { display: none; }
.app-page.active { display: block; animation: pageFadeIn .22s ease; }
@keyframes pageFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Pannello "Altro" ===== */
.more-sheet { position: fixed; inset: 0; z-index: 6000; display: flex; align-items: flex-end; justify-content: center; }
.more-sheet.hidden { display: none; }
.more-sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 20, 35, .45); animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.more-sheet-panel {
  position: relative; width: 100%; max-width: 520px; background: var(--bg-panel);
  border-radius: 20px 20px 0 0; padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 30px rgba(0,0,0,.25); animation: sheetUp .25s cubic-bezier(.32,.72,.35,1);
}
@media (min-width: 560px) { .more-sheet-panel { border-radius: 20px; margin-bottom: 90px; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.more-sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.more-sheet-header h3 { margin: 0; font-size: 1.05rem; }
.more-sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 420px) { .more-sheet-grid { grid-template-columns: repeat(2, 1fr); } }
.more-item {
  appearance: none; background: none; border: none; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 8px; padding: 10px 4px; border-radius: 12px; font-size: .78rem; font-weight: 600;
  color: var(--text); font-family: inherit;
}
.more-item:hover { background: var(--bg); }
.more-item .nav-icon-3d { width: 40px; height: 40px; color: var(--accent); }
.more-item .nav-icon-3d svg { width: 26px; height: 26px; stroke-width: 1.7; }

/* ===== Sfondo animato in base al meteo ===== */
.weather-bg {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background: linear-gradient(160deg, #4a9eff 0%, #7ecbff 60%, #bfe4ff 100%);
  transition: background 1.4s ease;
}
#app { position: relative; z-index: 1; }
body { background: transparent; }

/* ===== Community foto meteo ===== */
.community-upload-form { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 18px; }
.community-category-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.community-cat-btn {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; font-size: .82rem; cursor: pointer; color: var(--text); display: flex; align-items: center; gap: 6px;
}
.community-cat-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.community-upload-form textarea {
  width: 100%; resize: vertical; min-height: 44px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-panel); color: var(--text); font-family: inherit; margin-bottom: 10px;
}
.community-upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.community-upload-msg { margin-top: 10px; padding: 8px 10px; border-radius: 8px; font-size: .85rem; }
.community-upload-msg.ok { background: rgba(47, 169, 107, .15); color: #2fa96b; }
.community-upload-msg.error { background: rgba(225, 86, 86, .15); color: #e15656; }

.community-feed-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.community-scope-toggle { display: flex; gap: 4px; background: var(--bg); border-radius: 10px; padding: 3px; border: 1px solid var(--border); }
.scope-btn { background: none; border: none; color: var(--text-muted); padding: 6px 12px; border-radius: 8px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.scope-btn.active { background: var(--accent); color: #fff; }
.community-filter-select select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }

.community-group { margin-bottom: 20px; }
.community-group-title { font-weight: 700; margin-bottom: 10px; font-size: .95rem; }
.community-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.community-card { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.community-card img, .community-card video { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--border); }
.community-login-prompt { text-align: center; padding: 24px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 18px; }
.community-login-prompt p { margin-top: 0; }
.community-login-prompt .btn, .community-login-prompt .btn-secondary { margin: 4px; }
.community-card-body { padding: 8px 10px; }
.community-card-city { font-size: .8rem; font-weight: 600; }
.community-card-caption { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.community-card-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: .72rem; color: var(--text-muted); }
.community-report-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: .85rem; padding: 2px 4px; }
.community-report-btn:hover { color: var(--danger); }

.app-footer { text-align: center; color: var(--text-muted); font-size: .8rem; padding: 20px 20px 130px; }

/* ===== Elementi animati dello sfondo meteo ===== */
.wbg-sun {
  position: absolute; top: 8%; right: 14%; width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, #fff6d0 0%, #ffe17d 45%, rgba(255,225,125,0) 72%);
  box-shadow: 0 0 70px 20px rgba(255, 225, 125, .35);
  animation: wbgPulse 6s ease-in-out infinite;
}
@keyframes wbgPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.06); opacity: .9; } }

.wbg-moon {
  position: absolute; top: 10%; right: 16%; width: 70px; height: 70px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fdfdf6, #d8dbe4 70%);
  box-shadow: 0 0 40px 10px rgba(255,255,255,.25), inset -14px -6px 0 0 rgba(10,20,40,.35);
  animation: wbgPulse 8s ease-in-out infinite;
}

.wbg-star {
  position: absolute; border-radius: 50%; background: #fff;
  animation: wbgTwinkle 3s ease-in-out infinite;
}
@keyframes wbgTwinkle { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

.wbg-cloud {
  position: absolute; left: -30%; width: 240px; height: 70px; background: #fff; border-radius: 50px;
  filter: blur(2px); animation: wbgDrift linear infinite;
}
.wbg-cloud::before, .wbg-cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.wbg-cloud::before { width: 90px; height: 90px; top: -40px; left: 30px; }
.wbg-cloud::after { width: 110px; height: 110px; top: -55px; left: 110px; }
@keyframes wbgDrift { from { transform: translateX(0); } to { transform: translateX(140vw); } }

.wbg-rain {
  position: absolute; top: -5%; width: 2px; height: 60px;
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(210,230,255,.8));
  animation: wbgFall linear infinite;
}
@keyframes wbgFall { from { transform: translateY(-10vh); } to { transform: translateY(110vh); } }

.wbg-snow {
  position: absolute; top: -5%; border-radius: 50%; background: #fff;
  animation: wbgSnowFall linear infinite;
}
@keyframes wbgSnowFall {
  from { transform: translateY(-10vh) translateX(0); }
  50% { transform: translateY(50vh) translateX(20px); }
  to { transform: translateY(110vh) translateX(-10px); }
}

.wbg-fog {
  position: absolute; left: -20%; width: 140%; height: 90px;
  background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,.5), rgba(255,255,255,0));
  filter: blur(6px); animation: wbgFogDrift linear infinite;
}
@keyframes wbgFogDrift { from { transform: translateX(-10%); } to { transform: translateX(10%); } }

.wbg-lightning {
  position: absolute; inset: 0; background: #fff; opacity: 0; transition: opacity .08s ease;
}
.wbg-lightning.flash { opacity: .35; transition: opacity .05s ease; }

@media (prefers-reduced-motion: reduce) {
  .wbg-sun, .wbg-moon, .wbg-star, .wbg-cloud, .wbg-rain, .wbg-snow, .wbg-fog { animation: none !important; }
}

/* ===== Banner cookie ===== */
.cookie-banner {
  position: fixed; left: 12px; right: 12px; bottom: 78px; z-index: 7000;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 -4px 24px rgba(0,0,0,.2); padding: 14px 16px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  max-width: 760px; margin: 0 auto;
}
.cookie-banner-text { font-size: .85rem; color: var(--text); flex: 1; min-width: 220px; }
.cookie-banner-text a { margin-left: 4px; }
.cookie-banner-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Pagina Preferiti ===== */
.favorites-page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.favorite-page-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  cursor: pointer; transition: border-color .15s ease, transform .15s ease; position: relative;
}
.favorite-page-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.favorite-page-card .fpc-name { font-weight: 700; }
.favorite-page-card .fpc-country { font-size: .78rem; color: var(--text-muted); }
.favorite-page-card .fpc-remove {
  position: absolute; top: 8px; right: 8px; background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: .9rem; padding: 4px;
}
.favorite-page-card .fpc-remove:hover { color: var(--danger); }
.favorites-page-empty { text-align: center; padding: 30px 10px; color: var(--text-muted); }

/* ===== Accessibilità: skip link, focus da tastiera ===== */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 9999; background: var(--accent); color: #fff;
  padding: 12px 18px; border-radius: 0 0 10px 0; font-weight: 600; text-decoration: none;
}
.skip-link:focus { left: 0; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* ===== Pannello condivisione ===== */
.share-options { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.share-option {
  display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; font-size: .92rem; color: var(--text); text-decoration: none;
  cursor: pointer; font-family: inherit; text-align: left; width: 100%;
}
.share-option:hover { border-color: var(--accent); }

/* ===== Pannello accessibilità ===== */
.a11y-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.a11y-row:last-of-type { border-bottom: none; }
.a11y-btn-group { display: flex; gap: 6px; }
.a11y-btn {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  padding: 6px 12px; cursor: pointer; font-family: inherit; font-weight: 600;
}
.a11y-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.a11y-switch {
  width: 44px; height: 26px; border-radius: 999px; background: var(--border); border: none; position: relative;
  cursor: pointer; flex-shrink: 0; transition: background .2s ease;
}
.a11y-switch-knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform .2s ease; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.a11y-switch.on { background: var(--accent); }
.a11y-switch.on .a11y-switch-knob { transform: translateX(18px); }

/* Dimensione testo regolabile */
html[data-font-size="large"] { font-size: 113%; }
html[data-font-size="xlarge"] { font-size: 128%; }

/* Alto contrasto */
html.a11y-high-contrast {
  --bg: #000; --bg-panel: #000; --text: #fff; --text-muted: #e5e5e5; --border: #fff;
  --accent: #66b3ff; --accent-2: #ffd166; --danger: #ff6b6b; --success: #4ade80;
}
html.a11y-high-contrast .panel, html.a11y-high-contrast .current-card,
html.a11y-high-contrast .topbar, html.a11y-high-contrast .bottom-nav,
html.a11y-high-contrast .more-sheet-panel { border: 2px solid #fff; }
html.a11y-high-contrast .current-card { background: #000; }
html.a11y-high-contrast .weather-bg { opacity: .15; }
html.a11y-high-contrast .nav-item.active { color: #fff; }
html.a11y-high-contrast .nav-item.active .nav-icon-3d { color: #ffd166; }

/* Riduzione animazioni (in aggiunta a prefers-reduced-motion di sistema) */
html.a11y-reduce-motion *, html.a11y-reduce-motion *::before, html.a11y-reduce-motion *::after {
  animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important; scroll-behavior: auto !important;
}

/* Link sottolineati */
html.a11y-underline-links a { text-decoration: underline !important; }

/* ===== Avvisi meteo ===== */
.alerts-push-box { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; display: flex; align-items: center; flex-wrap: wrap; }
.alerts-add-row { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.alerts-add-row select { flex: 1; min-width: 160px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.alerts-list { display: flex; flex-direction: column; gap: 12px; }
.alert-card { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.alert-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.alert-card-city { font-weight: 700; }
.alert-card-types { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.alert-type-chip { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px; font-size: .78rem; cursor: pointer; color: var(--text-muted); }
.alert-type-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.alert-remove-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: .78rem; padding: 2px; }
.alert-remove-btn:hover { color: var(--danger); }

/* ===== Banner "Nuova versione disponibile" ===== */
.update-banner {
  position: fixed; left: 12px; right: 12px; bottom: 78px; z-index: 7500;
  background: var(--bg-panel); border: 1px solid var(--accent); border-radius: 14px;
  box-shadow: 0 -4px 24px rgba(0,0,0,.2); padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 760px; margin: 0 auto; font-size: .85rem; animation: fadeIn .25s ease;
}
