/* Babbo Linchetto — v3 (06/11/2026): stessa palette, interfaccia rifatta.
   Contrasti verificati (README, «Accessibilità»). Mobile first. */
:root {
  --bg: #0f1d1a;
  --bg-top: #17372e;
  --card: #172a25;
  --card-2: #1f3830;
  --card-3: #27483d;
  --text: #f4efe6;
  --dim: #c3cdc8;
  --gold: #e8c170;
  --red: #c8283c;
  --line: #7f9a90;       /* bordi dei campi: 4,9:1 su --card */
  --soft: #2c4a40;       /* filetti decorativi */
  --ok: #8fd6a4;
  --err: #ffb3b3;
  --cream: #f4efe6;
  --ink: #2b2420;
  --radius: 18px;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --tabbar: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  background: radial-gradient(120% 55% at 50% -8%, var(--bg-top) 0%, var(--bg) 62%) fixed, var(--bg);
}
.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: #1a1a1a; padding: .6rem 1rem; z-index: 30; }
.skip:focus { left: 8px; top: 8px; }

/* ---------- testata ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 640px; margin: 0 auto; padding: 14px 16px 6px; }
.brand { white-space: nowrap; display: inline-flex; align-items: center; gap: 10px; color: var(--gold); font-family: var(--display); font-weight: 700; font-size: 1.2rem; text-decoration: none; }
.brand img { border-radius: 10px; }
#nav { display: flex; gap: 10px; align-items: center; }
#nav a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 999px; background: var(--card); color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem; }
#nav a:hover { background: var(--card-2); }
#nav a { white-space: nowrap; }
@media (max-width: 440px) {
  .brand { font-size: 1.05rem; }
  .brand img { width: 30px; height: 30px; }
  #nav a .t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #nav a { padding: 0; width: 44px; justify-content: center; }
  .chip { padding: 6px 12px; font-size: .88rem; }
}

main { max-width: 640px; margin: 0 auto; padding: 8px 16px calc(var(--tabbar) + 40px); outline: none; }
main.senza-tab { padding-bottom: 48px; }

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-family: var(--display); font-size: 1.9rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; color: var(--gold); }
h3 { font-size: 1rem; margin: 1.1rem 0 .35rem; }
p { margin: .4rem 0 .8rem; }
.dim { color: var(--dim); }
.small { font-size: .92rem; }
a { color: var(--gold); text-underline-offset: 3px; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 6px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 2px; border-radius: 12px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.2em; }

/* ---------- pannelli ---------- */
.panel { background: var(--card); border-radius: var(--radius); padding: 18px; margin: 14px 0; }
.panel-h { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.panel-h .ico { color: var(--gold); width: 1.4em; height: 1.4em; }
.panel.flat { background: transparent; padding: 0; }
.panel.accent { background: linear-gradient(160deg, var(--card-2), var(--card)); border: 1px solid var(--soft); }

/* ---------- campi ---------- */
.field { margin: 1.2rem 0 0; }
.field > p { margin: .65rem 0 0; }
.field label, label.lbl { display: block; font-weight: 600; margin: 0 0 .5rem; }
.field input, .field textarea, .field select,
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px;
}
textarea { min-height: 88px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--dim); opacity: .75; }
input[type=date] { color-scheme: dark; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pwbox { position: relative; }
.pwbox input { padding-right: 92px; }
.pwbox button { position: absolute; right: 6px; top: 6px; min-height: 36px; padding: 4px 12px; font-size: .85rem; }
.row { display: flex; gap: 0 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.check { display: flex; align-items: flex-start; gap: 12px; font-weight: 400; margin: 1.1rem 0; cursor: pointer; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--red); margin-top: 2px; }

/* ---------- pulsanti ---------- */
button, .btn {
  font: inherit; font-weight: 700; cursor: pointer; border: 0; border-radius: 14px;
  padding: 12px 20px; min-height: 48px; background: var(--red); color: #fff; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:hover:not(:disabled), .btn:hover { filter: brightness(1.08); }
button.sec, .btn.sec { background: transparent; color: var(--text); border: 2px solid var(--line); }
button.ghost { background: transparent; color: var(--gold); padding: 8px 6px; }
button.danger { background: transparent; color: var(--err); border: 2px solid var(--err); }
button.small, .btn.small { min-height: 44px; padding: 8px 14px; font-size: .92rem; }
button.block, .btn.block { width: 100%; }
button:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.linkbtn { background: none; color: var(--gold); text-decoration: underline; text-underline-offset: 3px; padding: 8px 4px; min-height: 44px; font-weight: 600; }

/* segmentato (accedi / registrati, chat) */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--card); border-radius: 16px; margin: 14px 0; }
.seg button { flex: 1; background: transparent; color: var(--dim); min-height: 46px; border-radius: 12px; font-weight: 600; position: relative; }
.seg button[aria-pressed=true] { background: var(--card-3); color: var(--text); box-shadow: inset 0 0 0 2px var(--gold); }
.dot { position: absolute; top: 8px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--card); }

/* messaggi */
.msg { padding: 10px 14px; border-radius: 12px; margin: 10px 0; }
.msg.err { background: #3b1a1d; border: 2px solid var(--err); color: var(--err); }
.msg.err::before { content: "⚠ "; }
.msg.ok { background: #16342a; border: 2px solid var(--ok); color: var(--ok); }
.msg.ok::before { content: "✓ "; }

/* ---------- accesso ---------- */
.benvenuto { text-align: center; padding: 18px 0 4px; }
.spot { width: 168px; height: 168px; margin: 0 auto 14px; border-radius: 50%; background: var(--cream); display: grid; place-items: center; box-shadow: 0 0 0 6px var(--card-2); overflow: hidden; }
.spot img, .spot svg { width: 82%; height: 82%; object-fit: contain; }
.spot.sm { width: 120px; height: 120px; box-shadow: 0 0 0 4px var(--card-2); }
.benvenuto h1 { font-size: 2.2rem; }
.benvenuto p { color: var(--dim); max-width: 30em; margin-left: auto; margin-right: auto; }

/* ---------- elenco gruppi ---------- */
.gruppi { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.gruppo-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--card); border-radius: var(--radius); text-decoration: none; color: var(--text); border: 1px solid transparent; }
.gruppo-card:hover { border-color: var(--soft); background: var(--card-2); }
.gruppo-card .nome { font-family: var(--display); font-size: 1.15rem; font-weight: 700; }
.gruppo-card .sub { color: var(--dim); font-size: .9rem; }
.gruppo-card .chev { margin-left: auto; color: var(--gold); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--card-3); color: var(--text); white-space: nowrap; }
.pill.gold { background: var(--gold); color: #1a1a1a; }
.pill.ok { background: #16342a; color: var(--ok); }
.vuoto { text-align: center; padding: 18px 8px; }
.vuoto .spot { margin-bottom: 10px; }

/* ---------- intestazione del gruppo ---------- */
.gtesta { padding: 10px 0 2px; }
.gtesta h1 { margin-bottom: 10px; }
.gtesta.compatta { padding: 4px 0 0; }
.gtesta.compatta h1 { font-size: 1.4rem; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px; border-radius: 999px; background: var(--card); color: var(--text); font-size: .92rem; font-weight: 600; text-decoration: none; }
.chip .ico { color: var(--gold); }
a.chip { border: 1px solid var(--soft); }
a.chip:hover { background: var(--card-2); }

.tappe { display: flex; align-items: center; margin: 14px 0 4px; padding: 0; list-style: none; }
.tappa { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--dim); position: relative; text-align: center; }
.tappa::before { content: ""; position: absolute; top: 15px; right: 50%; width: 100%; height: 3px; background: var(--soft); z-index: 0; }
.tappa:first-child::before { display: none; }
.tappa .pallino { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); border: 2px solid var(--line); position: relative; z-index: 1; color: var(--dim); }
.tappa.fatta { color: var(--ok); }
.tappa.fatta::before { background: var(--ok); }
.tappa.fatta .pallino { background: #16342a; border-color: var(--ok); color: var(--ok); }
.tappa.attuale { color: var(--gold); }
.tappa.attuale::before { background: var(--gold); }
.tappa.attuale .pallino { background: var(--gold); border-color: var(--gold); color: #1a1a1a; }

/* ---------- persone e avatar ---------- */
.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-weight: 800; color: #1a2420; flex: none; font-size: 1rem; }
.avatar.sm { width: 32px; height: 32px; font-size: .85rem; }
.persone { list-style: none; margin: 0; padding: 0; }
.persone li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--soft); }
.persone li:last-child { border-bottom: 0; }
.persone .nome { font-weight: 600; flex: 1; min-width: 0; word-break: break-word; }

/* ---------- lista desideri ---------- */
.desideri { list-style: none; margin: 0; padding: 0; }
.desideri li { padding: 12px 0; border-bottom: 1px solid var(--soft); }
.desideri li:last-child { border-bottom: 0; }
.desideri .t { font-weight: 700; }
.desideri .m { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.idea { background: var(--bg); border-radius: 14px; padding: 12px 14px 14px; margin: 10px 0; border: 1px solid var(--soft); }
.idea .n { color: var(--gold); font-weight: 700; font-size: .85rem; }

/* ---------- la rivelazione ---------- */
.regalo { position: relative; text-align: center; padding: 22px 16px 20px; overflow: hidden; }
.regalo .spot { width: 200px; height: 200px; box-shadow: 0 0 0 8px var(--card-3), 0 0 0 10px var(--gold); transition: transform .3s; }
.regalo.aperto .spot { transform: scale(1.03); }
.regalo .tocca { display: block; width: 100%; background: none; padding: 0; min-height: 0; color: inherit; border-radius: 24px; }
.regalo .tocca:hover { filter: none; }
.regalo .etichetta { display: block; margin: 12px 0 4px; font-size: 1.05rem; font-weight: 700; color: var(--gold); }
.regalo .sopra { color: var(--dim); margin: 0 0 4px; }
.regalo h2:not(.sr) { margin: 10px 0 2px; }
.nome-grande { font-family: var(--display); font-size: 2.6rem; font-weight: 700; color: var(--gold); margin: 6px 0 4px; word-break: break-word; line-height: 1.1; }
.gift-lid { transform-box: fill-box; transform-origin: 15% 100%; transition: transform .55s cubic-bezier(.2,.9,.3,1.3); }
.regalo.aperto .gift-lid { transform: translate(30px, -26px) rotate(16deg); }
@keyframes pop { 0% { transform: scale(.8) rotate(-4deg); } 60% { transform: scale(1.07) rotate(1deg); } 100% { transform: scale(1) rotate(0); } }
.regalo.aperto .spot img { animation: pop .5s ease-out; }
.conf { position: absolute; top: 10px; width: 9px; height: 14px; border-radius: 2px; opacity: 0; animation: cade 1.6s ease-out forwards; }
@keyframes cade { 0% { opacity: 1; transform: translateY(0) rotate(0); } 100% { opacity: 0; transform: translateY(210px) rotate(300deg); } }

/* ---------- chat ---------- */
.chat { max-height: 52vh; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px 10px; }
.bubble { max-width: 84%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; word-break: break-word; }
.bubble.mine { align-self: flex-end; background: var(--red); color: #fff; border-bottom-right-radius: 5px; }
.bubble.their { align-self: flex-start; background: var(--card-3); border-bottom-left-radius: 5px; }
.bubble time { display: block; font-size: .72rem; margin-top: 3px; opacity: .9; }
.bubble.mine time { text-align: right; }
.chatform { display: flex; gap: 8px; align-items: flex-end; margin-top: 6px; }
.chatform textarea { min-height: 48px; height: 48px; flex: 1; resize: none; }
.chatform button { min-width: 48px; padding: 0 16px; }

/* ---------- tabella finale ---------- */
.tabella { list-style: none; margin: 0; padding: 0; }
.tabella li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--soft); }
.tabella li:last-child { border-bottom: 0; }
.coppia { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.coppia .freccia { color: var(--gold); }
.indovinato { font-size: .88rem; color: var(--dim); grid-column: 1 / -1; }
.indovinato.giusto { color: var(--ok); }

/* ---------- barra delle sezioni ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; background: #0c1815; border-top: 1px solid var(--soft); padding-bottom: env(safe-area-inset-bottom); }
.tabbar-in { display: flex; width: min(640px, 100%); }
.tabbar button { flex: 1; flex-direction: column; gap: 2px; background: transparent; color: var(--dim); min-height: var(--tabbar); border-radius: 0; font-size: .74rem; font-weight: 700; padding: 6px 2px; position: relative; }
.tabbar button .ico { width: 24px; height: 24px; }
.tabbar button[aria-current=page] { color: var(--gold); }
.tabbar button[aria-current=page]::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; background: var(--gold); border-radius: 0 0 4px 4px; }
.tabbar .dot { top: 6px; right: calc(50% - 22px); }
@media (min-width: 760px) {
  .tabbar { bottom: 14px; left: 0; right: 0; background: transparent; border: 0; pointer-events: none; }
  .tabbar-in { pointer-events: auto; background: #0c1815; border: 1px solid var(--soft); border-radius: 22px; overflow: hidden; box-shadow: 0 8px 30px #0008; }
}

#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--gold); color: #1a1a1a; font-weight: 700; padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center; z-index: 40; }
#toast.on { opacity: 1; }

details { margin: .6rem 0; }
summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; gap: 10px; color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .conf { display: none; }
}

/* profilo personale */
.profilo h3 { margin: 26px 0 10px; font-size: .95rem; color: var(--gold); }
.chips.sel { margin: 10px 0 14px; }
.chip.tag { border: 1px solid var(--soft); cursor: pointer; min-height: 40px; }
.chip.tag.on { background: var(--red); border-color: var(--red); color: #fff; }
.chips.ro { list-style: none; padding: 0; margin: 4px 0; }
.chips.ro .chip.tag { cursor: default; }
.chips.ro.evita .chip.tag { border-color: var(--red); }
.aggiungi { display: flex; gap: 12px; align-items: center; margin: 14px 0 6px; }
.aggiungi input { flex: 1 1 auto; }
.pf-riga { margin: 8px 0; }
.pf-k { font-size: .85rem; font-weight: 700; color: var(--gold); }
.pf-dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0 0; }
.pf-dl dt { font-weight: 700; color: var(--gold); font-size: .88rem; }
.pf-dl dd { margin: 0; overflow-wrap: anywhere; }
.azioni-elenco { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; }
.chip.tag.togli { border-style: dashed; border-color: var(--gold); }
.chip.tag .x { color: var(--gold); font-size: 1.1rem; line-height: 1; }
[hidden] { display: none !important; }
.desideri li.presa .t { color: var(--dim); text-decoration: line-through; text-decoration-thickness: 1px; }
.check.piccolo { font-size: .9rem; margin: .7rem 0 .2rem; }
.chips.ro li { list-style: none; }
.chips.ro a.chip { text-decoration: none; }
