:root {
  --ink: #2b1d16;
  --muted: #7a6a60;
  --paper: #fbf6ef;
  --card: #ffffff;
  --line: #eadfd3;
  --accent: #d9573b;
  --accent-dark: #b8432a;
  --gold: #f2b544;
  --ok: #2f7d5b;
  --radius: 18px;
  --font: ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}
main { max-width: 640px; margin: 0 auto; padding: 0 16px 32px; }
a { color: var(--accent-dark); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 7vw, 40px); }
h2 { font-size: 22px; }
h3 { font-size: 18px; margin-top: 1.2em; }
p { margin: 0 0 .9em; }

.top { max-width: 640px; margin: 0 auto; padding: 16px; }
.logo { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-size: 22px; }
.logo b { color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin: 0 0 16px; box-shadow: 0 1px 0 rgba(43, 29, 22, .04); }
.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.small { font-size: 14px; color: var(--muted); }
.muted { color: var(--muted); }
.hint { font-weight: 400; color: var(--muted); font-size: 14px; }
.kicker { text-transform: uppercase; letter-spacing: .08em; font-size: 13px; color: var(--muted); margin-bottom: .4em; }
.lead { font-size: 19px; }
.big-emoji { font-size: 56px; }

/* home */
.hero { padding: 24px 0 8px; }
.hero h1 { font-size: clamp(32px, 8.5vw, 48px); }
.steps { display: grid; gap: 12px; margin: 24px 0; }
@media (min-width: 600px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { margin: 0; }
.step .num { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; margin-bottom: 8px; }
.feature h2 { font-size: 20px; }

/* bottoni */
.btn {
  display: inline-block; border: 0; border-radius: 999px; padding: 12px 22px; margin: 4px 0;
  background: var(--accent); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }
.btn.big { display: block; width: 100%; padding: 16px; font-size: 19px; text-align: center; }
.btn.small { padding: 8px 16px; font-size: 15px; }
.btn.ghost { background: transparent; color: var(--accent-dark); box-shadow: inset 0 0 0 2px var(--accent); }
.btn.ghost:hover { background: #fdeee9; }
.btn.danger { background: transparent; color: #a23b2a; box-shadow: inset 0 0 0 2px #e3b4aa; }
.btn[disabled] { opacity: .6; cursor: wait; }
.hero .btn.big { max-width: 320px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions .btn { flex: 1 1 200px; text-align: center; }

/* form */
.form fieldset { border: 0; padding: 0; margin: 0 0 18px; }
.form legend { font-weight: 700; font-size: 20px; margin-bottom: 8px; }
.form label { display: block; font-weight: 600; margin-bottom: 14px; }
.form input:not([type=checkbox]), .form select, .form textarea, .copy-row input, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; font-weight: 400; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
}
.form input:focus, .form select:focus, .form textarea:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #f6d5cc; }
.form .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.form .check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--accent); flex: none; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.amounts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 18px; font: inherit; font-weight: 700; cursor: pointer; color: var(--ink); }
.chip.on { border-color: var(--accent); background: #fdeee9; color: var(--accent-dark); }
.summary { background: var(--paper); border-radius: 12px; padding: 12px 14px; font-size: 15px; }
.alert { background: #fdeee9; border: 1px solid #f3c6ba; color: #8a2f1d; border-radius: 12px; padding: 12px 16px; }
.alert.soft { background: #fff7e6; border-color: #f4dfae; color: #6b4e12; }

/* busta pubblica */
.hero-env { text-align: center; padding-top: 28px; }
.avatar { width: 112px; height: 112px; border-radius: 50%; object-fit: cover; border: 4px solid #fff; box-shadow: 0 0 0 3px var(--accent); margin: 0 auto 12px; display: block; }
.avatar.emoji { display: grid; place-items: center; font-size: 56px; background: #fdeee9; }
.hero-env .title { font-size: 19px; font-weight: 600; }
.hero-env .desc { color: var(--ink); }
.meta { color: var(--muted); font-size: 15px; }
.progress .count { font-size: 17px; margin-bottom: 8px; }
.bar { position: relative; height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; margin-bottom: 4px; }
.goal { text-align: right; margin: 0; }
.bar span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--gold), var(--accent)); border-radius: 999px; }
.progress { margin-top: 12px; }
.people { font-size: 16px; }

/* admin */
.save-link { border: 2px solid var(--gold); background: #fffaf0; }
.copy-row { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.copy-row input { margin: 0; font-size: 14px; color: var(--muted); }
.copy-row .btn { flex: none; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-top: 12px; }
.stats div { background: var(--paper); border-radius: 14px; padding: 12px 6px; }
.stats b { display: block; font-size: 22px; }
.stats span { font-size: 13px; color: var(--muted); }
#poster canvas { width: 100%; height: auto; border-radius: 14px; border: 1px solid var(--line); display: block; }
.list { width: 100%; border-collapse: collapse; }
.list td { padding: 10px 4px; border-bottom: 1px solid var(--line); }
.list .num { text-align: right; font-weight: 700; white-space: nowrap; }
.list .muted { text-align: right; font-size: 14px; white-space: nowrap; }
form + form { margin-top: 8px; }

/* biglietto */
.card-body { background: radial-gradient(circle at 20% 0%, #fdeee9, var(--paper) 55%); }
.greeting { text-align: center; padding: 24px 0 8px; }
.greeting h1 { font-size: clamp(36px, 10vw, 56px); color: var(--accent-dark); }
.greeting .title { font-size: 19px; font-weight: 600; }
.greeting .from { color: var(--muted); }
.messages { columns: 2 260px; column-gap: 14px; }
.msg { break-inside: avoid; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 14px; }
.msg blockquote { margin: 0 0 8px; font-size: 18px; white-space: pre-line; }
.msg figcaption { color: var(--accent-dark); font-weight: 700; }

/* pagine di testo */
.prose h2 { margin-top: 1.4em; }

.foot { max-width: 640px; margin: 0 auto; padding: 24px 16px 40px; color: var(--muted); font-size: 14px; text-align: center; }
.foot nav { display: flex; justify-content: center; gap: 18px; margin-bottom: 10px; }
.foot a { color: var(--muted); }

@media print {
  .top, .foot, .noprint { display: none; }
  body, .card-body { background: #fff; }
  .msg { border-color: #ccc; }
}

/* v0.2: percorso festa → regalo → dati per ricevere → invito */
.stepper { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; counter-reset: s; }
.stepper li { counter-increment: s; font-size: 13px; text-align: center; color: var(--muted); padding-top: 34px; position: relative; }
.stepper li::before { content: counter(s); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--line); color: var(--muted); font-weight: 700; }
.stepper li.done::before { content: '✓'; background: var(--ok); color: #fff; }
.stepper li.now { color: var(--ink); font-weight: 700; }
.stepper li.now::before { background: var(--accent); color: #fff; }
.stepper a { color: inherit; text-decoration: none; }
.lock-note { margin: 12px 0 0; background: var(--paper); border-radius: 12px; padding: 12px 14px; font-size: 15px; }
.themes { display: flex; flex-wrap: wrap; gap: 10px; }
.themes legend { font-size: 17px !important; font-weight: 600 !important; width: 100%; }
.form .theme { position: relative; display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 14px 6px 6px; cursor: pointer; }
.form .theme:has(input:checked) { border-color: var(--accent); background: #fdeee9; }
.theme input { position: absolute; opacity: 0; pointer-events: none; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); flex: none; }
details > summary { cursor: pointer; padding: 4px 0; list-style-position: inside; }
details[open] > summary { margin-bottom: 14px; }
.actions form { flex: 1 1 200px; margin: 0; }
.actions form .btn { width: 100%; }
