:root {
  --ink: #17202A;
  --muted: #4A5560;
  --line: #DDE2E7;
  --soft: #F3F5F7;
  --brand: #0F766E;
  --brand-dark: #115E59;
  --bg: #FFFFFF;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.4px; flex: 1; }
.seg { display: flex; background: var(--soft); border-radius: 22px; padding: 3px; }
.seg button { border: 0; background: none; height: 38px; padding: 0 14px; border-radius: 19px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon-btn:hover { background: var(--soft); }

.banner { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; background: #E6F4F1; font-size: 14px; }
.banner span { flex: 1; }

.filters { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.chip .dot { width: 10px; height: 10px; border-radius: 5px; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

main { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; }
#list { position: absolute; inset: 0; z-index: 450; background: var(--bg); overflow-y: auto; padding: 4px 16px 110px; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.item .dot { width: 12px; height: 12px; border-radius: 6px; flex: none; }
.item .txt { flex: 1; min-width: 0; }
.item .name { font-weight: 700; font-size: 16px; }
.item .addr { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; line-height: 1.5; }

.badge { display: inline-block; padding: 5px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }

.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 500;
  display: inline-flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 22px; border: 0; border-radius: 26px;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 6px 18px rgba(15,118,110,.35);
}
.fab:hover { background: var(--brand-dark); }

.pin { display: block; width: 28px; height: 28px; border-radius: 14px; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.leaflet-div-icon { background: none; border: 0; }
.area-btn { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 460; min-height: 40px; padding: 0 16px; border-radius: 20px; border: 0; background: #fff; color: var(--ink); font-weight: 700; font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.25); white-space: nowrap; }
.locate { position: absolute; right: 12px; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 450; width: 44px; height: 44px; border-radius: 22px; border: 0; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; }

/* Fogli (dialog) */
dialog.sheet {
  border: 0; padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: 520px; max-height: 90dvh; overflow-y: auto;
  margin: auto auto 0; border-radius: 22px 22px 0 0;
  color: var(--ink);
}
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 22px; } }
dialog::backdrop { background: rgba(15,23,32,.45); }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; flex: 1; font-size: 20px; font-weight: 800; }

.row { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.grow { flex: 1; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 16px 0 8px; }
.full { width: 100%; }
input[type="search"], input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="date"], input[type="time"], textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 14px; border: 1px solid #C3CAD1; background: #fff; font-size: 16px;
}
textarea { resize: vertical; }
.row input { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; font-size: 13px; font-weight: 600; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 16px; border-radius: 14px; border: 1px solid transparent; font-weight: 700; font-size: 15px; text-decoration: none; text-align: center; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 12px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.primary:disabled { background: #E2E8F0; color: #5B6670; cursor: not-allowed; }
.btn.ghost { background: #fff; border-color: #C3CAD1; color: var(--ink); }
.btn.whatsapp { background: #128C4B; color: #fff; }
.btn.danger-link { background: none; color: #B42318; width: 100%; font-weight: 600; }
.muted { color: var(--muted); font-size: 14px; margin: 6px 0; }
.from { font-size: 14px; background: #F3E8FF; color: #6B21A8; padding: 8px 12px; border-radius: 12px; }

.results { list-style: none; margin: 0 0 12px; padding: 0; }
.results button { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 12px 4px; }
.results .name { font-weight: 700; display: block; }
.results .addr { font-size: 13px; color: var(--muted); }

.verdicts { border: 0; margin: 14px 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.verdicts legend { font-weight: 700; font-size: 15px; margin-bottom: 8px; padding: 0; }
.verdicts button { min-height: 48px; border-radius: 14px; font-weight: 700; font-size: 15px; border: 2px solid transparent; }

.card { background: var(--soft); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.card-title { font-size: 18px; font-weight: 800; }
.quote { margin: 4px 0 0; font-style: italic; }
.counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.counts div { border-radius: 14px; padding: 10px 12px; font-size: 13px; font-weight: 700; }
.counts b { display: block; font-size: 22px; }
.steps { padding-left: 20px; line-height: 1.6; }
.steps li { margin-bottom: 8px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 1000; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Locali vicini da salvare */
.near { overflow: visible; }
.near-ico {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; border: 2px solid #0F766E; box-shadow: 0 2px 6px rgba(0,0,0,.3);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.near-name {
  position: absolute; top: 48px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis;
  font: 600 12px/1.2 system-ui, sans-serif; color: #17202A;
  background: rgba(255,255,255,.92); padding: 2px 6px; border-radius: 6px;
  pointer-events: none;
}

/* Foto del posto */
.photos { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; }
.thumb {
  flex: 0 0 auto; width: 76px; height: 76px; border-radius: 12px; overflow: hidden;
  border: 1px solid #D5DBE1; background: #F3F5F7; padding: 0; cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 2px dashed #0F766E; color: #0F766E; font: 600 12px/1.2 system-ui, sans-serif; text-align: center;
}
.thumb.add span:first-of-type { font-size: 24px; }
.photo-view {
  border: 0; padding: 12px; background: #111; width: 100%; max-width: 100vw; max-height: 100vh; height: 100%;
  margin: 0; box-sizing: border-box; display: none; flex-direction: column; gap: 12px;
}
.photo-view[open] { display: flex; }
.photo-view img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.photo-view .btn.ghost { color: #fff; border-color: #fff; background: transparent; }
.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: #0F766E; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.suggest:empty { display: none; }
.suggest .muted { width: 100%; margin: 0; }
.chip .dist { font-weight: 400; color: var(--muted); }
.cover { margin: 0 0 12px; border-radius: 14px; overflow: hidden; background: #F3F5F7; position: relative; }
.cover img { width: 100%; height: 180px; object-fit: cover; display: block; }
.cover-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 12px; }
.cover-tools .btn { cursor: pointer; }
.cover figcaption:empty { display: none; }
.cover figcaption { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: #fff; background: rgba(0,0,0,.5); padding: 2px 6px; border-radius: 6px; }
.item .side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.item .dist { font-size: 13px; font-weight: 600; color: var(--muted); }
.when { font-weight: 700; }
.when::first-letter { text-transform: uppercase; }
.leave { margin: 14px 0; padding: 12px 14px; border-radius: 14px; background: #ECFDF5; color: #065F46; font-size: 15px; }
.leave strong { font-size: 18px; }
#pOuting { margin-top: 4px; }

/* Account */
.account { margin: 12px 0; padding: 14px; border-radius: 16px; background: var(--soft); }
.acc-title { font-weight: 800; margin: 0 0 4px; }
.btn.google { background: #fff; border: 1px solid var(--line); color: #17202A; display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0; }
.acc-email summary { cursor: pointer; color: var(--muted); font-size: 14px; margin: 6px 0; }
.icon-btn.signed { position: relative; }
.icon-btn.signed::after { content: ''; position: absolute; right: 4px; bottom: 4px; width: 10px; height: 10px; border-radius: 5px; background: #16A34A; border: 2px solid #fff; }

/* Schermata di accesso obbligatorio */
.gate { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: var(--bg); color: var(--ink); }
.gate::backdrop { background: var(--bg); }
.gate-box { box-sizing: border-box; max-width: 420px; min-height: 100%; margin: 0 auto; padding: 48px 24px calc(32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; justify-content: center; text-align: center; }
.gate-logo { width: 88px; height: 88px; border-radius: 22px; margin: 0 auto 16px; }
.gate h2 { margin: 0 0 8px; font-size: 26px; }
.gate .btn.google { margin-top: 24px; min-height: 52px; font-size: 16px; }
.gate .acc-email { text-align: left; }
.gate .small { font-size: 13px; margin-top: 18px; }
.gsi-btn { display: flex; justify-content: center; min-height: 44px; margin-top: 24px; }
.gsi-btn[hidden] { display: none; }
.link-btn { border: 0; background: none; color: var(--muted); font-size: 13px; text-decoration: underline; margin: 12px auto 4px; padding: 6px; }
.gate :focus:not(:focus-visible) { outline: none; }

/* Uscite di gruppo */
.claim { margin: 14px 0 12px; }
.claim-list { display: flex; flex-wrap: wrap; gap: 8px; }
.answer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 16px; }
.answer button { min-height: 46px; border-radius: 14px; border: 1px solid #C3CAD1; background: #fff; color: var(--ink); font-weight: 700; font-size: 15px; }
.answer button[aria-pressed="true"][data-a="si"] { background: #15803D; border-color: #15803D; color: #fff; }
.answer button[aria-pressed="true"][data-a="forse"] { background: #B45309; border-color: #B45309; color: #fff; }
.answer button[aria-pressed="true"][data-a="no"] { background: #4A5560; border-color: #4A5560; color: #fff; }
.members-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.members { list-style: none; margin: 4px 0 12px; padding: 0; }
.members li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.m-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-status { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 10px; white-space: nowrap; }
.m-status.yes { background: #DCFCE7; color: #166534; }
.m-status.maybe { background: #FEF3C7; color: #92400E; }
.m-status.no { background: #E5E7EB; color: #374151; }
.m-status.go { background: #DBEAFE; color: #1E40AF; }
.m-status.here { background: #0F766E; color: #fff; }
.link-btn { background: none; border: 0; padding: 6px 0 0; color: var(--accent, #0F766E); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.note-form { margin-top: 8px; }
.note-form textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 10px; border: 1px solid #D1D5DB; border-radius: 12px; resize: vertical; }
.note-form .row { display: flex; gap: 8px; margin-top: 6px; }
.m-status.wait { background: var(--soft); color: var(--muted); }
.m-wa { font-size: 12px; font-weight: 700; color: #fff; background: #128C4B; padding: 6px 10px; border-radius: 10px; text-decoration: none; }
.m-del { border: 0; background: none; color: var(--muted); font-size: 16px; width: 36px; height: 36px; border-radius: 18px; }
.add-person { margin: 4px 0 12px; }
.add-person .row input { flex: 1; min-width: 0; }
.trips { margin: 8px 0 12px; padding: 4px 12px; border-radius: 16px; background: #ECFDF5; }
.trips-title { margin: 10px 4px 0; font-weight: 800; color: #065F46; }
.item.trip { border-bottom-color: #D1FAE5; }
.item.trip:last-child { border-bottom: 0; }
.trip-ico { font-size: 22px; width: 28px; text-align: center; }
.m-phone { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.notify-btn { margin: 4px 0 12px; }
.notify-btn.on { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.trip-btn { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 460; max-width: calc(100% - 32px); min-height: 44px; padding: 0 16px; border-radius: 22px; border: 0; background: #0F766E; color: #fff; font-weight: 700; font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-btn[hidden] { display: none; }
.banner.update { background: #0F766E; color: #fff; font-weight: 600; }
.banner.update .btn { background: #fff; color: #0F766E; }
.version-row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.version-row .link-btn { margin: 0; }

/* Menu laterale */
.menu-btn { margin-left: -8px; }
.drawer { margin: 0; padding: 0; border: 0; width: min(320px, 86vw); max-width: none; height: 100%; max-height: none; background: var(--bg); color: var(--ink); display: none; flex-direction: column; box-shadow: 4px 0 24px rgba(0,0,0,.2); }
.drawer[open] { display: flex; animation: drawer-in .2s ease-out; }
.drawer::backdrop { background: rgba(15, 23, 42, .45); }
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .drawer[open] { animation: none; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: calc(16px + env(safe-area-inset-top)) 12px 16px 16px; border-bottom: 1px solid var(--line); }
.drawer-head img { border-radius: 12px; }
.drawer-head > div { flex: 1; min-width: 0; }
.drawer-head .muted { margin: 2px 0 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-title { font-size: 20px; font-weight: 800; }
.drawer nav { flex: 1; overflow-y: auto; }
.drawer-list { list-style: none; margin: 0; padding: 8px; }
.drawer-list button, .drawer-list a { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 48px; padding: 0 12px; border: 0; border-radius: 12px; background: none; color: var(--ink); font-size: 16px; font-weight: 600; text-align: left; text-decoration: none; }
.drawer-list button:hover, .drawer-list a:hover { background: var(--soft); }
.drawer-list svg { color: var(--brand); flex: none; }
.drawer-list .danger, .drawer-list .danger svg { color: #B42318; }
.drawer-foot { padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); font-size: 13px; }

/* Eventi privati */
.event-btn { margin-top: 8px; }
.event-where { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; margin-bottom: 12px; border-radius: 12px; background: #F5F3FF; font-weight: 600; }
.event-where .link-btn { margin: 0; flex: none; }
.ev-pin { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 18px; background: #7C3AED; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); font-size: 17px; line-height: 1; }
.ev-pin.past { background: #DC2626; filter: saturate(.9); }
.menu-emoji { width: 22px; text-align: center; font-size: 18px; }

/* Notifiche */
.bell-btn { position: relative; margin-right: 4px; }
.bell-count { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #DC2626; color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; border: 2px solid #fff; box-sizing: content-box; }
.bell-btn.ring svg { animation: ring .9s ease 1; transform-origin: 50% 10%; }
@keyframes ring { 0%,100% { transform: rotate(0); } 20% { transform: rotate(16deg); } 40% { transform: rotate(-14deg); } 60% { transform: rotate(9deg); } 80% { transform: rotate(-5deg); } }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list button { width: 100%; display: flex; gap: 12px; align-items: flex-start; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 12px 4px; color: var(--ink); font-size: 15px; }
.notif-list .n-ico { font-size: 20px; width: 26px; text-align: center; flex: none; }
.notif-list .n-txt { flex: 1; }
.notif-list .n-time { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.notif-list .new .n-txt { font-weight: 700; }
.notif-list .new::after { content: ''; width: 10px; height: 10px; border-radius: 5px; background: #DC2626; flex: none; margin-top: 6px; }
.notif-empty { color: var(--muted); padding: 16px 4px; }

/* Livelli */
.layers-btn { position: absolute; right: 12px; bottom: calc(146px + env(safe-area-inset-bottom)); z-index: 450; width: 44px; height: 44px; border-radius: 22px; border: 0; background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; }
.layers-btn.on { background: #0F766E; color: #fff; }
.layers-btn[hidden] { display: none; }
.layer-opts { display: grid; gap: 10px; margin-bottom: 8px; }
.layer-opts button { display: flex; gap: 12px; align-items: center; text-align: left; padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: #fff; color: var(--ink); font-size: 15px; }
.layer-opts button[aria-checked="true"] { border-color: #0F766E; background: #F0FDFA; }
.layer-opts small, .check small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 2px; }
.lo-ico { font-size: 26px; }
.pin.pub { width: 26px; height: 26px; border: 3px dashed #fff; opacity: .92; color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
.ev-pin.pub { width: 30px; height: 30px; font-size: 14px; border-style: dashed; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 14px; font-weight: 600; font-size: 15px; }
.check input { width: 22px; height: 22px; margin-top: 1px; accent-color: #0F766E; flex: none; }
.pu-count { font-weight: 700; margin: 8px 0 6px; }
.pu-votes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.pu-notes { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.pu-notes li { padding: 10px 12px; border-radius: 12px; background: var(--soft); font-style: italic; }
.em-form { display: grid; gap: 4px; margin-top: 10px; text-align: left; }
.em-form .row .link-btn { margin: 4px 0; }
.kind-chips { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 12px; }
.kind-chip[aria-pressed="true"] { background: #0F766E; color: #fff; border-color: #0F766E; }
