:root {
  --cream: #FAF7F2;
  --cream-2: #F4EFE6;
  --surface: #FFFFFF;
  --ink: #1A2E26;
  --ink-soft: #5A6B63;
  --forest: #1F4D3F;
  --forest-deep: #143329;
  --caramel: #C4956C;
  --border: #E5DFD5;
  --border-strong: #D4CCBC;
  --success: #4A7C59;
  --error: #B85450;
  --shadow: 0 1px 2px rgba(20, 51, 41, 0.04), 0 8px 24px rgba(20, 51, 41, 0.06);
  --shadow-lg: 0 4px 12px rgba(20, 51, 41, 0.08), 0 24px 48px rgba(20, 51, 41, 0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  overscroll-behavior-y: contain;
}

body {
  font-family: 'Manrope', sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 90% 10%, rgba(31, 77, 63, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 10% 90%, rgba(196, 149, 108, 0.06) 0%, transparent 40%);
}

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    calc(20px + env(safe-area-inset-top, 0px))
    calc(20px + env(safe-area-inset-right, 0px))
    calc(32px + env(safe-area-inset-bottom, 0px))
    calc(20px + env(safe-area-inset-left, 0px));
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: block;
  object-fit: contain;
}
.brand-text { line-height: 1.2; }
.brand-text h1 {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 500;
}
.brand-text p {
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Bouton lecture vocale (text-to-speech).
   Off par défaut : aspect discret, identique à .conn-status.
   On : couleur forêt + label visible pour signaler que la voix parle. */
.tts-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 32px;
}
.tts-toggle:hover, .tts-toggle:focus-visible {
  background: var(--cream-2);
  color: var(--ink);
  border-color: var(--border-strong);
  outline: none;
}
.tts-toggle:focus-visible {
  box-shadow: 0 0 0 3px rgba(31, 77, 63, 0.2);
}
.tts-toggle .tts-label {
  display: none;          /* libellé masqué en off : icône suffit en barre */
}
.tts-toggle.tts-on {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
}
.tts-toggle.tts-on .tts-label {
  display: inline;        /* visible en on pour signaler l'état actif */
}
.tts-toggle.tts-on:hover {
  background: var(--forest-deep);
  color: var(--cream);
}

.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
}
.conn-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-soft);
}
.conn-dot.connected {
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(74, 124, 89, 0.4);
  animation: pulse 2s infinite;
}
.conn-dot.error { background: var(--error); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 124, 89, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(74, 124, 89, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 124, 89, 0); }
}

.view { display: none; flex-direction: column; flex: 1; }
.view.active { display: flex; animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero {
  text-align: center;
  margin: 16px 0 32px;
}
.hero h2 {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 12px;
}
.hero h2 em {
  font-style: italic;
  color: var(--caramel);
  font-weight: 400;
}
.hero p {
  color: var(--ink-soft);
  font-size: 15px;
  max-width: 360px;
  margin: 0 auto;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}
.choice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow);
  width: 100%;
  font-family: inherit;
}
.choice-card:hover, .choice-card:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--forest);
}
.choice-icon {
  width: 56px; height: 56px;
  flex-shrink: 0;
  border-radius: 16px;
  background: var(--cream-2);
  display: grid; place-items: center;
  color: var(--forest);
}
.choice-card:nth-child(2) .choice-icon {
  background: rgba(196, 149, 108, 0.12);
  color: var(--caramel);
}
.choice-text { flex: 1; }
.choice-text h3 {
  font-family: 'Fraunces', serif;
  font-size: 19px;
  font-weight: 500;
  margin-bottom: 4px;
}
.choice-text p {
  font-size: 13px;
  color: var(--ink-soft);
}
.choice-arrow { color: var(--ink-soft); }

.privacy-note {
  margin-top: 28px;
  padding: 14px 16px;
  background: var(--cream-2);
  border-radius: 12px;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.5;
}
.privacy-note strong { color: var(--ink); font-weight: 600; }

.cabinet-card {
  margin-top: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.cabinet-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: linear-gradient(to bottom, var(--cream-2), transparent);
  pointer-events: none;
}
.cabinet-mark {
  width: 52px; height: 52px;
  margin: 0 auto 16px;
  background: var(--forest);
  color: var(--cream);
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 12px rgba(31, 77, 63, 0.15);
}
.cabinet-name {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}
.cabinet-name em {
  font-style: italic;
  color: var(--forest);
  font-weight: 600;
}
.cabinet-tagline {
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 22px;
  position: relative;
  z-index: 1;
}

.specialties {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 26px;
}
.pill {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 100px;
  background: var(--cream-2);
  color: var(--ink);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill-accent {
  background: rgba(184, 84, 80, 0.08);
  color: var(--error);
  border-color: rgba(184, 84, 80, 0.2);
  font-weight: 600;
}

.cabinet-contact {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}
.contact-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--cream-2);
  text-decoration: none;
  color: var(--ink);
  transition: all 0.15s;
  border: 1px solid transparent;
}
.contact-row:hover, .contact-row:active {
  background: var(--surface);
  border-color: var(--forest);
  transform: translateY(-1px);
}
.contact-icon {
  width: 38px; height: 38px;
  background: var(--surface);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--forest);
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.contact-text { flex: 1; min-width: 0; }
.contact-label {
  font-size: 10px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
  font-weight: 600;
}
.contact-value {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
}
.contact-arrow {
  color: var(--ink-soft);
  flex-shrink: 0;
}

.cabinet-divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0 16px;
}

.privacy-line {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.5;
}
.privacy-line strong { color: var(--ink); font-weight: 600; }

.sub-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.back-btn {
  width: 40px; height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--ink);
  transition: all 0.15s;
}
.back-btn:hover { background: var(--cream-2); }
.sub-title {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}
.field label .required { color: var(--error); }
.field-hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 6px;
}

.input, .select, .textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* iOS Safari donne aux <input type="date"> une largeur intrinsèque basée
   sur le texte de l'icône de placeholder ("jj/mm/aaaa") + un bouton
   d'effacement, ce qui déborde du conteneur en mode wizard. On normalise
   l'apparence et on contraint la largeur. */
input[type="date"].input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(31, 77, 63, 0.1);
}
.textarea { resize: vertical; min-height: 80px; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235A6B63' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 44px;
}

.file-zone {
  border: 2px dashed var(--border-strong);
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--cream-2);
  transition: all 0.15s;
}
.file-zone:hover { border-color: var(--forest); background: rgba(31, 77, 63, 0.03); }
.file-zone.has-file { border-style: solid; border-color: var(--forest); background: rgba(74, 124, 89, 0.05); }
.file-zone svg { color: var(--ink-soft); margin-bottom: 8px; }
.file-zone.has-file svg { color: var(--success); }
.file-zone-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.file-zone-hint { font-size: 12px; color: var(--ink-soft); }
.file-zone input[type="file"] { display: none; }

.file-options {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.file-options button {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.file-options button:hover { background: var(--cream-2); }

.check-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 8px;
  user-select: none;
  line-height: 1.45;
}
.check-row:hover { background: var(--cream-2); }
.check-row input[type="checkbox"], .check-row input[type="radio"] {
  width: 20px; height: 20px;
  accent-color: var(--forest);
  flex-shrink: 0;
  margin: 0;
}
.check-row span { font-size: 14px; flex: 1; }
.radio-group { display: flex; gap: 10px; }
.radio-group .check-row { flex: 1; justify-content: center; }

.signature-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.signature-wrap.signed {
  border-color: var(--forest);
  background: rgba(31, 77, 63, 0.02);
}
.signature-canvas {
  display: block;
  width: 100%;
  height: 180px;
  touch-action: none;
  cursor: crosshair;
  background-image:
    linear-gradient(to right, transparent 0, transparent calc(100% - 1px), var(--border) 100%),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 31px,
      var(--border) 32px
    );
  background-size: 100% 100%;
}
.signature-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 14px;
  transition: opacity 0.2s;
}
.signature-wrap.signed .signature-placeholder { opacity: 0; }
.signature-baseline {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 32px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-strong) 8%, var(--border-strong) 92%, transparent);
  pointer-events: none;
}
.signature-x {
  position: absolute;
  left: 12px;
  bottom: 26px;
  color: var(--ink-soft);
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-style: italic;
  pointer-events: none;
  opacity: 0.6;
}
.signature-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  gap: 12px;
}
.signature-meta {
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.4;
  flex: 1;
}
.signature-clear {
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.signature-clear:hover { background: var(--cream-2); color: var(--ink); }
.signature-clear:disabled { opacity: 0.4; cursor: not-allowed; }

.action-bar {
  margin-top: auto;
  padding-top: 20px;
}
.btn {
  width: 100%;
  padding: 18px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary {
  background: var(--forest);
  color: var(--cream);
  box-shadow: 0 4px 14px rgba(31, 77, 63, 0.25);
}
.btn-primary:hover { background: var(--forest-deep); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.section-heading {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 500;
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}
.section-heading:first-child { margin-top: 0; }
.questionnaire-section:first-child .section-heading { margin-top: 0; }

.section-description {
  font-size: 13px;
  color: var(--ink-soft);
  margin: -4px 0 14px;
  line-height: 1.5;
}

.checkbox-group { display: flex; flex-direction: column; gap: 0; }
.checkbox-group.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
}
.checkbox-group.two-cols .check-row { margin-bottom: 0; }

.option-group { margin-bottom: 14px; }
.option-group:last-child { margin-bottom: 0; }
.option-group-heading {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 4px 0 8px;
}

.check-row-emphasized {
  border: 1px solid var(--forest);
  background: rgba(31, 77, 63, 0.04);
}

/* ---------- Wizard (questionnaire pas-à-pas) ----------
   Un champ par écran, gros boutons, gros textes. Conçu pour patients âgés
   ou malvoyants : touch targets >= 64px, font-size >= 18px. */

.view-wizard {
  display: none;
  flex-direction: column;
  flex: 1;
  padding-bottom: 24px;
}
.view-wizard.active { display: flex; }

.wizard-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.wizard-topbar .back-btn { width: 48px; height: 48px; }

.wizard-context {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 14px;
  min-height: 18px;
}

.wizard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
  flex: 1;
}

.wizard-question {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 14px;
}
.wizard-required, .wizard-optional {
  display: inline-block;
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 100px;
  margin-left: 8px;
  vertical-align: middle;
}
.wizard-required { color: var(--error); background: rgba(184, 84, 80, 0.1); }
.wizard-optional { color: var(--ink-soft); background: var(--cream-2); }

.wizard-hint {
  font-size: 16px;
  color: var(--ink-soft);
  margin-bottom: 22px;
  line-height: 1.55;
}

/* Affichage d'un seul champ à la fois ; !important pour battre le style
   inline `display:''` posé par form-renderer (showIf). */
.wizard-fields .questionnaire-section { display: contents; }
.wizard-fields .section-heading,
.wizard-fields .section-description { display: none !important; }
.wizard-fields .field { display: none !important; }
.wizard-fields .field.wizard-active { display: block !important; }
/* Le wizard rend la question lui-même : on masque seulement le <label> de
   question (créé par makeWrap), pas les <label class="check-row"> qui sont
   les contrôles eux-mêmes. */
.wizard-fields .field.wizard-active > label:not(.check-row) { display: none; }
.wizard-fields .field.wizard-active > .field-hint { display: none; }

/* Étape groupée (ex. nom + prénom + date de naissance sur le même écran).
   On réaffiche les labels et hints de chaque champ pour que le patient
   sache à quoi correspond chaque entrée, et on aère la pile. */
.wizard-fields-grouped .field.wizard-active-grouped {
  margin-bottom: 18px;
}
.wizard-fields-grouped .field.wizard-active-grouped:last-of-type {
  margin-bottom: 0;
}
.wizard-fields-grouped .field.wizard-active-grouped > label:not(.check-row) {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}
.wizard-fields-grouped .field.wizard-active-grouped > .field-hint {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 6px;
}
/* Inputs un cran plus compacts en mode groupé pour que les 3 champs tiennent
   à l'écran sans scroll sur un iPhone standard. */
.wizard-fields-grouped .field.wizard-active-grouped .input,
.wizard-fields-grouped .field.wizard-active-grouped .textarea,
.wizard-fields-grouped .field.wizard-active-grouped .select {
  font-size: 17px;
  padding: 14px 16px;
  border-radius: 12px;
}

/* Inputs : grandes tailles pour lisibilité */
.wizard-fields .field.wizard-active .input,
.wizard-fields .field.wizard-active .textarea,
.wizard-fields .field.wizard-active .select {
  font-size: 19px;
  padding: 18px 18px;
  border-radius: 14px;
  border-width: 2px;
}
.wizard-fields .field.wizard-active .textarea { min-height: 120px; }

/* Lignes à cocher : empilées verticalement, grosses */
.wizard-fields .field.wizard-active .radio-group,
.wizard-fields .field.wizard-active .checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wizard-fields .field.wizard-active .checkbox-group.two-cols {
  display: flex; /* on annule le grid 2 colonnes en mode wizard */
}
.wizard-fields .field.wizard-active .check-row {
  display: flex;             /* explicite pour battre tout reset éventuel */
  flex-direction: row;
  align-items: center;       /* case + texte alignés verticalement */
  padding: 14px 18px;        /* plus serré : moins d'espace vide qui faisait
                                « flotter » la case en haut visuellement */
  font-size: 18px;
  min-height: 56px;          /* hauteur cible du touch target */
  border-radius: 14px;
  border-width: 2px;
  margin: 0;
  gap: 16px;                 /* aération entre la case et le texte */
}
.wizard-fields .field.wizard-active .check-row span {
  align-self: center;        /* défensif : ignore tout vertical-align baseline */
  font-size: 18px;
  line-height: 1.3;          /* boîte de texte plus proche du carré du checkbox */
  flex: 1;
}
.wizard-fields .field.wizard-active .check-row input[type="checkbox"],
.wizard-fields .field.wizard-active .check-row input[type="radio"] {
  width: 24px;
  height: 24px;
  margin: 0;
  align-self: center;        /* iOS Safari ignore parfois align-items pour les
                                inputs natifs : on force ici. */
  flex-shrink: 0;
}
.wizard-fields .field.wizard-active .check-row:has(input:checked) {
  border-color: var(--forest);
  background: rgba(31, 77, 63, 0.06);
}

/* Multi-select avec groupes : entête de groupe lisible */
.wizard-fields .field.wizard-active .option-group-heading {
  font-size: 13px;
  margin: 12px 0 8px;
}

/* Signature : pad plus haut en mode wizard */
.wizard-fields .field.wizard-active .signature-canvas { height: 220px; }

.wizard-error {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(184, 84, 80, 0.08);
  border: 1px solid rgba(184, 84, 80, 0.25);
  border-radius: 12px;
  font-size: 15px;
  color: var(--error);
  font-weight: 500;
  display: none;
}
.wizard-error.shown { display: block; }

/* Overlays welcome / review */
.wizard-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 12px;
}
.wizard-overlay-icon {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--cream-2);
  color: var(--forest);
  display: grid;
  place-items: center;
  margin-bottom: 22px;
}
.wizard-overlay-icon.success { background: var(--success); color: white; }
.wizard-overlay-title {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  line-height: 1.2;
}
.wizard-overlay-duration {
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 14px;
}
.wizard-overlay-text {
  font-size: 17px;
  color: var(--ink-soft);
  line-height: 1.55;
  max-width: 420px;
}

/* Footer collant, toujours visible. padding-bottom intègre la safe-area
   iPhone (home indicator) pour ne pas masquer le bouton Suivant. */
.wizard-footer {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 16px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  margin-top: 18px;
  background: linear-gradient(to top, var(--cream) 70%, rgba(250, 247, 242, 0));
}
.btn-large {
  font-size: 18px;
  padding: 22px 22px;
  min-height: 64px;
  border-radius: 16px;
}
.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--border-strong);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--cream-2); }
.btn-ghost[hidden] { display: none; }
.wizard-footer .btn-ghost {
  padding-left: 18px;
  padding-right: 18px;
}
.wizard-footer .btn svg { flex-shrink: 0; }

/* Étape de bienvenue : seul "Commencer" est affiché, on le centre dans
   un format CTA plus compact plutôt que pleine largeur. */
.wizard-footer.wizard-footer-welcome {
  grid-template-columns: 1fr;
  justify-items: center;
}
.wizard-footer.wizard-footer-welcome .btn-primary {
  width: auto;
  min-width: 220px;
  max-width: 320px;
  padding-left: 36px;
  padding-right: 36px;
}

/* La barre de navigation reste toujours visible. Précédemment masquée
   jusqu'au scroll, ce qui piégeait les patients qui ne scrollaient jamais
   sur l'étape « Vos informations » (3 champs empilés, clavier ouvert). */

/* ---------- Language picker ----------
   Affiché à chaque entrée dans l'app. Bloque tout tant que le patient n'a
   pas sélectionné sa langue. Dessin volontairement chaleureux : grande
   carte au centre, prompt rotatif dans 8 langues, cartes pays grosses et
   tactiles. */
.lang-picker {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #1F4D3F 0%, #143329 100%);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.lang-picker.active { display: flex; animation: fadeIn 0.3s ease; }

.lang-picker-card {
  background: var(--surface);
  border-radius: 26px;
  padding: 28px 22px 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  margin: 32px 0;
}

.lang-picker-icon {
  width: 72px; height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: rgba(31, 77, 63, 0.10);
  color: var(--forest);
  display: grid;
  place-items: center;
}

.lang-picker-prompt {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 22px;
  min-height: 1.3em;
  transition: opacity 0.2s ease;
  color: var(--ink);
}

.lang-picker-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lang-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 14px;
  border: 2px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  min-height: 64px;
  color: var(--ink);
}
.lang-card:hover, .lang-card:active, .lang-card:focus-visible {
  border-color: var(--forest);
  background: var(--cream-2);
  outline: none;
  transform: translateY(-1px);
}
.lang-flag {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}
.lang-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.lang-native {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.lang-english {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.2;
}

@media (max-width: 420px) {
  .lang-picker-card { padding: 22px 16px 18px; }
  .lang-picker-prompt { font-size: 22px; margin-bottom: 18px; }
  .lang-picker-list { gap: 10px; }
  .lang-card { padding: 12px 10px; gap: 10px; min-height: 58px; }
  .lang-flag { font-size: 24px; }
  .lang-native { font-size: 15px; }
  .lang-english { font-size: 11px; }
}

/* ---------- RGPD information modal ----------
   Conforme CNIL : info visible par défaut, détails dépliables, case à
   cocher non pré-cochée, validation explicite. Le patient ne peut pas
   continuer tant qu'il n'a pas validé. */
.rgpd-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 51, 41, 0.45);
  backdrop-filter: blur(6px);
  z-index: 110;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.rgpd-modal.active { display: flex; animation: fadeIn 0.25s ease; }

.rgpd-card {
  background: var(--surface);
  border-radius: 22px;
  padding: 26px 26px 22px;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.rgpd-card[hidden] { display: none; }

.rgpd-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.rgpd-icon {
  width: 44px; height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: rgba(31, 77, 63, 0.08);
  color: var(--forest);
  display: grid;
  place-items: center;
}
.rgpd-title {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--ink);
}

.rgpd-summary,
.rgpd-details {
  overflow-y: auto;
  flex: 0 1 auto;
}
.rgpd-text {
  font-size: 16px;
  color: var(--ink);
  line-height: 1.55;
  margin-bottom: 12px;
  text-align: left;
}
.rgpd-text:last-child { margin-bottom: 0; }
.rgpd-text a { color: var(--forest); text-decoration: underline; }
.rgpd-placeholder {
  color: var(--ink-soft);
  font-style: italic;
}

/* Bouton "Voir plus" : volontairement contrasté (forest sur surface) et
   d'une taille tactile généreuse — la CNIL sanctionne une info détaillée
   masquée derrière un lien gris discret. */
.rgpd-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
  padding: 12px 18px;
  min-height: 44px;
  border: 2px solid var(--forest);
  border-radius: 12px;
  background: var(--surface);
  color: var(--forest);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  transition: background 0.15s, color 0.15s;
}
.rgpd-toggle:hover,
.rgpd-toggle:focus-visible {
  background: var(--forest);
  color: var(--cream);
  outline: none;
}
.rgpd-toggle-chevron {
  transition: transform 0.25s ease;
}
.rgpd-toggle.rgpd-toggle-open .rgpd-toggle-chevron {
  transform: rotate(180deg);
}

.rgpd-details {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-bottom: 4px;
  animation: rgpdSlideDown 0.3s ease;
}
.rgpd-details[hidden] { display: none; }
@keyframes rgpdSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.rgpd-section { margin-bottom: 14px; }
.rgpd-section:last-child { margin-bottom: 0; }
.rgpd-section-title {
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--forest);
  margin-bottom: 6px;
}

/* Zone de validation : reste visible (flex-shrink: 0), non scrollable. */
.rgpd-validation {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.rgpd-check {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 14px;
  min-height: 44px;
  user-select: none;
  background: var(--cream-2);
  transition: border-color 0.15s, background 0.15s;
}
.rgpd-check:hover { border-color: var(--forest); }
.rgpd-check:has(input:checked) {
  border-color: var(--forest);
  background: rgba(31, 77, 63, 0.06);
}
.rgpd-check input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--forest);
}
.rgpd-check span {
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}
.rgpd-validation .btn {
  width: 100%;
  min-height: 52px;
}
.rgpd-validation .btn:disabled {
  background: var(--border-strong);
  color: var(--ink-soft);
  box-shadow: none;
  cursor: not-allowed;
}

/* Écran de confirmation après validation. */
.rgpd-confirm {
  background: var(--surface);
  border-radius: 22px;
  padding: 36px 28px 28px;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.rgpd-confirm[hidden] { display: none; }
.rgpd-confirm-icon {
  width: 72px; height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  display: grid;
  place-items: center;
}
.rgpd-confirm-title {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 500;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}
.rgpd-confirm-text {
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.55;
  margin-bottom: 22px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}
/* `.btn` est un flex-container (display:flex) : il se comporte comme un
   bloc et ignore le `text-align: center` du parent. On le re-centre via
   `margin: 0 auto` puisqu'on lui a déjà donné une largeur auto. */
.rgpd-confirm .btn {
  width: auto;
  min-width: 200px;
  padding: 14px 32px;
  margin-left: auto;
  margin-right: auto;
}

/* Tablette portrait / mobile : on serre les paddings. */
@media (max-width: 600px) {
  .rgpd-modal { padding: 12px; }
  .rgpd-card { padding: 22px 20px 18px; }
  .rgpd-title { font-size: 19px; }
  .rgpd-text { font-size: 15px; }
}

.sending-overlay {
  position: fixed;
  inset: 0;
  background: rgba(250, 247, 242, 0.96);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    calc(32px + env(safe-area-inset-top, 0px))
    calc(32px + env(safe-area-inset-right, 0px))
    calc(32px + env(safe-area-inset-bottom, 0px))
    calc(32px + env(safe-area-inset-left, 0px));
  text-align: center;
}
.sending-overlay.active { display: flex; }

.sending-icon {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--surface);
  display: grid; place-items: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
  color: var(--forest);
}
.sending-icon svg {
  animation: rotate 2s linear infinite;
}
@keyframes rotate { to { transform: rotate(360deg); } }

.sending-icon.success { background: var(--success); color: white; }
.sending-icon.success svg { animation: none; }
.sending-icon.error { background: var(--error); color: white; }
.sending-icon.error svg { animation: none; }

.sending-title {
  font-family: 'Fraunces', serif;
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.sending-subtitle {
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 28px;
  max-width: 320px;
}
.sending-progress {
  width: 100%;
  max-width: 280px;
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}
.sending-progress-bar {
  height: 100%;
  background: var(--forest);
  width: 0%;
  transition: width 0.3s;
}

.error-banner {
  background: rgba(184, 84, 80, 0.08);
  border: 1px solid rgba(184, 84, 80, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--error);
  display: none;
}
.error-banner.shown { display: block; }

.fatal-banner {
  background: rgba(184, 84, 80, 0.08);
  border: 1px solid rgba(184, 84, 80, 0.25);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 16px 0;
  font-size: 13px;
  color: var(--error);
  text-align: center;
  line-height: 1.5;
}

/* ---------- Petits écrans (iPhone SE / 13 mini, ≤ 390px) ----------
   On serre les paddings et redescend les très grandes tailles serif pour
   éviter les débordements et les retours à la ligne disgracieux. */
@media (max-width: 390px) {
  .app { padding-left: 16px; padding-right: 16px; }

  header { margin-bottom: 22px; gap: 8px; }
  .brand { gap: 10px; min-width: 0; }
  .brand-text { min-width: 0; }
  .brand-text h1 {
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .conn-status { padding: 5px 10px; font-size: 11px; }

  .hero { margin: 8px 0 24px; }
  .hero h2 { font-size: 26px; }
  .hero p { font-size: 14px; }

  .choice-card { padding: 18px; gap: 14px; }
  .choice-icon { width: 48px; height: 48px; }
  .choice-text h3 { font-size: 17px; }

  .cabinet-card { padding: 24px 18px 18px; }
  .cabinet-name { font-size: 20px; }
  .specialties { margin-bottom: 20px; }
  .pill { font-size: 11px; padding: 5px 10px; }

  .form-card { padding: 18px; }

  .sub-title { font-size: 20px; }

  .wizard-card { padding: 22px 16px; }
  .wizard-question { font-size: 24px; }
  .wizard-hint { font-size: 15px; }
  .wizard-fields .field.wizard-active .input,
  .wizard-fields .field.wizard-active .textarea,
  .wizard-fields .field.wizard-active .select { font-size: 17px; padding: 16px; }
  .wizard-fields .field.wizard-active .check-row {
    padding: 12px 16px;
    font-size: 16px;
    min-height: 52px;
    gap: 14px;
  }
  .wizard-fields .field.wizard-active .check-row span { font-size: 16px; line-height: 1.3; }

  .wizard-fields-grouped .field.wizard-active-grouped { margin-bottom: 14px; }
  .wizard-fields-grouped .field.wizard-active-grouped .input {
    font-size: 16px;
    padding: 13px 14px;
  }

  .btn { padding: 16px; font-size: 15px; }
  .btn-large { padding: 18px; font-size: 17px; min-height: 58px; border-radius: 14px; }
}

/* =========================================================================
   FORM PICKER (after language selection) — replaces the legacy 2-card
   landing. Categories: Urgences (red), Médical (forest), Consentements.
   ========================================================================= */
.form-picker {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}
.form-picker-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.form-picker-heading {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
}
.form-picker-subheading {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 12px 0;
}
.form-picker-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.picker-category-heading {
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
  margin: 18px 4px 4px 4px;
}
.picker-category-heading:first-child { margin-top: 6px; }
.picker-category-urgent { color: #B85450; }

.picker-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  width: 100%;
  font-family: inherit;
  min-height: 84px;
}
.picker-card:hover, .picker-card:active, .picker-card:focus-visible {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  border-color: var(--forest);
  outline: none;
}
.picker-card-icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
}
.picker-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.picker-card-title {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}
.picker-card-subtitle {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.35;
}
.picker-card-chev {
  font-size: 28px;
  line-height: 1;
  color: var(--ink-soft);
  flex-shrink: 0;
  font-weight: 600;
}
.picker-card-sent-badge {
  background: rgba(31, 77, 63, 0.12);
  color: var(--forest);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 100px;
  flex-shrink: 0;
}

/* Urgence variant — same red as the cabinet card's .pill-accent */
.picker-card-urgent {
  border-color: rgba(184, 84, 80, 0.55);
  border-width: 1.5px;
}
.picker-card-urgent:hover,
.picker-card-urgent:active,
.picker-card-urgent:focus-visible {
  border-color: #B85450;
}

/* "Sent" state wins over urgent red — patient should clearly see ✓ */
.picker-card-sent {
  border-color: rgba(31, 77, 63, 0.45);
  border-width: 1.5px;
  opacity: 0.95;
}

/* Secondary card (free document upload) — quieter than the main forms */
.picker-card-secondary {
  background: var(--cream-2);
  border-style: dashed;
}
.picker-card-secondary .picker-card-title { font-size: 15px; }
.picker-card-secondary .picker-card-subtitle { font-size: 12px; }

@media (max-width: 480px) {
  .picker-card { padding: 14px; gap: 12px; min-height: 76px; }
  .picker-card-icon { width: 48px; height: 48px; }
  .picker-card-title { font-size: 16px; }
}

/* =========================================================================
   STATIC TEXT BLOCKS (consent forms) — legal paragraphs the patient must
   read before signing. Rendered inline in the form (via form-renderer).
   ========================================================================= */
.field-static {
  background: var(--cream-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 6px 0 14px 0;
}
.field-static .static-heading {
  font-weight: 600;
  color: var(--ink);
  font-size: 16px;
  margin-bottom: 6px;
}
.field-static .static-body {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.field-static-emphasized {
  background: #FFF8E1;
  border-color: rgba(184, 84, 80, 0.35);
}
.field-static-emphasized .static-body {
  font-weight: 500;
}

/* =========================================================================
   CONSENT READER VIEW (single-page "read & sign" for the 4 consents)
   ========================================================================= */
.view-consent .consent-subtitle {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 14px 0;
}
.consent-form .field { margin-bottom: 14px; }
/* Consent forms display every field in one scroll — no wizard active-class
   masking. Reset the .wizard-fields rule that would hide siblings. */
.consent-form,
.consent-form .field { display: block !important; }

