/* Fuori Soglia — stile dell'app.
   Tre identità (temi) tra cui scegliere, tutte sui colori del logo: verde salvia #858C6A e grigio #706E6F.
   Il tema si sceglie con ?tema=salvia | notte | pietra (resta memorizzato) e in futuro sarà fisso. */
:root, [data-theme='salvia'] {
  --paper: #f2f3ee; --surface: #ffffff; --surface-2: #e9ebe3;
  --ink: #262823; --ink-2: #4a4d43; --muted: #6c6e65; --line: #dcded5;
  --accent: #858c6a; --accent-ink: #ffffff; --accent-deep: #5c6347; --accent-soft: #e4e8d7;
  --bar: #262823; --bar-ink: #f2f3ee;
  --splash: #f2f3ee; --splash-ink: #262823; --splash-line: #858c6a;
  --ok: #4b6b3c; --ok-bg: #e5edd9; --danger: #b42318; --danger-bg: #fbe9e7; --warn-bg: #fbf0cf;
  --demo: #f2c94c; --demo-ink: #3a2e00; --demo-soft: #fdf3d2;
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --display-weight: 750; --display-tracking: -0.02em;
  --radius: 20px; --radius-sm: 13px;
  --shadow: 0 1px 2px rgba(38, 40, 35, .05), 0 10px 30px -18px rgba(38, 40, 35, .35);
  --logo-on-splash: url('/icons/logo.svg');
  color-scheme: light;
}
[data-theme='notte'] {
  --paper: #111210; --surface: #1b1c19; --surface-2: #24261f;
  --ink: #edeee8; --ink-2: #c9cbc0; --muted: #9a9c92; --line: #2e302a;
  --accent: #a3aa86; --accent-ink: #111210; --accent-deep: #c6cca8; --accent-soft: #2a2e22;
  --bar: #0b0c0a; --bar-ink: #edeee8;
  --splash: #0d0e0c; --splash-ink: #edeee8; --splash-line: #a3aa86;
  --ok: #a9c98f; --ok-bg: #22301b; --danger: #ff8a7a; --danger-bg: #3a1714; --warn-bg: #3a3010;
  --demo: #e8c25a; --demo-ink: #1d1600; --demo-soft: #332a10; --demo-box-ink: #f3e3b0;
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body: 'Outfit', system-ui, sans-serif;
  --display-weight: 650; --display-tracking: -0.01em;
  --radius: 22px; --radius-sm: 14px;
  --shadow: 0 1px 0 rgba(0, 0, 0, .35), 0 14px 34px -20px rgba(0, 0, 0, .9);
  --logo-on-splash: url('/icons/logo-negativo.svg');
  color-scheme: dark;
}
[data-theme='pietra'] {
  --paper: #e6e7e1; --surface: #f8f8f5; --surface-2: #dcded6;
  --ink: #1e201b; --ink-2: #41443a; --muted: #62645b; --line: #cdd0c6;
  --accent: #5e6648; --accent-ink: #ffffff; --accent-deep: #3f4530; --accent-soft: #d9ddc8;
  --bar: #2b2e25; --bar-ink: #eef0e8;
  --splash: #2b2e25; --splash-ink: #eef0e8; --splash-line: #c9d09f;
  --ok: #45633a; --ok-bg: #dce6d0; --danger: #a8281c; --danger-bg: #f5e3df; --warn-bg: #f3e8c4;
  --demo: #f0c342; --demo-ink: #352900; --demo-soft: #f6ebc5;
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --display-weight: 800; --display-tracking: -0.005em;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(30, 32, 27, .06), 0 8px 24px -16px rgba(30, 32, 27, .4);
  --logo-on-splash: url('/icons/logo-negativo.svg');
  color-scheme: light;
}
[data-theme='pietra'] h1, [data-theme='pietra'] h2, [data-theme='pietra'] .display { font-variation-settings: 'wdth' 118; font-style: italic; }
:root { --nav-h: 66px; --signal: var(--accent); --signal-ink: var(--accent-ink); --radius-pill: 999px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: calc(var(--nav-h) + 24px); scroll-padding-top: 120px; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-body);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: var(--font-display); line-height: 1.12; margin: 0 0 .5em; letter-spacing: var(--display-tracking); }
h1 { font-size: clamp(1.7rem, 4.6vw, 2.3rem); font-weight: var(--display-weight); }
h2 { font-size: 1.3rem; font-weight: var(--display-weight); }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 .8em; max-width: 68ch; }
a { color: inherit; text-underline-offset: 3px; }
small, .small { font-size: .875rem; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- struttura */
.boot { min-height: 100vh; display: grid; place-items: center; }
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--bar); color: var(--bar-ink);
  padding: max(env(safe-area-inset-top), 10px) 16px 0;
}
.topbar-row { display: flex; align-items: center; gap: 12px; max-width: 1080px; margin: 0 auto; min-height: 48px; }
.brand { text-decoration: none; color: inherit; display: inline-flex; align-items: center; padding: 4px 0; }
.brand img { display: block; height: 34px; width: auto; }
@media (min-width: 900px) { .brand img { height: 40px; } }
.topbar .who { margin-left: auto; font-size: .875rem; opacity: .85; text-align: right; line-height: 1.2; }
.topbar .who b { display: block; font-weight: 650; opacity: 1; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; max-width: 1080px; margin: 6px auto 0; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  white-space: nowrap; padding: 10px 12px 12px; text-decoration: none; color: inherit; opacity: .75; font-weight: 600;
  border-bottom: 4px solid transparent; font-size: .95rem;
}
.tabs a[aria-current='page'] { opacity: 1; border-bottom-color: var(--signal); }
/* Aree come schede di un raccoglitore: ogni colore = chi può vedere quelle pagine. */
:root { --area-admin: #c07a5a; --area-staff: #d6ab52; --area-client: #9aa77a; --area-ink: #1c1d19; }
[data-area='admin'] { --c: var(--area-admin); }
[data-area='staff'] { --c: var(--area-staff); }
[data-area='client'] { --c: var(--area-client); }
.topbar .who .role { display: inline-block; margin: 3px 0 2px; padding: 2px 9px; border-radius: 999px; background: var(--c); color: var(--area-ink);
  font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; opacity: 1; }
.topbar .who a { display: block; }
.binder { display: flex; gap: 6px; max-width: 1080px; margin: 14px auto 0; overflow-x: auto; scrollbar-width: none; align-items: flex-end; }
.binder::-webkit-scrollbar { display: none; }
.binder a { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; text-decoration: none; color: var(--bar-ink);
  padding: 8px 16px 9px; border-radius: 14px 14px 0 0; font-weight: 650; font-size: .9rem;
  background: color-mix(in srgb, var(--c) 16%, transparent); box-shadow: inset 0 3px 0 var(--c); opacity: .82; transition: background .2s, opacity .2s, padding .2s; }
.binder a::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.binder a:hover { opacity: 1; background: color-mix(in srgb, var(--c) 28%, transparent); }
.binder a[aria-current='true'] { background: var(--c); color: var(--area-ink); opacity: 1; padding-top: 11px; box-shadow: none; }
.binder a[aria-current='true']::before { background: color-mix(in srgb, var(--area-ink) 45%, transparent); }
.subnav { background: var(--c); margin: 0 -16px; padding: 0 16px; }
.subnav.none { height: 4px; background: color-mix(in srgb, var(--bar-ink) 15%, transparent); }
.subnav .tabs { margin-top: 0; color: var(--area-ink); }
.subnav .tabs a { opacity: .72; border-bottom-color: transparent; }
.subnav .tabs a[aria-current='page'] { opacity: 1; border-bottom-color: var(--area-ink); }
.preview-note { max-width: 1080px; margin: 14px auto 0; padding: 10px 14px; border-radius: var(--radius-sm, 12px); font-size: .92rem;
  background: color-mix(in srgb, var(--c) 22%, var(--surface, #fff)); border-left: 4px solid var(--c); }
@media (max-width: 1112px) { .preview-note { margin: 14px 16px 0; } }
main { max-width: 1080px; margin: 0 auto; padding: 20px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
.staff main { padding-bottom: 48px; }

/* barra in basso per i clienti (pollice) */
.bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .78rem; font-weight: 600; position: relative;
}
.bottomnav a svg { width: 24px; height: 24px; }
.bottomnav a[aria-current='page'] { color: var(--ink); }
.bottomnav a[aria-current='page']::before { content: ''; position: absolute; top: 0; left: 22%; right: 22%; height: 4px; background: var(--signal); }
@media (min-width: 900px) {
  .client .bottomnav { position: static; max-width: 1080px; margin: 0 auto; border: 0; background: transparent; display: flex; gap: 6px; padding: 0 16px; }
  .client .bottomnav a { height: auto; flex-direction: row; padding: 10px 14px; border-radius: var(--radius-sm); }
  .client .bottomnav a[aria-current='page'] { background: var(--surface); box-shadow: var(--shadow); }
  .client .bottomnav a[aria-current='page']::before { display: none; }
  .client main { padding-bottom: 48px; }
}

/* ---------- blocchi */
.page-head { margin-bottom: 18px; }
.page-head p { color: var(--muted); }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel-flat { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.spacer { flex: 1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* prossima seduta: l'elemento più importante per il cliente */
.next {
  background: var(--bar); color: var(--bar-ink); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; position: relative; overflow: hidden;
}
.next .when { font-size: clamp(1.9rem, 8vw, 2.6rem); font-family: var(--font-display); font-weight: 860; line-height: 1; margin: 6px 0 4px; }
.next .day { font-weight: 650; text-transform: capitalize; }
.next .meta { opacity: .8; }
.next::after { content: ''; position: absolute; left: 20px; right: 20px; bottom: 0; height: 6px; background: var(--signal); }

/* pulsanti */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: var(--radius-pill); padding: 11px 20px; min-height: 46px;
  font: inherit; font-weight: 680; cursor: pointer; background: var(--surface); color: var(--ink); border-color: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; line-height: 1.2;
}
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.signal { background: var(--signal); color: var(--signal-ink); border-color: var(--signal); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.link { background: none; border: 0; padding: 6px 0; min-height: 0; text-decoration: underline; font-weight: 600; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { background: none; border: 0; font-size: 1.6rem; line-height: 1; padding: 4px 8px; cursor: pointer; color: inherit; border-radius: var(--radius-sm); }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }

/* scelte (servizio, istruttore) */
.choices { display: grid; gap: 10px; }
@media (min-width: 640px) { .choices { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } }
.choice {
  text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
  font: inherit; color: inherit; display: flex; gap: 12px; align-items: flex-start; min-height: 64px;
}
.choice:hover { border-color: var(--ink-2); }
.choice[aria-pressed='true'] { border-color: var(--ink); box-shadow: inset 0 -4px 0 var(--signal); }
.choice b { display: block; font-weight: 720; }
.choice .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; margin-top: 4px; }
.steps { display: flex; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; flex-wrap: wrap; }
.steps li { font-size: .875rem; color: var(--muted); }
.steps li.done button { color: var(--ink); text-decoration: underline; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.steps li + li::before { content: '/'; margin-right: 8px; color: var(--line); }

/* giorni e orari: il cuore della prenotazione */
.days { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.day-btn {
  flex: none; width: 62px; scroll-snap-align: start; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--radius-sm);
  padding: 8px 4px; text-align: center; cursor: pointer; font: inherit; line-height: 1.15;
}
.day-btn .wd { font-size: .75rem; color: var(--muted); text-transform: capitalize; display: block; }
.day-btn .dn { font-size: 1.35rem; font-family: var(--font-display); font-weight: 820; display: block; }
.day-btn .mo { font-size: .72rem; color: var(--muted); display: block; }
.day-btn[aria-pressed='true'] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.day-btn[aria-pressed='true'] .wd, .day-btn[aria-pressed='true'] .mo { color: inherit; opacity: .8; }
.day-btn.nofree { opacity: .45; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.slot {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--radius-sm); padding: 10px 6px; cursor: pointer;
  font: inherit; text-align: center; min-height: 58px;
}
.slot .t { display: block; font-size: 1.25rem; font-family: var(--font-display); font-weight: 800; }
.slot .s { display: block; font-size: .75rem; color: var(--muted); }
.slot:hover:not(:disabled) { border-color: var(--ink); box-shadow: inset 0 -4px 0 var(--signal); }
.slot:disabled { cursor: not-allowed; opacity: .5; text-decoration: line-through; text-decoration-thickness: 1px; }
.slot.perfect { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface, #fff)); position: relative; }
.slot.perfect::after { content: ''; position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.slot-hint { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; }
.dot-perfect { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.prio-btn { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: .8rem; cursor: pointer; color: var(--muted); white-space: nowrap; }
.prio-btn.on { background: color-mix(in srgb, var(--area-staff) 30%, transparent); border-color: var(--area-staff); color: var(--ink); font-weight: 650; }
.smart-scale { margin: 16px 2.5% 2px; }
.smart-range { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(90deg, var(--accent) var(--p, 50%), color-mix(in srgb, var(--ink) 12%, transparent) var(--p, 50%)); }
.smart-range::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: var(--surface, #fff); border: 3px solid var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.smart-range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--surface, #fff); border: 3px solid var(--accent); }
.smart-ticks { display: flex; justify-content: space-between; gap: 4px; margin-bottom: 10px; }
.smart-ticks button { flex: 0 0 20%; }
.smart-ticks button { background: none; border: 0; font: inherit; font-size: .74rem; color: var(--muted); cursor: pointer; padding: 4px 2px; text-align: center; }
.smart-now { padding: 12px 14px; border-radius: var(--radius-sm, 12px); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.smart-level { font-family: var(--font-display); font-size: 1.05rem; }
.slot.mine { opacity: 1; text-decoration: none; background: var(--ok-bg); border-color: var(--ok); }

/* elenchi */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1 1 220px; min-width: 0; }
.list .time { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; min-width: 56px; }
.tag { display: inline-block; font-size: .78rem; font-weight: 650; padding: 2px 8px; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.tag.warn { background: var(--warn-bg); border-color: transparent; }
.tag.danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.swatch { width: 10px; align-self: stretch; border-radius: 3px; flex: none; }
.credit { display: flex; align-items: baseline; gap: 10px; }
.credit .n { font-size: 2rem; font-family: var(--font-display); font-weight: 860; line-height: 1; }
.note { background: var(--warn-bg); border-radius: var(--radius-sm); padding: 10px 12px; margin: 10px 0; }
.note.ok { background: var(--ok-bg); }
.note.err { background: var(--danger-bg); color: var(--danger); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty p { margin: 0 auto 12px; }
.loading { padding: 32px; text-align: center; color: var(--muted); }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 650; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.total { font-size: 1.6rem; font-family: var(--font-display); font-weight: 860; }

/* moduli */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; }
.field label { font-weight: 620; font-size: .92rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 44px; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: 2px solid var(--signal); outline-offset: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 1px 0 0; flex: none; accent-color: var(--ink); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.stepper button { width: 48px; height: 48px; border: 0; background: none; font-size: 1.5rem; cursor: pointer; color: var(--ink); }
.stepper output { min-width: 48px; text-align: center; font-size: 1.5rem; font-family: var(--font-display); font-weight: 820; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); padding: 10px 14px; font: inherit; cursor: pointer; color: var(--ink); min-height: 44px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
.week-editor .day { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
.week-editor .win { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.week-editor input[type='time'] { width: auto; min-width: 110px; }

/* accesso */
.auth { min-height: 100vh; display: grid; align-content: center; justify-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth .brand { margin: 0 auto 24px; }
.auth .brand img { height: auto; width: min(280px, 70vw); }

/* finestre */
dialog.sheet {
  border: 0; padding: 0; border-radius: var(--radius); background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 32px); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .55);
}
dialog.sheet.wide { width: min(820px, calc(100vw - 24px)); }
dialog.sheet::backdrop { background: rgba(12, 13, 10, .6); }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh; }
}
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0 20px; }
.sheet-head h2 { margin: 0; flex: 1; }
.sheet-body { padding: 12px 20px 22px; overflow-y: auto; max-height: calc(92vh - 60px); }

/* avvisi */
#toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(480px, calc(100vw - 24px)); }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); transition: opacity .3s, transform .3s; border-left: 6px solid var(--signal); }
.toast-error { background: var(--danger); color: #fff; border-left-color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
.demo-banner { background: var(--signal); color: var(--signal-ink); text-align: center; font-size: .85rem; font-weight: 650; padding: 4px 8px; }
dl.kv.receipt { grid-template-columns: 1fr auto; }
dl.kv.receipt dd { text-align: right; }

/* ---------- schermata di benvenuto (splash) */
.splash {
  position: relative; min-height: 100vh; min-height: 100dvh; overflow: hidden; isolation: isolate;
  background: var(--splash); color: var(--splash-ink);
  display: grid; align-content: center; justify-items: center; padding: 32px 16px calc(28px + env(safe-area-inset-bottom));
}
.ecg-field { position: absolute; inset: 0; z-index: -1; pointer-events: none;
  -webkit-mask-image: radial-gradient(120% 80% at 50% 45%, #000 30%, transparent 85%); mask-image: radial-gradient(120% 80% at 50% 45%, #000 30%, transparent 85%); }
.ecg-row { position: absolute; left: 0; width: 200%; height: 90px; display: flex; animation: ecg-scroll var(--dur, 38s) linear infinite; }
.ecg-row svg { width: 50%; height: 100%; flex: none; }
.ecg-row path { fill: none; stroke: var(--splash-line); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
@keyframes ecg-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.splash-inner { width: 100%; max-width: 440px; display: grid; justify-items: center; text-align: center; gap: 0; }
/* Apertura: linea del battito → logo che si disegna e pulsa → scritta → contenuti. */
.splash-hero { position: relative; width: min(300px, 74vw); margin-bottom: 26px; }
.splash-logo { display: block; width: 100%; height: auto; overflow: visible; position: relative; z-index: 1; }
.splash-logo .mark { fill: var(--accent); }
.splash-logo .mark-line { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
[data-theme='pietra'] .splash-logo .mark, [data-theme='notte'] .splash-logo .mark { fill: var(--splash-line); }
[data-theme='pietra'] .splash-logo .mark-line, [data-theme='notte'] .splash-logo .mark-line { stroke: var(--splash-line); }
.splash-logo .of { fill: var(--accent); }
[data-theme='pietra'] .splash-logo .of, [data-theme='notte'] .splash-logo .of { fill: var(--splash-line); }
.splash-logo .txt { fill: #706e6f; }
[data-theme='notte'] .splash-logo .txt, [data-theme='pietra'] .splash-logo .txt { fill: #eceee6; }
.mark-g { transform-box: fill-box; transform-origin: 50% 100%; }
.splash-logo .mark-fill { opacity: 0; }
.wipe { transform-box: fill-box; transform-origin: left center; transform: scaleX(0); }

/* la linea che attraversa lo schermo, all'altezza della base del battito */
.beam { position: absolute; top: 62.5%; left: 50%; width: 100vw; height: 2px; transform: translateX(-50%); pointer-events: none; }
.beam-line { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--splash-line) 70%, transparent) 30%, var(--splash-line)); }
.beam-head { position: absolute; top: 50%; left: 0; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; opacity: 0;
  background: var(--splash-line); box-shadow: 0 0 0 4px color-mix(in srgb, var(--splash-line) 25%, transparent), 0 0 24px 6px color-mix(in srgb, var(--splash-line) 55%, transparent); }
.beat { position: absolute; left: 50%; top: 38%; width: 70%; aspect-ratio: 1; margin-left: -35%; transform: translateY(-50%) scale(.2); border-radius: 50%;
  border: 1.5px solid var(--splash-line); opacity: 0; pointer-events: none; }

.splash:not(.instant) .beam-line { animation: beam-in 1.15s cubic-bezier(.7, 0, .3, 1) .15s forwards, beam-out .9s ease-in 1.9s forwards; }
.splash:not(.instant) .beam-head { animation: head-run 1.15s cubic-bezier(.7, 0, .3, 1) .15s forwards; }
.splash:not(.instant) .mark-line { animation: draw 1.05s cubic-bezier(.65, 0, .35, 1) .55s forwards, fade-out .5s ease 1.75s forwards; }
.splash:not(.instant) .mark-fill { animation: fade-in .55s ease 1.3s forwards; }
.splash:not(.instant) .mark-g { animation: thump .9s cubic-bezier(.3, 0, .2, 1) 1.32s both; }
.splash:not(.instant) .b1 { animation: ring 1.3s cubic-bezier(.2, .6, .3, 1) 1.34s forwards; }
.splash:not(.instant) .b2 { animation: ring 1.3s cubic-bezier(.2, .6, .3, 1) 1.6s forwards; }
.splash:not(.instant) .words { animation: unblur .9s cubic-bezier(.2, .7, .2, 1) 1.75s both; }
.splash:not(.instant) .wipe { animation: wipe .95s cubic-bezier(.65, 0, .35, 1) 1.7s forwards; }
.splash.instant .mark-fill, .splash.instant .wipe { opacity: 1; transform: none; }
.splash.instant .mark-line, .splash.instant .beam, .splash.instant .beat { display: none; }

@keyframes beam-in { to { transform: scaleX(1); } }
@keyframes beam-out { from { transform: scaleX(1); opacity: 1; } to { transform: scaleX(1) translateX(30%); opacity: 0; } }
@keyframes head-run { 0% { left: 0; opacity: 0; } 8% { opacity: 1; } 85% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade-in { to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes thump { 0% { transform: scale(1); } 14% { transform: scale(1.06, 1.1); } 30% { transform: scale(.99); } 46% { transform: scale(1.03, 1.05); } 70%, 100% { transform: scale(1); } }
@keyframes ring { 0% { opacity: .55; transform: translateY(-50%) scale(.2); } 100% { opacity: 0; transform: translateY(-50%) scale(1.9); } }
@keyframes wipe { to { transform: scaleX(1); } }
@keyframes unblur { from { filter: blur(10px); opacity: 0; transform: translateY(10px); } to { filter: blur(0); opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes word-up { from { transform: translateY(110%); } to { transform: none; } }

.splash h1 { font-size: clamp(1.65rem, 6.4vw, 2.25rem); margin: 0 0 8px; color: var(--splash-ink); text-wrap: balance; }
.reveal-title .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .08em; margin-right: .26em; }
.reveal-title .w:last-child { margin-right: 0; }
.reveal-title .w > span { display: inline-block; }
.splash:not(.instant) .reveal-title .w > span { animation: word-up .8s cubic-bezier(.2, .8, .2, 1) calc(2.15s + var(--i) * .07s) both; }
.splash .lead { margin: 0 auto 26px; font-size: 1.08rem; opacity: .78; }
.splash .cta { width: 100%; display: grid; gap: 10px; }
.splash:not(.instant) .lead { animation: rise .8s ease-out 2.6s both; }
.splash:not(.instant) .cta { animation: rise .8s ease-out 2.75s both; }
.splash:not(.instant) .ecg-field { animation: fade-in 2s ease 2.1s both; opacity: 0; }
.btn.google { display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f1f1f; border: 1px solid #dadce0; font-weight: 600; }
.btn.google:hover { background: #f7f8f8; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted, #777); font-size: .85rem; margin: 4px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .3; }
.splash .btn { width: 100%; min-height: 52px; font-size: 1.02rem; }
.splash .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.splash .btn.ghost { color: var(--splash-ink); border-color: color-mix(in srgb, var(--splash-ink) 25%, transparent); background: transparent; }
.splash .btn.link { color: var(--splash-ink); opacity: .8; }
.demo-box { margin-top: 18px; width: 100%; border-radius: var(--radius); padding: 16px; text-align: left;
  background: var(--demo-soft); color: var(--demo-box-ink, var(--demo-ink)); border: 1px dashed color-mix(in srgb, var(--demo) 70%, var(--demo-ink)); }
.splash:not(.instant) .demo-box { animation: rise .8s ease-out 2.9s both; }
.demo-box b { display: block; font-family: var(--font-display); font-size: 1.02rem; }
.demo-box p { margin: 2px 0 12px; font-size: .92rem; opacity: .85; }
.demo-box .row { gap: 8px; }
.demo-box .btn { flex: 1 1 140px; width: auto; min-height: 46px; background: var(--demo); border-color: var(--demo); color: var(--demo-ink) !important; font-weight: 700; }
.splash .panel { width: 100%; text-align: left; color: var(--ink); animation: rise .45s ease-out both; }
.theme-dots { margin-top: 22px; display: flex; gap: 8px; align-items: center; font-size: .82rem; opacity: .75; }
.splash:not(.instant) .theme-dots { animation: rise .8s ease-out 3.05s both; }
.theme-dots a { width: 22px; height: 22px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--splash-ink) 30%, transparent); display: inline-block; }
.theme-dots a[aria-current='true'] { border-color: var(--splash-ink); }
.demo-ribbon { background: var(--demo); color: var(--demo-ink); text-align: center; font-size: .85rem; font-weight: 700; padding: 6px 10px; display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.demo-ribbon button { background: none; border: 0; text-decoration: underline; font: inherit; color: inherit; cursor: pointer; padding: 0; }
@media (prefers-reduced-motion: reduce) { .ecg-row { animation: none; } .splash .mark-fill, .splash .wipe, .splash .ecg-field { opacity: 1 !important; transform: none !important; } .splash .mark-line, .splash .beam, .splash .beat { display: none; } }
