/* Secret Klaus – stile "Festa pop" ripreso da docs/demo/SecretKlaus_Demo.html.
   Mobile first (375 px), poi desktop (contenuto max 1080 px). Nessuno stile inline: CSP style-src 'self'. */

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { min-height: 100%; }
body {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  background: #fff radial-gradient(var(--dot) 1.3px, transparent 1.4px) 0 0 / 15px 15px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; }
img, svg { max-width: 100%; }
img { display: block; }
b, strong { font-weight: 800; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* .skip-link.btn: più specifico di .btn (position: relative), così non occupa spazio sopra l'intestazione */
.skip-link.btn { position: absolute; left: 12px; top: -80px; z-index: 100; }
.skip-link.btn:focus { top: 12px; }

/* ---------- intestazione ---------- */
.site-header {
  position: relative; z-index: 5;
  padding-top: env(safe-area-inset-top);
}
.site-header__in {
  display: flex; align-items: center; gap: 10px;
  max-width: var(--content-max); margin: 0 auto;
  min-height: var(--header-h);
  padding: 10px max(16px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left));
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.01em; text-decoration: none; min-height: 48px; }
.brand svg { flex: 0 0 34px; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.site-nav form { display: contents; }
@media (max-width: 459px) {
  .site-header--auth .brand__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* ---------- layout ---------- */
.main { flex: 1 0 auto; display: flex; flex-direction: column; position: relative; z-index: 2; }
.page {
  flex: 1 0 auto;
  display: flex; flex-direction: column;
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: 16px max(20px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.page--narrow { max-width: 560px; }
.page--prose { max-width: 760px; }
.page--center { justify-content: center; text-align: center; }
.site-footer {
  position: relative; z-index: 2;
  max-width: var(--content-max); width: 100%; margin: 0 auto;
  padding: 14px 20px calc(18px + env(safe-area-inset-bottom));
  font-size: 13px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
}
.site-footer a { font-weight: 700; color: var(--muted); }

/* ---------- tipografia ---------- */
.h1 { font-size: 34px; line-height: 1.02; font-weight: 800; letter-spacing: -.025em; }
.h2 { font-size: 24px; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; }
.h3 { font-size: 17px; line-height: 1.25; font-weight: 800; }
.lead { font-size: 16.5px; line-height: 1.45; }
.mut { color: var(--muted); }
.sm { font-size: 13px; line-height: 1.4; }
.err-text { color: var(--red-dark); font-weight: 700; }
.mark {
  background: var(--lime); padding: 0 6px; border: 2.5px solid var(--ink); border-radius: 8px;
  display: inline-block; transform: rotate(-2deg);
}
.prose { line-height: 1.55; }
.prose h2 { font-size: 21px; line-height: 1.15; font-weight: 800; letter-spacing: -.015em; margin: 28px 0 10px; }
.prose h3 { font-size: 17px; font-weight: 800; margin: 18px 0 6px; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose li::marker { font-weight: 800; color: var(--red); }
.prose a { font-weight: 700; text-decoration-thickness: 2px; text-underline-offset: 2px; }

/* ---------- adesivi e chip ---------- */
.stk {
  display: inline-block; border: 2px solid var(--ink); border-radius: 8px; padding: 2px 10px;
  font-weight: 800; font-size: 12px; line-height: 1.35; letter-spacing: .06em; text-transform: uppercase;
  background: var(--lime); transform: rotate(-3deg);
}
.stk.w { background: #fff; }
.stk.r { background: var(--red); color: #fff; }
.stk.y { background: var(--yellow); }
.stk--num { min-width: 30px; text-align: center; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; border: 2px solid var(--ink); border-radius: 99px;
  padding: 3px 10px; font-size: 12.5px; line-height: 1.3; font-weight: 700; background: #fff; white-space: nowrap;
}
.chip.ok { background: var(--lime-soft); }
.chip.no { background: var(--red-soft); }
.chip.wait { border-style: dashed; }
.chip.ink { background: var(--ink); color: var(--lime); }
.chip svg { flex: 0 0 auto; }

/* rotazioni degli adesivi */
.rot-0 { transform: none; }
.rot-n8 { transform: rotate(-8deg); }
.rot-n6 { transform: rotate(-6deg); }
.rot-n4 { transform: rotate(-4deg); }
.rot-n3 { transform: rotate(-3deg); }
.rot-n2 { transform: rotate(-2deg); }
.rot-p2 { transform: rotate(2deg); }
.rot-p3 { transform: rotate(3deg); }
.rot-p4 { transform: rotate(4deg); }
.rot-p8 { transform: rotate(8deg); }

/* ---------- pulsanti ---------- */
.btn {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 48px;
  border: 2.5px solid var(--ink); border-radius: var(--radius-m); box-shadow: var(--shadow);
  padding: 14px 16px; font-weight: 800; font-size: 16.5px; line-height: 1.2; text-align: center;
  background: #fff; color: var(--ink); text-decoration: none; cursor: pointer;
  transition: transform .08s, box-shadow .08s;
  touch-action: manipulation; user-select: none;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.red { background: var(--red); color: #fff; }
.btn.lime { background: var(--lime); }
.btn.ink { background: var(--ink); color: var(--lime); }
.btn.sm {
  width: auto; min-height: 0; padding: 8px 12px; font-size: 14px; border-radius: 11px; box-shadow: var(--shadow-m);
}
.btn.xs { width: auto; min-height: 0; padding: 5px 9px; font-size: 13px; border-radius: 10px; box-shadow: var(--shadow-s); }
/* bersaglio tattile di almeno 48 px anche per i pulsanti piccoli */
.btn.sm::after, .btn.xs::after, .back::after, .x::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: max(100%, 48px); height: max(100%, 48px); transform: translate(-50%, -50%);
}
.btn.sm:active, .btn.xs:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.dash { border-style: dashed; box-shadow: none; background: transparent; font-size: 14px; padding: 10px; }
.btn.dash:active { transform: none; background: rgba(29, 23, 48, .05); }
.btn.auto { width: auto; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-s); }
.btn.htmx-request { opacity: .7; cursor: progress; }

.back {
  position: relative;
  width: 42px; height: 42px; flex: 0 0 42px; border: 2.5px solid var(--ink); border-radius: 50%;
  background: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-s);
  color: var(--ink); text-decoration: none;
}
.back:active { transform: translate(2px, 2px); box-shadow: none; }
.x {
  position: relative;
  width: 26px; height: 26px; flex: 0 0 26px; border: 2px solid var(--ink); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: #fff; color: var(--ink);
}

/* ---------- carte e liste ---------- */
.card {
  display: block; background: #fff; border: 2.5px solid var(--ink); border-radius: var(--radius-l);
  box-shadow: var(--shadow-card); padding: 16px; color: var(--ink);
}
.card--tight { padding: 12px 14px; }
.card--list { padding: 4px 14px; }
.card--flat { box-shadow: var(--shadow-m); }
.card--dim { opacity: .75; box-shadow: var(--shadow-m); }
a.card, button.card { text-decoration: none; text-align: left; width: 100%; font: inherit; transition: transform .08s, box-shadow .08s; }
a.card:active, button.card:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }

.top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--start { align-items: flex-start; }
.gap { flex: 1; min-width: 0; }
.list .it { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 2px dashed var(--rule); }
.list .it:last-child { border-bottom: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 24px 0 10px; }

/* ---------- avatar ---------- */
.av {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; line-height: 1;
  background: #fff;
}
.av--l { width: 48px; height: 48px; flex-basis: 48px; font-size: 16px; }
.avs { display: flex; }
.avs .av { width: 32px; height: 32px; flex-basis: 32px; margin-left: -8px; font-size: 11px; }
.avs .av:first-child { margin-left: 0; }
.avs .av--more { background: var(--ink); color: var(--lime); }
/* palette della demo, assegnata in modo deterministico dal nome */
.av.c0 { background: #c6f432; } .av.c1 { background: #ffd23f; } .av.c2 { background: #ffb3c1; }
.av.c3 { background: #b9d8ff; } .av.c4 { background: #ffcf9e; } .av.c5 { background: #d4c4ff; }
.av.c6 { background: #a7f0d2; } .av.c7 { background: #fff; }

/* ---------- moduli ---------- */
.fld { display: block; margin-bottom: 14px; }
.fld__label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.fld input, .fld textarea, .fld select {
  width: 100%; min-height: 48px; border: 2.5px solid var(--ink); border-radius: 13px; padding: 12px 13px;
  font-size: 16px; background: #fff; outline: none; -webkit-appearance: none; appearance: none;
}
.fld select {
  padding-right: 38px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231d1730' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.fld input:focus, .fld textarea:focus, .fld select:focus { box-shadow: 3px 3px 0 var(--red); }
.fld input:disabled, .fld input[readonly] { background: #f4f4f7; }
.fld textarea { min-height: 120px; resize: none; line-height: 1.45; }
.fld__hint { display: block; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.fld__err { display: block; font-size: 13px; font-weight: 700; color: var(--red-dark); margin-top: 6px; }
.fld--err input, .fld--err textarea, .fld--err select { border-color: var(--red-dark); background: #fff8f8; }
.fld--inline { margin: 0; flex: 1; }
.form-error { min-height: 18px; margin: -4px 0 6px; }

/* interruttore: checkbox vera, nascosta, con il disegno della demo */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch__text { flex: 1; min-width: 0; }
.switch__hint { display: block; }
.switch__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle {
  width: 52px; height: 30px; border: 2.5px solid var(--ink); border-radius: 99px; background: #fff;
  position: relative; flex: 0 0 52px;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%;
  background: var(--ink); transition: left .15s;
}
.switch__input:checked + .toggle { background: var(--lime); }
.switch__input:checked + .toggle::after { left: 26px; }
.switch__input:focus-visible + .toggle { outline: 3px solid var(--red); outline-offset: 3px; }

/* passi della procedura */
.steps { display: flex; gap: 8px; margin: 2px 0 18px; list-style: none; }
.steps li { flex: 1; height: 8px; border: 2px solid var(--ink); border-radius: 99px; background: #fff; }
.steps li.on { background: var(--red); }

/* riquadro di fattibilità */
.feas { border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px 12px; font-size: 13.5px; line-height: 1.4; margin-top: 10px; }
.feas.ok { background: var(--lime-soft); }
.feas.am, .feas.warn { background: var(--amber-soft); }
.feas.ko { background: var(--red-soft); }
.feas b { display: block; font-size: 14.5px; }

/* ---------- timer a display digitale ---------- */
.lcd {
  display: inline-block; background: var(--ink); border: 2.5px solid var(--ink); border-radius: 18px;
  box-shadow: var(--shadow-timer); padding: 14px 18px; transform: rotate(-2deg);
}
.lcd .dg {
  font-family: var(--font-timer); color: var(--lime); font-size: 38px; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap; line-height: 1; font-variant-numeric: tabular-nums;
}
.lcd .dg small { font-size: 20px; margin-left: 1px; margin-right: 6px; }
.lcd .bl { animation: blink 1s steps(2) infinite; }
.lcd.mini { padding: 8px 11px; border-radius: 13px; box-shadow: 4px 4px 0 var(--red); }
.lcd.mini .dg { font-size: 21px; }
.lcd.mini .dg small { font-size: 13px; margin-right: 4px; }
@keyframes blink { 50% { opacity: .12; } }

/* ultimi 10 secondi e lampo */
.final {
  position: fixed; inset: 0; z-index: 35; background: var(--ink); display: none; flex-direction: column;
  align-items: center; justify-content: center; color: #fff;
}
.final.on { display: flex; }
.final .n { font-family: var(--font-timer); font-size: 190px; line-height: 1; color: var(--lime); font-weight: 700; }
.final .n.shk { animation: shake .45s; }
.final .l { font-size: 18px; font-weight: 700; margin-top: 10px; letter-spacing: .04em; }
@keyframes shake {
  0% { transform: scale(1.35) rotate(-6deg); } 30% { transform: scale(.92) rotate(4deg); }
  55% { transform: scale(1.05) rotate(-2deg); } 100% { transform: scale(1) rotate(0); }
}
.flash { position: fixed; inset: 0; background: #fff; z-index: 45; pointer-events: none; opacity: 0; }
.flash.go { animation: flash .7s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- foto di gruppo ---------- */
.photo {
  border: 2.5px solid var(--ink); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-card);
  background: var(--lime-soft); transform: rotate(1.2deg); position: relative;
}
.photo img { display: block; width: 100%; height: 170px; object-fit: cover; }
.photo .tape {
  position: absolute; top: -9px; left: 50%; width: 70px; height: 20px; margin-left: -35px; z-index: 1;
  background: var(--tape); border: 2px solid var(--ink); transform: rotate(-4deg);
}
.photo--empty { display: flex; align-items: center; justify-content: center; height: 170px; color: var(--muted); font-weight: 700; font-size: 14px; text-align: center; padding: 16px; }

/* ---------- rivelazione ---------- */
.gift { width: 220px; height: 220px; margin: 6px auto 0; display: block; cursor: pointer; }
.gift.idle { animation: wob 2.4s ease-in-out infinite; }
@keyframes wob {
  0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-5deg); } 80% { transform: rotate(5deg); }
  85% { transform: rotate(-4deg); } 90% { transform: rotate(3deg); }
}
.gift .lid { transition: transform .7s cubic-bezier(.2, 1.6, .4, 1), opacity .7s; transform-origin: 100px 85px; }
.gift.gone { display: none; }
.gift.open .lid { transform: translate(-30px, -150px) rotate(-38deg); opacity: 0; }
.gift.open .body { animation: squash .5s; }
@keyframes squash { 30% { transform: scale(1.08, .9); transform-origin: 100px 180px; } 100% { transform: scale(1); } }
.rname { display: none; text-align: center; }
.rname.on { display: block; animation: pop .7s cubic-bezier(.2, 1.7, .4, 1); }
@keyframes pop { 0% { transform: scale(.2) rotate(-12deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.bigname {
  display: inline-block; font-size: 50px; line-height: 1.15; font-weight: 800; letter-spacing: -.03em; background: var(--lime);
  border: 3px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow-l); padding: 4px 18px; transform: rotate(-3deg);
  overflow-wrap: anywhere;
}
.bigname--m { font-size: 46px; }
.tap { font-weight: 800; font-size: 15px; margin-top: 6px; text-align: center; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* illustrazione del pacco (logo grande) */
.hero-gift { position: relative; height: 170px; margin: 12px 0 4px; }
.hero-gift__svg { position: absolute; right: 10px; top: 10px; width: 150px; height: 150px; transform: rotate(8deg); }
.hero-gift .stk { position: absolute; }
.hero-gift__s1 { left: 4px; top: 30px; }
.hero-gift__s2 { left: 30px; top: 96px; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; flex: 1 0 auto; width: 100%; max-width: var(--chat-max); margin: 0 auto; }
.chead { display: flex; align-items: center; gap: 10px; padding: 10px 14px 12px; border-bottom: 2.5px solid var(--ink); background: #fff; flex: 0 0 auto; }
.chead .who { line-height: 1.15; min-width: 0; }
.chead .who b { font-size: 17px; display: block; }
.chead .who span { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.chead .btn.sm { padding: 7px 10px; font-size: 13px; white-space: nowrap; flex: 0 0 auto; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 16px 10px; scrollbar-width: none; }
.msgs::-webkit-scrollbar { display: none; }
.mu { margin: 0 0 14px 48px; display: flex; justify-content: flex-end; }
.mu > div {
  background: var(--lime-soft); border: 2px solid var(--ink); border-radius: 20px 20px 5px 20px; padding: 10px 13px;
  font-size: 15.5px; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere;
}
.ma { display: flex; gap: 10px; margin: 0 0 16px; }
.elf {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; background: var(--red); border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-s);
}
.elf--xl { width: 64px; height: 64px; flex-basis: 64px; border-radius: 18px; margin: 0 auto; transform: rotate(-6deg); box-shadow: var(--shadow); }
.ma .tx { font-size: 15.5px; line-height: 1.55; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ma .tx p { margin: 0 0 8px; }
.ma .tx ol, .ma .tx ul { margin: 2px 0 8px 20px; }
.ma .tx li { margin: 4px 0; }
.ma .tx li::marker { font-weight: 800; color: var(--red); }
.cur { display: inline-block; width: 9px; height: 17px; background: var(--red); vertical-align: -3px; margin-left: 2px; animation: blink .8s steps(2) infinite; }
.memchip {
  display: inline-flex; align-items: center; gap: 4px; margin: -6px 0 14px 40px; font-size: 12px; font-weight: 700;
  border: 2px solid var(--ink); border-radius: 99px; padding: 2px 9px; background: var(--lime);
  animation: pop .5s cubic-bezier(.2, 1.7, .4, 1);
}
.intr { font-size: 12px; color: var(--muted); margin-top: -4px; }
.empty { text-align: center; padding: 26px 6px 10px; }
.sugg { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }
.sugg button {
  border: 2px solid var(--ink); border-radius: 14px; padding: 10px 12px; text-align: left; font-size: 14.5px;
  font-weight: 600; background: #fff; box-shadow: var(--shadow-m); min-height: 48px;
}
.sugg button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.comp { flex: 0 0 auto; padding: 10px 12px calc(14px + env(safe-area-inset-bottom)); border-top: 2.5px solid var(--ink); background: #fff; }
.comp .box { display: flex; align-items: flex-end; gap: 8px; border: 2.5px solid var(--ink); border-radius: 24px; padding: 6px 6px 6px 14px; background: #fff; }
.comp textarea { flex: 1; border: 0; outline: none; resize: none; font-size: 16px; line-height: 1.4; max-height: 130px; padding: 7px 0; background: transparent; }
.send {
  position: relative;
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; background: var(--red); border: 2.5px solid var(--ink);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-s);
}
.send::after { content: ""; position: absolute; inset: -4px; }
.send.stop { background: var(--ink); }
.comp .fine { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 7px; }
.idea { display: flex; gap: 8px; align-items: flex-start; padding: 9px 0; border-bottom: 2px dashed var(--rule); font-size: 14px; }
.idea:last-child { border-bottom: 0; }

/* ---------- bottom sheet (dialog nativo) ---------- */
.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 560px; max-height: 82dvh;
  border: 0; border-top: 3px solid var(--ink); border-radius: 26px 26px 0 0; background: #fff; color: var(--ink);
  padding: 12px 18px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain;
}
.sheet[open] { animation: sheet-up .28s cubic-bezier(.2, .9, .3, 1); }
.sheet::backdrop { background: rgba(29, 23, 48, .45); }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.grab { width: 46px; height: 5px; border-radius: 9px; background: var(--ink); margin: 0 auto 12px; opacity: .25; }
.sheet__head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.sheet__head .h2 { flex: 1; }
.sheet__actions { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
@media (min-width: 700px) {
  .sheet {
    inset: 0; margin: auto; height: fit-content; max-height: 80dvh; border: var(--border); border-radius: var(--radius-l);
    box-shadow: var(--shadow-l); padding: 18px 22px 24px;
  }
  .sheet[open] { animation: sheet-pop .22s cubic-bezier(.2, 1.4, .4, 1); }
  .sheet .grab { display: none; }
}
@keyframes sheet-pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
body:has(.sheet[open]) { overflow: hidden; }

/* ---------- toast ---------- */
.toasts {
  position: fixed; left: 16px; right: 16px; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 60;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none; max-width: 480px; margin: 0 auto;
}
.toast {
  background: var(--ink); color: var(--lime); border: 2.5px solid var(--ink); border-radius: 15px; padding: 12px 14px;
  font-weight: 700; font-size: 14.5px; line-height: 1.35; box-shadow: 4px 4px 0 var(--red); pointer-events: auto;
  animation: toast-in .3s cubic-bezier(.2, 1.4, .4, 1);
  display: flex; align-items: flex-start; gap: 10px;
}
.toast__text { flex: 1; }
.toast.err { background: var(--red); color: #fff; box-shadow: var(--shadow); }
.toast.out { transform: translateY(calc(100% + 60px)); opacity: 0; transition: transform .3s ease-in, opacity .3s; }
@keyframes toast-in { from { transform: translateY(calc(100% + 60px)); } to { transform: none; } }

/* ---------- canvas degli effetti ---------- */
.snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

/* ---------- landing ---------- */
.landing__steps .stk { transform: none; }
.landing__actions { display: flex; flex-direction: column; gap: 12px; margin-top: auto; padding-top: 20px; }

/* ---------- pagine d'errore ---------- */
.err-code {
  display: inline-block; font-family: var(--font-timer); font-weight: 700; font-size: 64px; line-height: 1;
  color: var(--lime); background: var(--ink); border: 2.5px solid var(--ink); border-radius: 18px;
  box-shadow: var(--shadow-timer); padding: 12px 20px; transform: rotate(-2deg);
}
.err-gift { width: 150px; height: 150px; margin: 0 auto; transform: rotate(-8deg); }
.err-gift .lid { transform: translate(18px, -16px) rotate(14deg); transform-origin: 100px 85px; }

/* ---------- pagina componenti (solo sviluppo) ---------- */
.kit-grid { display: grid; gap: 20px; }
.kit-swatch { display: flex; flex-wrap: wrap; gap: 8px; }
.kit-swatch span { width: 56px; height: 56px; border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow-s); }
.sw-ink { background: var(--ink); } .sw-red { background: var(--red); } .sw-red-dark { background: var(--red-dark); }
.sw-red-soft { background: var(--red-soft); } .sw-lime { background: var(--lime); } .sw-lime-soft { background: var(--lime-soft); }
.sw-yellow { background: var(--yellow); } .sw-paper { background: var(--paper); } .sw-muted { background: var(--muted); }
.kit-final { position: relative; inset: auto; display: flex; height: 320px; border-radius: 20px; z-index: 0; }
.kit-final .n { font-size: 140px; }

/* ---------- utilità (sostituiscono gli stili inline della demo) ---------- */
.mt-0 { margin-top: 0; } .mt-4 { margin-top: 4px; } .mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; } .mt-12 { margin-top: 12px; } .mt-14 { margin-top: 14px; } .mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; } .mt-20 { margin-top: 20px; } .mt-22 { margin-top: 22px; } .mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-4 { margin-bottom: 4px; } .mb-6 { margin-bottom: 6px; } .mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; } .mb-14 { margin-bottom: 14px; } .mb-16 { margin-bottom: 16px; } .mb-18 { margin-bottom: 18px; }
.mb-24 { margin-bottom: 24px; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.wrap { flex-wrap: wrap; }
.center { justify-content: center; }
.tc { text-align: center; }
.fw-6 { font-weight: 600; } .fw-7 { font-weight: 700; } .fw-8 { font-weight: 800; }
.fs-15 { font-size: 15px; } .fs-17 { font-size: 17px; } .fs-18 { font-size: 18px; } .fs-22 { font-size: 22px; }
.push { margin-top: auto; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.actions { display: flex; flex-direction: column; gap: 12px; margin-top: auto; padding-top: 20px; }
.self-start { align-self: flex-start; }
.w-full { width: 100%; }
.minw-0 { min-width: 0; }

/* ---------- desktop ---------- */
@media (min-width: 700px) {
  .page { padding-top: 24px; }
  .actions { flex-direction: row-reverse; justify-content: flex-start; }
  .actions .btn { width: auto; min-width: 220px; }
  .toasts { left: 24px; right: 24px; }
}
@media (min-width: 900px) {
  .h1 { font-size: 46px; }
  .landing {
    display: grid; grid-template-columns: 1.05fr .95fr; grid-template-rows: 1fr 1fr; gap: 0 64px;
    align-content: center; padding-top: 40px; padding-bottom: 56px;
  }
  .landing__intro { grid-column: 1; grid-row: 1; align-self: end; }
  .landing__intro .lead { font-size: 19px; max-width: 30em; }
  .landing__intro .stk { font-size: 14px; }
  .landing__art { grid-column: 2; grid-row: 1 / span 2; align-self: center; max-width: 440px; width: 100%; justify-self: center; }
  .landing__actions { grid-column: 1; grid-row: 2; align-self: start; margin-top: 0; padding-top: 32px; flex-direction: row; }
  .landing__actions .btn { width: auto; flex: 1; }
  .landing .hero-gift { height: 250px; }
  .landing .hero-gift__svg { width: 220px; height: 220px; right: 0; }
  .landing .hero-gift .stk { font-size: 14px; }
  .landing .hero-gift__s1 { top: 40px; }
  .landing .hero-gift__s2 { top: 140px; left: 24px; }
  .landing .card .it { padding: 12px 0; font-size: 17px; }
  .kit-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- movimento ridotto ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .snow, .fx { display: none !important; }
}

/* --- B8 attesa e rivelazione */
/* conto alla rovescia (components/countdown.html, js/countdown.js) */
.countdown--full { text-align: center; margin-top: 10px; }
.countdown__title { font-weight: 800; font-size: 18px; }
.countdown--full .countdown__lcd { margin-top: 16px; }
.countdown__blocked { margin-top: 18px; text-align: left; }
.countdown--mini .countdown__title { font-size: 13px; line-height: 1.4; font-weight: 700; color: var(--muted); }
.countdown--mini .countdown__lcd { margin-top: 8px; }

/* pacco della rivelazione (components/reveal.html, js/reveal.js) */
.reveal { display: flex; flex-direction: column; flex: 1 0 auto; }
.reveal__title { text-align: center; font-weight: 800; font-size: 22px; line-height: 1.2; margin-top: 22px; }
.reveal__sub { text-align: center; font-weight: 600; }
.reveal__lead { font-weight: 800; font-size: 18px; margin: 56px 0 18px; }
.reveal .rname:focus { outline: none; }
button.gift { padding: 0; border: 0; background: none; border-radius: 24px; touch-action: manipulation; }
button.gift svg { display: block; width: 100%; height: 100%; }
button.gift:disabled { cursor: default; }
.gift.idle.wait { animation: wob-wait .5s ease-in-out infinite; }
@keyframes wob-wait { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@media (min-width: 700px) {
  .reveal__actions { justify-content: center; }
}

/* passaggio attesa → rivelazione e tra le pagine dello stesso sito (View Transitions tra documenti) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .35s; }
}

/* --- B6: eventi, procedura di creazione, vista organizzatore ------------------------------ */
/* I miei eventi */
.ev-list { list-style: none; display: grid; gap: 16px; }
.ev-card { overflow: hidden; }
.ev-card__cover {
  width: calc(100% + 32px); max-width: none; height: 120px; object-fit: cover;
  margin: -16px -16px 14px; border-bottom: 2.5px solid var(--ink);
}
/* procedura */
.wizard { display: flex; flex-direction: column; flex: 1 0 auto; }
.wizard__step + .wizard__step { margin-top: 28px; }
.wizard[data-wizard-mode="steps"] .wizard__step + .wizard__step { margin-top: 0; }
.wizard h2[tabindex]:focus { outline: none; }
.wiz-row > .fld { flex: 1; min-width: 0; }
.wiz-row > .fld:last-child { flex: 1.3; }
.wiz-preview { margin: -4px 0 6px; }
.wiz-preview .chip { white-space: normal; overflow-wrap: anywhere; }
.pair-row > .fld { flex: 1; min-width: 0; margin: 0; }
.pair-row__x { font-weight: 800; }
.feas__list { list-style: none; margin-top: 6px; }
.feas__list li { margin: 2px 0; }
.feas-wrap:empty { display: none; }
/* vista organizzatore */
.org-banner .btn { box-shadow: var(--shadow-s); }
.org-name { display: flex; gap: 4px; min-width: 0; }
.org-name__you { flex: 0 0 auto; }
.org-more { flex: 0 0 30px; width: 30px; height: 30px; }
.list .it--dim { opacity: .55; }
.photo-pick { cursor: pointer; }
.pre-line { white-space: pre-line; overflow-wrap: anywhere; }
@media (min-width: 900px) {
  .ev-list { grid-template-columns: 1fr 1fr; }
  .org-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 0 40px; align-items: start; }
  .org-side > section:first-child .section-title { margin-top: 0; }
}

/* --- B8 rifinitura (pagine non-chat) ------------------------------------------------------- */
/* intestazione: logo + menu anche a 375 px */
.site-nav .btn.sm { padding: 8px 11px; }
.site-nav .btn.lime { box-shadow: var(--shadow-s); }
@media (max-width: 359px) {
  .site-nav { gap: 6px; }
  .site-nav .btn.sm { padding: 7px 8px; font-size: 13px; }
}
/* riga in alto (indietro + adesivi): gli adesivi non vanno a capo, la riga sì */
.top { flex-wrap: wrap; row-gap: 10px; }
.top .stk { white-space: nowrap; max-width: calc(100% - 52px); overflow: hidden; text-overflow: ellipsis; }
/* link testuali con bersaglio tattile di 48 px */
.brand { min-width: 48px; }
.tap-link { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; min-width: 48px; font-weight: 700; text-underline-offset: 3px; }
.site-footer { padding-top: 6px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); align-items: center; }
.site-footer a { display: inline-flex; align-items: center; min-height: 48px; }
/* I miei eventi: schede alte uguali sulla griglia desktop, stato vuoto illustrato */
.ev-list > li { display: flex; }
.ev-list > li > .card { flex: 1; }
.empty-state { padding: 22px 18px 20px; }
.empty-state__gift { display: block; margin: 0 auto; transform: rotate(-8deg); }
/* landing: link "Accedi" sotto i pulsanti */
.landing__login { text-align: center; margin: -6px 0 -12px; }
@media (min-width: 900px) {
  .landing__actions { flex-wrap: wrap; }
  .landing__login { flex-basis: 100%; text-align: left; margin: 0; }
}
/* evento annullato / gioco iniziato senza di te: pacco aperto e vuoto */
.state-art { display: flex; justify-content: center; margin: 4px 0 18px; }
/* zona pericolosa del profilo */
.danger-zone { background: var(--red-soft); border-style: dashed; box-shadow: none; }
.danger-zone .fld input { background: #fff; }
.danger-zone .mut { color: var(--ink); }
/* nomi lunghi nell'adesivo del sorteggiato */
.bigname--long { font-size: 38px; }
.bigname--longer { font-size: 30px; }
@media (min-width: 700px) {
  .bigname--long { font-size: 44px; }
  .bigname--longer { font-size: 38px; }
}
/* caricamento della foto (organizer.js): anteprima con velo e rotella */
.photo--busy::after {
  content: ""; position: absolute; inset: 0; z-index: 2;
  background: rgba(255, 255, 255, .55);
}
.photo--busy::before {
  content: ""; position: absolute; left: 50%; top: 50%; z-index: 3; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border: 5px solid var(--ink); border-right-color: var(--lime); border-radius: 50%;
  animation: photo-spin .8s linear infinite;
}
@keyframes photo-spin { to { transform: rotate(360deg); } }
.photo-pick:focus-within { outline: 3px solid var(--red); outline-offset: 3px; }
/* contenitore dello scambio htmx della procedura (events/new.html) */
.wizard-box { display: flex; flex-direction: column; flex: 1 0 auto; }
/* procedura: su desktop il pulsante (dentro i contenitori data-wizard-only) va a destra come in .actions */
@media (min-width: 700px) {
  .wizard .actions > div { display: flex; justify-content: flex-end; }
  .wizard .actions > div[hidden] { display: none; }
}
/* pagina d'invito: su mobile una colonna con l'azione in basso, su desktop due colonne */
.invite { max-width: 560px; }
.invite__act { display: flex; flex-direction: column; flex: 1 0 auto; }
.invite__act > form.stack { flex: 1 0 auto; }
@media (min-width: 900px) {
  .invite {
    max-width: 1000px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 56px;
    align-items: start; align-content: start;
  }
  .invite__act {
    margin-top: 58px; padding: 20px 22px 24px; background: #fff;
    border: var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-card);
  }
  .invite__act .actions { flex-direction: column; }
  .invite__act .actions .btn { width: 100%; }
}

/* --- B10 chat */
/* Pagina a schermo intero: scorre solo la lista dei messaggi. chat.js imposta --vv-h/--vv-top dal
   visual viewport, così il campo resta sopra la tastiera virtuale (iOS Safari). */
body.page-chat {
  position: fixed; left: 0; right: 0; top: var(--vv-top, 0);
  height: var(--vv-h, 100dvh); min-height: 0; overflow: hidden; overscroll-behavior: none;
}
.page-chat .main { flex: 1 1 auto; min-height: 0; }
.page-chat .toasts { bottom: calc(var(--comp-h, 140px) + 12px); }
.chat { flex: 1 1 auto; min-height: 0; max-width: none; display: flex; flex-direction: row; }
.chat__col { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chat__side { display: none; }
.chead {
  padding: calc(10px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
}
.chead .who { flex: 0 1 auto; }
.chead .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chead .who span { display: block; overflow: hidden; text-overflow: ellipsis; }
.chead__mem { position: relative; }
.chead__mem .cnt {
  position: absolute; top: -10px; right: -8px; display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 5px; border: 2px solid var(--ink); border-radius: 99px;
  background: var(--red); color: #fff; font-size: 11.5px; line-height: 1; transform: rotate(6deg);
}
.msgs-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.msgs { flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.msgs__list { list-style: none; }
.empty__lead { line-height: 1.45; max-width: 30em; margin-left: auto; margin-right: auto; }
.sugg { max-width: 460px; margin-left: auto; margin-right: auto; }

/* testo dell'assistente in markdown */
.ma .md > :last-child { margin-bottom: 0; }
.ma .tx h1, .ma .tx h2, .ma .tx h3, .ma .tx h4 { font-size: 17px; line-height: 1.3; font-weight: 800; margin: 14px 0 6px; }
.ma .tx h1 { font-size: 19px; }
.ma .md > :first-child { margin-top: 0; }
.ma .tx a { color: var(--red-dark); font-weight: 700; text-underline-offset: 2px; }
.ma .tx code { font-family: ui-monospace, monospace; font-size: .9em; background: var(--lime-soft); border-radius: 5px; padding: 0 4px; }
.ma .tx pre { background: #f6f5fa; border: 2px solid var(--ink); border-radius: var(--radius-s); padding: 10px 12px; overflow-x: auto; margin: 0 0 8px; }
.ma .tx pre code { background: none; padding: 0; }
.ma .tx blockquote { border-left: 3px solid var(--lime); padding-left: 10px; margin: 0 0 8px; color: var(--muted); }
.ma .tx hr { border: 0; border-top: 2px dashed var(--rule); margin: 12px 0; }
.ma .tx table { display: block; overflow-x: auto; border-collapse: collapse; margin: 0 0 8px; font-size: 14.5px; }
.ma .tx th, .ma .tx td { border: 1.5px solid var(--rule); padding: 4px 8px; text-align: left; }
.ma .md .cur:only-child { margin-left: 0; }

/* azioni e stati dei messaggi */
.ma__tools { display: flex; gap: 8px; margin-top: 6px; }
.copy {
  position: relative; display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 4px 9px 4px 7px;
  border-radius: 9px; font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.copy::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 48px; transform: translateY(-50%); }
.copy:hover, .copy.done { color: var(--ink); background: rgba(29, 23, 48, .06); }
.ma[data-status="streaming"] .ma__tools { display: none; }
.intr { margin-top: 4px; }
.intr--err { color: var(--red-dark); font-weight: 700; }
.ma__err { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 6px; }
.ma__err .intr { margin-top: 0; }
.mu[data-status="error"] > div { border-style: dashed; background: #fff; }
li.memchip { width: fit-content; }
.memchip svg { flex: 0 0 auto; }
.tobottom {
  position: absolute; left: 50%; bottom: 12px; z-index: 3; transform: translateX(-50%);
  width: 44px; height: 44px; border-radius: 50%; background: #fff; border: var(--border); box-shadow: var(--shadow-m);
  display: flex; align-items: center; justify-content: center; color: var(--ink);
}
.tobottom::after { content: ""; position: absolute; inset: -4px; }
.tobottom:active { transform: translate(calc(-50% + 2px), 2px); box-shadow: var(--shadow-s); }

/* campo di scrittura */
.comp { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
.comp textarea { max-height: calc(1.4em * 6 + 14px); overflow-y: hidden; }
.comp textarea::placeholder { color: var(--muted); }
.comp .box:focus-within { box-shadow: var(--shadow-m); }
.send .i-stop, .send.stop .i-send { display: none; }
.send.stop .i-stop { display: block; }
.send:active { transform: translate(2px, 2px); box-shadow: none; }
.chars { margin: 0 8px 6px; text-align: right; font-size: 12px; font-weight: 700; color: var(--muted); }
.chars.over { color: var(--red-dark); }
.comp .fine--note { margin-top: 8px; }
.comp .fine + .fine { margin-top: 2px; }

/* "Cosa ricordo" (chat/_memory.html): sheet su mobile, colonna su desktop */
.memory__head { display: flex; align-items: center; gap: 10px; }
.sheet .memory__head { display: none; }
.memory__empty { margin-top: 6px; }
.sheet .memory__empty { margin-top: 0; }
.memory__sec { margin-top: 14px; }
.sheet .memory__sec:first-of-type { margin-top: 4px; }
.memory__label { font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.memory__chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.memory__chips .chip { white-space: normal; overflow-wrap: anywhere; font-size: 13px; }
.memory__chips .chip:has(form) { padding-right: 3px; }
.memory__chips .x { width: 20px; height: 20px; flex-basis: 20px; border-width: 1.5px; }
.memory__ideas { list-style: none; }
.memory__ideas .idea .chip { flex: 0 0 auto; margin-top: 1px; }
.memory__ideas .idea b { overflow-wrap: anywhere; }
.memory__restart { margin-top: 18px; }

@media (prefers-reduced-motion: no-preference) {
  .mu.in, .ma.in { animation: msg-in .22s ease-out; }
}
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (min-width: 700px) {
  .chat__col { max-width: var(--chat-max); margin: 0 auto; border-left: var(--border); border-right: var(--border); }
  .msgs { padding: 22px 28px 12px; }
  .comp { padding: 12px 22px 16px; }
}
@media (min-width: 1100px) {
  .chat { width: 100%; max-width: calc(var(--chat-max) + 384px); margin: 0 auto; gap: 24px; }
  .chat__col { margin: 0; }
  .chat__side {
    display: block; flex: 0 0 360px; align-self: flex-start; margin-top: 20px; max-height: calc(100% - 40px);
    overflow-y: auto; overscroll-behavior: contain; background: #fff; border: var(--border); border-radius: var(--radius-l);
    box-shadow: var(--shadow-l); padding: 16px 20px 20px;
  }
  .chead__mem { display: none; }
}

/* --- PWA */
/* banner "versione nuova" (components/pwa.html, js/pwa.js): sul telefono una striscia fissa in
   basso, nella chat sopra il campo di scrittura; sul computer un riquadro in basso a destra */
.pwa-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 55;
  display: flex; align-items: center; gap: 10px; max-width: 480px; margin: 0 auto;
  padding: 8px 10px 8px 10px; background: #fff; color: var(--ink);
  border: var(--border); border-radius: 18px; box-shadow: var(--shadow);
  font-weight: 700; font-size: 14.5px; line-height: 1.3;
  animation: toast-in .3s cubic-bezier(.2, 1.4, .4, 1);
}
.pwa-banner__ico {
  flex: 0 0 34px; width: 34px; height: 34px; border: 2px solid var(--ink); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--yellow); transform: rotate(-8deg);
}
.pwa-banner__text { flex: 1; min-width: 0; }
.pwa-banner .btn.sm { flex: 0 0 auto; box-shadow: var(--shadow-s); }
.pwa-banner__x { flex: 0 0 26px; }
.page-chat .pwa-banner { bottom: calc(var(--comp-h, 140px) + 12px); }
/* il banner non copre i pulsanti in fondo alla pagina; i toast salgono sopra il banner */
body.pwa-banner-on:not(.page-chat) { padding-bottom: 84px; }
body.pwa-banner-on:not(.page-chat) .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); }
body.pwa-banner-on.page-chat .toasts { bottom: calc(var(--comp-h, 140px) + 88px); }
@media (min-width: 700px) {
  .pwa-banner { left: auto; right: 24px; bottom: 24px; width: 380px; margin: 0; padding: 10px 12px; }
  .page-chat .pwa-banner { bottom: 24px; }
  body.pwa-banner-on:not(.page-chat) { padding-bottom: 0; }
  body.pwa-banner-on:not(.page-chat) .toasts, body.pwa-banner-on.page-chat .toasts { bottom: calc(22px + env(safe-area-inset-bottom)); }
}
@media (min-width: 700px) and (max-width: 1099px) {
  /* chat tra 700 e 1099 px: la colonna è centrata, il riquadro resta sopra il campo */
  .page-chat .pwa-banner { bottom: calc(var(--comp-h, 140px) + 12px); }
}

/* avviso "Sei offline": in alto, discreto, non prende i tocchi */
.pwa-offline {
  position: fixed; left: 0; right: 0; top: calc(8px + env(safe-area-inset-top)); z-index: 70;
  display: flex; justify-content: center; padding: 0 16px; pointer-events: none;
}
.pwa-offline__pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px;
  background: var(--amber-soft); border: 2px solid var(--ink); border-radius: var(--radius-pill);
  box-shadow: var(--shadow-s); font-size: 13px; font-weight: 700; line-height: 1.25;
}
.pwa-offline__pill .ico { flex: 0 0 auto; }

/* riga "Installa l'app" del Profilo e invito in "I miei eventi" */
.pwa-install__ico {
  flex: 0 0 40px; width: 40px; height: 40px; border: 2.5px solid var(--ink); border-radius: 12px;
  display: flex; align-items: center; justify-content: center; background: var(--lime); box-shadow: var(--shadow-s);
  transform: rotate(-4deg);
}
.pwa-install__title { display: block; }
.pwa-install__sub { display: block; margin-top: 2px; }
.pwa-install .btn.sm, .pwa-invite .btn.sm { flex: 0 0 auto; }
.pwa-invite {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 12px 14px;
  background: var(--lime-soft); border: var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-m);
}
.pwa-invite__title { display: block; font-size: 16px; line-height: 1.25; margin-bottom: 2px; }
.pwa-invite__side { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; flex: 0 0 auto; }

/* guida per iPhone: tre passi numerati */
.pwa-steps { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.pwa-steps li { display: flex; align-items: flex-start; gap: 12px; }
.pwa-steps__n {
  flex: 0 0 30px; width: 30px; height: 30px; border: 2px solid var(--ink); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--lime);
  font-weight: 800; font-size: 14px; box-shadow: var(--shadow-s);
}
.pwa-steps__tx { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); line-height: 1.4; }
.pwa-steps__tx b { display: block; color: var(--ink); font-size: 15.5px; line-height: 1.3; margin-bottom: 2px; }
.pwa-steps__ico { display: inline-block; vertical-align: -4px; margin-left: 4px; color: var(--red-dark); }
