/* Colori, caratteri e pezzi comuni a gallery e pannello. Chiaro di base, scuro con data-theme="dark". */
:root {
  --bg: #fbfaf8;
  --fg: #1c1c1b;
  --muted: #8d8a85;
  --line: #e8e5e0;
  --soft: #f2f0ec;
  --card: #ffffff;
  --heart: #b5473a;
  --ok: #4f7a5a;
  --scrim: rgba(251, 250, 248, 0.92);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #121212;
  --fg: #ebe9e6;
  --muted: #8b8884;
  --line: #2a2928;
  --soft: #1b1b1a;
  --card: #1a1a19;
  --heart: #d9695a;
  --ok: #7fae8a;
  --scrim: rgba(18, 18, 18, 0.92);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 300 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.serif { font-family: var(--serif); font-weight: 300; }
.muted { color: var(--muted); }
.caps { text-transform: uppercase; letter-spacing: 0.18em; font-size: 11px; font-weight: 400; }

/* Pulsanti: sottili, rettangolari, senza ombre */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 22px; border: 1px solid var(--fg); border-radius: 0;
  background: transparent; color: var(--fg); cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.16em; font-size: 11px; font-weight: 400; text-decoration: none;
  transition: background 0.2s, color 0.2s, opacity 0.2s;
}
.btn:hover { background: var(--fg); color: var(--bg); }
.btn.solid { background: var(--fg); color: var(--bg); }
.btn.solid:hover { opacity: 0.85; }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { background: var(--soft); color: var(--fg); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.danger { border-color: var(--heart); color: var(--heart); }
.btn.danger:hover { background: var(--heart); color: #fff; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; background: transparent; color: inherit; cursor: pointer; border-radius: 50%;
  transition: background 0.2s, opacity 0.2s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.icon-btn svg { width: 20px; height: 20px; }

/* Campi: solo una linea sotto */
.field { display: block; margin: 0 0 18px; }
.field > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.input {
  width: 100%; min-height: 42px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; border-radius: 0; outline: none; transition: border-color 0.2s;
}
.input:focus { border-color: var(--fg); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.5; }

/* Finestra sopra la pagina */
.modal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade 0.2s ease;
}
.modal-box {
  width: min(440px, 100%); max-height: calc(100svh - 32px); overflow: auto;
  background: var(--card); border: 1px solid var(--line); padding: 32px clamp(20px, 5vw, 36px) 28px;
}
.modal-box h2 { margin: 0 0 6px; font: 300 30px/1.15 var(--serif); }
.modal-box p { margin: 0 0 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 24px; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 90;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 12px 20px; background: var(--fg); color: var(--bg); font-size: 13px;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Su iPhone un campo con il carattere sotto i 16 px fa ingrandire tutta la pagina quando lo tocchi. */
@media (hover: none), (max-width: 720px) { .input, textarea, select { font-size: 16px; } }

/* Finestre sul telefono: in alto, così la tastiera non le copre. */
@media (max-width: 600px) {
  .modal { place-items: start center; padding-top: max(16px, env(safe-area-inset-top)); overflow-y: auto; }
  .modal-box { padding: 26px 20px 22px; }
}
