/* =====================================================================
   WikiCV · componenti di base condivisi (sito pubblico e app)
   Richiede assets/tokens.css caricato PRIMA.
   I nomi delle classi sono quelli di app/styles.css (BEM leggero:
   .blocco, .blocco__parte, .blocco--variante, stato con .on / .open o
   con l'attributo ARIA corrispondente).
   Ordine: 0 base · 1 tipografia · 2 pulsanti · 3 campi · 4 card ·
           5 pill, punteggi, badge · 6 chip, segmenti, schede ·
           7 accordion · 8 barra, avatar, kbd, skeleton · 9 modale ·
           10 toast · 11 layout · 12 telefono · 13 movimento ridotto
   Regole d'uso: docs/mvp-v2/design-system.md · Vetrina: docs/ds/
   ===================================================================== */

/* ---------- 0. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink-2); font: var(--type-body); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
img, svg { max-width: 100%; }
svg { flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-t2); color: var(--ink); }
:focus-visible { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); }
[hidden] { display: none !important; }

/* Solo per lettori di schermo */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Vai al contenuto: invisibile finché non arriva il focus da tastiera */
.skip { position: fixed; top: 8px; left: 8px; z-index: var(--z-skip); display: inline-flex; align-items: center; height: var(--ctl-h); padding: 0 16px; border-radius: var(--r-ctl); background: var(--ink); color: var(--on-ink); font: var(--type-ui); text-decoration: none; transform: translateY(calc(-100% - 16px)); transition: transform var(--dur-2) var(--ease-out); }
.skip:focus, .skip:focus-visible { transform: none; outline: var(--focus-width) solid var(--accent-on-dark); outline-offset: 2px; }

/* ---------- 1. Tipografia: tre livelli sempre visibili ---------- */
.h1 { font: var(--type-h1); letter-spacing: var(--tracking-serif); color: var(--ink); text-wrap: balance; }
.h2 { font: var(--type-h2); letter-spacing: -0.01em; color: var(--ink); }
.h3 { font: var(--type-h3); color: var(--ink); }
.num-xl { font: var(--type-num-xl); letter-spacing: -0.02em; font-variant-numeric: lining-nums tabular-nums; color: var(--ink); }
.txt { font: var(--type-body); color: var(--ink-2); }
.strong { font: var(--type-strong); color: var(--ink); }
.label { font: var(--type-label); color: var(--ink-3); }
.caps { font: var(--type-label); color: var(--ink-3); }
.meta { font: var(--type-meta); color: var(--ink-3); }
.serif { font: var(--type-serif); color: var(--ink); }
.desc { font: var(--type-desc); color: var(--ink-2); max-width: var(--measure); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.overline { font: var(--type-caps); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--ink-3); }

/* Scala marketing (sito pubblico) */
.display { font: var(--type-display); letter-spacing: var(--tracking-display); color: var(--ink); text-wrap: balance; }
.mk-h1 { font: var(--type-mk-h1); letter-spacing: var(--tracking-display); color: var(--ink); text-wrap: balance; }
.mk-h2 { font: var(--type-mk-h2); letter-spacing: var(--tracking-serif); color: var(--ink); text-wrap: balance; }
.mk-h3 { font: var(--type-mk-h3); color: var(--ink); }
.lead { font: var(--type-lead); color: var(--ink-2); max-width: 52ch; }
.display em, .mk-h1 em, .mk-h2 em { font-style: italic; font-weight: 400; }

/* Testo su fondi tenui: --ink-3 non arriva a 4.5:1, si scurisce un poco */
.zone .meta, .zone .label, .zone .muted, .zone .caps,
.on-tint .meta, .on-tint .label, .on-tint .muted, .on-tint .caps { color: var(--ink-3-on-tint); }

/* Link: d'azione (da soli) e nel testo (sempre sottolineati: il colore da solo non basta) */
.link { color: var(--accent); font-weight: 600; text-decoration: none; border-radius: 2px; cursor: pointer; }
.link:hover { color: var(--accent-h); text-decoration: underline; text-underline-offset: 3px; }
.link--inline { font-weight: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.link--inline:hover { text-decoration-thickness: 2px; }

/* ---------- 2. Pulsanti ---------- */
.btn { --btn-h: var(--ctl-h); position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--btn-h); min-width: var(--btn-h); padding: 0 16px; border-radius: var(--r-ctl); border: 1px solid transparent; background: transparent; font: var(--type-ui); text-decoration: none; white-space: nowrap; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; transition: background-color var(--dur-1) var(--ease-std), border-color var(--dur-1) var(--ease-std), color var(--dur-1) var(--ease-std), transform var(--dur-1) var(--ease-std); }
.btn:focus-visible { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); }
.btn:active:not(:disabled):not([aria-disabled="true"]):not([aria-busy="true"]) { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }

/* Primario: Cobalto pieno. Uno solo per fase. */
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-h); }
.btn--primary:active { background: var(--accent-h); box-shadow: inset 0 1px 2px rgba(0,0,0,.18); }

/* Secondario: bianco con bordo */
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn--secondary:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn--secondary:active { background: var(--surface-3); }

/* Terziario: solo testo */
.btn--tertiary { --btn-h: var(--ctl-h-sm); min-width: 0; padding: 0 4px; color: var(--ink-2); }
.btn--tertiary:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.btn--danger { color: var(--lo); }
.btn--danger:hover { color: var(--lo); }

/* Misure */
.btn--sm { --btn-h: var(--ctl-h-sm); padding: 0 12px; }
.btn--lg { --btn-h: var(--ctl-h-lg); padding: 0 24px; font-size: 15px; }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: var(--btn-h); }

/* Disabilitato: si vede che non si può usare, senza sparire */
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; }
.btn--primary:disabled, .btn--primary[aria-disabled="true"] { background: var(--surface-3); color: var(--ink-3-on-tint); }
.btn--secondary:disabled, .btn--secondary[aria-disabled="true"] { background: var(--surface); border-color: var(--line); color: var(--ink-3); }
.btn--tertiary:disabled, .btn--tertiary[aria-disabled="true"] { color: var(--ink-3); text-decoration: none; }

/* In corso: aria-busy="true" + testo che dice cosa succede ("Salvo…") */
.btn[aria-busy="true"] { cursor: progress; pointer-events: none; }
.btn[aria-busy="true"]::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: ds-spin .7s linear infinite; flex: none; }
.btn[aria-busy="true"] > svg:first-child { display: none; }

/* Pulsante icona (azioni di riga): bersaglio 32px, sempre con aria-label */
.icon-btn { width: var(--icon-btn); height: var(--icon-btn); border-radius: var(--r-sm); display: inline-grid; place-items: center; color: var(--ink-3); background: transparent; border: 0; padding: 0; cursor: pointer; transition: background-color var(--dur-1), color var(--dur-1); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn[aria-pressed="true"] { background: var(--accent-t); color: var(--accent-h); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; background: none; }

/* ---------- 3. Campi ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label, .field__label { display: flex; align-items: center; gap: 8px; font: var(--type-label); color: var(--ink-2); }
.field__opt { font: var(--type-meta); color: var(--ink-3); }
.field__help { font: var(--type-meta); color: var(--ink-3); }
.field__err { display: flex; align-items: flex-start; gap: 6px; font: var(--type-label); color: var(--lo); }
.field__err svg { width: 14px; height: 14px; margin-top: 1px; }

.input, .select, .textarea { width: 100%; height: var(--ctl-h); padding: 0 12px; border: 1px solid var(--line-3); border-radius: var(--r-ctl); background: var(--surface); color: var(--ink); font: var(--type-input); transition: border-color var(--dur-1), box-shadow var(--dur-1); }
textarea.input, .textarea { height: auto; min-height: 84px; padding: 10px 12px; line-height: 22px; resize: vertical; }
textarea.input.serif, .textarea.serif { font: var(--type-serif); }
select.input, .select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; background: var(--surface) 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='%234A4843' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; }
.input--sm { height: var(--ctl-h-sm); }
/* Campo o menu a pillola (barre degli strumenti, filtri): stesso bordo a 3:1, solo più morbido */
.input--pill { border-radius: var(--r-pill); }
select.input--pill { padding-left: 14px; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-2); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-halo); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; }
/* Errore: bordo rosso + messaggio .field__err collegato con aria-describedby */
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"],
.field--error .input, .field--error .select, .field--error .textarea { border-color: var(--lo); }
.input[aria-invalid="true"]:focus, .select[aria-invalid="true"]:focus, .textarea[aria-invalid="true"]:focus,
.field--error .input:focus, .field--error .select:focus, .field--error .textarea:focus { box-shadow: 0 0 0 3px var(--lo-bg); }
/* Disabilitato e sola lettura */
.input:disabled, .select:disabled, .textarea:disabled { background-color: var(--surface-2); border-color: var(--line); color: var(--ink-3-on-tint); cursor: not-allowed; }
.input[readonly], .textarea[readonly] { background: var(--surface-2); border-color: var(--line); }

/* Ricerca con icona */
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 36px; }

/* Casella di spunta */
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; cursor: pointer; font: 500 14px/20px var(--sans); color: var(--ink); }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.check:has(input:disabled) { color: var(--ink-3); cursor: not-allowed; }

/* Interruttore: <button role="switch" aria-checked> */
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0; border: 0; background: none; cursor: pointer; font: 500 12px/16px var(--sans); color: var(--ink-2); }
.switch__t { position: relative; flex: none; width: 34px; height: 20px; border-radius: var(--r-pill); background: var(--line-3); transition: background-color var(--dur-2); }
.switch__t::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform var(--dur-2) var(--ease-out); }
.switch[aria-checked="true"] .switch__t { background: var(--accent); }
.switch[aria-checked="true"] .switch__t::after { transform: translateX(14px); }
.switch:disabled { cursor: not-allowed; color: var(--ink-3); }
.switch:disabled .switch__t { background: var(--line-2); }

/* ---------- 4. Card e zone ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); padding: var(--pad-card); min-width: 0; }
.card--flush { padding: 0; overflow: hidden; }
.card--link { display: block; color: inherit; text-decoration: none; cursor: pointer; transition: border-color var(--dur-1), box-shadow var(--dur-1); }
.card--link:hover { border-color: var(--ink-3); }
.card--sel, .card[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.card-h > div { display: grid; gap: 4px; min-width: 0; flex: 1 1 240px; }
.card-sec { padding-top: 20px; margin-top: 20px; border-top: 1px solid var(--line); }
.zone { background: var(--surface-2); border: 0; border-radius: var(--r-zone); padding: 16px; }
.cards { display: grid; gap: var(--gap-cards); }

/* ---------- 5. Pill, punteggi, badge ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-pill); border: 1px solid transparent; background: var(--surface-3); color: var(--st-neutral-fg); font: var(--type-label); white-space: nowrap; }
.pill--neutral { background: var(--surface); border-color: var(--line); color: var(--ink-2); font-weight: 500; }
.pill--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
/* Stati della candidatura (nomi delle classi uguali a app.js) */
.s-da_analizzare, .s-non_selezionata, .s-ritirata { background: var(--st-neutral-bg); color: var(--st-neutral-fg); }
.s-analizzata, .s-cv_pronto, .s-inviata { background: var(--st-blue-bg); color: var(--st-blue-fg); }
.s-colloquio { background: var(--st-violet-bg); color: var(--st-violet-fg); }
.s-offerta { background: var(--st-green-bg); color: var(--st-green-fg); }
.s-importing { background: var(--surface-2); color: var(--ink-3-on-tint); }
/* Pill che è anche un menu (stato modificabile) */
select.pill { appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23161615' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }

/* Badge di punteggio: numero + (fuori o dentro) l'etichetta testuale, mai solo colore */
.score { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: var(--r-pill); font: 700 12px/16px var(--sans); font-variant-numeric: tabular-nums; background: var(--surface-3); color: var(--ink-2); }
.sc-hi { background: var(--hi-bg); color: var(--hi); }
.sc-mid { background: var(--mid-bg); color: var(--mid); }
.sc-lo { background: var(--lo-bg); color: var(--lo); }
.t-hi { color: var(--hi); } .t-mid { color: var(--mid); } .t-lo { color: var(--lo); }

/* Badge: etichette piccole e conteggi */
.badge { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 20px; min-width: 20px; padding: 0 7px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--ink-2); font: 700 12px/16px var(--sans); font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge--accent { background: var(--accent-t); color: var(--accent-h); }
.badge--ink { background: var(--ink); color: var(--on-ink); }
.badge--outline { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); }

/* ---------- 6. Chip, segmenti, schede ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: var(--chip-h); padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 500 14px/20px var(--sans); white-space: nowrap; cursor: pointer; transition: border-color var(--dur-1), background-color var(--dur-1), color var(--dur-1); }
.chip:hover { border-color: var(--ink-3); }
.chip.on, .chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--accent-t); border-color: var(--accent); color: var(--accent-h); font-weight: 600; }
.chip__ck { display: none; width: 14px; height: 14px; }
.chip.on .chip__ck, .chip[aria-pressed="true"] .chip__ck, .chip[aria-checked="true"] .chip__ck { display: block; }
.chip:disabled, .chip[aria-disabled="true"] { cursor: not-allowed; border-color: var(--line); color: var(--ink-3); background: var(--surface); }
.chip--sm { height: 30px; padding: 0 10px; }
.chip--static { cursor: default; background: var(--surface-2); border-color: var(--line); }
.chip--static:hover { border-color: var(--line); }
.chip--add { border-style: dashed; color: var(--ink-2); }
.chip--add:hover { border-color: var(--accent); color: var(--accent-h); background: var(--accent-t); }
.chip .x { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: -8px; border: 0; padding: 0; border-radius: 50%; background: none; color: var(--ink-3); cursor: pointer; }
.chip .x:hover { background: var(--line); color: var(--ink); }
.chip .x svg { width: 14px; height: 14px; }

/* Controllo a segmenti (scelta tra due o tre modi: Link / Testo) */
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; gap: 2px; padding: 3px; background: var(--surface-3); border: 0; border-radius: var(--r-ctl); }
.seg button { height: 30px; padding: 0 12px; border: 0; border-radius: var(--r-sm); background: none; font: var(--type-ui); color: var(--ink-3-on-tint); cursor: pointer; transition: color var(--dur-1), background-color var(--dur-1); }
.seg button:hover { color: var(--ink); }
.seg button.on, .seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-raised); }
.seg button em { font-style: normal; margin-left: 6px; color: var(--ink-3-on-tint); font-variant-numeric: tabular-nums; font-weight: 500; }

/* Filtri a pillola morbida (alla Tandem): grigio chiarissimo senza bordo,
   quello attivo in Cobalto tenue. <div role="group"> di <button aria-pressed> */
.fpills { display: flex; flex-wrap: wrap; gap: 6px; }
.fpill { display: inline-flex; align-items: center; gap: 6px; height: var(--chip-h); padding: 0 14px; border: 0; border-radius: var(--r-pill); background: var(--surface-3); color: var(--ink-2); font: var(--type-ui); font-weight: 500; white-space: nowrap; cursor: pointer; transition: background-color var(--dur-1), color var(--dur-1); }
.fpill:hover { background: var(--line); color: var(--ink); }
.fpill em { font-style: normal; font-weight: 500; color: var(--ink-3-on-tint); font-variant-numeric: tabular-nums; }
.fpill.on, .fpill[aria-pressed="true"] { background: var(--accent-t); color: var(--accent-h); font-weight: 600; }
.fpill.on em, .fpill[aria-pressed="true"] em { color: var(--accent-h); }
/* Al telefono le pillole restano su una riga e scorrono dentro se stesse, mai la pagina.
   Una sfumatura sul bordo dice che ce ne sono altre: compare solo se c'è davvero da scorrere
   (timeline di scorrimento; dove non è supportata le pillole scorrono senza sfumatura). */
@property --fp-l { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --fp-r { syntax: "<length>"; inherits: false; initial-value: 0px; }
@keyframes fpills-fade { 0% { --fp-l: 0px; --fp-r: 28px; } 12% { --fp-l: 28px; } 88% { --fp-r: 28px; } 100% { --fp-l: 28px; --fp-r: 0px; } }
@media (max-width: 640px) {
  .fpills { flex-wrap: nowrap; min-width: 0; max-width: calc(100% + 8px); overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding: 4px; margin: -4px; }
  .fpills::-webkit-scrollbar { display: none; }
  @supports (animation-timeline: scroll(self inline)) {
    .fpills { -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--fp-l), #000 calc(100% - var(--fp-r)), transparent); mask-image: linear-gradient(90deg, transparent, #000 var(--fp-l), #000 calc(100% - var(--fp-r)), transparent); animation: fpills-fade linear both; animation-timeline: scroll(self inline); }
  }
}

/* Puntino "nuovo": l'unico accento in una riga, sempre con testo per i lettori di schermo */
.newdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }

/* Schede: role="tablist" > .tab[role="tab"][aria-selected] */
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 8px; height: var(--tab-h); padding: 0; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; font: var(--type-ui); color: var(--ink-3); text-decoration: none; white-space: nowrap; cursor: pointer; transition: color var(--dur-1), border-color var(--dur-1); }
.tab:hover { color: var(--ink); }
.tab.on, .tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab:focus-visible { outline-offset: -2px; border-radius: var(--r-xs); }

/* ---------- 7. Accordion (.acc): <details> nativo oppure bottone con aria-expanded ---------- */
.acc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); overflow: hidden; }
.acc + .acc { margin-top: 12px; }
.acc__h { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 56px; padding: 16px 20px; border: 0; background: none; text-align: left; cursor: pointer; list-style: none; transition: background-color var(--dur-1); }
.acc__h::-webkit-details-marker { display: none; }
.acc__h:hover { background: var(--surface-hover); }
.acc__h:focus-visible { outline-offset: -2px; border-radius: var(--r-card); }
.acc__t { display: grid; gap: 2px; flex: 1; min-width: 0; }
.acc__chev { width: 20px; height: 20px; color: var(--ink-3); transition: transform var(--dur-2) var(--ease-out); }
.acc.open .acc__chev, .acc[open] .acc__chev, .acc__h[aria-expanded="true"] .acc__chev { transform: rotate(180deg); }
.acc__b { background: transparent; border-top: 1px solid var(--line); padding: 16px 20px; }

/* ---------- 8. Barra, avatar, tasti, skeleton, messaggi ---------- */
/* Barra di avanzamento: role="progressbar" con aria-valuenow, e il numero scritto accanto */
.bar { height: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width var(--dur-4) var(--ease-out); }
.bar--thin { height: 4px; border: 0; background: var(--line); }
.bar--ink > i { background: var(--ink); }
.bar.b-hi > i { background: var(--hi); } .bar.b-mid > i { background: var(--mid-bar); } .bar.b-lo > i { background: var(--lo); }

.avatar { width: 32px; height: 32px; border-radius: var(--r-pill); background: var(--accent-t); color: var(--accent-h); display: grid; place-items: center; font: 700 12px/1 var(--sans); overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 24px; height: 24px; }
.avatar--lg { width: 72px; height: 72px; font-size: 20px; }
.avatar--empty { background: var(--surface-2); color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line-2); }

.kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: var(--r-xs); background: var(--surface); color: var(--ink-2); font: 600 12px/16px var(--sans); white-space: nowrap; }

.sk { display: block; height: 12px; border-radius: var(--r-xs); background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: ds-shimmer 1.3s ease infinite; }

/* Messaggio in linea (errore di modulo, avviso breve) */
.msg { display: flex; gap: 8px; align-items: center; font: var(--type-strong); color: var(--lo); }
.msg--ok { color: var(--hi); }

/* ---------- 9. Modale: role="dialog" aria-modal="true" aria-labelledby ---------- */
.modal-bg { position: fixed; inset: 0; z-index: var(--z-modal); background: var(--overlay); display: grid; place-items: center; padding: 16px; animation: ds-fade var(--dur-2) var(--ease-std); }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: var(--r-modal); box-shadow: var(--shadow-over); padding: 24px; display: grid; gap: 20px; animation: ds-pop var(--dur-2) var(--ease-out); }
.modal--sm { width: min(420px, 100%); }
.modal__h { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.modal__h > div { display: grid; gap: 4px; min-width: 0; }
.modal__x { margin: -4px -8px 0 0; }
.modal__f { display: flex; justify-content: flex-end; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 4px; }

/* ---------- 10. Toast: contenitore con role="status" aria-live="polite" ---------- */
.toasts, #toasts { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: var(--z-toast); display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--ink); color: var(--on-ink); font: var(--type-ui); padding: 12px 16px; border-radius: var(--r-zone); box-shadow: var(--shadow-over); animation: ds-toast var(--dur-3) var(--ease-out); }
.toast svg { width: 16px; height: 16px; }
.toast__a { margin-left: 8px; padding: 0; border: 0; background: none; color: var(--accent-on-dark); font: var(--type-ui); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.toast__a:focus-visible { outline-color: var(--accent-on-dark); }

/* ---------- 11. Layout minimo ---------- */
.stack { display: grid; gap: 16px; align-content: start; }
.stack-sm { display: grid; gap: 8px; align-content: start; }
.stack-lg { display: grid; gap: 24px; align-content: start; }
.stack > *, .stack-sm > *, .stack-lg > * { min-width: 0; }
.stack > .btn, .stack-sm > .btn, .stack-lg > .btn { justify-self: start; }
.stack > .btn--block, .stack-sm > .btn--block, .stack-lg > .btn--block { justify-self: stretch; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--top { align-items: flex-start; }

/* ---------- 12. Telefono: bersagli da 44px e campi a 16px (niente zoom su iPhone) ---------- */
@media (max-width: 640px) {
  .btn:not(.btn--sm):not(.btn--tertiary):not(.btn--icon) { --btn-h: var(--tap); }
  .input:not(.input--sm), .select { height: var(--tap); }
  .input, .select, .textarea { font-size: 16px; }
  .modal { padding: 20px; }
  .modal__f { flex-direction: column-reverse; align-items: stretch; }
  .modal__f .btn { width: 100%; }
  .toasts, #toasts { bottom: 24px; }
}

/* ---------- Animazioni ---------- */
@keyframes ds-spin { to { transform: rotate(360deg); } }
@keyframes ds-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes ds-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ds-pop { from { transform: translateY(4px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ds-toast { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 13. Movimento ridotto ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  /* Gli indicatori di attesa restano leggibili: lo spinner diventa un anello fermo, lo skeleton una tinta piatta */
  .btn[aria-busy="true"]::before { border-right-color: currentColor; opacity: .5; }
  .sk { background: var(--surface-3); }
}
