/* Stile del sito: mobile-first, nessuna risorsa esterna (font di sistema, decorazioni SVG).
   Palette: bianco e azzurro con dettagli dorati (le fedi). I colori del testo hanno
   un contrasto di almeno 4.5:1 sugli sfondi in cui vengono usati. */

:root {
  --white: #ffffff;
  --paper: #fbfdff;      /* sfondo pagina */
  --sky: #eaf3fc;        /* fasce e sfondi tenui */
  --sky-deep: #dcebf9;
  --blue: #2a64a3;       /* link, pulsanti, accenti (contrasto 6:1 su bianco) */
  --blue-dark: #1b4778;  /* titoli (contrasto 9:1 su bianco) */
  --blue-soft: #9fbfe0;  /* solo decorazioni */
  --gold: #c9a24a;       /* solo decorazioni */
  --gold-dark: #7d5f14;  /* testo dorato (contrasto 5.5:1 su bianco) */
  --ink: #23303f;        /* testo (contrasto 12:1) */
  --muted: #54657a;      /* testo secondario (contrasto 5.8:1) */
  --line: #d3e2f2;
  --serif: "Cormorant Garamond", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --radius: 1.25rem;
  --shadow: 0 12px 32px rgba(42, 100, 163, 0.14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

h1, h2 { font-family: var(--serif); font-weight: 500; line-height: 1.15; margin: 0; }
h1 { font-size: 2.25rem; }
h2 { font-size: 2.1rem; text-align: center; color: var(--blue-dark); }

p { margin: 0 0 1rem; }
a { color: var(--blue); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Layout generale ---------- */

main { max-width: 36rem; margin: 0 auto; padding: 2rem 1.25rem; }
main.landing, main.gate, main.centered { max-width: none; padding: 0; }
main.wide { max-width: 72rem; }

main.centered {
  min-height: 80vh;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1.25rem;
  background: linear-gradient(180deg, var(--sky), var(--paper));
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.note { color: var(--muted); font-style: italic; font-size: 0.95rem; }
.lead { text-align: center; font-size: 1.1rem; color: var(--muted); }
.eyebrow {
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.8rem;
  color: var(--gold-dark);
  text-align: center;
}

.divider { display: block; width: 11rem; height: 1.5rem; margin: 0.9rem auto 1.5rem; color: var(--gold); }

.rings { display: block; width: 8.5rem; height: 5.9rem; margin: 0 auto 0.75rem; filter: drop-shadow(0 4px 6px rgba(125, 95, 20, 0.25)); }

/* ---------- Menu ---------- */

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

nav {
  max-width: 44rem; margin: 0 auto; padding: 0.2rem 0.5rem;
  display: flex; flex-wrap: wrap; justify-content: center;
}

nav a {
  padding: 0.55rem 0.55rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-decoration: none;
  color: var(--blue-dark);
  border-bottom: 2px solid transparent;
}

nav a:hover, nav a:focus-visible, nav a[aria-current="page"] {
  color: var(--blue);
  border-bottom-color: var(--gold);
}

/* ---------- Scenografia (rami, fiori bianchi, petali) ---------- */

.scenery { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.deco { position: absolute; display: block; }
.branch-tl { top: -0.5rem; left: -1.5rem; width: 13rem; height: 8rem; color: var(--blue-soft); transform: rotate(8deg); }
.branch-br { bottom: -0.5rem; right: -1.5rem; width: 13rem; height: 8rem; color: var(--blue-soft); transform: rotate(188deg); }
.blossom-tr { top: 1rem; right: -1.6rem; width: 6.5rem; height: 6.5rem; filter: drop-shadow(0 3px 5px rgba(42, 100, 163, 0.25)); animation: spin 120s linear infinite; }
.blossom-bl { bottom: 1.5rem; left: -1.8rem; width: 5.5rem; height: 5.5rem; filter: drop-shadow(0 3px 5px rgba(42, 100, 163, 0.25)); animation: spin 150s linear infinite reverse; }

/* Petali bianchi: ombra e bordo leggeri per vederli sullo sfondo chiaro */
.petal {
  position: absolute; top: -1.5rem;
  width: 0.8rem; height: 1.1rem;
  background: radial-gradient(circle at 30% 30%, #ffffff, #f2f7fd);
  border-radius: 80% 0 80% 0;
  box-shadow: 0 0 0 1px rgba(159, 191, 224, 0.55), 0 3px 6px rgba(42, 100, 163, 0.2);
  animation: fall 14s linear infinite;
}
.petal:nth-child(5)  { left: 6%;  animation-delay: -1s;  animation-duration: 15s; }
.petal:nth-child(6)  { left: 18%; animation-delay: -6s;  animation-duration: 12s; width: 0.65rem; height: 0.9rem; }
.petal:nth-child(7)  { left: 31%; animation-delay: -10s; animation-duration: 17s; width: 0.95rem; height: 1.3rem; }
.petal:nth-child(8)  { left: 46%; animation-delay: -3s;  animation-duration: 13s; }
.petal:nth-child(9)  { left: 58%; animation-delay: -8s;  animation-duration: 16s; width: 0.65rem; height: 0.9rem; }
.petal:nth-child(10) { left: 71%; animation-delay: -12s; animation-duration: 14s; width: 0.95rem; height: 1.3rem; }
.petal:nth-child(11) { left: 83%; animation-delay: -5s;  animation-duration: 18s; }
.petal:nth-child(12) { left: 93%; animation-delay: -9s;  animation-duration: 12s; width: 0.65rem; height: 0.9rem; }

@keyframes fall {
  0%   { transform: translate3d(0, -2rem, 0) rotate(0deg); }
  50%  { transform: translate3d(2.2rem, 45vh, 0) rotate(180deg); }
  100% { transform: translate3d(-1rem, 100vh, 0) rotate(360deg); }
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .petal, .blossom-tr, .blossom-bl { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Pagina della password ---------- */

main.gate {
  position: relative; min-height: 100vh; min-height: 100svh;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(circle at 15% 10%, #ffffff 0, transparent 45%),
    radial-gradient(circle at 90% 90%, var(--sky-deep) 0, transparent 50%),
    linear-gradient(180deg, var(--sky), #f6faff);
}

.gate-card { position: relative; z-index: 1; width: 100%; max-width: 26rem; padding: 2rem 1.5rem; }
.gate-card h1 { text-align: center; font-size: 2.6rem; color: var(--blue-dark); font-style: italic; }

/* ---------- Pagina interna ---------- */

.hero {
  position: relative; overflow: hidden;
  min-height: calc(100vh - 3rem); min-height: calc(100svh - 3rem);
  display: flex; align-items: center; justify-content: center;
  padding: 4rem 1.25rem;
  background:
    radial-gradient(circle at 18% 12%, #ffffff 0, transparent 50%),
    radial-gradient(circle at 88% 88%, var(--sky-deep) 0, transparent 55%),
    linear-gradient(180deg, var(--sky), #f6faff);
  scroll-margin-top: 6rem;
}

.hero-inner { position: relative; z-index: 1; max-width: 34rem; text-align: center; }

.names {
  display: flex; flex-direction: column; align-items: center;
  font-size: clamp(3.4rem, 15vw, 6.5rem);
  font-style: italic; font-weight: 400;
  color: var(--blue-dark);
  line-height: 1;
}
.names .amp { font-size: 0.55em; color: var(--gold-dark); line-height: 1.1; }

.date {
  font-family: var(--serif);
  font-size: 2rem; font-weight: 600;
  color: var(--gold-dark);
  margin: 0 0 0.25rem;
}
.place { font-size: 1.05rem; letter-spacing: 0.04em; color: var(--ink); }
.welcome { color: var(--muted); max-width: 28rem; margin: 1.25rem auto 1.75rem; }

.band { padding: 4rem 1.25rem; scroll-margin-top: 6rem; }
.band-cream { background: var(--sky); }
.band-blush { background: linear-gradient(180deg, var(--sky-deep), var(--sky)); }
.section-inner { max-width: 38rem; margin: 0 auto; }
.section-inner > .note { text-align: center; }

/* Programma */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  display: grid; grid-template-columns: 4.6rem 1.5rem 1fr; align-items: center;
  column-gap: 0.4rem;
  padding: 1rem 0;
}
.timeline li::before {
  content: ""; grid-column: 2; grid-row: 1; justify-self: center;
  width: 0.85rem; height: 0.85rem; border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(201, 162, 74, 0.35);
  position: relative; z-index: 1;
}
.timeline li::after {
  content: ""; position: absolute; top: 0; bottom: 0;
  left: calc(4.6rem + 0.4rem + 0.75rem - 1px);
  width: 2px; background: var(--blue-soft);
}
.timeline li:first-child::after { top: 50%; }
.timeline li:last-child::after { bottom: 50%; }
.timeline .time {
  grid-column: 1; grid-row: 1; text-align: right;
  font-family: var(--serif); font-size: 1.7rem; font-weight: 600; color: var(--blue-dark);
}
.timeline .what { grid-column: 3; grid-row: 1; padding-left: 0.4rem; font-size: 1.1rem; }

/* Come arrivare */
.place-card { text-align: center; }
.pin { display: block; width: 2.2rem; height: 2.2rem; margin: 0 auto 0.5rem; color: var(--blue); }
address { font-style: normal; margin-bottom: 1.25rem; font-size: 1.1rem; }
.tips { margin: 1.5rem 0 1rem; padding-left: 1.2rem; color: var(--muted); }
.tips li { margin-bottom: 0.4rem; }

/* ---------- Bottoni ---------- */

.button, button {
  display: inline-block;
  padding: 0.8rem 1.8rem;
  font: inherit; font-weight: 600;
  color: var(--white);
  background: var(--blue);
  border: 2px solid var(--blue);
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}
.button:hover, button:hover {
  background: var(--blue-dark); border-color: var(--blue-dark);
  transform: translateY(-1px); box-shadow: 0 8px 18px rgba(27, 71, 120, 0.28);
}
.button:focus-visible, button:focus-visible, nav a:focus-visible, a:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 3px;
}
button.secondary { background: transparent; color: var(--blue-dark); border-color: var(--blue); }
button.secondary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: var(--white); box-shadow: none; }
button.small { padding: 0.4rem 1.2rem; font-size: 0.9rem; }
button.danger { background: #a12626; border-color: #a12626; }
.wide-button { width: 100%; margin-top: 0.5rem; }
.button-link { /* usato dalle pagine admin */
  display: inline-block; padding: 0.7rem 1.5rem; color: var(--white); background: var(--blue);
  border-radius: 999px; text-decoration: none;
}

/* ---------- Modulo ---------- */

.form-card, .gate-card form { text-align: left; }
.field { margin-bottom: 1.1rem; }
label { display: block; margin-bottom: 0.3rem; font-weight: 600; font-size: 0.95rem; color: var(--blue-dark); }

input[type="text"], input[type="number"], input[type="password"], textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid #bdd2e8;
  border-radius: 0.8rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(42, 100, 163, 0.18);
}
textarea { resize: vertical; font-family: inherit; }

.counts { display: grid; gap: 0 1rem; }
@media (min-width: 34rem) { .counts { grid-template-columns: repeat(3, 1fr); } }

.checkbox { display: flex; gap: 0.7rem; align-items: flex-start; margin: 0; }
.checkbox input { width: 1.25rem; height: 1.25rem; margin-top: 0.2rem; accent-color: var(--blue); flex: none; }
.checkbox label { margin: 0; font-weight: 400; color: var(--ink); }

.error { color: #a12626; margin: 0.4rem 0 0; font-size: 0.95rem; }

/* ---------- Risposta già inviata ---------- */

.previous-card { text-align: center; }
.previous-card .eyebrow { margin-bottom: 0.25rem; }
.previous-name { font-family: var(--serif); font-size: 1.8rem; font-style: italic; color: var(--blue-dark); margin-bottom: 0.5rem; }
.previous-details { list-style: none; margin: 0 0 1.25rem; padding: 0; color: var(--muted); }
.center { text-align: center; }

details.another { margin-top: 1.5rem; }
details.another summary {
  cursor: pointer; text-align: center; color: var(--blue);
  font-weight: 600; padding: 0.5rem; margin-bottom: 1rem;
}

/* ---------- Conferma ---------- */

.thanks-card { max-width: 28rem; text-align: center; }
.thanks-card h1 { color: var(--blue-dark); font-style: italic; font-size: 2.6rem; }
.flower-icon { display: block; width: 4.5rem; height: 4.5rem; margin: 0 auto 0.5rem; }
.summary { margin: 1.25rem 0; text-align: left; }
.summary dt { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 0.8rem; }
.summary dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Piè di pagina ---------- */

.site-footer { text-align: center; padding: 2.5rem 1.25rem 3rem; background: var(--sky); }
.footer-names { font-family: var(--serif); font-size: 1.8rem; font-style: italic; color: var(--blue-dark); margin: 0; }
.footer-date { letter-spacing: 0.3em; color: var(--gold-dark); margin: 0 0 1.25rem; font-size: 0.9rem; }

/* ---------- Area admin ---------- */

.flash { background: #e6f3ea; border: 1px solid #a9d3b6; padding: 0.6rem 0.9rem; border-radius: 0.5rem; }
.totals { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0; }
.totals div { flex: 1 1 8rem; background: var(--white); border: 1px solid var(--line); border-radius: 0.6rem; padding: 0.6rem 0.9rem; }
.totals dt { font-size: 0.85rem; color: var(--muted); }
.totals dd { margin: 0; font-size: 1.6rem; font-weight: 600; }
.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; background: var(--white); }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
td.notes { min-width: 12rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.cancel { margin-left: 1rem; }

/* ---------- Persone nel modulo RSVP ---------- */

.person {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 1rem 1rem;
  margin: 0 0 1rem;
  min-width: 0;
}
.person legend { padding: 0 0.5rem; font-family: var(--serif); font-size: 1.3rem; color: var(--blue-dark); }
.age-field[hidden] { display: none; }
.age-field input { max-width: 8rem; }
.add-person { text-align: center; margin-bottom: 1.25rem; }
.add-person button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Primo pulsante di invio: serve solo al tasto Invio, non si vede */
.default-submit { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Chi comunica che non partecipa indica solo il nome */
.is-declining .attending-only { display: none; }

/* Pulsanti che hanno senso solo con JavaScript */
.js-only { display: none; }
.js .js-only { display: inline-block; }

.previous-people, .people-list { list-style: none; margin: 0 0 1.25rem; padding: 0; text-align: left; }
.previous-people li, .people-list li { padding: 0.3rem 0; border-bottom: 1px solid var(--line); }
.previous-people li:last-child, .people-list li:last-child { border-bottom: 0; }
.people-list { margin: 0; }
.tag {
  display: inline-block; margin-left: 0.3rem; padding: 0 0.5rem;
  font-size: 0.8rem; border-radius: 999px;
  background: var(--sky); color: var(--blue-dark);
}
.tag-no { background: #fbe9e9; color: #8a1f1f; margin-left: 0; }

/* ---------- Modulo compatto (soprattutto da telefono) ---------- */

.person { position: relative; padding: 0.25rem 0.75rem 0.7rem; margin: 0 0 0.6rem; border-radius: 0.9rem; }
.person legend { padding: 0 0.4rem; font-size: 1.05rem; }
.person-name input { padding: 0.6rem 0.8rem; }
.person-options { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 1.1rem; margin-top: 0.5rem; }
.opt { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.95rem; }
.opt input { width: 1.15rem; height: 1.15rem; accent-color: var(--blue); flex: none; }
.person-options .age-field { display: inline-block; margin: 0; }
.person-options .age-field input { width: 5.5rem; padding: 0.4rem 0.6rem; }
.person .error { margin: 0.25rem 0 0; }

/* "Rimuovi" in alto a destra della scheda, sulla riga del titolo */
.remove-person {
  position: absolute; top: -0.75rem; right: 0.6rem;
  padding: 0.15rem 0.6rem; font-size: 0.8rem; font-weight: 600;
  color: var(--blue-dark); background: var(--white);
  border: 1px solid var(--blue-soft); border-radius: 999px;
}
.remove-person:hover { background: var(--sky); color: var(--blue-dark); transform: none; box-shadow: none; border-color: var(--blue); }

.add-person { margin: 0.25rem 0 0.9rem; }
.add-person button { padding: 0.5rem 1.2rem; font-size: 0.95rem; }
.footnote { margin: 0.4rem 0 0; font-size: 0.85rem; color: var(--muted); }
.form-card textarea { padding: 0.6rem 0.8rem; }

@media (max-width: 34rem) {
  .band { padding: 2.5rem 1rem; }
  .form-card { padding: 1rem; }
  .field { margin-bottom: 0.8rem; }
  .person { padding: 0.2rem 0.6rem 0.6rem; }
  .lead { font-size: 1rem; }
}
.person-options .age-field[hidden] { display: none; }

/* ---------- Dashboard admin (compatta: serve a chi organizza, non agli invitati) ---------- */

main.admin { font-size: 0.9rem; line-height: 1.35; padding: 1rem; background: var(--paper); }
.admin h1 { font-size: 1.5rem; }
.admin-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.admin-actions { display: inline-flex; align-items: center; gap: 0.5rem; }
form.inline { display: inline; margin: 0; }
.button-link.small { padding: 0.3rem 0.9rem; font-size: 0.85rem; }
.admin button { padding: 0.3rem 0.9rem; font-size: 0.85rem; }

.admin .totals { margin: 0.6rem 0; gap: 0.4rem; }
.admin .totals div { flex: 1 1 6rem; padding: 0.3rem 0.6rem; }
.admin .totals dt { font-size: 0.75rem; }
.admin .totals dd { font-size: 1.15rem; }

.admin input[type="text"], .admin input[type="number"], .admin input[type="search"], .admin textarea {
  padding: 0.2rem 0.4rem; font-size: 0.9rem; border-radius: 0.4rem; border-width: 1px;
}
.filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.8rem 0; }
.filter input { width: 16rem; max-width: 100%; }
.when { color: var(--muted); font-size: 0.8rem; }

.new-group { margin: 0.6rem 0; padding: 0.5rem 0.8rem; box-shadow: none; border: 1px dashed var(--blue-soft); }
.new-group summary { cursor: pointer; font-weight: 600; color: var(--blue); }

.group { background: var(--white); border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.4rem 0.6rem; margin: 0 0 0.6rem; }
.group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; margin-bottom: 0.3rem; }
.group-head .who { font-weight: 600; }
.group-head .del { margin-left: auto; font-size: 0.8rem; color: #8a1f1f; }

table.people { width: 100%; table-layout: fixed; border-collapse: collapse; }
.people th, .people td { padding: 0.15rem 0.25rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.people th { font-size: 0.75rem; }
.people th:first-child { width: auto; }
.people th.c, .people td.c { width: 4.2rem; text-align: center; }
.people td input[type="text"], .people td input[type="number"] { width: 100%; }
.people td.c input[type="number"] { max-width: 3.4rem; }
.people td.c input[type="checkbox"] { accent-color: var(--blue); width: 1rem; height: 1rem; }
.people .error { margin: 0.1rem 0 0; font-size: 0.8rem; }

.group-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; margin-top: 0.4rem; }
.group-foot textarea { flex: 1 1 14rem; min-height: 0; resize: vertical; }
.group-foot .opt { font-size: 0.9rem; }
.group-foot label { margin: 0; font-weight: 400; display: inline; font-size: 0.9rem; color: var(--ink); }

/* Pulsante "+" per aggiungere una riga a un gruppo (dashboard admin) */
.admin button.add-row {
  width: 1.9rem; height: 1.9rem; padding: 0; font-size: 1.2rem; line-height: 1;
  border-radius: 50%; color: var(--blue-dark); background: var(--white); border: 1px solid var(--blue);
}
.admin button.add-row:hover { background: var(--sky); color: var(--blue-dark); transform: none; box-shadow: none; }

/* ---------- Ritocchi dashboard admin ---------- */

/* Nome di chi ha compilato: in grassetto e ben leggibile */
.group-head .who { font-weight: 700; font-size: 1.05rem; color: var(--blue-dark); }

/* Inviata / modificata una sotto l'altra */
.when.stacked { display: inline-flex; flex-direction: column; gap: 0.05rem; line-height: 1.25; }

/* Il "+" è disegnato con due barre: resta perfettamente centrato nel cerchio, qualunque sia il font */
.admin button.add-row { position: relative; font-size: 0; flex: none; }
.admin button.add-row::before, .admin button.add-row::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  background: currentColor; border-radius: 1px; transform: translate(-50%, -50%);
}
.admin button.add-row::before { width: 0.9rem; height: 2px; }
.admin button.add-row::after { width: 2px; height: 0.9rem; }

/* Telefono: ogni persona è una scheda (nome su tutta la riga, opzioni sotto) invece di colonne
   strette che si sovrappongono */
@media (max-width: 40rem) {
  table.people, .people tbody, .people tr, .people td { display: block; }
  .people thead { display: none; }
  .people tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.9rem;
    padding: 0.4rem 0; border-bottom: 1px solid var(--line);
  }
  .people td { padding: 0; border: 0; width: auto; }
  .people td.name-cell { flex: 1 1 100%; }
  .people th.c, .people td.c { width: auto; text-align: left; }
  .people td.c { display: inline-flex; align-items: center; gap: 0.3rem; }
  .people td.c::before { content: attr(data-label); font-size: 0.8rem; color: var(--muted); }
  .people td.c input[type="number"] { width: 3.6rem; max-width: none; }
  .group-head .del { margin-left: 0; }
}

/* ---------- Riepiloghi compatti (conferma invio, eliminazione gruppo) ---------- */

/* Intestazione del gruppo: titolo a sinistra, "Elimina gruppo" a destra, date sotto */
.group-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.1rem 0.6rem; }
.group-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.5rem; min-width: 0; }
.group-head .del { margin-left: 0; white-space: nowrap; }
.group-head .when.stacked { flex: 1 1 100%; }

/* Riepilogo: etichetta e valore sulla stessa riga (una sotto l'altra solo su telefono) */
.summary { display: grid; grid-template-columns: minmax(7rem, 12rem) 1fr; gap: 0.35rem 0.8rem; margin: 0.6rem 0; }
.summary dt { margin: 0; font-size: 0.8rem; }
.summary dd { margin: 0; }
.summary .previous-people, .summary .people-list { margin: 0; }

/* Pagina di conferma: nessun centraggio verticale, scheda e testi più stretti */
main.centered { min-height: 0; align-items: flex-start; padding: 1.5rem 1.25rem 2rem; }
.thanks-card { padding: 1.1rem 1.25rem; }
.thanks-card .rings { width: 5.5rem; height: 3.8rem; margin-bottom: 0.2rem; }
.thanks-card .flower-icon { width: 3.5rem; height: 3.5rem; margin-bottom: 0.2rem; }
.thanks-card h1 { font-size: 2.1rem; }
.thanks-card .lead { margin: 0.3rem 0 0; }
.thanks-card .note { margin: 0.5rem 0; }
.thanks-card p { margin-bottom: 0.6rem; }

@media (max-width: 34rem) {
  .summary { grid-template-columns: 1fr; gap: 0; }
  .summary dt { margin-top: 0.45rem; }
}

/* Gli a capo contano solo nel testo scritto dall'utente (allergie); altrimenti l'indentazione
   del template appare come righe vuote tra le persone. */
.summary dd { white-space: normal; }
.summary .notes-text { white-space: pre-wrap; }

/* ---------- Dashboard defense ---------- */
.range-switch { display: flex; gap: 0.4rem; margin: 0.6rem 0; }
.range-switch a {
  padding: 0.25rem 0.8rem; border: 1px solid var(--blue-soft); border-radius: 999px;
  text-decoration: none; font-size: 0.85rem; color: var(--blue-dark); background: var(--white);
}
.range-switch a[aria-current="true"] { background: var(--blue); border-color: var(--blue); color: var(--white); }
.section-title { text-align: left; font-size: 1.15rem; margin: 1.2rem 0 0.3rem; color: var(--blue-dark); }
table.events { width: 100%; border-collapse: collapse; background: var(--white); font-size: 0.85rem; }
.events th, .events td { text-align: left; padding: 0.25rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.events code { font-size: 0.82rem; word-break: break-all; }
.events td.ua { max-width: 16rem; overflow-wrap: anywhere; color: var(--muted); font-size: 0.78rem; }
.ban-inline { display: inline-flex; gap: 0.3rem; align-items: center; margin: 0; }
.ban-inline select, .manual-ban select { padding: 0.15rem 0.3rem; font-size: 0.82rem; }
.manual-ban { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.5rem; }
.manual-ban input[type="text"] { flex: 1 1 10rem; }

.tag-old { background: var(--sky); color: var(--muted); }

/* ---------- Tema scuro (solo /defense: <html data-theme="dark">) ---------- */

html[data-theme="dark"] {
  color-scheme: dark;
  --white: #1b2431;      /* superfici: card, tabelle */
  --paper: #111821;      /* sfondo pagina */
  --sky: #1a2736;
  --sky-deep: #223349;
  --blue: #7fb4ee;       /* link, pulsanti, accenti (contrasto 8:1 sullo sfondo) */
  --blue-dark: #cfe3fa;  /* titoli */
  --blue-soft: #3b5a80;
  --gold: #d4b25c;
  --gold-dark: #e4c877;
  --ink: #e6edf5;
  --muted: #a3b2c4;      /* contrasto 7:1 sullo sfondo */
  --line: #2c3b4f;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}
html[data-theme="dark"] button.danger { background: #c84646; border-color: #c84646; color: #fff; }
html[data-theme="dark"] .error { color: #ff9a9a; }
html[data-theme="dark"] .flash { background: #17352a; border-color: #2c6b4f; color: var(--ink); }
html[data-theme="dark"] .tag-no { background: #4a2020; color: #ffb4b4; }
html[data-theme="dark"] .tag-old { background: var(--sky); color: var(--muted); }
html[data-theme="dark"] .range-switch a { background: var(--white); border-color: var(--blue-soft); }
html[data-theme="dark"] .range-switch a[aria-current="true"] { background: var(--blue); border-color: var(--blue); color: var(--paper); }
html[data-theme="dark"] .events td.ua { color: var(--muted); }
