:root {
  --bg: #f6f5f2; --card: #ffffff; --text: #1d1d1b; --muted: #6b6a66;
  --border: #e4e2dc; --accent: #6b21a8; --accent-text: #ffffff; --chip: #f1efe9;
  --ok: #15803d; --ok-bg: #ecfdf3; --err: #b91c1c; --err-bg: #fef2f2;
  --warn-bg: #fff7ed; --warn: #b45309; --code: #f1efe9;
  --course: #0f766e; --course-bg: #e3f3f0;
  --personal: #c2410c; --personal-bg: #fff1e6;
}
/* Tema: automatico (segue il sistema) salvo scelta esplicita in <html data-theme="light|dark"> */
:root { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161614; --card: #21201d; --text: #ecebe7; --muted: #9a988f;
    --border: #33322d; --accent: #c084fc; --accent-text: #1d1d1b; --chip: #2c2b27;
    --ok: #4ade80; --ok-bg: #12261a; --err: #f87171; --err-bg: #2b1515;
    --warn-bg: #2a1f12; --warn: #fbbf24; --code: #2c2b27;
    --course: #5eead4; --course-bg: #12302c;
    --personal: #fb923c; --personal-bg: #2e1d12;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161614; --card: #21201d; --text: #ecebe7; --muted: #9a988f;
  --border: #33322d; --accent: #c084fc; --accent-text: #1d1d1b; --chip: #2c2b27;
  --ok: #4ade80; --ok-bg: #12261a; --err: #f87171; --err-bg: #2b1515;
  --warn-bg: #2a1f12; --warn: #fbbf24; --code: #2c2b27;
  --course: #5eead4; --course-bg: #12302c;
  --personal: #fb923c; --personal-bg: #2e1d12;
}
* { box-sizing: border-box; }
.icon {
  width: 1.05em; height: 1.05em; flex: none; vertical-align: -0.15em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.meta > span, .meta > a, .iconbtn, .btn { display: inline-flex; align-items: center; gap: 5px; }
.checks td .icon { margin-right: 6px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
code { background: var(--code); padding: 1px 5px; border-radius: 4px; font-size: 13px; white-space: nowrap; }
code.path { white-space: normal; word-break: break-all; }
.wrap { max-width: 920px; margin: 0 auto; padding: 24px 16px 64px; }
/* Profili e Post analizzati hanno tabelle con molte colonne: schede più larghe, sempre centrate */
#tab-profiles, #tab-posts, #tab-users, #tab-map { max-width: 1280px; }
#pf_list { overflow-x: auto; }
[hidden] { display: none !important; }

/* --- Eventi --- */
header h1 { margin: 0 0 4px; font-size: 26px; }
header p { margin: 0; color: var(--muted); font-size: 13px; }
.filters {
  /* Riferimento per i menu a tendina, che sugli schermi stretti si aprono a tutta larghezza */
  position: relative;
  background: var(--bg);
  display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 0; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
input, select, textarea {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
/* Solo la ricerca principale: il campo dentro i menu a tendina ha regole sue */
.filters > input[type=search] { flex: 1 1 220px; }
.multi { position: relative; }
.multi-btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; color: var(--text); cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.multi.active .multi-btn { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.multi-panel {
  position: absolute; z-index: 5; top: calc(100% + 4px); left: 0;
  width: max-content; min-width: 240px; max-width: min(340px, calc(100vw - 32px)); max-height: 60vh; overflow: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .15); padding: 6px;
}
.multi-head {
  position: sticky; top: -6px; z-index: 1; background: var(--card);
  display: flex; flex-direction: column; gap: 6px;
  padding: 4px 8px 8px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.multi-head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.multi-search { flex: none; display: block; width: 100%; min-width: 0; font-size: 14px; padding: 7px 10px; -webkit-appearance: none; appearance: none; }
.multi-none { color: var(--muted); font-size: 13px; padding: 6px 8px; margin: 0; }
.multi-panel label {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  color: var(--text); font-size: 14px; cursor: pointer;
}
.multi-panel label:hover { background: var(--chip); }
.multi-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-name small { font-size: 12px; color: var(--muted); }
.count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Calendario del filtro date */
.cal-panel { width: 300px; padding: 10px; }
.cal-modes { display: flex; background: var(--chip); border-radius: 8px; padding: 3px; margin-bottom: 8px; }
.cal-modes button {
  flex: 1; font: inherit; font-size: 13px; border: 0; background: none; color: var(--muted);
  padding: 5px; border-radius: 6px; cursor: pointer;
}
.cal-modes button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.cal-head strong { text-transform: capitalize; font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-grid .dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal-grid button {
  position: relative; aspect-ratio: 1; font: inherit; font-size: 14px; border: 0; border-radius: 8px;
  background: none; color: var(--text); cursor: pointer; font-variant-numeric: tabular-nums;
}
.cal-grid button:hover { background: var(--chip); }
.cal-grid button.past { color: var(--muted); }
.cal-grid button.today { font-weight: 700; box-shadow: inset 0 0 0 1px var(--border); }
.cal-grid button.has-events::after {
  content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px;
  margin-left: -2px; border-radius: 50%; background: var(--accent);
}
.cal-grid button.in-range { background: var(--chip); border-radius: 0; }
.cal-grid button.selected { background: var(--accent); color: var(--accent-text); border-radius: 8px; font-weight: 600; }
.cal-grid button.selected::after { background: var(--accent-text); }
.cal-hint { margin: 8px 2px; font-size: 12px; color: var(--muted); }
.cal-presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cal-presets button:not(.linkbtn) {
  font: inherit; font-size: 13px; border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 3px 10px; cursor: pointer;
}
.cal-presets button:not(.linkbtn):hover { border-color: var(--muted); }
.cal-presets .linkbtn { margin-left: auto; }
.filters > label, .fsheet > label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.day h2 {
  font-size: 14px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent); margin: 28px 0 10px;
  /* Il giorno visualizzato resta in alto, subito sotto la barra in alto (l'unica fissa) */
  position: sticky; top: calc(var(--topbar-h, 0px) + var(--fbar-h, 0px)); z-index: 1;
  background: var(--bg); padding: 8px 0; margin-bottom: 2px; transition: top .2s ease;
}
.event {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 10px;
}
.event h3 { margin: 0 0 4px; font-size: 17px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 13px; }
.event p { margin: 8px 0 0; }
.chip {
  display: inline-block; background: var(--chip); border-radius: 999px;
  padding: 1px 9px; font-size: 12px; color: var(--text);
}
.event a { text-decoration: none; }
.event .links { margin-top: 8px; }
.event.is-new { border-color: var(--accent); }
.event.flash { box-shadow: 0 0 0 3px var(--accent); transition: box-shadow .3s; }
.event.is-course { border-left: 4px solid var(--course); }
.chip.course { display: inline-flex; align-items: center; gap: 4px; background: var(--course-bg); color: var(--course); font-weight: 600; vertical-align: 2px; }
.chip.new { background: var(--accent); color: var(--accent-text); font-weight: 600; vertical-align: 2px; }
.chip.personal { background: var(--personal-bg); color: var(--personal); font-weight: 600; vertical-align: 2px; }
.event a:hover { text-decoration: underline; }
.empty { color: var(--muted); text-align: center; padding: 48px 0; }
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 24px; color: var(--muted); font-size: 14px;
}

/* --- App --- */
.topbar { border-bottom: 1px solid var(--border); background: var(--card); position: sticky; top: 0; z-index: 4; }
.brand {
  font: inherit; font-weight: 700; color: var(--text); background: none; border: 0; padding: 0; cursor: pointer;
}
.topbar .inner {
  max-width: 920px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.tabs { display: flex; gap: 4px; }
.tabs button {
  font: inherit; border: 0; background: none; color: var(--muted);
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.tabs button.active { background: var(--chip); color: var(--text); font-weight: 600; }
.topbar .inner { flex-wrap: wrap; }
.tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.iconbtn {
  position: relative; font: inherit; font-size: 14px; border: 0; background: none; color: var(--text);
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.iconbtn:hover { background: var(--chip); }
.badge {
  position: absolute; top: 0; right: 0; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: var(--accent-text);
  font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}
.linkbtn { font: inherit; font-size: 13px; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; }

/* Pannello notifiche */
.popover {
  position: fixed; z-index: 10; top: 52px; right: max(16px, calc((100vw - 920px) / 2 + 16px));
  width: min(360px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .15); padding: 8px;
}
.popover-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 8px; }
.notif {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  font: inherit; font-size: 14px; color: var(--text); background: none; border: 0;
  border-top: 1px solid var(--border); padding: 8px; cursor: pointer;
}
.notif:hover { background: var(--chip); border-radius: 8px; }
.notif span { color: var(--muted); font-size: 12.5px; }
.empty-small { color: var(--muted); font-size: 14px; padding: 8px; margin: 0; }
.push-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between;
  border-top: 1px solid var(--border); margin-top: 6px; padding: 10px 8px 4px; font-size: 13.5px; color: var(--muted);
}
.push-row .btn { font-size: 13px; padding: 5px 10px; }

/* Account */
.evbtn {
  display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 13px; color: var(--muted);
  background: none; border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; cursor: pointer;
}
.evbtn:hover { color: var(--text); border-color: var(--muted); }
.evbtn.on { color: var(--accent); border-color: var(--accent); }
.evbtn.on .icon { fill: currentColor; }
.google-btn { min-height: 44px; margin: 4px 0 12px; }
.fineprint { color: var(--muted); font-size: 12.5px; margin: 8px 0 12px; }
.btn.danger { color: var(--err); }

/* Suggerimenti di profili (wizard) */
.sugg { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.sugg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.sugg-head a { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.sugg-actions { margin-left: auto; display: flex; gap: 6px; }
.sugg-actions .btn { font-size: 13px; padding: 5px 10px; }
.sugg ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; }
.btn.danger:hover { border-color: var(--err); }

.toast {
  position: fixed; z-index: 20; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: calc(100vw - 32px); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}

dialog {
  width: min(420px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 14px;
  background: var(--card); color: var(--text); padding: 22px;
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog h2 { margin: 0 0 6px; font-size: 20px; }
dialog .lead { color: var(--muted); margin: 0 0 14px; font-size: 14px; }

.setup { display: grid; grid-template-columns: 230px 1fr; gap: 24px; align-items: start; }
/* Menu laterale delle impostazioni, a gruppi */
.settings-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 14px; }
.sn-group { display: flex; flex-direction: column; gap: 2px; }
.sn-label {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 0 10px 4px;
}
.settings-nav button {
  font: inherit; text-align: left; border: 0; background: none; color: var(--text);
  padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: center;
}
.settings-nav button > span:first-of-type { flex: 1; min-width: 0; }
.settings-nav button .icon { width: 17px; height: 17px; color: var(--muted); flex: none; }
.settings-nav button:hover { background: var(--chip); }
.settings-nav button.active { background: var(--card); box-shadow: inset 0 0 0 1px var(--border); font-weight: 600; }
.settings-nav button.active .icon { color: var(--accent); }
.sn-ok { display: grid; color: var(--ok); }
.sn-ok .icon { width: 15px !important; height: 15px !important; color: var(--ok) !important; stroke-width: 3; }
.sn-todo { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.panel section + section { margin-top: 16px; }

.panel section {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px;
}
.panel h2 { margin: 0 0 6px; font-size: 21px; }
.panel h3 { margin: 22px 0 8px; font-size: 16px; }
.panel .lead { color: var(--muted); margin: 0 0 16px; }
.howto { padding-left: 20px; margin: 0 0 16px; }
.howto li { margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.field input, .field textarea, .field select { font-weight: 400; width: 100%; }
.field small { font-weight: 400; color: var(--muted); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: .5; cursor: progress; }
.result { border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; white-space: pre-wrap; }
.result:empty { display: none; }
.result.ok { background: var(--ok-bg); color: var(--ok); }
.result.err { background: var(--err-bg); color: var(--err); }
.note { background: var(--warn-bg); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 12px 0; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 12px; }
.choice {
  display: block; border: 1px solid var(--border); border-radius: 12px; padding: 14px; cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice strong { display: inline-block; margin-bottom: 6px; }
.choice ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--muted); }
.accounts label { display: flex; gap: 8px; align-items: center; padding: 6px 0; }
.checks { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 12px; }
.checks td, .checks th { padding: 6px 8px; border-top: 1px solid var(--border); vertical-align: top; }
.checks th { text-align: left; font-weight: 600; color: var(--muted); border-top: 0; }
.checks .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.checks .ok { color: var(--ok); } .checks .err { color: var(--err); }
pre.log {
  background: var(--code); border-radius: 8px; padding: 12px; font-size: 12.5px;
  max-height: 360px; overflow: auto; white-space: pre-wrap; margin: 0 0 12px;
}
pre.log:empty { display: none; }
details { margin: 12px 0; }
details summary { cursor: pointer; font-weight: 600; }

/* Admin: barra larga come le pagine (1280 px), nome e schede su una riga. Se non ci stanno, le
   schede vanno su una riga tutta loro che scorre di lato (niente buco accanto al nome) */
body:not(.public) .topbar .inner { max-width: 1280px; }
@media (max-width: 1120px) {
  body:not(.public) .topbar .tabs { order: 3; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 6px 16px 2px; }
  body:not(.public) .topbar .tabs::-webkit-scrollbar { display: none; }
  body:not(.public) .tabs button { flex: none; white-space: nowrap; }
}
@media (max-width: 720px) {
  /* Le schede dell'admin scorrono di lato invece di allargare la pagina */
  .topbar .tabs { order: 3; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 6px 16px 2px; }
  .topbar .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; white-space: nowrap; }
  .filters select { max-width: 100%; min-width: 0; }
  .setup { grid-template-columns: 1fr; gap: 14px; }
  /* Sul telefono le sezioni diventano una fila di schede che scorre di lato */
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; gap: 4px; margin: 0 -16px; padding: 0 16px;
    scrollbar-width: none; }
  .settings-nav::-webkit-scrollbar { display: none; }
  .sn-group { flex-direction: row; gap: 4px; }
  .sn-label { display: none; }
  .settings-nav button { flex: none; white-space: nowrap; padding: 7px 12px; }
  .panel section { padding: 18px; }
}

/* Su schermi stretti i menu dei filtri si aprono a tutta larghezza */
@media (max-width: 600px) {
  /* Sotto i 16px iPhone ingrandisce la pagina quando si tocca un campo */
  input, select, textarea, .multi-search { font-size: 16px; }
  .multi { position: static; }
  .multi-panel, .cal-panel { left: 0; right: 0; width: auto; max-width: none; }
}

/* --- Menu laterale (sito pubblico) --- */
.layout { display: block; }
.menu-btn { display: none; }
.sidebar { font-size: 14px; }
.side-section { margin-bottom: 22px; }
.side-section h2 {
  display: flex; align-items: center; gap: 6px; margin: 0 0 8px;
  font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.sidebar li:hover { background: var(--chip); }
.side-item {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; text-align: left;
  font: inherit; color: var(--text); background: none; border: 0; padding: 7px 8px; cursor: pointer;
}
.side-item b, .side-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item b { font-weight: 600; }
.side-item span { color: var(--muted); font-size: 12.5px; }
.side-x {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px;
  background: none; color: var(--muted); cursor: pointer; opacity: .6;
}
.side-x:hover { opacity: 1; color: var(--err); }
.side-empty { color: var(--muted); margin: 0 0 10px; line-height: 1.45; }
.sidebar details summary { color: var(--muted); font-weight: 500; font-size: 13px; padding: 6px 8px; }
.side-backdrop { display: none; }
.side-sub { font-size: 14px; margin: 18px 0 6px; }
.sugg-mine { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.sugg-mine li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid var(--border); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }

/* Il menu è una colonna a tutta altezza: le due sezioni si dividono lo spazio e scorrono
   ognuna per conto suo, l'invito a suggerire pagine resta in fondo */
.sidebar:not([hidden]) { display: flex; flex-direction: column; }
.sidebar .side-favorites, .sidebar .side-saved { flex: 1 1 0; min-height: 120px; display: flex; flex-direction: column; margin-bottom: 0; }
.sidebar .side-saved { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 10px; }
.side-scroll { flex: 1 1 auto; overflow-y: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.side-section h2 .count { margin-left: auto; font-weight: 500; letter-spacing: 0; }
.side-suggest {
  flex: none; display: flex; flex-direction: column; gap: 4px; margin-top: 12px; padding: 12px;
  background: var(--chip); border-radius: 10px; font-size: 13.5px;
}
.side-suggest span { color: var(--muted); }
.side-suggest .btn { align-self: flex-start; margin-top: 4px; font-size: 13px; padding: 6px 10px; }

/* Schermi larghi: colonna fissa a sinistra */
@media (min-width: 960px) {
  body.public .topbar .inner { max-width: 1220px; }
  body.public .layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; max-width: 1220px; margin: 0 auto; padding: 0 16px; }
  body.public .layout .wrap { margin: 0; padding-left: 0; padding-right: 0; max-width: none; }
  body.public .sidebar {
    position: sticky; top: var(--topbar-h, 0px); align-self: start; height: calc(100vh - var(--topbar-h, 0px));
    padding: 20px 4px 16px 0;
  }
  body.public .layout .sidebar[hidden] + .side-backdrop + .wrap { grid-column: 1 / -1; }
}

/* Telefono e schermi stretti: menu a scomparsa */
@media (max-width: 959px) {
  body.public .menu-btn:not([hidden]) { display: inline-flex; margin-left: -8px; }
  body.public .sidebar {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(320px, 86vw);
    background: var(--card); border-right: 1px solid var(--border);
    padding: 20px 14px; transform: translateX(-105%); transition: transform .2s ease;
    box-shadow: 0 0 30px rgba(0, 0, 0, .2);
  }
  body.public.side-open .sidebar { transform: none; }
  body.public.side-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, .4); }
}

/* --- Pagina dei profili (sito pubblico, #profili) --- */
.back { display: inline-block; margin-bottom: 10px; font-size: 14px; text-decoration: none; }
.pp-filters { align-items: center; }
.pp-sort { white-space: nowrap; }
.pp-dir { border: 1px solid var(--border); background: var(--card); color: var(--muted); }
.pp-list { list-style: none; margin: 0; padding: 0; }
.pp-help { margin-top: 6px !important; }
.pp-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) 150px 110px auto; align-items: center; gap: 12px;
  padding: 12px 8px; border-bottom: 1px solid var(--border);
}
.pp-star {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--muted); font-size: 17px;
}
.pp-star:hover { border-color: var(--accent); color: var(--accent); }
.pp-star.on { color: var(--accent); border-color: var(--accent); }
.pp-star.on .icon { fill: currentColor; }
.pp-main { display: flex; flex-direction: column; min-width: 0; }
.pp-name {
  font: inherit; font-weight: 600; color: var(--text); text-align: left; padding: 0; border: 0; background: none;
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pp-name:hover { color: var(--accent); }
.pp-ig { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; text-decoration: none; align-self: flex-start; max-width: 100%; }
.pp-ig .icon { width: .9em; height: .9em; }
.pp-last, .pp-count { display: flex; flex-direction: column; font-size: 14px; font-variant-numeric: tabular-nums; }
.pp-last small, .pp-count small { color: var(--muted); font-size: 12px; }
.pp-count b { font-size: 16px; }
/* Nascondi: i suoi eventi non compaiono mai (preferenza dell'utente) */
.pp-hide {
  display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px; background: var(--card); color: var(--muted);
}
.pp-hide:hover { border-color: var(--muted); color: var(--text); }
.pp-hide .icon { width: 15px; height: 15px; }
.pp-hide.on { color: var(--text); border-color: var(--text); }
.pp-row.is-hidden .pp-main, .pp-row.is-hidden .pp-last, .pp-row.is-hidden .pp-count, .pp-row.is-hidden .pp-star { opacity: .45; }
.account-profiles { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 6px; text-decoration: none; }
.account-profiles .icon { width: 16px; height: 16px; }
.side-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding: 8px 8px 0; text-decoration: none; }
@media (max-width: 600px) {
  .pp-row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "star main count" "star last count" "star hide hide"; row-gap: 2px; }
  .pp-hide { grid-area: hide; justify-self: start; margin-top: 6px; padding: 3px 9px; }
  .pp-star { grid-area: star; }
  .pp-main { grid-area: main; }
  .pp-last { grid-area: last; flex-direction: row; gap: 4px; font-size: 12.5px; color: var(--muted); }
  .pp-count { grid-area: count; text-align: right; }
  .pp-count small { max-width: 80px; }
}

/* Scelta del tema nella finestra dell'account */
.theme-row { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; font-size: 14px; }
.theme-row .cal-modes { flex: 1; margin: 0; }

/* In questo periodo: carosello orizzontale */
.day.ongoing h2 { display: flex; align-items: center; gap: 8px; }
.day.ongoing h2 .count { font-weight: 500; }
.car-nav { margin-left: auto; display: flex; gap: 2px; }
.car-nav .iconbtn { padding: 4px 6px; color: var(--muted); }
.car-nav .iconbtn:disabled { opacity: .35; cursor: default; }
.carousel {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  padding: 2px 2px 10px; margin: 0 -2px 6px; scrollbar-width: thin;
}
.carousel .event {
  flex: 0 0 min(340px, 85%); scroll-snap-align: start; margin: 0; display: flex; flex-direction: column;
}
.carousel .event p { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.carousel .event .links { margin-top: auto; padding-top: 8px; }
/* Sul telefono si scorre col dito: niente frecce */
@media (pointer: coarse) { .car-nav { display: none; } }

/* Happening: iniziano entro un'ora o sono iniziati da meno di un'ora */
.day.happening h2 { display: flex; align-items: center; gap: 8px; }
.day.happening h2 .count { font-weight: 500; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #e5484d; animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .5); } 50% { box-shadow: 0 0 0 5px rgba(229, 72, 77, 0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.chip.live { background: #e5484d; color: #fff; font-weight: 600; vertical-align: 2px; border-color: transparent; }

/* Mostre e rassegne lunghe: lista compatta, chiusa all'inizio */
.longrun { background: var(--card); border: 1px solid var(--border); border-radius: 12px; margin: 20px 0 6px; }
.longrun summary {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px; cursor: pointer; list-style: none;
  font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--accent);
}
.longrun summary::-webkit-details-marker { display: none; }
.longrun summary .count { font-weight: 500; }
.longrun summary .lr-hint { font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
.longrun summary .icon { margin-left: auto; color: var(--muted); transition: transform .2s; }
.longrun[open] summary .icon { transform: rotate(180deg); }
.longrun ul { list-style: none; margin: 0; padding: 0 16px 8px; }
.longrun li { padding: 8px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.longrun li.is-new .lr-title::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 6px; vertical-align: 2px; }
.lr-title { color: var(--text); font-weight: 600; text-decoration: none; }
.lr-meta { font-size: 13px; color: var(--muted); }
.lr-when.on { color: var(--text); }
.longrun li.flash { box-shadow: 0 0 0 3px var(--accent); border-radius: 6px; transition: box-shadow .3s; }

/* Altre date di un evento ripetuto */
.also { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 13px; color: var(--muted); }

/* Condivisione */
.share-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-bottom: 12px; }
.share-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); text-decoration: none; font-size: 14px; font-weight: 500;
}
.share-item:hover { border-color: var(--muted); }
.share-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.share-copy { display: flex; gap: 8px; }
.share-copy input { flex: 1; min-width: 0; color: var(--muted); }

/* Suggerimenti di più profili */
.sugg-row { border: 1px solid var(--border); border-radius: 10px; padding: 8px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.sugg-row-head { display: flex; align-items: center; gap: 4px; }
.sugg-row-head input { flex: 1; min-width: 0; }
.sugg-row textarea { width: 100%; resize: vertical; font-size: 14px; }
.sugg-row-msg { font-size: 12.5px; color: var(--muted); }
.sugg-row-msg:empty { display: none; }
.sugg-row-msg.ok { color: var(--ok); }
.sugg-add { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 10px; }

/* Notifiche: swipe di lato o × per toglierne una */
.notif-row {
  position: relative; display: flex; align-items: stretch; border-top: 1px solid var(--border);
  touch-action: pan-y; transition: transform .18s ease, opacity .18s ease; background: var(--card);
}
.notif-row.dragging { transition: none; user-select: none; }
.notif-row .notif { border-top: 0; flex: 1; min-width: 0; }
.notif-x {
  flex: none; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 8px; opacity: .6;
}
.notif-x:hover { opacity: 1; color: var(--err); }
.notif-hint { color: var(--muted); font-size: 12px; text-align: center; margin: 6px 0 2px; }
@media (pointer: fine) { .notif-hint { display: none; } }

/* --- Post analizzati (app admin) --- */
.muted { color: var(--muted); }
.err-text { color: var(--err); }
.find-box { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin: 16px 0 4px; }
.find-box .fineprint { margin: 2px 0 10px; }
.find-row { display: flex; flex-wrap: wrap; gap: 8px; }
.find-row input { flex: 1 1 260px; min-width: 0; }
.find-row select { flex: 0 1 220px; min-width: 0; }
.find-box .result { margin: 10px 0 0; }
#find_extra:not(:empty) { margin-top: 10px; }
.post-status { margin: 0; flex-wrap: wrap; }
.post-status button { white-space: nowrap; }
.table-scroll { overflow-x: auto; margin: 0 0 12px; }
.pp-table tr.clickable { cursor: pointer; }
.pp-table tr.clickable:hover td { background: var(--chip); }
.post-profile { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin: 0 0 16px; }
.pp-headline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.pp-headline h2 { margin: 0; font-size: 19px; flex: 1 1 auto; }
.pp-headline a { font-size: 14px; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.pp-headline .linkbtn { display: inline-flex; align-items: center; gap: 2px; flex-basis: 100%; }
.post-profile .meta { margin: 6px 0 10px; }
.live-cap { max-width: 360px; color: var(--muted); font-size: 13px; }
.post-card { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; }
.post-card:not(:has(.pc-thumb)) { grid-template-columns: minmax(0, 1fr); }
.pc-thumb { display: block; width: 96px; aspect-ratio: 4 / 5; border-radius: 8px; overflow: hidden; background: var(--chip); }
.pc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc-thumb.broken img { display: none; }
.pc-thumb.broken::after { content: "immagine scaduta"; display: grid; place-items: center; height: 100%; font-size: 11px; color: var(--muted); text-align: center; padding: 4px; }
.pc-body .meta { align-items: center; }
.chip.st-ok { display: inline-flex; align-items: center; gap: 3px; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.chip.st-ok .icon { width: 12px; height: 12px; }
.chip.st-none { color: var(--muted); }
.chip.st-err { background: var(--err-bg); color: var(--err); font-weight: 600; }
.pc-events { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.pc-events li { margin-bottom: 3px; }
.pc-events .chip { margin-left: 4px; }
.event p.pc-note { margin: 8px 0 0; font-size: 14px; background: var(--chip); border-radius: 8px; padding: 6px 10px; }
.pc-caption { margin: 8px 0 0; font-size: 14px; }
.pc-caption summary { font-weight: 500; color: var(--muted); font-size: 13px; }
.pc-caption p { white-space: pre-wrap; margin: 6px 0 0; max-height: 260px; overflow: auto; }
.post-card .result { margin: 8px 0 0; }
.post-card .links { align-items: center; }
@media (max-width: 600px) {
  .post-card { grid-template-columns: 64px minmax(0, 1fr); gap: 10px; }
  .pc-thumb { width: 64px; }
}
.post-status button { flex: none; padding: 5px 10px; }
.post-card .result.err { max-height: 6.5em; overflow: auto; font-size: 13px; }
.pp-table .hl { background: var(--chip); font-weight: 700; }
.posts-title { font-size: 16px; margin: 20px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.posts-title .count { font-weight: 500; }
.find-box .linkbtn#manual_open { margin-top: 10px; }
.manual-box .row { gap: 0 12px; }
.manual-box textarea { resize: vertical; }
.pc-events .linkbtn { font-size: 12px; color: var(--err); }

/* --- Profili (app admin) --- */
.pf-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pf-header .btn { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.pf-header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* Utenti del sito (scheda Utenti): riquadri di numeri e tabella degli account */
.su-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 4px 0 14px; }
.su-stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px;
  display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.su-stat strong { font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }
.su-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 6px 14px 2px; overflow-x: auto; }
.su-card .su-list { margin-bottom: 6px; }
.pf-header .btn .icon { width: 16px; height: 16px; }
.pf-toolbar { align-items: center; }
.pf-toolbar input[type=search] { flex: 1 1 200px; }
.pf-scan { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.pf-scan select { padding: 3px 6px; }
#pf_log:not(:empty) { margin-top: 10px; max-height: 200px; }
#pf_result:not(:empty) { margin-top: 10px; }

.pf-table td { vertical-align: middle; padding-top: 10px; padding-bottom: 10px; }
.pf-table tr[data-pf-row] { cursor: pointer; }
.pf-sort { font: inherit; font-weight: 600; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.pf-sort:hover, .pf-sort.on { color: var(--text); }
.pf-arrow { font-size: .9em; opacity: .35; }
.pf-sort.on .pf-arrow { opacity: 1; color: var(--accent); }
.pf-table tr[data-pf-row]:hover td { background: var(--chip); }
.pf-table tr.is-paused .pf-who, .pf-table tr.is-paused .pf-activity { opacity: .55; }
.pf-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.pf-open { font: inherit; font-weight: 600; color: var(--text); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.pf-open:hover { text-decoration: underline; }
.pf-ig { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; text-decoration: none; }
.pf-ig .icon { width: .85em; height: .85em; }
/* Indirizzo predefinito del profilo */
.pf-place { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); margin-top: 2px;
  max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-place .icon { width: 13px; height: 13px; flex: none; }
.pf-d-place { margin-top: 16px; }
.pf-d-place label { display: block; margin-bottom: 6px; }
.pf-place-row { display: flex; gap: 8px; }
.pf-place-row input { flex: 1; min-width: 0; }
/* Tag dell'evento inserito a mano */
.m-tags { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.m-tags legend { padding: 0; margin-bottom: 6px; font-weight: 600; }
/* È anche un .field (colonna, input larghi il 100%): qui invece fila di caselle compatte */
.field.m-tags { flex-direction: row; flex-wrap: wrap; gap: 8px 18px; }
.field.m-tags legend { flex-basis: 100%; }
.m-tags label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; cursor: pointer; white-space: nowrap; }
.field.m-tags input[type=checkbox] { width: auto; margin: 0; flex: none; }
.pf-why { color: var(--muted); font-size: 12.5px; margin-top: 3px; max-width: 230px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-activity small { font-size: 12.5px; }
/* Ultima lettura, in piccolo sotto al nome */
.pf-read { white-space: nowrap; font-size: 12px; color: var(--muted); margin-top: 2px; }
.pf-read .chip.method { font-size: 10.5px; }
/* Colonna Posizione: indirizzo su una riga, precisione sotto */
.pf-where { max-width: 240px; }
.pf-where .pf-place { margin: 0; max-width: 240px; color: var(--text); font-size: 13px; }
.pf-where .pf-place span { overflow: hidden; text-overflow: ellipsis; }
.pf-where .pf-map { display: inline-block; margin: 3px 0 0; }
.pf-table td.pf-activity strong { font-size: 15px; }
.chip.method { font-size: 11.5px; padding: 0 7px; margin-left: 2px; vertical-align: 1px; }
.pf-actions { text-align: right; white-space: nowrap; }
.pf-coords code { font-size: 12.5px; white-space: nowrap; }
/* Indirizzo e coordinate modificabili con un clic nella tabella */
.pf-editable { font: inherit; color: inherit; text-align: left; background: none; border: 1px dashed transparent; border-radius: 6px;
  padding: 3px 6px; margin: -4px -7px; cursor: text; max-width: 100%; display: block; }
.pf-editable:hover, .pf-editable:focus-visible { border-color: var(--border); background: var(--chip); }
.pf-editable .pf-place { display: flex; }
.pf-inline { width: 100%; min-width: 180px; font-size: 13px; padding: 5px 8px; }
.pf-coords .pf-inline { min-width: 200px; }
.pf-gmaps .evbtn { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; text-decoration: none; margin: 0; }
.pf-gmaps .evbtn .icon { width: 14px; height: 14px; }
.pf-actions .evbtn { margin: 0 0 0 4px; }
.pf-more { font-weight: 700; letter-spacing: .05em; padding-left: 10px; padding-right: 10px; }
.evbtn.danger:hover { color: var(--err); border-color: var(--err); }
.evbtn:disabled { opacity: .45; cursor: default; }

/* Stato di un profilo: un bollino solo */
.st { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-ok { background: var(--ok-bg); color: var(--ok); }
.st-err { background: var(--err-bg); color: var(--err); }
.st-warn { background: var(--warn-bg); color: var(--warn); }
.st-none, .st-paused { background: var(--chip); color: var(--muted); }

/* Finestre: aggiunta e dettaglio */
dialog.pf-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; }
#pf_add_dialog input[type=text] { width: 100%; }
#pf_add_dialog .result, #pf_extra:not(:empty) { margin-top: 10px; }
#pf_add_dialog .actions { margin: 16px 0 0; }
.pf-d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.pf-d-head h2 { margin: 0 0 2px; }
.pf-d-head .iconbtn { margin: -6px -10px 0 0; }
.pf-d-status { border-radius: 10px; padding: 10px 12px; background: var(--chip); font-size: 14px; }
.pf-d-status.st-box-err { background: var(--err-bg); }
.pf-d-status.st-box-warn { background: var(--warn-bg); }
.pf-d-status.st-box-ok { background: var(--ok-bg); }
.pf-d-status .st { background: var(--card); }
.pf-d-status ul, .pf-d-status p { margin: 6px 0 0; padding-left: 18px; }
.pf-d-status p { padding: 0; }
.pf-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 14px 0; font-size: 14px; }
.pf-facts dt { color: var(--muted); }
.pf-facts dd { margin: 0; overflow-wrap: anywhere; }
.pf-d-method { border-top: 1px solid var(--border); padding-top: 12px; font-size: 14px; }
.pf-d-method .cal-modes { margin: 8px 0 4px; }
.pf-d-method .fineprint { margin: 4px 0 0; }
#pf_detail_result:not(:empty) { margin: 12px 0 0; }
.pf-d-actions { border-top: 1px solid var(--border); padding-top: 14px; margin: 14px 0 0; }
.pf-d-actions .danger { margin-left: auto; }

/* Telefono: ogni profilo è una scheda compatta di tre righe */
@media (max-width: 600px) {
  .pf-table, .pf-table tbody { display: block; }
  .pf-table tr:has(th) { display: none; }
  /* nome e ⋯ / stato / posizione / post e eventi della settimana */
  .pf-table tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 6px 12px; align-items: center;
    padding: 12px 0; border-top: 1px solid var(--border); }
  .pf-table tr[data-pf-row]:hover td { background: none; }
  .pf-table td, .pf-table td.num { display: block; border: 0; padding: 0; }
  .pf-table td.pf-who { grid-column: 1 / 4; grid-row: 1; }
  .pf-table td.pf-actions { grid-column: 4; grid-row: 1; }
  .pf-table td.pf-status { display: flex; align-items: center; gap: 6px; min-width: 0; grid-column: 1 / -1; }
  .pf-why { margin: 0; max-width: none; }
  .pf-table td.pf-where { grid-column: 1 / -1; max-width: none; display: flex; align-items: center; gap: 6px; min-width: 0; }
  .pf-table td.pf-where .pf-place { max-width: none; min-width: 0; }
  .pf-table td.pf-where .pf-map { margin: 0; }
  .pf-table td.pf-coords { grid-column: 1 / 3; font-size: 13px; }
  .pf-table td.pf-coords:has(.muted) { display: none; }
  .pf-table td.pf-gmaps { grid-column: 1 / -1; }
  .pf-table td.pf-activity { display: inline; font-size: 13px; color: var(--muted); }
  .pf-table td.pf-activity strong { font-size: 13px; color: var(--text); }
  .pf-table td.pf-activity::after { content: " " attr(data-label); }
  .pf-facts { grid-template-columns: 1fr; gap: 0; }
  .pf-facts dd { margin-bottom: 8px; }
  .pf-d-actions .btn { flex: 1 1 auto; }
  .pf-d-actions .danger { margin-left: 0; }
}
/* Suggerimenti in attesa: numero sul pulsante della scheda Profili e riquadro evidenziato */
.tabs button { position: relative; }
.tab-badge { top: -4px; right: -6px; }
#tab-profiles #sugg_box { margin: 16px 0; background: var(--card); border: 1px solid var(--accent); border-radius: 12px; padding: 4px 16px 12px; }
#sugg_box h3 { display: flex; align-items: baseline; gap: 8px; }
#sugg_box h3 .count { font-weight: 500; font-size: 14px; }
.multi-quick { white-space: nowrap; }
/* Sezione Instaloader: testi diversi se è il metodo principale o quello di riserva */
section:not(.as-fallback) .fallback-only, section.as-fallback .primary-only { display: none; }

/* Pulsanti principali di ogni evento: post Instagram e calendario */
.ev-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.evbtn.main {
  color: var(--text); font-weight: 600; padding: 6px 14px; text-decoration: none; background: var(--chip); border-color: transparent;
}
.evbtn.main:hover { border-color: var(--muted); text-decoration: none; }
.ev-actions + .links { margin-top: 8px; }
.carousel .event .ev-actions { margin-top: auto; padding-top: 10px; }
.carousel .event .ev-actions + .links { margin-top: 8px; padding-top: 0; }
.cal-grid-opts { grid-template-columns: 1fr 1fr; }
@media (max-width: 400px) { .cal-grid-opts { grid-template-columns: 1fr; } }
/* Link "Segnala un problema" in fondo al menu laterale */
.side-bug { display: inline-flex; align-items: center; gap: 6px; margin: 14px 8px 0; color: var(--muted); font-size: 13px; }
.side-bug:hover { color: var(--accent); }
/* Segnalazioni (app admin) */
.bug-msg { white-space: pre-wrap; margin: 8px 0 4px; }
.sugg.bug.done { opacity: .7; }
#bugs_done_box { margin-top: 20px; }
#bugs_done_box summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }

/* --- Filtri su telefono (sito pubblico) ---
   Su schermi larghi #f_sheet non è un pannello: i suoi controlli restano nella barra dei filtri. */
.fsheet-head, .fsheet-foot, .fsheet-backdrop { display: none; }
/* Filtri attivi da togliere (es. "Tutti gli eventi di…"): su ogni schermo, in una riga a sé */
.factive { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; order: 3; flex-basis: 100%; }
.factive .fchip { font-size: 13px; padding: 3px 8px 3px 10px; border-color: var(--accent); color: var(--accent); }
.factive .fchip .icon { width: 14px; height: 14px; }
.factive .linkbtn { margin-left: 4px; }
.fsheet { display: contents; }

/* Intestazione degli eventi: titolo a sinistra, "Mostra passati" in alto a destra */
.ev-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.switch { display: inline-flex; align-items: center; gap: 8px; flex: none; margin-top: 6px; cursor: pointer;
  font-size: 14px; color: var(--muted); white-space: nowrap; }
.switch input[type=checkbox] {
  flex: none; -webkit-appearance: none; appearance: none; margin: 0; cursor: pointer; order: 2;
  position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--border); border: 0; padding: 0;
  transition: background .15s ease;
}
.switch input[type=checkbox]::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s ease;
}
.switch input[type=checkbox]:checked { background: var(--accent); }
.switch input[type=checkbox]:checked::before { transform: translateX(16px); }
.switch input[type=checkbox]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Filtri rapidi: date e categorie (#fcats), a scorrimento orizzontale sul telefono */
.fbar { display: flex; gap: 8px; order: 2; flex-basis: 100%; flex-wrap: wrap; }
#fcats { order: 3; }
#fcats:empty { display: none; }
.fchip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none;
  font: inherit; font-size: 14px; color: var(--text); background: var(--card); cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px;
}
.fchip:hover { border-color: var(--muted); text-decoration: none; }
.fchip .icon { width: 16px; height: 16px; }
.fbar .fchip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.fbar .fchip.on .icon { fill: none; }
.fchip-link { color: var(--accent); border-style: dashed; }
/* Su schermi larghi il calendario è il menu "Quando" nella barra: il pulsante serve solo sul telefono */
@media (min-width: 601px) { #f_open { display: none; } }

@media (max-width: 600px) {
  .wrap { padding-top: 14px; }
  header h1 { font-size: 22px; }
  header p { font-size: 12px; }

  /* La barra resta in alto e scompare scorrendo in giù (vedi hideOnScroll in events.js) */
  #filters {
    position: sticky; top: var(--topbar-h, 0px); z-index: 3;
    flex-direction: column; flex-wrap: nowrap; gap: 8px;
    margin: 0 -16px 8px; padding: 10px 16px;
    transition: transform .2s ease;
  }
  #filters > input[type=search] { flex: none; }
  #filters.fbar-hidden { transform: translateY(-100%); }
  body.sheet-open #filters { z-index: 40; transform: none; }
  body.sheet-open { overflow: hidden; }

  .fbar {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin: 0 -16px; padding: 0 16px;
  }
  .fbar::-webkit-scrollbar { display: none; }
  /* Calendario: solo l'icona */
  .fcal { padding: 6px 10px; }
  .ev-header .switch { font-size: 13px; }
  .fbadge {
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; font-size: 11px; font-weight: 700;
    line-height: 18px; text-align: center; background: var(--accent-text); color: var(--accent);
  }
  .factive { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  .factive .fchip { font-size: 13px; padding: 3px 8px 3px 10px; border-color: var(--accent); color: var(--accent); }
  .factive .fchip .icon { width: 14px; height: 14px; }
  .factive .linkbtn { margin-left: 4px; }

  /* Pannello dal basso */
  .fsheet-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4);
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  body.sheet-open .fsheet-backdrop { opacity: 1; pointer-events: auto; }
  .fsheet {
    position: fixed; left: 0; right: 0; bottom: 0; max-height: 88vh; max-height: 88dvh;
    display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
    background: var(--card); border-radius: 16px 16px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, .2);
    padding: 0 16px; transform: translateY(105%); visibility: hidden;
    transition: transform .25s ease, visibility 0s .25s;
  }
  .fsheet.open { transform: none; visibility: visible; transition: transform .25s ease; }
  .fsheet-head {
    order: -2; position: sticky; top: 0; z-index: 2; background: var(--card);
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    padding: 18px 0 10px; border-bottom: 1px solid var(--border); touch-action: none;
  }
  .fsheet-head strong { font-size: 16px; }
  .fsheet-head .linkbtn { justify-self: start; font-size: 15px; }
  .fsheet-head .iconbtn { justify-self: end; margin-right: -8px; }
  .fsheet-grip {
    position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
    border-radius: 2px; background: var(--border);
  }
  .fsheet .multi { padding: 14px 0; border-bottom: 1px solid var(--border); }
  .fsheet #dates { order: -1; }
  .fsheet .multi::before {
    content: attr(data-title); display: block; margin-bottom: 8px;
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  }
  .fsheet .multi-btn { width: 100%; justify-content: space-between; }
  .fsheet .multi-btn span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fsheet .multi-panel {
    position: static; width: auto; min-width: 0; max-width: none; max-height: none; overflow: visible;
    border: 0; box-shadow: none; padding: 6px 0 0; background: none;
  }
  .fsheet .multi-head { position: static; padding: 4px 0 8px; }
  .fsheet .multi-panel label { padding: 9px 4px; }
  /* Il calendario è sempre aperto */
  .fsheet #dates .multi-btn { display: none; }
  .fsheet #dates .multi-panel[hidden] { display: block !important; }
  .fsheet #dates .multi-panel { padding: 0; }
  .fsheet .cal-grid button { aspect-ratio: auto; height: 38px; }
  /* Le date rapide sono già nella barra; per toglierne una si tocca di nuovo o si usa Azzera */
  .fsheet .cal-presets { display: none; }
  .fsheet .cal-hint { margin-bottom: 0; }
  .fsheet > label {
    justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border);
    color: var(--text); font-size: 15px;
  }
  .fsheet > select { margin: 14px 0 0; }
  /* Spunte come interruttori */
  .fsheet > label input[type=checkbox] {
    order: 2; flex: none; -webkit-appearance: none; appearance: none; margin: 0; cursor: pointer;
    position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--border);
    transition: background .15s ease;
  }
  .fsheet > label input[type=checkbox]::before {
    content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s ease;
  }
  .fsheet > label input[type=checkbox]:checked { background: var(--accent); }
  .fsheet > label input[type=checkbox]:checked::before { transform: translateX(18px); }
  .fsheet-foot {
    display: block; position: sticky; bottom: 0; margin-top: auto; background: var(--card);
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  }
  .fsheet-foot .btn { width: 100%; padding: 12px; font-size: 16px; }
}

/* --- Mappa (#mappa, sito pubblico) --- */
#map_btn { text-decoration: none; color: inherit; }
#map_btn.on { color: var(--accent); }
.map-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 14px 0 10px; }
.map-controls .cal-modes { margin: 0; }
.map-controls .fbar { margin: 0; }
.map-box {
  height: calc(100dvh - 250px); min-height: 360px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); background: var(--chip); z-index: 0;
}
.map-pin-wrap { background: none; border: 0; }
.map-pin {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); border: 3px solid var(--card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35); box-sizing: border-box;
}
.map-pin:not(.has-count) { width: 20px; height: 20px; margin: 5px; }
.map-pin b { font-size: 12px; line-height: 1; font-weight: 700; }
.map-pin.ev { background: var(--personal); color: #fff; }
/* Il CSS di Leaflet si carica dopo questo (map.js, alla prima apertura) e a parità di specificità
   vincerebbe lui (riquadri bianchi anche nel tema scuro): ogni regola parte da .map-box */
.map-box.leaflet-container { font: inherit; background: var(--chip); }
.map-box .leaflet-popup-content-wrapper, .map-box .leaflet-popup-tip { background: var(--card); color: var(--text); }
.map-box .leaflet-popup-content { margin: 12px 14px; font-size: 14px; line-height: 1.4; }
.map-box.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.map-box.leaflet-container a { color: var(--accent); }
.map-box .leaflet-bar a, .map-box .leaflet-bar a:hover { background: var(--card); color: var(--text); border-color: var(--border); }
.map-box .leaflet-control-attribution { background: color-mix(in srgb, var(--card) 80%, transparent) !important; color: var(--muted); }
.map-box .leaflet-control-attribution a { color: var(--muted); }
.map-pop { max-height: 280px; overflow-y: auto; }
.map-prof { display: flex; flex-direction: column; padding: 6px 0; border-bottom: 1px solid var(--border); }
.map-prof:first-child { padding-top: 0; }
.map-prof a { font-size: 13px; }
.map-prof .linkbtn { text-align: left; padding: 2px 0 0; font-size: 13px; }
.map-addr { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.map-place { display: block; padding-right: 14px; }
.map-events { list-style: none; margin: 8px 0 0; padding: 0; }
.map-events button {
  display: flex; flex-direction: column; width: 100%; text-align: left; font: inherit; color: var(--text);
  background: none; border: 0; border-top: 1px solid var(--border); padding: 6px 0; cursor: pointer;
}
.map-events button:hover b { color: var(--accent); }
.map-events button.on { background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 6px; padding: 6px; }
.map-events button.on b { color: var(--accent); }
.map-events span { font-size: 12px; color: var(--muted); }
@media (max-width: 640px) {
  .map-box { height: calc(100dvh - 230px); border-radius: 10px; }
}
.map-none { font-size: 13px; color: var(--muted); }
.map-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9) saturate(.6); }
.pf-d-place input { width: 100%; }
.pf-coords-label { margin-top: 12px; }
.pf-d-place .actions { margin-top: 4px; }
.pf-map { font-size: 11px; padding: 0 6px; border-radius: 999px; margin-left: 4px; white-space: nowrap; background: var(--chip); }
.pf-map-ok { color: var(--ok); background: var(--ok-bg); }
.pf-map-warn { color: var(--warn); background: var(--warn-bg); }
.pf-map-err { color: var(--err); background: var(--err-bg); }
.pf-map-err { color: var(--err); background: var(--err-bg); }

/* Categorie da mostrare (menu utente) */
.acc-cats-box { margin: 4px 0 14px; }
.acc-cats-head { display: flex; align-items: center; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.acc-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.acc-cat {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--chip); font-size: 14px; cursor: pointer;
}
.acc-cat:has(input:checked) { border-color: var(--accent); }
.acc-cat input { accent-color: var(--accent); margin: 0; }
.acc-cats-box .fineprint { margin-top: 6px; }
.acc-paid { margin: 0 0 14px; }
.acc-paid .switch { margin-top: 0; font-weight: 600; }
.acc-paid .fineprint { margin-top: 4px; }

/* Titolo nella barra in alto: nell'intestazione restano riepilogo e "Mostra passati", su una riga */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ev-header-compact { align-items: center; margin-top: 2px; }
.ev-header-compact #summary { margin: 0; min-width: 0; }
.ev-header-compact .switch { margin-top: 0; }
.brand { font-size: 17px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* Logo AroJam: barattolo nel colore del tema (azzurro per gli hunter), nome e, su schermi larghi, il sottotitolo */
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 22px; height: 29px; flex: none; color: var(--accent); }
/* Nome e frase in un blocco a larghezza fissa: una frase lunga non spinge via i pulsanti.
   Se non ci sta, la frase scorre (portal.js aggiunge .scrolling e una copia per il giro continuo) */
.brand-text { display: flex; flex-direction: column; flex: none; width: 300px; line-height: 1.15; }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.brand-tag { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.brand-tag-in { display: inline-block; }
.brand-tag-in > span + span { padding-left: 48px; }
.brand-tag.scrolling { text-overflow: clip;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6px, #000 calc(100% - 18px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6px, #000 calc(100% - 18px), transparent); }
.brand-tag.scrolling .brand-tag-in { animation: brand-tag-scroll var(--tag-dur, 12s) linear infinite; }
.brand:hover .brand-tag-in { animation-play-state: paused; }
/* Ferma all'inizio di ogni giro per un attimo, poi scorre fino alla copia (identica all'originale) */
@keyframes brand-tag-scroll { 0%, 15% { transform: translateX(0); } 100% { transform: translateX(calc(-1 * var(--tag-dist, 0px))); } }
@media (prefers-reduced-motion: reduce) {
  .brand-tag.scrolling { text-overflow: ellipsis; -webkit-mask-image: none; mask-image: none; }
  .brand-tag.scrolling .brand-tag-in { animation: none; display: inline; }
  .brand-tag-in > span[aria-hidden] { display: none; }
}
@media (max-width: 720px) { .brand-text { width: 190px; } }
@media (max-width: 560px) { .brand-text { width: 140px; } .brand-name { font-size: 18px; } .brand-tag { font-size: 11.5px; } }
@media (max-width: 380px) { .brand-text { width: 112px; } }

/* "In questi giorni" / "Eventi di lunga durata": due tab sullo stesso livello */
.day.head-tabs h2 { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; }
.htab {
  font: inherit; text-transform: inherit; letter-spacing: inherit; background: none; border: 0; cursor: pointer;
  padding: 2px 0 4px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent;
  display: inline-flex; align-items: center; gap: 6px;
}
.htab .count { font-weight: 500; }
.htab.on { color: var(--accent); border-bottom-color: var(--accent); }
.htab:hover:not(.on) { color: var(--text); }
.htab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.head-tabs .longrun { margin: 6px 0; }
.head-tabs .longrun .lr-hint { margin: 10px 16px 2px; font-size: 12px; color: var(--muted); }
.lr-more { margin: 0 16px 12px; }

/* Mappa e "Attorno a me" nella barra delle date rapide: chip come gli altri */
#map_btn, .fnear { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.fnear .icon { width: 15px; height: 15px; }
#map_btn .icon { width: 16px; height: 16px; }
/* Posizione dell'utente sulla mappa */
.map-me {
  width: 34px; height: 34px; border-radius: 50%; background: #2563eb; color: #fff; border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .25), 0 2px 6px rgba(0, 0, 0, .45); box-sizing: border-box;
  display: grid; place-items: center;
}
.map-me svg { width: 18px; height: 18px; fill: currentColor; }

/* --- Colore delle schede per categoria (primo tag), scelto dall'admin ---
   --cat è il pastello (tema chiaro); --cat-dk / --cat-dk2 la stessa tinta scura (tema scuro), vedi catVars */
.event.has-cat, .fbar .fchip.fcat, .longrun li[style*="--cat"] {
  --cat-bg: var(--cat); --cat-line: color-mix(in srgb, var(--cat), var(--text) 18%);
  --cat-on: color-mix(in srgb, var(--cat), var(--text) 16%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.event.has-cat, .fbar .fchip.fcat, .longrun li[style*="--cat"]) {
    --cat-bg: var(--cat-dk); --cat-line: var(--cat-dk2); --cat-on: var(--cat-dk2);
  }
}
:root[data-theme="dark"] :is(.event.has-cat, .fbar .fchip.fcat, .longrun li[style*="--cat"]) {
  --cat-bg: var(--cat-dk); --cat-line: var(--cat-dk2); --cat-on: var(--cat-dk2);
}
.event.has-cat { background: var(--cat-bg); border-color: var(--cat-line); }
/* Più tag colorati: sfumatura orizzontale fra i colori (fino a tre), il primo a sinistra */
.event.cats-2, .longrun li.cats-2 { --cat-bg-b: var(--cat-b); }
.event.cats-3, .longrun li.cats-3 { --cat-bg-b: var(--cat-b); --cat-bg-c: var(--cat-c); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.event, .longrun li):is(.cats-2, .cats-3) { --cat-bg-b: var(--cat-b-dk); --cat-bg-c: var(--cat-c-dk); }
}
:root[data-theme="dark"] :is(.event, .longrun li):is(.cats-2, .cats-3) { --cat-bg-b: var(--cat-b-dk); --cat-bg-c: var(--cat-c-dk); }
.event.has-cat .chip:not(.live):not(.new) { background: color-mix(in srgb, var(--card) 65%, transparent); }
/* Eventi di lunga durata: righe colorate come le schede, un clic apre il menu delle opzioni */
.head-tabs .longrun ul { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 10px; }
.head-tabs .longrun li { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.head-tabs .longrun li:hover { filter: brightness(.98); }
.longrun li[style*="--cat"] { background: var(--cat-bg); border-color: var(--cat-line); }
.event.has-cat.cats-2, .longrun li.cats-2 { background: linear-gradient(90deg, var(--cat-bg) 15%, var(--cat-bg-b) 85%); }
.event.has-cat.cats-3, .longrun li.cats-3 { background: linear-gradient(90deg, var(--cat-bg) 8%, var(--cat-bg-b) 50%, var(--cat-bg-c) 92%); }

/* --- Menu delle opzioni di un evento --- */
.event { position: relative; }
.event h3 { padding-right: 30px; }
.ev-more {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer;
}
.ev-more:hover, .ev-more:focus-visible { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.ev-more .icon { width: 20px; height: 20px; }
.ev-flags { display: inline-flex; gap: 4px; vertical-align: -1px; color: var(--accent); }
.ev-flags .icon { width: 15px; height: 15px; fill: currentColor; }
.ev-src .ev-flags .icon, .lr-meta .ev-flags .icon { width: 12px; height: 12px; }
/* Pagina da cui viene il post, sopra il titolo */
.ev-src {
  font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 2px; padding-right: 30px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Un clic (o un tocco) sulla scheda apre il menu delle opzioni */
#list .event { cursor: pointer; }
@media (hover: hover) {
  #list .event { transition: box-shadow .15s; }
  #list .event:hover { box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }
}
/* Sul telefono un tocco sulla scheda apre il menu delle opzioni */
@media (hover: none) {
  .event, .longrun li { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
    cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .12s, filter .12s; }
  .event:active, .longrun li:active { transform: scale(.985); filter: brightness(.97); }
}
.ev-menu {
  position: fixed; z-index: 30; min-width: 240px; max-width: min(320px, calc(100vw - 16px));
  background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2); padding: 6px; display: flex; flex-direction: column;
}
.ev-menu-head { display: flex; flex-direction: column; padding: 8px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.ev-menu-head b { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ev-menu-head span { font-size: 12px; color: var(--muted); }
.ev-menu [role=menuitem] {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.ev-menu [role=menuitem]:hover, .ev-menu [role=menuitem]:focus-visible { background: var(--chip); outline: none; }
.ev-menu [role=menuitem] .icon { color: var(--muted); width: 18px; height: 18px; }
.ev-menu [role=menuitem].on .icon { color: var(--accent); fill: currentColor; }
.ev-menu-backdrop { position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, .35); }
/* Sul telefono: pannello dal basso */
.ev-menu.sheet {
  left: 0; right: 0; bottom: 0; top: auto; max-width: none; min-width: 0; border-radius: 16px 16px 0 0;
  padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); animation: ev-sheet-in .18s ease-out;
}
.ev-menu.sheet [role=menuitem] { padding: 13px 12px; font-size: 15px; }
@keyframes ev-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .ev-menu.sheet { animation: none; } }
/* La scheda toccata, in risalto sopra il pannello: titolo e data nel pannello non servono più */
.ev-menu.sheet.has-preview .ev-menu-head { display: none; }
.ev-menu-preview {
  position: fixed; left: 10px; right: 10px; z-index: 30; overflow-y: auto; overscroll-behavior: contain;
  border-radius: 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, .35); animation: ev-preview-in .2s ease-out;
}
.ev-menu-preview > * { margin: 0 !important; }
.ev-menu-preview .event { box-shadow: none; }
.ev-menu-preview .longrun { border: 0; }
.ev-menu-preview .longrun ul { margin: 0; padding: 0; }
.ev-menu-preview .longrun li { border-top: 0; }
.ev-menu-preview a, .ev-menu-preview button { pointer-events: none; }
.ev-menu-preview .event:active, .ev-menu-preview li:active { transform: none; filter: none; }
@keyframes ev-preview-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ev-menu-preview { animation: none; } }

/* Suggerimento sopra la lista */
.ev-tip {
  display: flex; align-items: center; gap: 8px; margin: 10px 0 0; padding: 6px 6px 6px 12px; border-radius: 10px;
  background: var(--chip); color: var(--muted); font-size: 13px;
}
.ev-tip span { flex: 1; }
.ev-tip .iconbtn { padding: 4px; color: var(--muted); }

/* Admin: colori delle categorie */
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: 8px 0 4px; }
.color-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.color-row input[type=color] { width: 40px; height: 34px; padding: 2px; border-radius: 8px; flex: none; cursor: pointer; }
.color-sample { flex: 1; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); color: #1d1d1b; font-size: 14px; }

/* Chip delle categorie col colore della categoria */
.fbar .fchip.fcat { background: var(--cat-bg); border-color: var(--cat-line); color: var(--text); }
.fbar .fchip.fcat.on { background: var(--cat-on); border-color: var(--text); color: var(--text); font-weight: 600; }

/* Admin: riepilogo del post aggiunto */
.recap-list { list-style: none; margin: 0 0 8px; padding: 0; }
.recap-list li { display: flex; flex-direction: column; gap: 2px; padding: 9px 0; border-top: 1px solid var(--border); }
.recap-list li span { font-size: 13px; color: var(--muted); }
.recap-list .recap-tags { font-size: 12px; }
#add_recap .actions a.btn { text-decoration: none; }

/* Post analizzati: rianalisi dei post in errore, sotto al titolo */
.posts-retry { margin: 10px 0 4px; }
.posts-retry .btn { display: inline-flex; align-items: center; gap: 6px; }
.posts-retry .icon { width: 16px; height: 16px; }

/* Post analizzati: statistiche complessive del periodo */
.pp-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px; }
.pp-stats > div { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; min-width: 120px; }
.pp-stats span { display: block; font-size: 12px; color: var(--muted); }
.pp-stats b { font-size: 18px; font-variant-numeric: tabular-nums; }
.pp-stats b small { font-size: 13px; font-weight: 600; color: var(--muted); }
.pp-stats .ok b { color: var(--ok); }
.pp-stats .err b { color: var(--err); }
.pp-stats .fineprint { flex-basis: 100%; margin: 0; }

/* Tabella dei profili in Post analizzati: intestazioni su una riga, testo lungo che va a capo */
.pp-table th { white-space: nowrap; }
.pp-table td.num { white-space: nowrap; }
.pp-table td:last-child { min-width: 170px; }

/* Post analizzati: catture degli hunter da approvare */
.hunts-box { margin: 18px 0; }
.hunts-box .posts-title .icon { width: 18px; height: 18px; vertical-align: -3px; }
.hunt { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; background: var(--card);
  border: 1px solid var(--accent); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.hunt-photo { padding: 0; border: 0; background: var(--chip); border-radius: 8px; overflow: hidden; cursor: zoom-in;
  align-self: start; min-height: 120px; }
.hunt-photo img { display: block; width: 100%; height: auto; }
.hunt-photo.big { grid-column: 1 / -1; cursor: zoom-out; }
.hunt-head { font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hunt-note { font-size: 13px; color: var(--muted); margin: 6px 0; }
.hunt-events { margin: 8px 0; display: grid; gap: 10px; }
/* Evento di una cattura: campi compilati dall'AI, modificabili prima di approvare */
.hunt-ev { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 4px; margin: 0; min-width: 0; }
.hunt-ev .field { margin-bottom: 8px; font-size: 13px; }
.hunt-ev .field input, .hunt-ev .field textarea { font-size: 14px; }
.hunt-ev-head { display: flex; gap: 8px; align-items: flex-end; }
.hunt-ev-head .field { flex: 1; }
.hunt-ev-head .iconbtn { margin-bottom: 8px; }
.hunt-ev-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hunt-tags { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 2px 0 8px; font-size: 13px; }
.hunt-tags .tag-opt { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }
.hunt-tags input { width: auto; margin: 0; }
[data-hunt-add] { display: inline-flex; align-items: center; gap: 6px; }
[data-hunt-add] .icon { width: 15px; height: 15px; }
@media (max-width: 700px) { .hunt-ev-row { grid-template-columns: 1fr; } }
.hunts-done { font-size: 13.5px; }
.hunts-done ul { margin: 6px 0 0; padding-left: 18px; }
.ok-text { color: var(--ok); }
.hunter-chip { font-size: 11px; }
@media (max-width: 600px) { .hunt { grid-template-columns: 1fr; } }

/* --- Hunter: locandine fotografate per strada (hunt.js) --- */
.hunter-chip { background: color-mix(in srgb, var(--accent) 14%, var(--card)); color: var(--accent); font-weight: 600;
  white-space: nowrap; }
.ev-src .hunter-chip { font-size: 11px; padding: 1px 8px; }
/* Pulsante "Cattura" in alto, in evidenza: è l'azione principale di un hunter */
.hunt-btn { color: var(--accent); font-weight: 600; }
.hunt-btn .icon { width: 19px; height: 19px; }
@media (max-width: 520px) { .hunt-btn-label { display: none; } }
/* Gli hunter hanno l'app in azzurro invece che in arancio: cambia solo il colore principale
   (classe "hunter" su <html>, messa da hunt.js) */
:root.hunter { --accent: #0284c7; --accent-text: #ffffff; }
@media (prefers-color-scheme: dark) {
  :root.hunter:not([data-theme="light"]) { --accent: #38bdf8; --accent-text: #0c1a24; }
}
:root.hunter[data-theme="dark"] { --accent: #38bdf8; --accent-text: #0c1a24; }
.hunt-dialog { width: min(460px, calc(100vw - 32px)); }
.hunt-dialog h2 { margin-bottom: 10px; }
.hunt-preview { display: block; max-width: 100%; max-height: 38vh; margin: 0 auto 12px; border-radius: 10px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .2); }
.hunt-wait { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.hunt-wait .spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: hunt-spin .8s linear infinite; }
@keyframes hunt-spin { to { transform: rotate(360deg); } }
.hunt-intro { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.hunt-actions { flex-wrap: wrap; }
.hunt-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.hunt-actions .btn .icon { width: 17px; height: 17px; }
.hunt-history { font-size: 13px; margin: 6px 0 4px; }
.hunt-history:empty { display: none; }
.hunt-history ul { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; }
.hunt-st { font-size: 11.5px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: var(--chip); }
.hunt-st.ok { color: var(--ok); background: var(--ok-bg); }
.hunt-st.err { color: var(--err); background: var(--err-bg); }
.hunt-st.muted { color: var(--muted); }

#tab-postlist h1 .count { font-size: 15px; vertical-align: middle; }

/* Post trovati: post nascosti (eventi fuori dal sito) ed eliminazione */
.post-card.is-hidden .pc-thumb, .post-card.is-hidden .pc-events { opacity: .5; }
.chip.st-hidden { background: var(--chip); color: var(--muted); font-weight: 600; }
.chip.st-hidden .icon { width: 13px; height: 13px; }
.evbtn.danger { color: var(--err); }

/* --- Chi siamo (#chi-siamo) e piè di pagina ----------------------------------------------- */
#about_page { max-width: 680px; }
.about-hero { display: flex; align-items: center; gap: 18px; margin: 6px 0 18px; }
.about-logo { width: 64px; height: 85px; flex: none; color: var(--accent); }
.about-hero h1 { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -.03em; }
.about-claim { margin: 4px 0 0; font-size: 17px; color: var(--muted); line-height: 1.4; }
.about-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.about-stats:empty { display: none; }
.about-stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.about-stat b { display: block; font-size: 26px; font-weight: 800; color: var(--accent); letter-spacing: -.02em; }
.about-stat span { font-size: 13.5px; color: var(--muted); }
.about-sec { margin-top: 26px; line-height: 1.55; }
.about-sec h2 { font-size: 19px; margin: 0 0 6px; }
.about-sec p { margin: 0 0 8px; }
.about-steps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 12px; }
.about-steps li { display: flex; gap: 12px; align-items: flex-start; }
.about-steps p { margin: 2px 0 0; color: var(--muted); }
.about-step-n { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 15px; }
.contact-form { margin-top: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.contact-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .contact-row { grid-template-columns: 1fr; } }
.contact-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.contact-ok { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--muted); margin-bottom: 10px; }
.contact-ok input { margin-top: 2px; flex: none; }
.contact-form .actions { margin-top: 4px; }
/* :target spostato sotto la barra in alto (sticky) */
#about_page section[id] { scroll-margin-top: 70px; }

.site-footer { margin: 40px 0 24px; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; font-size: 13.5px; }
.foot-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.foot-brand b { font-weight: 800; letter-spacing: -.02em; }
.foot-brand span { color: var(--muted); }
.foot-logo { width: 16px; height: 21px; color: var(--accent); flex: none; }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.foot-links a, .foot-links .linkbtn { font-size: 13.5px; color: var(--muted); text-decoration: none; }
.foot-links a:hover, .foot-links .linkbtn:hover { color: var(--accent); }
/* Sulla mappa la pagina è già piena: niente piè di pagina */
body.page-map .site-footer { display: none; }
/* Scorciatoie in fondo al menu laterale (le stesse del piè di pagina) */
.side-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 16px 8px 0; padding-top: 12px; border-top: 1px solid var(--border); }
.side-links a, .side-links .linkbtn { font-size: 13px; color: var(--muted); text-decoration: none; }
.side-links a:hover, .side-links .linkbtn:hover { color: var(--accent); }
/* Chi siamo · Collabora · Dona in cima al menu laterale */
.side-top { display: flex; flex-direction: column; gap: 4px; margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.side-top a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; background: var(--chip);
  color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600; }
.side-top a span { flex: 1; }
.side-top a .icon { width: 18px; height: 18px; color: var(--accent); flex: none; }
.side-top a .icon:last-child { width: 16px; height: 16px; color: var(--muted); }
.side-top a:hover { background: color-mix(in srgb, var(--accent) 10%, var(--chip)); }
.sidebar .side-top { flex: none; }

/* Dona (#dona) */
#donate_page { max-width: 680px; }
.donate-box { margin-top: 22px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; text-align: center; }
.donate-btn { font-size: 16px; padding: 11px 26px; text-decoration: none; }
.donate-amounts { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin: 14px 0 6px; color: var(--muted); font-size: 14px; }
.donate-amounts .fchip { text-decoration: none; }

/* --- Admin: Eventi trovati -------------------------------------------------------------- */
.el-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.el-row.is-archived { opacity: .6; }
.el-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.el-when { font-size: 12.5px; color: var(--accent); font-weight: 600; text-transform: capitalize; }
.el-title { font-weight: 600; font-size: 15px; }
.el-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.el-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.el-chips .chip { font-size: 11.5px; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.el-actions { display: flex; flex-direction: column; gap: 4px; flex: none; }
.el-actions .evbtn { justify-content: flex-start; }
@media (max-width: 640px) {
  .el-row { flex-direction: column; }
  .el-actions { flex-direction: row; flex-wrap: wrap; }
}
.el-dialog { width: min(720px, calc(100vw - 24px)); }
.el-dialog .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
@media (max-width: 640px) { .el-dialog .row { grid-template-columns: 1fr; } }
.map-search { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.map-search input { flex: 1 1 260px; min-width: 0; }
.map-search select { flex: 0 1 240px; }
