:root {
  color-scheme: light;
  /* Niente ingrandimento automatico dei testi sui telefoni: altererebbe la lettura parafoveale. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Font di sistema: San Francisco su Mac e iPhone, Roboto su Android. */
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f6f6f4;
  color: #1c1c1c;
  --accent: #0e6e66;
  --accent-dark: #0a524c;
  --accent-soft: #e3f1ef;
  --surface: #ffffff;
  --canvas: #f6f6f4;
  --line: #d4d4d0;
  --muted: #5f5f5f;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .52; }

.shell { width: min(1080px, 100%); margin: 0 auto; padding: 24px; }
.topbar { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.brand { margin: 0; color: var(--accent); font-size: 1.1rem; letter-spacing: .06em; }
.status, .helper { color: var(--muted); }
.grid { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 20px; }
.panel, .control-card, .rail-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.stack { display: grid; gap: 14px; }
.row, .button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea { width: 100%; color: #1c1c1c; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
textarea { min-height: 130px; resize: vertical; line-height: 1.45; }
button { border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; color: #1c1c1c; background: #fff; font-weight: 600; }
button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
button.wide { width: 100%; min-height: 46px; }
.code { font-size: clamp(2rem, 7vw, 4rem); letter-spacing: .18em; font-variant-numeric: tabular-nums; margin: 8px 0; }
.preview { min-height: 420px; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; text-align: center; overflow: hidden; }
.reading { width: min(760px, 100%); }
.reading h2 { color: var(--muted); font-size: 1rem; font-weight: 500; }
.context { color: #6f7471; transition: opacity .2s ease; }
.context.dimmed { opacity: .22; }
.active-segment { font-size: clamp(1.8rem, 4.5vw, 3.5rem); line-height: 1.25; margin: 28px 0; }
.progress { color: var(--muted); font-variant-numeric: tabular-nums; }
.join { width: min(440px, 100%); margin: 12vh auto 0; }
.hidden { display: none !important; }
.error { color: var(--danger); min-height: 1.4em; margin: 0; }
.scene-kicker { margin: 0 0 18px; color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.phrase-card { color: #1c1c1c; font-size: clamp(2rem, 6vw, 4.5rem); font-weight: 600; line-height: 1.18; text-wrap: balance; }

.director-body { min-width: 980px; }
/* Regia: una sola scala tipografica. Pulsanti 14/600, titoli delle card 16/700, testi d'aiuto 12/400. */
.director-body button { font-size: 14px; line-height: 1.25; }
.director-shell { min-height: 100vh; display: flex; flex-direction: column; }
.director-topbar { min-height: 70px; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fff; border-bottom: 1px solid var(--line); }
.director-identity, .session-summary, .media-actions { display: flex; align-items: center; gap: 12px; }
.director-identity { min-width: 0; gap: 16px; }
.director-brand { margin: 0; color: var(--accent); font-size: 15px; line-height: 1; white-space: nowrap; }
.session-summary { gap: 10px; }
.live-status { white-space: nowrap; }
.director-brand span { color: var(--muted); font-weight: 600; }
.eyebrow, .section-label { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.session-code { font-size: 22px; letter-spacing: .08em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.compact-button { height: 36px; padding: 0 12px; font-size: 13px; }
.live-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.live-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.media-actions { gap: 8px; flex-shrink: 0; }
.media-actions button { height: 40px; padding: 0 14px; white-space: nowrap; }
.media-actions .future { border-style: dashed; }
.director-workspace { flex: 1; display: grid; grid-template-columns: 220px minmax(560px, 1fr) 280px; gap: 16px; padding: 16px 20px 24px; }
.scene-sidebar { display: flex; flex-direction: column; gap: 6px; }
.scene-sidebar .section-label { padding: 4px 8px; }
.scene-nav { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; text-align: left; }
.scene-nav span { font-size: 14px; }
.scene-nav small { color: var(--muted); font-size: 11px; font-weight: 500; }
.scene-nav.active { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.scene-nav.active small { color: var(--accent-dark); }
.sidebar-note { margin: 8px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.director-main { min-width: 0; display: grid; grid-template-columns: 236px minmax(320px, 1fr); gap: 16px; align-items: start; }
.participant-preview { position: sticky; top: 16px; display: grid; gap: 8px; }
.phone-frame { width: 236px; height: 500px; overflow: hidden; display: flex; flex-direction: column; background: #f6f6f4; border: 6px solid #1c1c1c; border-radius: 28px; box-shadow: 0 8px 24px #1c1c1c14; }
.phone-bar { height: 32px; flex: 0 0 auto; display: flex; align-items: center; padding: 0 12px; border-bottom: 1px solid var(--line); background: #fff; font-size: 11px; font-weight: 700; }
.phone-content { flex: 1; width: 100%; min-width: 0; padding: 18px 14px; display: flex; flex-direction: column; justify-content: center; overflow: auto; text-align: center; }
.phone-content .active-segment { font-size: 25px; margin: 16px 0; }
.phone-content .context { font-size: 12px; }
.phone-content .phrase-card { font-size: 27px; line-height: 1.2; }
.control-stack, .director-rail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.control-card { display: grid; gap: 12px; padding: 16px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-heading h2 { margin: 2px 0 0; font-size: 16px; }
.card-heading.compact { align-items: baseline; }
.card-heading.compact > span { color: var(--muted); font-size: 13px; }
.ready-badge { padding: 4px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); font-size: 11px; font-weight: 600; white-space: nowrap; }
.helper { margin: 0; font-size: 12px; line-height: 1.45; }
.button-row > button { flex: 1; min-width: 110px; }
.camera-placeholder { height: 158px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border-radius: 12px; background: #2a2a2a; color: #e6e6e6; text-align: center; }
.camera-placeholder span { color: #bdbdbd; font-size: 11px; }
.rail-card { padding: 14px; }
.participants { list-style: none; display: grid; gap: 8px; margin: 12px 0 0; padding: 0; color: #1c1c1c; font-size: 14px; }
.participants li { padding: 8px 0; border-bottom: 1px solid #eeeeeb; }
.participants li::after { content: "collegato"; float: right; color: var(--accent); font-size: 12px; font-weight: 600; }
.participants li:only-child::after { content: ""; }
.future-card { border-style: dashed; }

@media (max-width: 1180px) {
  .director-workspace { grid-template-columns: 190px minmax(520px, 1fr); }
  .director-rail { grid-column: 1 / -1; display: grid; grid-template-columns: 220px 1fr 1fr; }
  .camera-placeholder { height: auto; min-height: 140px; }
}

@media (max-width: 760px) {
  .shell { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  .preview { min-height: 55vh; }
}

/* Tastiera e impulsi audio: adattamento dei motori legacy. */
.piano { position: relative; display: flex; height: 144px; width: 100%; touch-action: manipulation; }
.piano-key { border-radius: 0 0 5px 5px; padding: 0 0 8px; font-size: 9px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
/* Lettera della tastiera fisica che suona quel tasto. */
.piano-key kbd { font: 600 11px/1 system-ui, sans-serif; padding: 2px 4px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-dark); }
.piano-key.black kbd { background: #ffffff26; color: #fff; }
.piano-key.white { flex: 1; min-width: 0; background: #fff; color: #333; }
.piano-key.black { position: absolute; width: 4.4%; height: 60%; z-index: 1; color: #fff; background: #252525; font-size: 8px; }
.piano-key:disabled { opacity: .65; }
.bpm-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.bpm-presets button { padding: 8px 10px; font-size: 12px; }
.beat-dot { display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); opacity: .6; vertical-align: middle; }
.voice-orb { --note-color: #0e6e66; width: min(150px, 50vw); aspect-ratio: 1; border-radius: 50%; background: var(--note-color); margin: 30px auto; opacity: .6; transition: background .12s; }
#client-audio { margin-bottom: 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.preparation-title { font-size: clamp(1.5rem, 4vw, 2.6rem); margin: 0 0 20px; color: var(--accent); }
.preparation-caption { white-space: pre-wrap; font-size: clamp(1.2rem, 3vw, 2rem); line-height: 1.5; }
.phone-content .preparation-title { font-size: 20px; margin-bottom: 10px; }
.phone-content .preparation-caption { font-size: 15px; margin: 8px 0 0; }

/* Preparazione · layout diviso: Valentina in alto, esercizio sotto. */
.prep-layout { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.presenter-slot { height: 34svh; min-height: 150px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; border-radius: 12px; background: #2a2a2a; color: #e6e6e6; }
.presenter-avatar { width: 96px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: #4a4a4a; border: 4px solid #5fb8ae; font-size: 36px; font-weight: 600; }
.presenter-name { margin: 0; font-size: 14px; font-weight: 600; }
.prep-body { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.prep-photo { width: 100%; margin: 0; }
.prep-photo img { display: block; width: 100%; aspect-ratio: 4 / 3; max-height: 26svh; object-fit: contain; border-radius: 12px; background: #e4e4e0; }
.phone-content .prep-photo img { max-height: 130px; }
.presenter-slot { height: 28svh; }

/* Il pannello principale della scheda viene prima del metronomo condiviso. */
#parafoveal-controls, #phrase-controls { order: -1; }

/* Font condensato della lettura, ospitato nell'app (IBM Plex Sans Condensed, licenza OFL in assets/fonts). */
@font-face { font-family: "IBM Plex Sans Condensed"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/ibm-plex-sans-condensed-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans Condensed"; font-style: italic; font-weight: 400; font-display: swap; src: url("/assets/fonts/ibm-plex-sans-condensed-latin-400-italic.woff2") format("woff2"); }

/* Lettura parafoveale, come nel legacy: righe centrate, interlinea 2, «+» al centro dell'area. */
.para-stage { position: relative; width: 100%; min-width: 0; display: flex; align-items: center; justify-content: center; }
.para-fixation { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5; color: var(--accent); font-size: 1.8rem; font-weight: 900; line-height: 1; opacity: .85; pointer-events: none; }
.para-grid { width: 100%; min-width: 0; padding: 1rem; color: #1c1c1c; font-family: "IBM Plex Sans Condensed", system-ui, sans-serif; font-size: clamp(1rem, 2.5vw, 1.4rem); line-height: 2; text-align: center; }
/* Una riga del pattern = una riga dello schermo; la dimensione la adatta parafoveal.js. */
.para-line { width: max-content; margin: 0 auto .2rem; white-space: nowrap; }
/* Distrattori in inglese: corsivo come nel legacy e 2 px più piccoli delle parole da leggere. */
.para-word i { font-weight: 400; font-size: calc(1em - 2px); }
.phone-content:has(.para-stage) { justify-content: flex-start; padding: 8px 4px; }
.phone-content .para-grid { padding: 0; font-size: 8.5px; line-height: 1.8; }
.phone-content .para-fixation { font-size: 18px; }

/* Finestra di condivisione per Zoom: contenuto grande su tutta la finestra, nessun comando. */
.share-body { overflow: hidden; }
.share-shell { height: 100vh; display: flex; flex-direction: column; }
.share-stage { flex: 1; width: 100%; max-width: none; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4vh 6vw; text-align: center; }
.share-stage:has(.para-stage) { justify-content: flex-start; }
.share-stage .phrase-card { font-size: clamp(2.4rem, 5.5vw, 5.5rem); max-width: 22ch; }
.share-stage .para-grid { font-size: clamp(1rem, 1.9vw, 1.7rem); }
.share-stage .prep-layout { max-width: 1100px; }
.share-stage .prep-photo img { max-height: 55vh; }
.share-stage .voice-orb { width: min(260px, 40vh); }
.share-footer { height: 44px; flex-shrink: 0; display: flex; align-items: center; gap: 14px; padding: 0 20px; border-top: 1px solid var(--line); background: #fff; }
.share-footer .helper { font-size: 13px; }
.share-overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: #1c1c1cb3; }
.share-setup-card { width: min(560px, 100%); }
.share-setup-card h1 { margin: 0; font-size: 1.5rem; }
.share-setup-card p { margin: 0; line-height: 1.5; }
.share-howto { padding: 12px; border-radius: 10px; background: var(--accent-soft); line-height: 1.5; }
.media-actions .share-open { border-color: var(--accent); color: var(--accent-dark); white-space: nowrap; }
.media-actions .share-open.live { background: var(--accent-soft); }

/* Telefono: meno cornice, così esercizio e musica restano nella prima schermata. */
@media (max-width: 600px) {
  .shell { padding: 12px; }
  .topbar { margin-bottom: 10px; }
  #stage.panel { padding: 12px; }
  #client-audio { margin-bottom: 10px; padding: 10px 12px; gap: 4px 10px; }
  #client-audio .helper { font-size: 12px; margin: 0; }
  #client-audio button { padding: 8px 12px; }
  .presenter-slot { height: 24svh; min-height: 130px; }
  .prep-photo img { max-height: 24svh; }
  .prep-layout, .prep-body { gap: 8px; }
  .preparation-title { font-size: 1.4rem; margin-bottom: 4px; }
  .preparation-caption { font-size: 1.05rem; line-height: 1.4; margin: 0; }
  /* Lettura parafoveale: niente margini di pagina né riquadro, tutta la larghezza al testo. */
  .shell:has(.para-stage) { padding: 12px 0 0; }
  .shell:has(.para-stage) .topbar, .shell:has(.para-stage) #client-audio { margin-left: 12px; margin-right: 12px; }
  #stage.panel:has(.para-stage) { padding: 0; border: 0; border-radius: 0; background: transparent; }
  #stage .para-grid { padding: 4px 8px 24px; }
}
.photo-dots { display: flex; gap: 6px; }
.photo-dots span { width: 7px; height: 7px; border-radius: 4px; background: var(--line); transition: width .2s; }
.photo-dots span.active { width: 18px; background: var(--accent); }
.music-chip { margin: 4px 0 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 13px; font-weight: 600; }
.phone-content:has(.prep-layout) { justify-content: flex-start; padding: 10px; }
.phone-content .presenter-slot { height: 150px; min-height: 0; }
.phone-content .presenter-avatar { width: 64px; border-width: 3px; font-size: 24px; }
.phone-content .prep-layout { gap: 10px; }

.exercise-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.exercise-button { display: grid; gap: 4px; align-content: start; text-align: left; padding: 12px; }
.exercise-button strong { font-size: 14px; font-weight: 600; line-height: 1.3; }
.exercise-button small { color: var(--muted); font-size: 12px; font-weight: 400; }
.exercise-button.on-air { border: 2px solid var(--accent); background: #e3f1ef; padding: 11px; }
.exercise-button.on-air small::after { content: " · in onda"; color: var(--accent); font-weight: 600; }
.track-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.track-buttons button { height: 40px; padding: 0 10px; white-space: nowrap; }
.track-buttons [aria-pressed="true"] { border: 2px solid var(--accent); background: #e3f1ef; }
input[type="range"] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); }
.inline-range { flex: 1.4; grid-template-columns: auto auto minmax(100px, 1fr); align-items: center; gap: 8px; white-space: nowrap; overflow: visible; }
.inline-range output { color: #1c1c1c; font-variant-numeric: tabular-nums; min-width: 3ch; }
