:root {
  --bg: #17181a;
  --bg-elev: #1f2124;
  --bg-elev-2: #26292d;
  --border: #34373c;
  --text: #eef0f2;
  --text-dim: #a2a8b0;
  --text-faint: #6b7178;
  --accent: #6fbf8b;
  --accent-dark: #4a9c6c;
  --accent-contrast: #0d1a12;
  --warn: #e09f3e;
  --danger: #e0645f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 6px 24px rgba(0,0,0,0.35);
  --topbar-h: 60px;
  --bottomnav-h: 62px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 16px calc(var(--bottomnav-h) + 24px);
}
.container-full { max-width: none; padding: 0; }

/* ── Topbar / bottom nav ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 1500;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  white-space: nowrap;
}
.brand-emoji { font-size: 1.4rem; }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 600;
  font-size: .95rem;
}
.topnav a.active, .topnav a:hover { color: var(--text); background: var(--bg-elev-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.utente { color: var(--text-dim); font-size: .9rem; font-weight: 600; }
.btn-link {
  background: none; border: none; color: var(--text-faint); font-size: .85rem;
  padding: 6px 4px; text-decoration: underline;
}

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--bottomnav-h);
  display: flex; background: var(--bg-elev); border-top: 1px solid var(--border);
  z-index: 1500; padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-faint); font-size: .72rem; font-weight: 700;
}
.bottomnav a span:first-child { font-size: 1.25rem; }
.bottomnav a.active { color: var(--accent); }

@media (min-width: 900px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  .container { padding-bottom: 32px; }
}

/* ── Buttons / forms ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elev-2); color: var(--text); font-weight: 700; font-size: .95rem;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; border-radius: 999px; }
.hidden { display: none !important; }

.fab {
  position: fixed; right: 20px; bottom: calc(var(--bottomnav-h) + 20px);
  width: 58px; height: 58px; border-radius: 999px; background: var(--accent);
  color: var(--accent-contrast); font-size: 1.7rem; border: none; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; z-index: 1500;
}
@media (min-width: 900px) { .fab { bottom: 28px; } }

label {
  display: block; font-size: .85rem; font-weight: 700; color: var(--text-dim);
  margin-bottom: 14px;
}
label > span.label-text { display: block; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=date], input[type=time],
input[type=number], input[type=search], textarea, select {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text);
  font-size: 1rem; margin-top: 2px;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); padding: 8px 0; margin-bottom: 0; }
.checkbox-row input { width: auto; margin: 0; }
.rating-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

/* ── Login ────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box {
  width: 100%; max-width: 360px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px; text-align: center;
}
.login-logo { font-size: 3rem; }
.login-box h1 { margin: 6px 0 2px; }
.login-sub { color: var(--text-dim); margin-bottom: 22px; }
.login-box form { text-align: left; }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .9rem; }
.alert-error { background: rgba(224,100,95,.15); color: #f3a19d; border: 1px solid rgba(224,100,95,.4); }

/* ── Cards / generic ─────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 10px; }
.page-header h1 { margin: 0; font-size: 1.4rem; }
.card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-emoji { font-size: 2.6rem; margin-bottom: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 999px;
  font-size: .78rem; font-weight: 700;
}
.chip-scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; }
.chip-btn {
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-dim);
  padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: .85rem; white-space: nowrap;
}
.chip-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end;
  justify-content: center; z-index: 2000;
}
.modal-overlay.hidden { display: none; }
.modal {
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 18px 18px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius); margin: 20px; }
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h2 { margin: 0; font-size: 1.15rem; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 1.4rem; padding: 4px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ── Toast ────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottomnav-h) + 16px); transform: translate(-50%, 20px);
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 999px; font-weight: 700; font-size: .88rem;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 2100;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { border-color: var(--danger); color: #f3a19d; }

/* ── Calendario ───────────────────────────────────────────────────────── */
.cal-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-nav-btn {
  width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text); font-size: 1.1rem;
}
.cal-title { font-weight: 800; font-size: 1.1rem; flex: 1; text-align: center; min-width: 140px; }
.cal-view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.cal-view-btn { padding: 7px 13px; background: var(--bg-elev); color: var(--text-dim); border: none; font-weight: 700; font-size: .82rem; }
.cal-view-btn.active { background: var(--accent); color: var(--accent-contrast); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { text-align: center; font-size: .72rem; font-weight: 800; color: var(--text-faint); padding-bottom: 4px; text-transform: uppercase; }
.cal-day {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  min-height: 68px; padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: pointer;
}
.cal-day.altro-mese { opacity: .35; }
.cal-day.oggi { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-day-num { font-weight: 700; font-size: .85rem; }
.cal-ev-dot { width: 6px; height: 6px; border-radius: 999px; display: inline-block; margin-right: 3px; }
.cal-ev-indicatore { font-size: .68rem; color: var(--accent); font-weight: 700; }

.cal-week-list { display: flex; flex-direction: column; gap: 8px; }
.cal-week-row {
  display: flex; align-items: center; gap: 12px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer;
}
.cal-week-row.oggi { border-color: var(--accent); }
.cal-week-day-name { font-weight: 800; font-size: .78rem; color: var(--text-faint); text-transform: uppercase; width: 40px; }
.cal-week-day-num { font-weight: 800; font-size: 1.2rem; width: 30px; }
.cal-week-events { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; }
.cal-week-empty { color: var(--text-faint); font-size: .85rem; }

.evento-riga {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.evento-riga:last-child { border-bottom: none; }
.evento-riga-colore { width: 4px; align-self: stretch; border-radius: 4px; min-height: 30px; }
.evento-riga-info { flex: 1; }
.evento-riga-titolo { font-weight: 700; }
.evento-riga-meta { font-size: .78rem; color: var(--text-dim); }

/* ── Note ─────────────────────────────────────────────────────────────── */
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.nota-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 8px;
}
.nota-card h3 { margin: 0; font-size: 1rem; }
.nota-card p { margin: 0; font-size: .88rem; color: var(--text-dim); white-space: pre-wrap; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.nota-meta { display: flex; align-items: center; justify-content: space-between; font-size: .72rem; color: var(--text-faint); }

/* ── Galleria ─────────────────────────────────────────────────────────── */
.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.foto-thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg-elev-2); }
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-thumb .foto-del {
  position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.55); color: #fff; border: none;
  width: 24px; height: 24px; border-radius: 999px; font-size: .8rem; display: flex; align-items: center; justify-content: center;
}
.upload-actions { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 1900; display: flex; align-items: center; justify-content: center; }
.lightbox.hidden { display: none; }
.lightbox img { max-width: 94vw; max-height: 88vh; border-radius: 8px; }
.lightbox-close { position: absolute; top: 16px; right: 16px; background: none; border: none; color: #fff; font-size: 2rem; }
.lightbox-cap { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; color: #ddd; font-size: .9rem; padding: 0 20px; }

/* ── Viaggi ───────────────────────────────────────────────────────────── */
.viaggi-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; gap: 4px; }
.viaggi-tabs button {
  background: none; border: none; padding: 10px 16px; color: var(--text-dim); font-weight: 700;
  border-bottom: 2px solid transparent;
}
.viaggi-tabs button.active { color: var(--accent); border-color: var(--accent); }

#mappaViaggi { width: 100%; height: 320px; border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; border: 1px solid var(--border); }
.leaflet-popup-content-wrapper { background: var(--bg-elev); color: var(--text); border-radius: var(--radius-sm); }
.leaflet-popup-tip { background: var(--bg-elev); }
.mappa-popup h4 { margin: 0 0 6px; font-size: .95rem; }
.mappa-popup a { color: var(--accent); font-weight: 700; font-size: .85rem; display: block; margin-top: 3px; }

.viaggio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.viaggio-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
}
.viaggio-card-img { height: 130px; background: var(--bg-elev-2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.viaggio-card-body { padding: 12px 14px; }
.viaggio-card-body h3 { margin: 0 0 3px; font-size: 1.02rem; }
.viaggio-card-meta { font-size: .8rem; color: var(--text-dim); margin-bottom: 6px; }
.viaggio-card-stats { display: flex; gap: 12px; font-size: .78rem; color: var(--text-faint); }

.viaggio-hero { position: relative; height: 190px; margin: -20px -16px 16px; background: var(--bg-elev-2) center/cover no-repeat; display: flex; align-items: flex-end; }
.viaggio-hero-overlay { width: 100%; background: linear-gradient(transparent, rgba(0,0,0,.75)); padding: 40px 16px 14px; }
.viaggio-hero-overlay h1 { margin: 0; font-size: 1.4rem; color: #fff; }
.viaggio-hero-overlay p { margin: 2px 0 0; color: #ddd; font-size: .85rem; }
@media (min-width: 640px) { .viaggio-hero { margin: -20px -16px 16px; border-radius: 0 0 var(--radius) var(--radius); } }

.ristorante-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px 15px; margin-bottom: 10px;
}
.ristorante-card h4 { margin: 0 0 3px; }
.ristorante-data { color: var(--text-faint); font-size: .78rem; margin-bottom: 6px; }
.stars { color: var(--warn); letter-spacing: 1px; }
.ristorante-ratings { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0; }
.ristorante-ratings span { font-size: .8rem; color: var(--text-dim); white-space: nowrap; }
.ristorante-ratings .stars { font-size: .75rem; }
.crit-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.crit-chip { font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.crit-chip.si { background: rgba(111,191,139,.18); color: var(--accent); }
.crit-chip.no { background: rgba(224,100,95,.14); color: #e0928e; }

.select-cover { color: var(--accent); font-size: .78rem; font-weight: 700; }

.suggerimenti-dropdown {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px;
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  max-height: 220px; overflow-y: auto; z-index: 10;
}
.suggerimenti-dropdown:empty { border: none; }
.suggerimenti-dropdown .chip-btn { border-radius: 0; border-width: 0 0 1px; margin-top: 0 !important; }
.suggerimenti-dropdown .chip-btn:last-child { border-bottom: none; }
