/* Toni caldi e poco contrastati per lunghe sessioni; tema scuro automatico. */
:root {
  --sfondo: #ebe8e1;
  --superficie: #f8f6f1;
  --bordo: #d6d0c4;
  --bordo-commento: #b9ae9b;
  --testo: #2f3134;
  --tenue: #75726b;

  --grigio: #dfdcd5;
  --grigio-hover: #d3cfc6;
  --grigio-testo: #3a3936;

  --arancio: #f1a66b;
  --arancio-hover: #eb9656;
  --arancio-testo: #3a210c;

  --celeste: #cde7ef;
  --celeste-hover: #b9dde8;
  --celeste-testo: #1c4854;

  --salvia: #d9e3d3;
  --salvia-hover: #cad8c2;
  --salvia-testo: #25361f;

  --ok: #4f7a45;
  --attenzione: #a35f1f;
  --ombra: 0 1px 2px rgba(60, 50, 30, .06), 0 6px 20px rgba(60, 50, 30, .06);

  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Noto Sans Hebrew", "Noto Sans Arabic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --sfondo: #1e2023;
    --superficie: #27292d;
    --bordo: #393c41;
    --bordo-commento: #56524a;
    --testo: #e3e0d9;
    --tenue: #9a968e;
    --grigio: #34373b;
    --grigio-hover: #3e4146;
    --grigio-testo: #dcd9d2;
    --arancio: #d98a50;
    --arancio-hover: #e39a63;
    --arancio-testo: #1d1006;
    --celeste: #2c4f5a;
    --celeste-hover: #355e6b;
    --celeste-testo: #d6edf3;
    --salvia: #33412f;
    --salvia-hover: #3c4c37;
    --salvia-testo: #dde8d6;
    --ok: #8fbb84;
    --attenzione: #e0a468;
    --ombra: 0 1px 2px rgba(0, 0, 0, .25), 0 6px 20px rgba(0, 0, 0, .2);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--sfondo);
  color: var(--testo);
  font-family: var(--font);
  font-size: 15px;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd {
  font: 600 .72rem/1 var(--font);
  padding: .18rem .4rem;
  border-radius: 5px;
  border: 1px solid currentColor;
  opacity: .55;
  margin-left: .35rem;
  vertical-align: middle;
}

/* ---------- avvio ---------- */
.avvio {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.zona {
  width: min(680px, 100%);
  padding: 64px 32px;
  text-align: center;
  background: var(--superficie);
  border: 2px dashed var(--bordo-commento);
  border-radius: 22px;
  box-shadow: var(--ombra);
}
.zona h1 { margin: 0 0 18px; font-size: 1.7rem; font-weight: 600; }
.zona .grande { font-size: 1.35rem; margin: 0 0 26px; }
.tasto-avvio {
  border: 0;
  background: var(--grigio);
  color: var(--grigio-testo);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 1.05rem;
}
.tasto-avvio:hover { background: var(--grigio-hover); }
.nota { color: var(--tenue); margin: 22px 0 0; line-height: 1.5; }
.chi-sei { display: block; font-size: 1.2rem; margin-bottom: 22px; }
.chi-sei input {
  font: inherit; color: inherit; width: 12em; margin-left: 10px; padding: 8px 12px;
  border: 1px solid var(--bordo-commento); border-radius: 10px; background: var(--sfondo);
}
.elenco-file { display: grid; gap: 10px; }
.tasto-file { display: grid; gap: 4px; width: 100%; }
.tasto-file span { font-size: .88rem; color: var(--tenue); }
.velo-trascina {
  position: fixed; inset: 12px;
  display: grid; place-items: center;
  border: 3px dashed var(--arancio);
  border-radius: 22px;
  background: color-mix(in srgb, var(--sfondo) 85%, transparent);
  font-size: 1.8rem; font-weight: 600;
  z-index: 50;
  pointer-events: none;
}

/* ---------- lavoro ---------- */
.lavoro {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px 24px 18px;
}

.barra {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}
.barra-file { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.nome-file { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.salvataggio {
  border: 0; background: none; padding: 0;
  color: var(--tenue); font-size: .88rem;
  white-space: nowrap; cursor: default;
}
.salvataggio.ok { color: var(--ok); }
.salvataggio.in-attesa { cursor: pointer; text-decoration: underline dotted; }
.salvataggio.attenzione { color: var(--attenzione); cursor: pointer; text-decoration: underline dotted; }
.barra-riga { display: flex; align-items: center; gap: 10px; font-size: 1rem; white-space: nowrap; }
.badge {
  font-size: .82rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--arancio);
  color: var(--arancio-testo);
}
.badge.skip { background: var(--celeste); color: var(--celeste-testo); }
.barra-comandi { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }

.piccolo {
  border: 1px solid var(--bordo);
  background: var(--superficie);
  padding: 6px 12px;
  border-radius: 9px;
  font-size: .9rem;
}
.piccolo:hover { background: var(--grigio); }
.piccolo.evidenzia { background: var(--arancio); color: var(--arancio-testo); border-color: transparent; }

.interruttore { display: inline-flex; align-items: center; gap: 8px; margin-right: 8px; cursor: pointer; font-size: .92rem; user-select: none; }
.interruttore input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.traccia {
  width: 38px; height: 22px; border-radius: 999px;
  background: var(--grigio-hover);
  position: relative; transition: background .15s;
}
.traccia::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--superficie); transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.interruttore input:checked + .traccia { background: #7fbfd1; }
.interruttore input:checked + .traccia::after { transform: translateX(16px); }
.interruttore input:focus-visible + .traccia { outline: 2px solid var(--arancio); outline-offset: 2px; }

.avanzamento { display: flex; align-items: center; gap: 14px; }
.progresso {
  flex: 1; height: 6px; border-radius: 999px; overflow: hidden;
  background: var(--grigio); display: flex;
}
.prog-fatte { background: #9cb78f; transition: width .25s; }
.prog-skip { background: #8ccadb; transition: width .25s; }

/* ---------- lavoro condiviso: un colore per persona ---------- */
.c-rosso { --chi: #cf4a41; }
.c-blu { --chi: #3f74cf; }
.c-verde { --chi: #3f9160; }
.c-viola { --chi: #8a56c2; }
.c-grigio { --chi: #8a8780; }
.prog-skip.di-chi { background: var(--chi); }
.badge.skip.di-chi { background: var(--chi); color: #fff; }
.chi { white-space: nowrap; }
.chi::before {
  content: ""; display: inline-block; width: .62em; height: .62em; border-radius: 50%;
  background: var(--chi); margin-right: .4em;
}
.chi.assente { opacity: .45; }
.presenti { display: flex; gap: 12px; font-size: .88rem; color: var(--tenue); }
select.piccolo { color: inherit; font: inherit; font-size: .9rem; }
.conteggio { color: var(--tenue); font-size: .88rem; white-space: nowrap; }

/* ---------- 4 box ---------- */
.griglia {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}
.box {
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--superficie);
  border: 1px solid var(--bordo);
  border-radius: 16px;
  box-shadow: var(--ombra);
  padding: 14px 22px 16px;
}
.box-commento { border: 2px solid var(--bordo-commento); }
.box h2 {
  margin: 0 0 8px;
  font-size: .78rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--tenue);
}
.box h2 span { font-weight: 500; }
.testo {
  flex: 1; min-height: 0;
  overflow-y: auto;
  line-height: 1.45;
  font-size: 22px;
  overflow-wrap: anywhere;
}
.testo p { margin: 0 0 .5em; white-space: pre-wrap; }
.testo p:last-child { margin-bottom: 0; }
.testo .etichetta {
  font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--tenue); margin: 0 0 2px;
}
.testo .vuoto { color: var(--tenue); font-style: italic; }

.fine {
  display: grid; place-items: center; text-align: center;
  background: var(--superficie); border: 1px solid var(--bordo); border-radius: 16px;
  padding: 24px; min-height: 0;
}
.fine h2 { font-size: 1.8rem; font-weight: 600; margin: 0 0 12px; }
.fine p { font-size: 1.1rem; color: var(--tenue); margin: 0 0 20px; }
.fine .comandi-fine { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- tasti in basso ---------- */
.azioni {
  display: flex; justify-content: space-between; align-items: stretch; gap: 16px;
}
.azioni-destra { display: flex; gap: 12px; }
.tasto {
  border: 0;
  border-radius: 14px;
  padding: 12px 22px;
  min-height: 80px;
  min-width: 250px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px;
  text-align: left;
  box-shadow: var(--ombra);
  transition: background .12s, transform .06s;
}
.tasto:active { transform: translateY(1px); }
.tasto:disabled { opacity: .45; cursor: default; }
.tasto .tag { font-size: .76rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; opacity: .75; }
.tasto .nome { font-size: 1.3rem; font-weight: 600; }
.tasto .origine { font-size: .82rem; opacity: .7; }

.tasto-attuale { background: var(--salvia); color: var(--salvia-testo); min-width: 340px; max-width: 48%; }
.tasto-attuale:hover { background: var(--salvia-hover); }
.tasto-attuale.incerta .nome { text-decoration: line-through; opacity: .6; }
.tasto-attuale.confermata .tag { opacity: 1; color: var(--ok); }
.tasto-attuale.modificata { background: var(--arancio); color: var(--arancio-testo); }
.tasto-attuale.modificata:hover { background: var(--arancio-hover); }
.tasto-attuale.modificata .tag { opacity: 1; }
.tasto-attuale.modificata .origine { opacity: .85; }
.tasto-elenco { background: var(--grigio); color: var(--grigio-testo); }
.tasto-elenco:hover { background: var(--grigio-hover); }
.tasto-skip { background: var(--celeste); color: var(--celeste-testo); min-width: 190px; }
.tasto-skip:hover { background: var(--celeste-hover); }

/* ---------- elenco label ---------- */
.pannello {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(40, 36, 30, .18);
}
.pannello-carta {
  position: absolute;
  right: 24px; bottom: 118px;
  width: min(540px, calc(100vw - 32px));
  max-height: min(72vh, 700px);
  display: flex; flex-direction: column;
  background: var(--superficie);
  border: 1px solid var(--bordo);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(40, 30, 15, .22);
  overflow: hidden;
}
.cerca { position: relative; padding: 14px; border-bottom: 1px solid var(--bordo); }
.cerca input {
  width: 100%;
  font: 1.15rem var(--font);
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--bordo);
  background: var(--sfondo);
  color: var(--testo);
  outline: none;
}
.cerca input:focus { border-color: var(--arancio); }
.suggerimento {
  position: absolute; right: 30px; top: 50%; transform: translateY(-50%);
  color: var(--tenue); font-size: .9rem; pointer-events: none;
}
.lista { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.lista li { margin: 0 0 5px; }
.voce {
  width: 100%;
  display: flex; align-items: baseline; gap: 12px;
  border: 2px solid transparent;
  background: var(--grigio);
  color: var(--grigio-testo);
  padding: 9px 14px;
  border-radius: 10px;
  text-align: left;
  font-size: 1.08rem;
}
.voce:hover { background: var(--grigio-hover); }
.voce .codice { font-size: .8rem; color: var(--tenue); min-width: 2.4em; }
.voce.cursore { border-color: var(--bordo-commento); }
.voce.scelta { background: var(--arancio); color: var(--arancio-testo); }
.voce.scelta .codice { color: inherit; opacity: .7; }
.voce.scelta:hover { background: var(--arancio-hover); }
.lista .niente { color: var(--tenue); padding: 14px; font-style: italic; }
.pannello-piede {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--bordo);
}
.selezione-testo { flex: 1; min-width: 0; color: var(--tenue); font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selezione-testo.piena { color: var(--testo); font-weight: 600; }
.conferma {
  border: 0; border-radius: 10px; padding: 9px 18px;
  background: var(--arancio); color: var(--arancio-testo); font-weight: 600;
}
.conferma:hover { background: var(--arancio-hover); }
.conferma:disabled { background: var(--grigio); color: var(--tenue); cursor: default; }

/* ---------- avviso ---------- */
.avviso {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 40;
  max-width: min(640px, calc(100vw - 32px));
  background: var(--testo); color: var(--sfondo);
  padding: 12px 20px; border-radius: 12px;
  box-shadow: var(--ombra);
  font-size: 1rem;
}

/* ---------- schermi stretti ---------- */
@media (max-width: 820px) {
  .lavoro { height: auto; min-height: 100dvh; padding: 12px 16px; }
  .barra { grid-template-columns: 1fr; }
  .barra-comandi { justify-content: flex-start; }
  .griglia { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .testo { max-height: 38vh; }
  .azioni, .azioni-destra { flex-direction: column; }
  .tasto, .tasto-attuale { min-width: 0; max-width: none; width: 100%; }
  .pannello-carta { right: 16px; bottom: 16px; }
}
