/* Icone: le emoji le disegna un font incluso nel programma (Noto Color Emoji, licenza OFL,
   fonts/LICENSE-Noto-Emoji.txt), cosi' sono uguali su ogni PC e tablet e Windows mostra anche
   le bandiere dei Paesi. Vale solo per i caratteri emoji (unicode-range): il testo resta nel
   suo font. Un browser che non sa disegnare questo tipo di font usa le emoji di sistema. */
@font-face {
  font-family: "ChatDR Emoji";
  src: url("fonts/Noto-COLRv1.ttf") format("truetype") tech(color-COLRv1);
  font-display: swap;
  unicode-range: U+00A9, U+00AE, U+200D, U+203C, U+2049, U+20E3, U+2122, U+2139, U+2194-21AA, U+231A-23FF,
    U+24C2, U+25AA-25FE, U+2600-27BF, U+2934-2935, U+2B05-2B55, U+3030, U+303D, U+3297, U+3299, U+FE0F,
    U+1F000-1FAFF, U+E0020-E007F;
}

:root {
  --ink: #14242b;
  --muted: #566a73;
  --line: #d3dde1;
  --bg: #eef2f3;
  --panel: #ffffff;
  --primary: #0b6467;
  --primary-strong: #084c4f;
  --primary-soft: #dcefee;
  --staff-soft: #e4edf8;
  --patient-soft: #faf0dc;
  --alert: #bf1f1c;
  --alert-strong: #971613;
  --alert-soft: #fde8e7;
  --warn: #7f5200;
  --warn-soft: #fff2d1;
  --ok: #17754a;
  --ok-soft: #e0f3e9;
  --body: #b9c8ce;
  --radius: 14px;
  --font: "ChatDR Emoji", "Segoe UI", Roboto, "Noto Sans", "Noto Naskh Arabic", "Noto Sans Arabic", "Noto Sans Devanagari", "Noto Sans Gurmukhi", "Noto Sans Ethiopic", "Nirmala UI", "Raavi", "Nyala", "Ebrima", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

h1, h2, p { margin: 0; }

button, input { font: inherit; color: inherit; }

button { cursor: pointer; touch-action: manipulation; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
}

.btn:disabled { opacity: .45; cursor: default; }

.btn.is-on { background: var(--primary-soft); border-color: var(--primary); }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }

.btn-primary:active:not(:disabled) { background: var(--primary-strong); }

.btn-big { min-height: 64px; padding: 12px 28px; font-size: 1.15em; }

.btn-quiet { background: transparent; border-color: transparent; }

.btn-alert { background: var(--alert); border-color: var(--alert); color: #fff; min-height: 52px; padding: 8px 20px; }

.btn-alert:active { background: var(--alert-strong); }

.btn-danger { background: var(--alert); border-color: var(--alert); color: #fff; }

.btn-danger-quiet { color: var(--alert); border-color: var(--alert); background: var(--panel); }

.flag {
  display: inline-block;
  width: 36px;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(20, 36, 43, .18);
  flex: none;
}

.flag svg { display: block; width: 100%; height: 100%; }

.flag--big { width: 120px; height: 80px; border-radius: 8px; }

.brand-mark { font-size: 1.1rem; font-weight: 700; letter-spacing: .01em; color: var(--primary); user-select: none; -webkit-user-select: none; }

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar-gap { flex: 1; }

.topbar-pair { color: var(--muted); font-size: .9rem; }

.offline, .alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  font-weight: 600;
}

.offline { background: var(--warn-soft); color: var(--warn); }

.alert-banner { background: var(--alert); color: #fff; font-size: 1.15rem; }

.alert-banner .btn { color: var(--ink); flex: none; }

/* Scelta della lingua */

.welcome {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px 16px;
}

.welcome .brand-mark { font-size: 1.3rem; }

.welcome-hello {
  min-height: 2.8em;
  display: flex;
  align-items: center;
  font-size: clamp(1.4rem, 3.2vw, 2.1rem);
  font-weight: 600;
  text-align: center;
}

.lang-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  max-width: 1040px;
}

.lang-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 224px;
  min-height: 164px;
  padding: 16px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.lang-tile:active { background: var(--primary-soft); border-color: var(--primary); }

.lang-native { font-size: 1.35rem; font-weight: 600; }

.lang-latin { margin-top: -8px; color: var(--muted); font-size: .95rem; }

.welcome-error, .setup-error { color: var(--alert); font-weight: 600; min-height: 1.4em; }

/* Schede a tutto schermo */

.notice-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.notice-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 660px;
  padding: 32px;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-size: 1.25rem;
}

.notice-card h1 { font-size: 1.6rem; }

.notice-big { font-size: 1.6rem; text-align: center; }

/* Tablet paziente */

.patient-page { font-size: 18px; }

.patient-shell, .staff-shell { height: 100dvh; display: flex; flex-direction: column; }

/* Il tablet e' in verticale: la domanda sta sopra, la conversazione e il microfono sotto. */
.patient-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
}

.patient-layout.has-question { grid-template-rows: minmax(0, 3fr) minmax(0, 2fr); }

.task-panel, .talk-panel, .staff-col {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.task-panel { overflow-y: auto; padding: 20px; display: flex; flex-direction: column; }

.talk-panel { display: flex; flex-direction: column; overflow: hidden; }

.panel-idle { display: flex; flex-direction: column; gap: 10px; }

.panel-hint { font-size: 1.05rem; }

.panel-wait { margin: auto; font-size: 2.5rem; color: var(--muted); }

.quick-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-block-end: 4px;
  scrollbar-width: thin;
}

.quick {
  flex: none;
  max-width: 280px;
  min-height: 56px;
  padding: 8px 14px;
  text-align: start;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 600;
}

.quick:active { background: var(--primary-soft); border-color: var(--primary); }

.question { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }

.question-title { font-size: 1.5rem; line-height: 1.25; }

/* Simbolo dell'argomento accanto alla domanda: aiuta chi legge poco. */
.question-head { display: flex; align-items: center; gap: 14px; }

.question-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--primary-soft);
  font-size: 2.4rem;
  line-height: 1;
}

.question-note {
  padding: 10px 14px;
  background: var(--primary-soft);
  border-radius: 10px;
  font-weight: 600;
}

.question-hint { color: var(--muted); font-size: .95rem; }

.widget-stack { display: flex; flex-direction: column; gap: 14px; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 10px 16px;
  text-align: start;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  font-weight: 600;
}

.choice:active { background: var(--primary-soft); }

.choice.is-on { background: var(--primary-soft); border-color: var(--primary); }

.choice-icon { font-size: 1.7rem; line-height: 1; flex: none; }

/* Tastiera dell'eta' */

.age-widget { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.age-side { display: flex; flex-direction: column; gap: 10px; }

.age-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 12px;
}

.age-value { font-size: 3.2rem; font-weight: 700; line-height: 1.1; }

.age-unit { color: var(--muted); font-size: 1.1rem; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.key {
  min-height: 68px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  font-size: 1.7rem;
  font-weight: 700;
}

.key:active { background: var(--primary-soft); border-color: var(--primary); }

.key--soft { background: var(--bg); color: var(--muted); }

/* Scala del dolore */

.pain-widget { display: flex; flex-direction: column; gap: 10px; }

.pain-row { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 6px; }

.pain-tile {
  /* Dal verde al rosso secondo il valore. */
  --hue: calc(145 - var(--pain) * 14.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 150px;
  padding: 10px 2px;
  border: 2px solid hsl(var(--hue) 55% 38%);
  border-radius: 10px;
  background: hsl(var(--hue) 70% 92%);
}

.pain-tile:active { background: hsl(var(--hue) 70% 80%); }

.pain-face { font-size: 1.8rem; line-height: 1; min-height: 1em; }

.pain-number { font-size: 1.6rem; font-weight: 700; }

.pain-ends { display: flex; justify-content: space-between; color: var(--muted); font-weight: 600; }

/* Mappa del corpo */

.body-widget { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }

.body-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.body-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 200px; }

.bm { display: flex; flex-direction: column; gap: 8px; }

/* Il corpo non si schiaccia: se serve, scorre il riquadro della domanda. */
.question--body .body-widget { flex: none; }

.patient-layout.has-body { grid-template-rows: minmax(0, 5fr) minmax(0, 2fr); }

.bm-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }

.bm-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 4px 6px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-weight: 600;
  line-height: 1.15;
}

.bm-tab.is-on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }

/* Il pallino rosso dice in quale vista ci sono zone gia' scelte. */
.bm-tab.has-mark::after {
  content: "";
  position: absolute;
  top: 5px;
  inset-inline-end: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--alert);
}

.bm-figure { margin: 0; display: flex; flex-direction: column; min-height: 0; align-items: center; flex: 1; }

.bm-caption { font-weight: 700; font-size: .85rem; }

.bm-sides {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 280px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 600;
}

.bm-svg { width: 100%; height: min(62vh, 560px); touch-action: manipulation; }

.bm-svg--head, .bm-svg--belly { height: min(46vh, 400px); }

.bm-shape { fill: var(--body); stroke: var(--panel); stroke-width: 1.4; stroke-linejoin: round; }

.bm-base { fill: var(--body); }

.bm-limb { stroke: var(--body); }

.bm-touch { stroke: transparent; pointer-events: stroke; }

.bm-decor { fill: none; stroke: #6f858d; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }

.bm-region { cursor: pointer; outline: none; }

@media (hover: hover) {
  .bm-region:hover .bm-shape { fill: #a3b6bd; }

  .bm-region:hover .bm-limb { stroke: #a3b6bd; }
}

.bm-region:focus-visible .bm-shape { stroke: var(--primary); stroke-width: 3; }

.bm-region:focus-visible .bm-limb { stroke: var(--primary); }

.bm-region.is-on .bm-shape { fill: var(--alert); }

.bm-region.is-on .bm-limb { stroke: var(--alert); }

.bm--static { flex-direction: row; flex-wrap: wrap; flex: none; gap: 6px; }

.bm--static .bm-figure { flex: 1 1 80px; }

.bm--static .bm-region { cursor: default; }

.bm--static .bm-svg { height: 170px; }

.bm--static .bm-svg--head { height: 110px; }

.bm--static .bm-sides { font-size: .7rem; max-width: 120px; }

/* Conversazione */

.conversation {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overscroll-behavior: contain;
}

.entry {
  max-width: 92%;
  padding: 8px 12px;
  border-radius: 12px;
  flex: none;
}

.entry--theirs { align-self: flex-start; background: var(--staff-soft); }

.entry--mine { align-self: flex-end; background: var(--patient-soft); }

.staff-page .entry--theirs { background: var(--patient-soft); }

.staff-page .entry--mine { background: var(--staff-soft); }

.entry--ask { border-inline-start: 4px solid var(--primary); }

.entry--notable { outline: 2px solid var(--alert); }

.entry--alert {
  align-self: stretch;
  max-width: none;
  background: var(--alert-soft);
  color: var(--alert);
  font-weight: 700;
  text-align: center;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}

.entry-step { color: var(--muted); font-size: .85rem; font-weight: 600; }

.entry-main { display: flex; align-items: flex-start; gap: 6px; }

.entry-text { flex: 1; font-size: 1.08rem; font-weight: 500; overflow-wrap: anywhere; }

.entry-secondary {
  margin-top: 2px;
  color: var(--muted);
  font-size: .88rem;
  overflow-wrap: anywhere;
}

.entry-tag { margin-top: 3px; color: var(--muted); font-size: .72rem; }

.entry-warn {
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: .82rem;
  font-weight: 600;
}

.entry-ack { margin-top: 4px; font-size: .85rem; font-weight: 700; }

.entry-ack--yes { color: var(--ok); }

.entry-ack--no { color: var(--alert); }

.entry-ack-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.speak-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 1.05rem;
  line-height: 1;
}

.chip {
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: .92rem;
  font-weight: 600;
  text-align: start;
}

.chip:active { background: var(--primary-soft); }

.chip--yes { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }

.chip--no { border-color: var(--alert); color: var(--alert); background: var(--alert-soft); }

/* Casella di testo */

.composer { padding: 10px 12px; border-top: 1px solid var(--line); }

.composer-row { display: flex; gap: 8px; }

.composer-input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.composer-input:focus { outline: none; border-color: var(--primary); }

.composer-send { min-width: 84px; }

/* Pulsante da tenere premuto: il tocco non deve selezionare testo ne' aprire menu. */
.talk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex: none;
  min-width: 64px;
  min-height: 52px;
  padding: 8px 16px;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.talk--large { flex: 1; width: 100%; min-height: 96px; border-radius: 48px; font-size: 1.25rem; }

.talk.is-on { background: var(--alert); box-shadow: 0 0 0 6px var(--alert-soft); }

.talk.is-busy { background: var(--muted); }

.talk-icon { display: inline-flex; width: 28px; height: 28px; pointer-events: none; }

.talk--large .talk-icon { width: 44px; height: 44px; }

.talk-icon svg { width: 100%; height: 100%; }

.talk-label { pointer-events: none; }

.composer--large { display: flex; flex-direction: column; gap: 8px; }

.composer-main { display: flex; align-items: center; gap: 8px; }

.composer-keyboard { flex: none; width: 64px; min-height: 64px; font-size: 1.6rem; }

.composer--large .composer-status { margin: 0; text-align: center; font-size: 1rem; }

.activity { min-height: 1.5em; padding-inline: 14px; color: var(--primary); font-size: .92rem; font-weight: 600; }

.staff-speak-lang {
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font: inherit;
  color: inherit;
}

.connect-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; }

.qr { background: #fff; border-radius: 12px; border: 1px solid var(--line); }

.steps { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 260px; }

.mic-test { display: flex; flex-direction: column; gap: 10px; }

.composer-status { min-height: 1.3em; margin-top: 4px; color: var(--muted); font-size: .85rem; }

.composer-status.is-error { color: var(--alert); font-weight: 600; }

/* Tablet operatore */

.staff-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 300px;
  gap: 10px;
  padding: 10px;
}

.staff-col { display: flex; flex-direction: column; overflow-y: auto; padding: 12px; gap: 10px; }

.staff-talk { padding: 0; overflow: hidden; }

.col-title { font-size: 1rem; }

.tabs { display: none; background: var(--panel); border-bottom: 1px solid var(--line); }

.tab { flex: 1; min-height: 46px; border: 0; background: transparent; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; }

.tab.is-on { color: var(--primary); border-bottom-color: var(--primary); }

.peer { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }

.peer::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--alert); }

.peer.is-on::before { background: var(--ok); }

.staff-lang { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }

.btn-next { width: 100%; min-height: 58px; font-size: 1.02rem; text-align: center; }

.procedure-note { color: var(--muted); }

.procedure-note--done { color: var(--ok); font-weight: 600; }

.step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.step { display: flex; align-items: center; gap: 4px; border-radius: 8px; }

.step-ask {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: start;
}

.step-ask:disabled { cursor: default; }

.step-ask:not(:disabled):active { background: var(--primary-soft); }

.step-mark {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--body);
}

.step--answered .step-mark { background: var(--ok); border-color: var(--ok); }

.step--pending { background: var(--primary-soft); }

.step--pending .step-mark { background: var(--primary); border-color: var(--primary); }

.step--skipped .step-mark { border-style: dashed; }

.step--na { opacity: .5; }

.step-text { display: flex; flex-direction: column; min-width: 0; }

.step-label { font-weight: 600; font-size: .95rem; }

.step-icon { margin-inline-end: 6px; }

.step-value { font-size: .84rem; color: var(--ink); overflow-wrap: anywhere; }

.step-value--muted { color: var(--muted); }

.step-skip {
  flex: none;
  min-height: 36px;
  padding: 2px 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .82rem;
  text-decoration: underline;
}

.staff-waiting {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  max-width: 620px;
  margin-inline: auto;
}

.staff-lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }

.staff-lang-btn { justify-content: flex-start; }

.summary-lang { color: var(--muted); }

.summary-list { margin: 0; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 4px 10px; font-size: .92rem; }

.summary-list dt { color: var(--muted); }

.summary-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.summary-list .is-notable { color: var(--alert); font-weight: 700; }

.summary-foot { color: var(--muted); font-size: .78rem; }

.confirm-dialog {
  max-width: 480px;
  border: 0;
  border-radius: var(--radius);
  padding: 24px;
  color: var(--ink);
}

.confirm-dialog::backdrop { background: rgba(20, 36, 43, .55); }

.confirm-dialog h2 { margin-bottom: 8px; }

.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast {
  position: fixed;
  inset-block-end: 20px;
  inset-inline: 0;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin-inline: auto;
  padding: 12px 20px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.toast.is-on { opacity: 1; pointer-events: auto; }

.copy-fallback { width: min(420px, 80vw); height: 160px; color: var(--ink); }

/* Pagine di servizio */

.setup-card { font-size: 1rem; gap: 14px; }

.setup-card label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }

.setup-card input:not([type="radio"]) {
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-weight: 400;
}

.setup-card fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.setup-card legend { font-weight: 600; padding: 0; margin-bottom: 4px; }

.setup-card .radio { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; min-height: 40px; }

.setup-foot { color: var(--muted); font-size: .92rem; }

.setup-foot a { color: var(--primary); }

.diag { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 12px; }

.diag h2 { margin-top: 12px; font-size: 1.1rem; }

.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.check {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.check p { color: var(--muted); font-size: .9rem; }

.check-mark { font-weight: 700; flex: none; width: 1.2em; text-align: center; }

.check--ok .check-mark { color: var(--ok); }

.check--bad .check-mark { color: var(--alert); }

.check--bad { border-color: var(--alert); }

.check-sample { padding: 4px 14px 10px; font-size: 1.05rem; }

.check-sample small { color: var(--muted); }

/* Foto: nella conversazione, a schermo intero e fotocamera */

.entry-photo { display: block; max-width: min(100%, 280px); max-height: 220px; border-radius: 10px; background: var(--bg); object-fit: contain; }

.photo-open { padding: 0; border: 0; background: none; cursor: zoom-in; }

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(10, 20, 24, .92);
  cursor: zoom-out;
}

.photo-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }

.camera-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
  background: #0d1a1f;
  color: #fff;
}

.camera-hint { text-align: center; font-size: 1.05rem; }

.camera-frame { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; border-radius: 12px; overflow: hidden; background: #000; }

.camera-video, .camera-preview { width: 100%; height: 100%; object-fit: contain; }

.camera-status { min-height: 1.4em; text-align: center; color: #ffb4b0; font-weight: 600; }

.camera-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.camera-actions .btn { flex: 1 1 40%; }

.composer-photo { flex: none; width: 64px; min-height: 64px; font-size: 1.6rem; }

.composer--typing .composer-main { justify-content: flex-end; }

/* Collegamento del telefono */

.connect-code { display: flex; flex-direction: column; gap: 4px; min-width: 260px; }

.connect-label { color: var(--muted); }

.connect-address { font-size: 1.5rem; font-weight: 700; overflow-wrap: anywhere; }

.pair-code { font-size: 2.6rem; font-weight: 800; letter-spacing: .08em; color: var(--primary); font-variant-numeric: tabular-nums; }

.pair-code--small { font-size: 1.2rem; letter-spacing: .05em; }

.connect-qr { display: flex; flex-direction: column; gap: 6px; max-width: 260px; }

.pair-box { padding: 10px 14px; border: 1px dashed var(--primary); border-radius: 10px; background: var(--primary-soft); }

.pair-code-input { font-size: 2rem; letter-spacing: .15em; text-align: center; font-variant-numeric: tabular-nums; }

/* Fasi della procedura (finestra dell'operatore) */

.phase-nav { display: flex; flex-wrap: wrap; gap: 4px; }

.phase-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: .84rem;
  font-weight: 600;
  text-align: start;
}

.phase-btn.is-on { border-color: var(--primary); background: var(--primary); color: #fff; }

.phase-sep { width: 100%; margin-top: 4px; color: var(--muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

.phase-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: .74rem;
  font-weight: 700;
  text-align: center;
}

.phase-btn.is-on .phase-count { background: #fff; }

.phase-info { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: 10px; background: var(--staff-soft); font-size: .84rem; }

.phase-who { color: var(--muted); }

.phase-warning { padding: 6px 8px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }

.phase-done { display: flex; flex-direction: column; gap: 8px; }

.step-value.is-notable { color: var(--alert); font-weight: 700; }

.step-group { border-top: 1px solid var(--line); padding-top: 4px; }

.step-group > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px 6px;
  border-radius: 8px;
  font-weight: 700;
  font-size: .92rem;
  cursor: pointer;
}

.step-group > summary:hover { background: var(--bg); }

/* Frasi pronte con ricerca */

.staff-phrases {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

.phrase-head { display: flex; align-items: center; gap: 10px; }

.phrase-title { flex: none; max-width: 40%; color: var(--muted); font-size: .84rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.phrase-search {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.phrase-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 158px; overflow-y: auto; scrollbar-width: thin; }

.phrase-chip, .chip--ask { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; text-align: start; }

.chip-icon { flex: none; }

.chip--ask { border-style: dashed; border-color: var(--primary); color: var(--primary-strong); }

.chip--ask:disabled { opacity: .5; cursor: default; }

.entry-icon { flex: none; font-size: 1.6rem; line-height: 1.2; }

/* Riepilogo diviso come le schede del software PS */

.summary-section { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; border-top: 1px solid var(--line); }

.summary-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.summary-head h3 { margin: 0; font-size: .95rem; }

.summary-where { color: var(--muted); font-size: .76rem; }

.btn-small { min-height: 32px; padding: 2px 10px; font-size: .84rem; }

/* Tavola a immagini del paziente */

.board-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }

.board-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 50px;
  padding: 4px 6px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-weight: 700;
  line-height: 1.15;
}

.board-tab.is-on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }

.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }

.board-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 112px;
  padding: 8px 6px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

.board-tile:active { background: var(--primary-soft); border-color: var(--primary); }

.board-tile.is-sent { border-color: var(--ok); background: var(--ok-soft); }

.board-icon { font-size: 2.6rem; line-height: 1; }

.board-label { font-size: .98rem; overflow-wrap: anywhere; }

/* Risposte scritte, data e Paese */

.choice-grid--yesno { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.choice-grid--yesno .choice { flex-direction: column; justify-content: center; text-align: center; min-height: 96px; font-size: 1.15rem; }

.choice-grid--yesno .choice-icon { font-size: 2.2rem; }

.choice-grid--country { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.choice-grid--country .choice { min-height: 56px; padding: 8px 12px; }

.text-answer {
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font: inherit;
  font-size: 1.3rem;
}

.text-answer:focus { border-color: var(--primary); outline: none; }

.text-answer--long { min-height: 110px; resize: vertical; }

.text-answer--short { max-width: 220px; font-size: 1.6rem; text-align: center; letter-spacing: .04em; }

/* Zone indicate dal paziente dalla tavola: lo schema compare sotto la frase. */
.entry .bm--static { margin-top: 6px; }

.widget-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.widget-row > .btn-primary { flex: 1; min-width: 160px; }

.widget-row > .text-answer { flex: 1; min-width: 180px; }

.date-widget { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 20px; align-items: start; }

.date-widget > .widget-row { grid-column: 1 / -1; }

.date-top { display: flex; flex-direction: column; gap: 6px; }

.date-display {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 12px;
}

.date-part { display: flex; flex-direction: column; align-items: center; }

.date-value { font-size: 2.4rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: .04em; }

.date-caption { color: var(--muted); font-size: .85rem; }

.date-slash { font-size: 2.2rem; color: var(--muted); line-height: 1.1; }

.date-month { min-height: 1.4em; text-align: center; font-weight: 700; color: var(--primary-strong); }

/* Tablet in verticale e schermi stretti */

/* Se il tablet viene ruotato, domanda e conversazione si affiancano. */
@media (min-aspect-ratio: 1/1) and (min-width: 901px) {
  .patient-layout, .patient-layout.has-question {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    grid-template-rows: minmax(0, 1fr);
  }
}

@media (max-aspect-ratio: 1/1), (max-width: 900px) {
  .tabs { display: flex; }

  .staff-layout { grid-template-columns: minmax(0, 1fr); }

  .staff-layout > .staff-col { display: none; }

  .staff-layout[data-active="steps"] > [data-tab="steps"],
  .staff-layout[data-active="talk"] > [data-tab="talk"],
  .staff-layout[data-active="summary"] > [data-tab="summary"] { display: flex; }
}

@media (min-width: 901px) and (max-width: 1180px) and (min-aspect-ratio: 1/1) {
  .staff-layout { grid-template-columns: 240px minmax(0, 1fr) 240px; }
}

@media (max-width: 620px) {
  /* Telefono: le 16 lingue stanno in una schermata, su tre colonne. */
  .welcome { gap: 10px; padding: 12px 10px; justify-content: flex-start; }

  .welcome-hello { min-height: 2.4em; font-size: 1.2rem; }

  .lang-grid { gap: 8px; }

  .lang-tile { width: calc(33.333% - 6px); min-height: 92px; gap: 4px; padding: 8px 4px; }

  .lang-native { font-size: 1rem; text-align: center; line-height: 1.15; }

  .lang-latin { margin-top: -2px; font-size: .76rem; }

  .flag--big { width: 58px; height: 39px; }

  .pair-code { font-size: 2.1rem; }

  .talk--large { min-height: 72px; font-size: 1.02rem; gap: 6px; }

  .talk--large .talk-icon { width: 32px; height: 32px; }

  .composer-keyboard, .composer-photo { width: 54px; min-height: 54px; font-size: 1.35rem; }

  .age-widget { grid-template-columns: minmax(0, 1fr); }

  .pain-row { grid-template-columns: repeat(6, minmax(0, 1fr)); }

  .pain-tile { min-height: 96px; }

  .notice-card { padding: 20px; font-size: 1.1rem; }

  .board-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }

  .board-tile { min-height: 96px; padding: 6px 4px; }

  .board-icon { font-size: 2.2rem; }

  .board-label { font-size: .86rem; }

  .board-tab { font-size: .8rem; min-height: 50px; flex-direction: column; gap: 0; padding: 4px 2px; }

  .question-icon { width: 52px; height: 52px; font-size: 2rem; border-radius: 12px; }

  .question-head { gap: 10px; }

  .bm-tab { font-size: .8rem; flex-direction: column; gap: 2px; }

  .bm-svg { height: min(64vh, 520px); }

  .bm-svg--head, .bm-svg--belly { height: min(44vh, 340px); }

  .choice-grid--country { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .choice-grid--yesno .choice { min-height: 84px; }

  .date-value { font-size: 2rem; }

  .date-widget { grid-template-columns: minmax(0, 1fr); gap: 10px; }

  .date-widget .key { min-height: 54px; font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* Audio trattenuto dal browser: un tocco qui lo fa partire. */
.audio-pending {
  position: fixed;
  right: 16px;
  bottom: 96px;
  z-index: 50;
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 2.2rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  animation: audio-pulse 1.4s ease-in-out infinite;
}

.audio-pending[hidden] { display: none; }

@keyframes audio-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .audio-pending { animation: none; }
}
