/* Layout: app a schermo singolo, colonna centrale max 520px (mobile-first, usabile anche su PC).
   Temi = variabili CSS (data-theme), modo scuro = data-mode="dark". */
:root {
  --cream: #fbf8f4;
  --surface: #ffffff;
  --line: #ece6f2;
  --ink: #3f3552;
  --ink-soft: #7a6f8c;
  --ink-faint: #cfc7da;
  --accent: #9a83e0;
  --accent-deep: #7656bf;
  --accent-soft: #e6dcff;
  --mist: #f6f2ff;
  --bg-1: #f3edff;
  --bg-2: #fbf1f6;
  --btn-1: #b3a0ee;
  --btn-2: #8f74dd;
  --danger: #d9506e;
  --ok: #3ea883;
  --warn: #e0963a;
  --c-swim: #4f8fd9;
  --c-cycle: #e8607f;
  --c-skin: #d98a4a;
  --c-med: #3ea883;
  --c-habit: #9a83e0;
  --font-display: 'Fredoka', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Nunito', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="rosa"] { --accent: #ee7f9f; --accent-deep: #d2527a; --accent-soft: #ffd9e3; --mist: #fff1f5; --bg-1: #ffe9ef; --bg-2: #f3ecff; --btn-1: #f79ab5; --btn-2: #e8688b; }
:root[data-theme="menta"] { --accent: #4fc39a; --accent-deep: #2f9473; --accent-soft: #cdeee0; --mist: #effaf5; --bg-1: #e2f6ed; --bg-2: #e8eefb; --btn-1: #74d4b2; --btn-2: #3fb88d; }
:root[data-theme="azzurro"] { --accent: #6f9af0; --accent-deep: #4a74c9; --accent-soft: #d7e6ff; --mist: #eef4ff; --bg-1: #e3edff; --bg-2: #efe9fb; --btn-1: #93b4f5; --btn-2: #628ee8; }
:root[data-theme="pesca"] { --accent: #f09468; --accent-deep: #cf6d3e; --accent-soft: #ffe0cf; --mist: #fff4ee; --bg-1: #ffeadd; --bg-2: #fbeff6; --btn-1: #f7ab88; --btn-2: #ec8657; }

:root[data-mode="dark"] {
  --cream: #17131f;
  --surface: #221c2e;
  --line: #342c44;
  --ink: #efe9fa;
  --ink-soft: #b4a9c8;
  --ink-faint: #54496a;
  --mist: #2a2238;
  --accent-soft: #3a2f55;
  --bg-1: #1a1523;
  --bg-2: #1d1727;
  color-scheme: dark;
}
:root[data-mode="dark"][data-theme="rosa"] { --accent-soft: #5a2c3d; --mist: #2d2029; }
:root[data-mode="dark"][data-theme="menta"] { --accent-soft: #1f4a3b; --mist: #1f2d29; }
:root[data-mode="dark"][data-theme="azzurro"] { --accent-soft: #263d66; --mist: #1f2638; }
:root[data-mode="dark"][data-theme="pesca"] { --accent-soft: #5a3622; --mist: #2d2420; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2)) fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }

/* ---- Avvio ---- */
.boot-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; color: var(--ink-soft); }
.boot-screen svg { animation: spin 3s linear infinite; }
.boot-error { max-width: 420px; white-space: pre-wrap; font-size: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: left; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Guscio ---- */
.app-shell { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--cream); box-shadow: 0 0 60px -30px rgba(60, 40, 100, .4); position: relative; }
.app-header { position: sticky; top: 0; z-index: 20; padding: calc(env(safe-area-inset-top) + 12px) 16px 10px; background: linear-gradient(180deg, var(--accent-soft), var(--cream)); display: flex; align-items: center; gap: 10px; }
.app-header h1 { font-family: var(--font-display); font-size: 22px; font-weight: 600; line-height: 1.1; }
.app-header .sub { font-size: 13px; color: var(--ink-soft); }
/* in fondo spazio per la barra delle schede e per il pulsante «+», così l'ultima riga non resta mai sotto */
.app-main { flex: 1; padding: 6px 16px calc(156px + env(safe-area-inset-bottom)); }
.screen-enter { animation: enter .22s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.bottom-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 520px; z-index: 30; display: flex; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px -16px rgba(60, 40, 100, .35); }
.nav-item { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; background: none; border: 0; border-radius: 14px; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.nav-item svg { width: 24px; height: 24px; }
.nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item.is-active { color: var(--accent-deep); background: var(--accent-soft); }
:root[data-mode="dark"] .nav-item.is-active { color: var(--ink); }

/* ---- Elementi base ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 14px; box-shadow: 0 4px 18px -12px rgba(80, 60, 120, .3); }
.card + .card, .stack > * + * { margin-top: 12px; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--ink-soft); }
.tiny { font-size: 12px; }
.section-title { font-family: var(--font-display); font-weight: 600; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); margin: 18px 4px 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center; border: 0; border-radius: 14px; padding: 10px 16px; font-weight: 800; background: var(--accent-soft); color: var(--accent-deep); transition: transform .08s ease, filter .15s; }
:root[data-mode="dark"] .btn { color: var(--ink); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: linear-gradient(180deg, var(--btn-1), var(--btn-2)); color: #fff !important; box-shadow: 0 6px 14px -8px var(--accent-deep); }
.btn-danger { background: transparent; color: var(--danger) !important; border: 1.5px solid var(--danger); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 12px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--mist); display: inline-flex; align-items: center; justify-content: center; color: var(--ink-soft); flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.fab { position: fixed; z-index: 25; right: max(16px, calc(50% - 244px)); bottom: calc(86px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border-radius: 50%; border: 0; background: linear-gradient(180deg, var(--btn-1), var(--btn-2)); color: #fff; box-shadow: 0 10px 22px -8px var(--accent-deep); display: flex; align-items: center; justify-content: center; }
.fab svg { width: 26px; height: 26px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--mist); color: var(--ink-soft); border: 1.5px solid transparent; white-space: nowrap; }
button.chip { cursor: pointer; }
.chip.is-on { background: var(--accent-soft); color: var(--accent-deep); border-color: var(--accent); }
:root[data-mode="dark"] .chip.is-on { color: var(--ink); }
.chip-warn { background: #fff0d6; color: #a8651b; }
.chip-bad { background: #ffe0e6; color: #b3304e; }
.chip-ok { background: #d9f3e8; color: #23805f; }
:root[data-mode="dark"] .chip-warn { background: #4a3818; color: #f3c277; }
:root[data-mode="dark"] .chip-bad { background: #4d2230; color: #ff9db1; }
:root[data-mode="dark"] .chip-ok { background: #1d4034; color: #8ee0bf; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.seg { display: flex; padding: 3px; gap: 3px; border-radius: 14px; background: var(--mist); }
.seg button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 11px; font-weight: 800; font-size: 13px; color: var(--ink-soft); }
.seg button.is-on { background: var(--surface); color: var(--accent-deep); box-shadow: 0 2px 8px -4px rgba(60, 40, 100, .4); }
:root[data-mode="dark"] .seg button.is-on { color: var(--ink); }

.field { display: block; margin-top: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 800; color: var(--ink-soft); margin: 0 2px 4px; }
.input { width: 100%; padding: 10px 12px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--surface); outline: none; min-height: 42px; }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 70px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
input[type="date"], input[type="time"] { min-width: 0; -webkit-appearance: none; appearance: none; }

.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--ink-faint); transition: background .15s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 2px 4px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }

.empty { text-align: center; padding: 26px 16px; color: var(--ink-soft); }
.empty .big { font-size: 38px; margin-bottom: 6px; }
.progress { height: 8px; border-radius: 999px; background: var(--mist); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--btn-1), var(--btn-2)); border-radius: 999px; transition: width .3s ease; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }

/* ---- Voci spuntabili (Oggi, medicine, skincare) ---- */
.check-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.check-row:last-child { border-bottom: 0; }
.check { width: 30px; height: 30px; border-radius: 50%; border: 2.5px solid var(--ink-faint); background: transparent; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; padding: 0; }
.check svg { width: 18px; height: 18px; opacity: 0; transform: scale(.5); transition: all .15s; }
.check.is-done { background: var(--ok); border-color: var(--ok); }
.check.is-done svg { opacity: 1; transform: none; }
.check-row.is-done .label { text-decoration: line-through; color: var(--ink-soft); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.time-tag { font-family: var(--font-display); font-weight: 600; font-size: 13px; color: var(--ink-soft); min-width: 46px; }

.hero { border-radius: 22px; padding: 16px; color: #fff; background: linear-gradient(135deg, var(--btn-1), var(--btn-2)); box-shadow: 0 14px 28px -16px var(--accent-deep); }
.hero h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.hero p { margin: 2px 0 0; opacity: .92; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--mist); border-radius: 16px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-family: var(--font-display); font-size: 20px; }
.stat span { font-size: 11px; color: var(--ink-soft); font-weight: 700; }

/* ---- Calendario ---- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 800; color: var(--ink-soft); padding: 2px 0; }
.cal-day { position: relative; aspect-ratio: 1; border: 0; border-radius: 12px; background: transparent; font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; padding: 0; }
.cal-day.is-out { opacity: .3; }
.cal-day.is-today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-day.is-sel { background: var(--accent-soft); }
/* stessi colori per i giorni del calendario e per i quadratini della legenda (.sw): così la legenda è uguale ai giorni */
.cal-day.t-period, .legend .sw.t-period { background: #ffc9d4; color: #9c2c47; }
.cal-day.t-pred, .legend .sw.t-pred { background: repeating-linear-gradient(45deg, #ffe3e9, #ffe3e9 4px, #fff 4px, #fff 8px); color: #b3304e; }
.cal-day.t-fertile, .legend .sw.t-fertile { background: #d8ecff; color: #2c63a8; }
.cal-day.t-ovu, .legend .sw.t-ovu { background: #4f8fd9; color: #fff; }
:root[data-mode="dark"] .cal-day.t-period, :root[data-mode="dark"] .legend .sw.t-period { background: #6b2a3d; color: #ffd0da; }
:root[data-mode="dark"] .cal-day.t-pred, :root[data-mode="dark"] .legend .sw.t-pred { background: repeating-linear-gradient(45deg, #4a2634, #4a2634 4px, #2a1d28 4px, #2a1d28 8px); color: #ffb3c3; }
:root[data-mode="dark"] .cal-day.t-fertile, :root[data-mode="dark"] .legend .sw.t-fertile { background: #223a5c; color: #b5d6ff; }
.cal-day .mark { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--accent-deep); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: var(--ink-soft); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; flex: none; }
.legend .sw { width: 18px; height: 18px; border-radius: 6px; }
.legend .pill-sw { width: 18px; height: 18px; aspect-ratio: auto; font-size: 0; }

/* ---- Grafici (components/ui/LineChart.jsx) ----
   Colori verificati con il validatore dataviz (2026-11-24): blu/arancione per massima/minima superano contrasto 3:1,
   separazione per daltonismo (ΔE ≥ 24) e visione normale, in chiaro (#ffffff) e in scuro (#221c2e).
   Serie unica: in chiaro --accent-deep (≥ 3,5:1 con tutti i temi; --accent da solo scende a 2,2:1), in scuro --accent (≥ 5,2:1). */
:root { --chart-1: var(--accent-deep); --chart-sys: #2a78d6; --chart-dia: #eb6834; }
:root[data-mode="dark"] { --chart-1: var(--accent); --chart-sys: #3987e5; --chart-dia: #d95926; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--ink-soft); font-size: 10px; font-weight: 700; font-family: var(--font-body); }
.chart-dot { stroke: var(--surface); stroke-width: 2; }
.chart-cross { stroke: var(--ink-faint); stroke-width: 1; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-soft); font-weight: 700; margin: 0 0 4px 40px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i, .chart-key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.chart-tip { position: absolute; padding: 6px 9px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .45); pointer-events: none; font-size: 13px; }

/* ---- Misure: schede dei tipi ---- */
.measure-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.measure-tile { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 18px; padding: 12px; box-shadow: 0 4px 18px -12px rgba(80, 60, 120, .3); color: var(--ink); }
.measure-tile .big { font-family: var(--font-display); font-weight: 600; font-size: 24px; line-height: 1.1; margin-top: 6px; }
.measure-tile .big small { font-size: 12px; color: var(--ink-soft); font-family: var(--font-body); font-weight: 700; margin-left: 4px; }

/* ---- Altro: tutte le sezioni ---- */
.hub-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.hub-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 6px 12px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 800; font-size: 13px; box-shadow: 0 4px 18px -12px rgba(80, 60, 120, .3); }
.hub-tile svg { width: 28px; height: 28px; color: var(--accent-deep); }
:root[data-mode="dark"] .hub-tile svg { color: var(--accent); }
.hub-pin { position: absolute; top: 6px; left: 6px; font-style: normal; font-size: 9px; font-weight: 800; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-deep); }
:root[data-mode="dark"] .hub-pin { color: var(--ink); }
.hub-badge { position: absolute; top: 6px; right: 8px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; }

/* ---- Impostazioni: anteprima della barra in basso ---- */
.bar-preview { display: flex; gap: 4px; padding: 8px 4px; border-radius: 16px; background: var(--mist); margin-bottom: 6px; }
.bar-preview span { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--ink-soft); }
.bar-preview svg { width: 20px; height: 20px; }
.bar-preview small { font-size: 10px; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-preview .is-chosen { color: var(--accent-deep); }
:root[data-mode="dark"] .bar-preview .is-chosen { color: var(--accent); }
.bar-preview .is-empty { justify-content: center; border: 1.5px dashed var(--ink-faint); border-radius: 10px; min-height: 38px; }

/* ---- Ciclo: riepilogo «per il medico» ---- */
.doc-rows { margin-top: 8px; }
.doc-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0 2px; border-top: 1px solid var(--line); }
.doc-row:first-child { border-top: 0; }
.doc-row b { font-family: var(--font-display); font-weight: 600; font-size: 17px; text-align: right; }
.doc-sub { text-align: right; padding-bottom: 4px; }

/* ---- Confezione della pillola (blister 4 × 7) ---- */
.pill-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.pill-cell { aspect-ratio: 1; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; background: #f3b6c9; color: #7a2848; }
.pill-cell.is-placebo { background: #e7e1ee; color: #6f6680; }
.pill-cell.is-break { background: transparent; color: var(--ink-faint); outline: 1.5px dashed var(--ink-faint); outline-offset: -2px; }
.pill-cell.is-taken { background: var(--ok); color: #fff; }
.pill-cell.is-missed { outline: 2.5px solid var(--warn); outline-offset: -2px; }
.pill-cell.is-today { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }
:root[data-mode="dark"] .pill-cell { background: #6b2f4a; color: #ffd3e2; }
:root[data-mode="dark"] .pill-cell.is-placebo { background: #3b3448; color: #c9c0d8; }
:root[data-mode="dark"] .pill-cell.is-break { background: transparent; }
:root[data-mode="dark"] .pill-cell.is-taken { background: var(--ok); color: #fff; }

/* ---- Allenamento guidato (WorkoutRunner): schermo intero ---- */
.runner { position: fixed; inset: 0; z-index: 150; background: var(--cream); display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; animation: fade .2s ease both; }
.runner-head { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; }
.runner-body { flex: 1; overflow-y: auto; padding: 16px; }
.runner-title { font-family: var(--font-display); font-weight: 600; font-size: 26px; line-height: 1.15; margin-top: 2px; }
.runner-center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.runner-done { margin-top: 16px; padding: 16px; font-size: 18px; border-radius: 18px; }
.runner-foot { display: flex; justify-content: space-between; gap: 4px; padding: 6px 10px; border-top: 1px solid var(--line); }
.runner-foot .btn { padding: 8px 10px; font-size: 13px; }
.runner-list { display: flex; gap: 6px; overflow-x: auto; padding: 6px 16px calc(12px + env(safe-area-inset-bottom)); }
.timer-ring { --pct: 100; width: 220px; height: 220px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--mist) 0); position: relative; margin: 8px 0; }
.timer-ring::before { content: ''; position: absolute; inset: 14px; border-radius: 50%; background: var(--cream); }
.timer-ring span { position: relative; font-family: var(--font-display); font-weight: 600; font-size: 56px; font-variant-numeric: tabular-nums; }
.timer-ring.is-work { background: conic-gradient(var(--ok) calc(var(--pct) * 1%), var(--mist) 0); width: 180px; height: 180px; }
.timer-ring.is-work span { font-size: 44px; }

/* ---- Giorni del mese selezionabili (farmaci «giorni del mese») ---- */
.month-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.month-days button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 0; font-weight: 800; font-size: 13px; color: var(--ink-soft); }
.month-days button.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Diario: faccine dell'umore e della qualità del sonno */
.faces { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.faces.three { grid-template-columns: repeat(3, 1fr); }
.faces button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 8px 2px 6px; font-size: 24px; line-height: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--ink-soft); min-width: 0; }
.faces button span { font-size: 10.5px; font-weight: 800; line-height: 1.15; }
.faces button.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.stat-grid.two { grid-template-columns: repeat(2, 1fr); }

/* Statistiche: barre orizzontali (components/ui/BarList.jsx) */
.bar-row { padding: 9px 0; border-bottom: 1px solid var(--line); }
.bar-row:last-child { border-bottom: 0; }
.bar-track { height: 8px; border-radius: 4px; background: var(--mist); overflow: hidden; margin-top: 5px; }
.bar-track i { display: block; height: 100%; border-radius: 4px; background: var(--chart-1); }
.big-pct { font-family: var(--font-display); font-size: 34px; line-height: 1; }

/* Riepilogo per il medico: un foglio bianco (anche in modo scuro), in stampa si vede solo lui */
.report { margin-top: 14px; background: #fff; color: #1f1a2b; border: 1px solid var(--line); border-radius: 14px; padding: 18px 16px; font-size: 13.5px; line-height: 1.45; }
.report h2 { font-family: var(--font-display); font-size: 21px; font-weight: 600; margin: 0 0 2px; color: #1f1a2b; }
.report h3 { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px; color: #1f1a2b; border-bottom: 1.5px solid #d9d2e4; padding-bottom: 3px; }
.report p { margin: 4px 0; }
.report-head { margin-bottom: 14px; }
.report-sec { margin-top: 14px; break-inside: avoid; }
.report-muted { color: #5d5470; font-size: 12px; }
.report-table { width: 100%; border-collapse: collapse; }
.report-table th { text-align: left; font-size: 11.5px; color: #5d5470; font-weight: 800; padding: 4px 6px 4px 0; border-bottom: 1px solid #d9d2e4; }
.report-table td { vertical-align: top; padding: 6px 6px 6px 0; border-bottom: 1px solid #ece7f3; }
.report-dl { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 4px 10px; margin: 0; }
.report-dl dt { color: #5d5470; font-weight: 700; }
.report-dl dd { margin: 0; font-weight: 700; }
.report-foot { margin-top: 18px; padding-top: 8px; border-top: 1px solid #d9d2e4; }

@media print {
  @page { margin: 14mm; }
  html, body, .app-shell, .app-main { background: #fff !important; box-shadow: none !important; }
  .app-shell { max-width: none; }
  .app-main { padding: 0 !important; }
  .app-header, .bottom-nav, .fab, .toast-host, .no-print { display: none !important; }
  .screen-enter { animation: none !important; transform: none !important; }
  .report { border: 0; border-radius: 0; padding: 0; margin: 0; font-size: 11.5pt; }
}

/* Persone e animali: etichetta «per chi è» accanto al nome */
.who-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); font-size: 11.5px; font-weight: 800; vertical-align: 1px; white-space: nowrap; }

/* ---- Settimana (giorni della settimana selezionabili) ---- */
.days { display: flex; gap: 5px; }
.days button { flex: 1; border: 1.5px solid var(--line); background: var(--surface); border-radius: 11px; padding: 8px 0; font-weight: 800; font-size: 12px; color: var(--ink-soft); }
.days button.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- Cassetto inferiore ---- */
.sheet-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(30, 20, 50, .45); animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-panel { position: relative; width: 100%; max-width: 520px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; background: var(--cream); border-radius: 26px 26px 0 0; animation: rise .25s ease both; display: flex; flex-direction: column; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { position: sticky; top: 0; z-index: 2; background: var(--cream); padding: 6px 16px 8px; }
.sheet-drag { touch-action: none; padding-top: 4px; }
.sheet-grip { display: block; width: 44px; height: 5px; border-radius: 999px; background: var(--ink-faint); margin: 2px auto 10px; }
.sheet-body { padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet-actions { display: flex; gap: 8px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }

/* ---- Avvisi ---- */
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; max-width: min(92vw, 440px); padding: 10px 16px; border-radius: 16px; background: var(--ink); color: var(--cream); font-weight: 700; font-size: 14px; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .5); animation: enter .2s ease both; border: 0; }
.toast.is-error { background: var(--danger); color: #fff; }
.toast.is-soft { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.toast.is-tap { cursor: pointer; }

@media (min-width: 560px) { .app-shell { margin-top: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---- account e cassaforte (2026-11-25) ---- */
.save-reminder { margin-top: 12px; border: 2px solid var(--accent); background: var(--mist); }
.stack-sm { display: grid; gap: 8px; }
.recovery-key { display: block; margin: 10px 0 4px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px dashed var(--accent);
  font-size: 15px; font-weight: 800; letter-spacing: .04em; line-height: 1.6; word-break: break-all; user-select: all; }
.welcome-screen { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px 16px;
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2)); overflow-y: auto; }
.welcome-box { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 22px 18px;
  text-align: center; box-shadow: 0 18px 40px -24px rgba(80, 60, 120, .5); }
.welcome-box h1 { font-size: 24px; margin: 6px 0 4px; }
.welcome-box .field, .welcome-box label { text-align: left; }
