/* ------------------------------------------------------------------
   Maquette Latarjet 3D — feuille de style
   Thème clinique : neutres froids légèrement teintés turquoise,
   accent bleu-vert médical, typographie IBM Plex.
------------------------------------------------------------------ */

:root {
  --bg:        #e8ecee;
  --stage-bg:  #e6ebec;
  --surface:   #ffffff;
  --surface-2: #f2f5f6;
  --surface-3: #e9eef0;
  --border:    #d5dde0;
  --border-2:  #c3ced2;
  --ink:       #16242a;
  --ink-2:     #53636a;
  --ink-3:     #7b8a90;
  --accent:    #0e7c8a;
  --accent-2:  #0b6472;
  --accent-ink:#ffffff;
  /* Couleur secondaire de la marque : un orange chaud, en face du turquoise.
     Elle ne porte aucune information clinique (pour l'alerte, c'est --warn) —
     elle réchauffe, elle ponctue, et c'est tout ce qu'on lui demande. */
  --brand-2:    #e0743c;
  --brand-2-ink:#ffffff;
  --danger:    #c4423b;
  --danger-ink:#ffffff;
  --warn:      #b8561a;   /* volet Instabilité */
  --warn-ink:  #ffffff;
  --bone:      #a07c3f;   /* volet Structures */
  --bone-ink:  #ffffff;
  --ok:        #2f9e5f;   /* coche « étape terminée » */
  --ok-ink:    #ffffff;
  --focus:     #1aa0b3;
  --shadow:    0 1px 2px rgba(16,32,38,.06), 0 8px 24px rgba(16,32,38,.10);
  --shadow-sm: 0 1px 2px rgba(16,32,38,.10);
  --r:   10px;
  --r-sm: 7px;
  color-scheme: light;
}

/* Un seul thème, clair. La maquette est montrée en consultation puis capturée
   en image pour le patient, qui l'annote parfois sur papier : une capture
   sombre ne s'imprime pas, et un téléphone réglé en sombre affichait sinon une
   maquette sombre d'emblée. La préférence du système n'est donc pas suivie —
   c'est aussi pourquoi color-scheme est verrouillé sur « light » ci-dessus. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- App shell ---------- */
#app {
  height: 100dvh;
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: 58px 1fr;
  grid-template-areas: "top top" "panel stage";
}
#topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
/* Le bandeau du logo est un lien vers le catalogue (a.brand) ; il reste une
   simple zone de titre quand le patient a ouvert la page depuis un QR code,
   où ce retour n'aurait aucun sens — d'où le style conditionné à [href]. */
.brand {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  text-decoration: none; color: inherit; border-radius: 11px;
}
.brand[href] { cursor: pointer; }
.brand[href] .brand-mark { transition: opacity .15s ease; }
.brand[href] .brand-txt strong { transition: color .15s ease; }
.brand[href]:hover .brand-mark { opacity: .74; }
.brand[href]:hover .brand-txt strong { color: var(--accent); }
.brand[href]:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
/* La marque EMET : deux profils de visage décalés — la personne réelle en
   turquoise, son jumeau numérique en orange. Posée à même le bandeau, sans
   pastille de couleur derrière : le tracé est fin, un aplat l'écraserait et
   masquerait justement les deux couleurs qui font le sens du logo. */
.brand-mark { flex: none; width: auto; height: 36px; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-txt strong {
  font-family: "IBM Plex Sans Condensed", "IBM Plex Sans", sans-serif;
  font-weight: 600; font-size: 15px; letter-spacing: .005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-txt span { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* Témoin d'enregistrement d'une consultation (cf. core/js/consultation.js) :
   un point et un mot, pour que le praticien sache — sans bouton — que le
   cas qu'il montre est enregistré. Hors capture (data-no-capture). */
.consult-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 0 11px; height: 34px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 12px; font-weight: 500; color: var(--ink-3); white-space: nowrap;
}
.consult-chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.consult-chip.is-saved   { color: var(--ink-2); }
.consult-chip.is-saved   .consult-chip-dot { background: var(--ok); }
.consult-chip.is-saving  .consult-chip-dot,
.consult-chip.is-loading .consult-chip-dot { background: var(--accent); animation: consult-pulse 1s ease-in-out infinite; }
.consult-chip.is-offline, .consult-chip.is-error, .consult-chip.is-notfound { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.consult-chip.is-offline .consult-chip-dot, .consult-chip.is-error .consult-chip-dot, .consult-chip.is-notfound .consult-chip-dot { background: var(--danger); }
@keyframes consult-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (max-width: 640px) { .consult-chip-txt { display: none; } .consult-chip { padding: 0 12px; } }

/* Le lien du patient ne répond plus (désactivé, expiré) : on le lui dit,
   au milieu de la scène, plutôt que de lui montrer une maquette vierge. */
#consult-notice {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%); z-index: 30;
  margin: 0; padding: 10px 16px; border-radius: 10px; max-width: min(92%, 420px);
  background: var(--surface); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  box-shadow: var(--shadow); font-size: 14px; font-weight: 500; text-align: center;
}

/* bouton « Lecture vocale » du bandeau (aria-pressed = activé) */
.icon-btn.voice-btn {
  display: inline-flex; align-items: center; gap: 7px;
  width: auto; padding: 0 12px; font-size: 12.5px; font-weight: 500;
}
.voice-btn svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.voice-btn .wave { opacity: .35; }
.icon-btn.voice-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.voice-btn[aria-pressed="true"] .wave { opacity: 1; }

.icon-btn {
  border: 1px solid var(--border); background: var(--surface);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center; font-size: 15px; color: var(--ink-2);
}
.icon-btn:hover { color: var(--ink); border-color: var(--border-2); }
#btn-panel-toggle { display: none; }
/* bouton de capture : confirmation brève après l'enregistrement */
.icon-btn.is-done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Panel ---------- */
#panel {
  grid-area: panel;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
  z-index: 15;
}
.panel-scroll { height: 100%; overflow-y: auto; padding: 14px 12px 28px; }

/* Chaque volet est une carte. --tone = couleur du volet (pastille, bouton principal). */
.grp {
  --tone: var(--accent); --tone-ink: var(--accent-ink);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
/* tons portés par le volet ou directement par un bouton (qui peut quitter son volet sur mobile) */
.tone-bone   { --tone: var(--bone);   --tone-ink: var(--bone-ink); }
.tone-warn   { --tone: var(--warn);   --tone-ink: var(--warn-ink); }
.tone-danger { --tone: var(--danger); --tone-ink: var(--danger-ink); }
.grp.plain { background: none; border: 0; box-shadow: none; padding: 4px 2px 0; }

.grp-head { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.grp-icon {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--tone) 14%, var(--surface));
  color: var(--tone);
}
.grp-icon svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.grp-head-txt { display: block; flex: 1; min-width: 0; }
.grp-title { display: block; margin: 0; font-size: 14px; font-weight: 600; line-height: 1.25; color: var(--ink); }
.grp-sub { display: block; margin: 2px 0 0; font-size: 11.5px; line-height: 1.35; color: var(--ink-3); }

/* volet repliable : <details class="grp"><summary class="grp-head"> */
summary.grp-head { margin: 0; cursor: pointer; list-style: none; user-select: none; }
summary.grp-head::-webkit-details-marker { display: none; }
summary.grp-head::after {
  content: ""; flex: none; width: 7px; height: 7px; margin: 0 4px 3px 0;
  border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg); transition: transform .18s;
}
details.grp[open] > summary.grp-head { margin-bottom: 12px; }
details.grp[open] > summary.grp-head::after { transform: translateY(3px) rotate(-135deg); }
summary.grp-head:hover .grp-title { color: var(--tone); }

.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.ctl-btn {
  border: 1px solid var(--border-2); background: var(--surface-2);
  color: var(--ink); border-radius: var(--r-sm);
  padding: 8px 10px; font-size: 12.5px; font-weight: 500; cursor: pointer;
  text-align: center; line-height: 1.25;
  transition: background .15s, border-color .15s, box-shadow .15s, filter .15s, color .15s;
}

/* Boutons d'action principaux : pastille ronde + libellé.
   .hero = bouton plein (couleur du volet), .play = lancement d'une animation. */
.ctl-btn.hero, .ctl-btn.play {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 8px 14px 8px 8px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; text-align: left; line-height: 1.3;
}
.btn-ico { position: relative; flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; }
/* étape du parcours terminée : petite coche verte sur la pastille */
.ctl-btn.is-done .btn-ico::after {
  content: "✓"; position: absolute; right: -5px; bottom: -5px;
  width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ok); color: var(--ok-ink); border: 2px solid var(--surface);
  font-size: 9px; font-weight: 700; line-height: 1;
}
.btn-ico svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.ctl-btn.hero {
  background: var(--tone); border-color: var(--tone); color: var(--tone-ink);
  box-shadow: 0 6px 16px -8px var(--tone);
}
.ctl-btn.hero:hover { background: var(--tone); border-color: var(--tone); filter: brightness(1.08); }
.ctl-btn.hero .btn-ico { background: color-mix(in srgb, var(--tone-ink) 20%, transparent); }
.ctl-btn.hero .ico-reduce { display: none; }
.ctl-btn.hero.is-luxed {                               /* état « Réduire » : bouton clair, pastille pleine */
  background: color-mix(in srgb, var(--tone) 10%, var(--surface)); color: var(--tone); box-shadow: none;
}
.ctl-btn.hero.is-luxed:hover { filter: none; background: color-mix(in srgb, var(--tone) 16%, var(--surface)); }
.ctl-btn.hero.is-luxed .btn-ico { background: var(--tone); color: var(--tone-ink); }
.ctl-btn.hero.is-luxed .ico-go { display: none; }
.ctl-btn.hero.is-luxed .ico-reduce { display: block; }
.ctl-btn.play {
  background: color-mix(in srgb, var(--tone) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--tone) 30%, var(--border));
}
.ctl-btn.play:hover { background: color-mix(in srgb, var(--tone) 13%, var(--surface)); border-color: var(--tone); }
.ctl-btn.play .btn-ico { background: var(--tone); color: var(--tone-ink); box-shadow: 0 3px 8px -3px var(--tone); }
.btn-short { display: none; }                          /* libellé court : barre mobile uniquement */

/* « Recommencer depuis le début », dans la carte en fin de parcours */
#card { --tone: var(--accent); --tone-ink: var(--accent-ink); }
#btn-restart { margin-top: 14px; }

/* rebond en boucle tant que l'utilisateur n'a cliqué sur aucun bouton */
.ctl-btn.nudge { animation: nudge-bounce 1.4s ease-in-out infinite; }
@keyframes nudge-bounce {
  0%, 55%, 100% { transform: translateY(0); }
  18% { transform: translateY(-8px); }
  34% { transform: translateY(0); }
  44% { transform: translateY(-3px); }
}
.ctl-btn:hover { border-color: var(--accent); background: var(--surface-3); }
.ctl-btn:active { transform: translateY(1px); }
.ctl-btn.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ctl-btn.wide { width: 100%; margin-top: 7px; }
.ctl-btn.accent-line { border-left: 3px solid var(--accent); text-align: left; }
.ctl-btn.ghost { background: transparent; border-style: dashed; color: var(--ink-2); }
.ctl-btn.ghost:hover { color: var(--danger); border-color: var(--danger); background: transparent; }

/* switches */
.switch {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; cursor: pointer; user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  flex: none; width: 36px; height: 20px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border-2);
  position: relative; transition: background .16s, border-color .16s;
}
.switch-track::after {
  content: ""; position: absolute; top: 1px; left: 1px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform .16s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch-label { font-size: 13px; color: var(--ink); }

/* « Voir plus » : options secondaires masquées par défaut (<div class="more" hidden>) */
.more { margin-top: 10px; padding-top: 4px; border-top: 1px dashed var(--border); }
.more-link {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; padding: 2px 0;
  border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--tone, var(--accent));
}
.more-link::after {                                     /* chevron : bas = replié, haut = déplié */
  content: ""; width: 6px; height: 6px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg); transition: transform .18s;
}
.more-link[aria-expanded="true"]::after { transform: translateY(1px) rotate(-135deg); }
.more-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.more-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

/* sliders */
.slider { margin-top: 12px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.slider-head span { font-size: 13px; font-weight: 500; }
.slider-head output {
  font-family: "IBM Plex Mono", monospace; font-size: 12.5px; font-weight: 500;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.slider-hint { margin: 5px 0 0; font-size: 11px; color: var(--ink-3); }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px;
  background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--surface-3); border: 1px solid var(--border-2); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--surface-3); border: 1px solid var(--border-2); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -8px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}

/* steps */
.steps { display: flex; flex-direction: column; gap: 5px; }
.step-btn {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--border-2); background: var(--surface-2);
  border-radius: var(--r-sm); padding: 8px 10px; cursor: pointer;
  font-size: 12.5px; text-align: left; color: var(--ink); line-height: 1.2;
}
.step-btn b {
  flex: none; width: 20px; height: 20px; border-radius: 5px;
  display: grid; place-items: center; font-size: 11px;
  background: var(--surface-3); color: var(--ink-2);
  font-family: "IBM Plex Mono", monospace;
}
.step-btn:hover { border-color: var(--accent); }
.step-btn.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step-btn.is-active b { background: rgba(255,255,255,.22); color: var(--accent-ink); }

.disclaimer { margin: 12px 0 0; font-size: 10.5px; line-height: 1.5; color: var(--ink-3); }

.ann-out {
  margin: 8px 0 0; padding: 8px; max-height: 220px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 10.5px; line-height: 1.55;
  color: var(--ink); white-space: pre-wrap; word-break: break-word;
  -webkit-user-select: text; user-select: text;
}

/* ---------- Stage ---------- */
#stage { grid-area: stage; position: relative; background: var(--stage-bg); overflow: hidden; }
#canvas-wrap { position: absolute; inset: 0; }
#canvas-wrap canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }

/* Filigrane : « Docteur Chelli » répété en diagonale sur toute la scène 3D.
   Discret (faible opacité) mais couvre l'ensemble de la vue plutôt qu'un
   seul coin : un enregistrement vidéo de la maquette ne peut pas s'en
   débarrasser par un simple recadrage, contrairement à un logo isolé.
   Technique : un même motif SVG (texte blanc sur fond transparent) sert de
   masque — sa couleur vient de --ink, sans dupliquer le SVG.
   Le motif avec le NOM est fabriqué par core/js/practitioner.js, qui seul
   sait quel praticien est connecté ; tant qu'il ne l'a pas dit, le masque
   est vide et la scène reste nue. */
:root {
  --watermark-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="540" height="300"></svg>');
}
#watermark {
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background-color: var(--ink); opacity: .05;
  -webkit-mask-image: var(--watermark-mask); mask-image: var(--watermark-mask);
  -webkit-mask-repeat: repeat; mask-repeat: repeat;
  -webkit-mask-size: 540px 300px; mask-size: 540px 300px;
}
@media (max-width: 640px) {
  #watermark { -webkit-mask-size: 370px 206px; mask-size: 370px 206px; }
}

/* Interrupteurs d'affichage posés sur la scène, en haut à gauche. Les vues
   toutes faites (3/4, antérieure, postérieure…) ont été retirées : le
   praticien tourne la maquette au doigt, ce qui reste plus rapide et plus
   parlant pour le patient que de choisir un angle dans une liste. */
#stage-chips {
  position: absolute; top: 12px; left: 12px; z-index: 6;
  display: flex; gap: 6px; flex-wrap: wrap; max-width: 60%;
}
.chip {
  border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px);
  border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 500;
  color: var(--ink-2); cursor: pointer;
}
.chip:hover { color: var(--ink); border-color: var(--accent); }

/* Interrupteur « Repères & labels » : une pastille, avec un point d'état
   à gauche. */
.chip-switch { display: inline-flex; align-items: center; gap: 7px; user-select: none; }
.chip-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-switch::before {
  content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-2); transition: background .16s;
}
.chip-switch:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-switch:has(input:checked)::before { background: currentColor; }
.chip-switch:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Encart consultation (médecin, date du jour, patient, QR code) — en haut à droite
   de la scène, replié par défaut derrière un petit bouton rond */
#consult-info { position: absolute; top: 12px; right: 12px; z-index: 7; }
/* Écran « capture » : quand l'encart est ouvert, il ne reste que la maquette et
   l'encart — ni menu, ni interrupteurs, ni carte explicative. Capture d'écran
   prête à être annotée puis remise au patient. */
#app.is-clean { grid-template-columns: 1fr; grid-template-areas: "top" "stage"; }
#app.is-clean #panel,
#app.is-clean #stage-chips,
#app.is-clean #guide-bar,
#app.is-clean #card { display: none; }
/* « Info-bulles » décoché : la carte explicative n'apparaît plus du tout (consultation) */
#app.no-card #card { display: none; }
/* le ☰ reste accessible, même sur grand écran : il fait revenir le menu */
#app.is-clean #btn-panel-toggle { display: grid; }
.ci-toggle {
  list-style: none; cursor: pointer;
  width: 36px; height: 36px; margin-left: auto; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px); box-shadow: var(--shadow-sm); color: var(--ink-2);
}
.ci-toggle::-webkit-details-marker { display: none; }
.ci-toggle:hover { color: var(--ink); border-color: var(--accent); }
.ci-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ci-ico-close, #consult-info[open] .ci-ico-open { display: none; }
#consult-info[open] .ci-ico-close { display: block; }
#consult-info[open] {
  width: 260px; padding: 14px 18px 16px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
/* déplié : le bouton devient une petite croix dans le coin de l'encart */
#consult-info[open] .ci-toggle {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px;
  border: 0; background: transparent; box-shadow: none; backdrop-filter: none;
}
.ci-body { display: flex; flex-direction: column; gap: 3px; }
.ci-doctor { font-size: 17px; font-weight: 600; color: var(--ink); padding-right: 26px; }
.ci-date { font-size: 15px; color: var(--ink-2); }
.ci-patient {
  display: flex; flex-direction: column;
  margin-top: 8px; padding-top: 9px; border-top: 1px solid var(--border);
  font-size: 15px; color: var(--ink-3);
}
/* deux lignes vierges : le nom du patient est écrit à la main */
.ci-line { height: 36px; border-bottom: 1.5px dashed var(--border-2); }
.ci-qr { margin: 14px 0 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ci-qr-img { line-height: 0; }
.ci-qr img, .ci-qr canvas { width: 150px; height: 150px; border-radius: 8px; background: #fff; }   /* fond blanc : le QR reste lisible quel que soit ce qu'il y a derrière */
.ci-qr figcaption { font-size: 12.5px; color: var(--ink-2); text-align: center; }

/* Récapitulatif des lésions configurées — en bas à droite, visible uniquement en
   mode « capture » (encart consultation ouvert) : il fait partie de l'image remise
   au patient, à côté du QR code. Rempli par le script de chaque maquette. */
#lesion-recap { display: none; }
#app.is-clean #lesion-recap {
  display: block;
  position: absolute; right: 12px; bottom: 12px; z-index: 7;
  width: 260px; padding: 12px 16px 13px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.lr-title {
  margin: 0 0 8px; padding-bottom: 7px; border-bottom: 1px solid var(--border);
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-2);
}
.lr-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.lr-list li { display: flex; align-items: baseline; gap: 8px; font-size: 14px; line-height: 1.35; }
.lr-name { flex: none; color: var(--ink-3); }
.lr-dots { flex: 1; min-width: 10px; border-bottom: 1px dotted var(--border-2); translate: 0 -3px; }
.lr-val { flex: none; text-align: right; color: var(--ink-2); }
.lr-val.is-lesion { color: var(--danger); font-weight: 600; }
/* lignes des pathologies annexes (bursite, CSA) : une seule mention, sans valeur */
.lr-list li.lr-flag { color: var(--danger); font-weight: 500; }

/* Traitement proposé — en bas à gauche, pendant du bilan anatomique : écran
   « capture » seulement, et seulement si au moins un geste a été retenu.
   Les mêmes numéros entourés sont posés sur la maquette (#treat-marks), à
   l'endroit du geste. Rempli par le socle (core/js/consult-layer.js) à partir
   des gestes déclarés par la maquette. */
#treat-recap, #treat-marks { display: none; }
#app.is-clean #treat-recap:has(li) {
  display: block;
  position: absolute; left: 12px; bottom: 12px; z-index: 7;
  width: 260px; padding: 12px 16px 13px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.tr-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.tr-list li { display: flex; align-items: center; gap: 9px; font-size: 14px; line-height: 1.3; color: var(--ink); }
.tr-num {
  flex: none; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-family: "IBM Plex Sans", sans-serif; font-size: 12.5px; font-weight: 600; line-height: 1;
}
#app.is-clean #treat-marks { display: block; position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
/* pastille sur la maquette : plus grande, cerclée de blanc pour se détacher de l'os (lisible sur la TV) */
.tr-mark {
  position: absolute; transform: translate(-50%, -50%);
  width: 32px; height: 32px; font-size: 17px;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  transition: opacity .18s;
}

#labels, #ann-labels { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
#ann-labels { z-index: 8; }
.ann-tag {
  position: absolute; transform: translate(-50%, -50%);
  min-width: 16px; height: 16px; padding: 0 3px; border-radius: 999px;
  background: #ff2d1a; color: #fff; font: 700 10px/16px "IBM Plex Mono", monospace;
  text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.lbl {
  position: absolute; transform: translate(-50%, -50%);
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  white-space: nowrap; color: var(--ink);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--border-2);
  padding: 2px 7px; border-radius: 999px;
  backdrop-filter: blur(4px);
  transition: opacity .18s;
}
.lbl::before {
  content: ""; position: absolute; left: -5px; top: 50%;
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
  transform: translateY(-50%);
}
.lbl.lesion::before { background: var(--danger); }

/* Carte explicative : au milieu à droite de la scène, en gros caractères
   (lisible par le patient). Elle se ré-anime à chaque nouveau message. */
#card {
  position: absolute; right: 16px; top: 50%; translate: 0 -50%; z-index: 6;
  margin: 0; width: min(340px, 36%);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 14px; padding: 18px 20px;
  box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
#card.is-new { animation: card-in .45s ease-out; }
@keyframes card-in {
  from { opacity: .35; transform: translateX(12px); }
  to   { opacity: 1;   transform: none; }
}
#card-title {
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 14px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 8px;
}
#card-body { margin: 0; font-size: 17px; line-height: 1.5; color: var(--ink); text-wrap: pretty; white-space: pre-line; } /* "\n" = consigne sur sa propre ligne */
/* petite croix de fermeture (la carte se rouvre au message suivant) */
#card:has(.card-close) #card-title { padding-right: 26px; }
.card-close {
  position: absolute; top: 10px; right: 10px;
  width: 28px; height: 28px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center;
  background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background .15s, color .15s;
}
.card-close svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; fill: none; }
.card-close:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.card-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* barre du parcours guidé : mobile uniquement (voir Responsive) */
#guide-bar { display: none; }

#loader {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--stage-bg); color: var(--ink-2); font-size: 13px;
}
.spin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#errbox {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center; font-size: 13px; line-height: 1.6;
  background: var(--stage-bg); color: var(--danger);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-areas: "top" "stage"; }
  #btn-panel-toggle { display: grid; }
  #panel {
    position: fixed; top: 58px; bottom: 0; left: 0; width: min(340px, 86vw);
    transform: translateX(-101%); transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  #panel.is-open { transform: none; }
  #stage-chips { max-width: calc(100% - 72px); top: 64px; }            /* laisse la place au bouton de l'encart consultation */
  #consult-info { top: 64px; }
  #consult-info[open] { width: 220px; padding: 12px 14px 14px; }
  .ci-doctor { font-size: 15px; }
  .ci-date, .ci-patient { font-size: 13px; }
  .ci-line { height: 30px; }
  .ci-qr img, .ci-qr canvas { width: 120px; height: 120px; }
  #app.is-clean #lesion-recap,
  #app.is-clean #treat-recap:has(li) { width: 200px; padding: 10px 12px 11px; }
  .lr-list li { font-size: 12.5px; }
  .tr-list li { font-size: 12.5px; gap: 7px; }
  .tr-list .tr-num { width: 20px; height: 20px; font-size: 11.5px; }
  .tr-mark { width: 28px; height: 28px; font-size: 15px; }
  /* barre fixe du parcours guidé en haut de la scène (boutons déplacés par le script) */
  #guide-bar {
    --tone: var(--accent); --tone-ink: var(--accent-ink);
    position: absolute; top: 0; left: 0; right: 0; z-index: 7;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
    padding: 8px 10px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border-bottom: 1px solid var(--border); backdrop-filter: blur(8px);
  }
  #guide-bar .ctl-btn.hero, #guide-bar .ctl-btn.play {
    gap: 7px; padding: 5px 8px 5px 5px; border-radius: 10px; font-size: 12.5px;
  }
  #guide-bar .btn-ico { width: 26px; height: 26px; }
  #guide-bar .btn-ico svg { width: 14px; height: 14px; }
  #guide-bar .btn-label { display: none; }
  #guide-bar .btn-short { display: inline; }
  .grp.guide-only { display: none; }                   /* volet vidé de son bouton */
  /* petit écran : la carte repasse en bas, sur toute la largeur */
  #card { top: auto; bottom: 12px; left: 12px; right: 12px; translate: none; width: auto; padding: 14px 16px; }
  #card-body { font-size: 15.5px; }
}
/* téléphone : les deux encarts du bas se partagent la largeur */
@media (max-width: 520px) {
  #app.is-clean #treat-recap:has(li),
  #app.is-clean #lesion-recap { width: calc(50% - 18px); }
}
@media (max-width: 560px) {
  .brand-txt span { display: none; }
  .voice-txt { display: none; }
  .icon-btn.voice-btn { width: 34px; padding: 0; justify-content: center; }
  #topbar { gap: 10px; }
}


/* ---------- Pointeur tactile (écran projeté en consultation) ----------
   Repère visible sous le doigt ou le stylet : l'écran de l'iPad est renvoyé
   sur un téléviseur, où le doigt du praticien n'apparaît pas. Purement
   décoratif et non cliquable : aucun geste n'est intercepté.
   (cf. core/js/touch-pointer.js — la couche n'existe que sur
   appareil tactile, et jamais pour la souris) */
#touch-pointers {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  overflow: hidden; contain: strict;
}
#touch-pointers i { position: absolute; top: 0; left: 0; display: block; border-radius: 50%; }
.tp-dot {
  width: 42px; height: 42px;
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  border: 2.5px solid var(--accent);
  /* liseré clair : le repère reste lisible sur l'os clair comme sur le fond sombre */
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .55), 0 2px 8px rgba(0, 0, 0, .28);
  opacity: 1; transition: opacity .22s ease, transform .22s ease;
}
.tp-dot.is-out { opacity: 0; }
.tp-ring {
  width: 42px; height: 42px;
  border: 2px solid var(--accent);
  animation: tp-ripple .55s ease-out forwards;
}
@keyframes tp-ripple {
  from { opacity: .55; }
  to   { opacity: 0; width: 108px; height: 108px; }   /* translate(-50%,-50%) recentre tout seul */
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}

/* ==================================================================
   VUE PATIENT — la maquette ouverte depuis un QR code

   Le patient arrive sur un téléphone, tenu à une main, après avoir scanné
   la capture d'écran que son médecin lui a remise. Il n'a pas de panneau de
   contrôle à manipuler et le QR code ne lui sert plus à rien : il a besoin
   de voir son épaule en grand, de lire ce qu'on a trouvé, et de revoir le
   geste proposé. D'où cette vue : la maquette, et deux boutons au pouce qui
   ouvrent chacun leur fiche.
================================================================== */
#app.is-patient { grid-template-columns: 1fr; grid-template-areas: "top" "stage"; }
#app.is-patient #panel,
#app.is-patient #stage-chips,
#app.is-patient #guide-bar,
#app.is-patient #btn-panel-toggle,
#app.is-patient #btn-shot,
#app.is-patient #btn-reload,
#app.is-patient #consult-info { display: none; }
/* la carte pédagogique reste : c'est elle qui explique le geste qu'il rejoue,
   remontée au-dessus de la barre de boutons */
#app.is-patient #card { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
#app.is-patient #treat-marks { display: block; position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }

/* --- barre de boutons, posée au pouce --- */
#patient-bar { display: none; }
#app.is-patient #patient-bar {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, color-mix(in srgb, var(--stage-bg) 96%, transparent) 62%, transparent);
}
.pt-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 52px; padding: 10px 12px;                    /* cible tactile confortable */
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-sm);
  font: inherit; font-size: 14.5px; font-weight: 600; line-height: 1.2; text-align: left;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pt-btn svg { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pt-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pt-btn[aria-pressed="true"] svg { stroke: var(--accent-ink); }

/* --- fiche coulissante --- */
#patient-scrim {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(10, 22, 27, .32);
  opacity: 0; transition: opacity .2s ease;
}
#patient-scrim.is-open { opacity: 1; }
#patient-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 11;
  max-height: 76%; display: flex; flex-direction: column;
  padding: 0 14px calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--border); border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 32px rgba(16, 32, 38, .18);
  transform: translateY(101%); transition: transform .22s ease;
}
#patient-sheet.is-open { transform: none; }
.pt-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 0 10px; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
/* petite poignée, pour que la fiche se lise comme un tiroir qu'on referme */
.pt-head::before {
  content: ""; position: absolute; top: 6px; left: 50%; translate: -50% 0;
  width: 36px; height: 4px; border-radius: 2px; background: var(--border-2);
}
.pt-title { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.25; }
.pt-sub { margin: 3px 0 0; font-size: 12.5px; line-height: 1.35; color: var(--ink-3); }
.pt-close {
  flex: none; display: grid; place-items: center;
  width: 38px; height: 38px; margin-left: auto;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
.pt-close svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.pt-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }

/* Les deux encarts du praticien servent de contenu aux fiches : on annule leur
   positionnement d'origine, et l'on n'affiche que celui de la fiche ouverte. */
#app.is-patient #patient-sheet #lesion-recap,
#app.is-patient #patient-sheet #treat-recap {
  display: none;
  position: static; width: auto; padding: 0;
  background: none; border: none; box-shadow: none; backdrop-filter: none;
}
#app.is-patient #patient-sheet.is-findings #lesion-recap,
#app.is-patient #patient-sheet.is-treatment #treat-recap { display: block; }
#app.is-patient #patient-sheet .lr-title { display: none; }     /* le titre est déjà celui de la fiche */
#app.is-patient #patient-sheet .lr-list li { font-size: 15.5px; padding: 3px 0; }
#app.is-patient #patient-sheet .tr-list { gap: 10px; }
#app.is-patient #patient-sheet .tr-list li { flex-wrap: wrap; font-size: 15.5px; }

/* --- « Revoir ce geste » --- */
.pt-play {
  display: inline-flex; align-items: center; gap: 7px;
  margin-left: auto; min-height: 38px; padding: 7px 14px;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 999px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pt-play svg { width: 14px; height: 14px; fill: currentColor; }
.pt-play:hover { background: var(--accent-2); }

/* --- grand écran : la fiche devient un panneau latéral --- */
@media (min-width: 760px) {
  #app.is-patient #patient-bar {
    grid-template-columns: repeat(2, minmax(0, 240px));
    justify-content: center; background: none; padding-bottom: 16px;
  }
  #patient-sheet {
    left: auto; right: 16px; bottom: 16px; top: auto;
    width: 380px; max-height: min(70%, 560px);
    border-radius: 16px; border: 1px solid var(--border);
    padding: 0 18px 18px;
    transform: translateY(calc(100% + 24px));
  }
  #patient-scrim { background: rgba(10, 22, 27, .18); }
  #app.is-patient #card { bottom: 88px; }
}
/* fiche sans contenu : on le dit, plutôt que de laisser un rectangle blanc */
.pt-empty { margin: 4px 0 8px; font-size: 15px; line-height: 1.5; color: var(--ink-3); }
