/* ===== Couleurs et réglages généraux ===== */
:root {
  color-scheme: light;
  --bg: #f7f2ee;
  --surface: #ffffff;
  --ink: #231816;
  --ink-soft: #6f625c;
  --line: #ece2da;
  --primary: #c81f30;
  --primary-2: #e2342d;
  --accent: #ffd9c4;
  --danger: #8e1a1a;
  --primary-ink: #6e2419;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 30, 20, .06), 0 6px 20px rgba(60, 30, 20, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
/* Texte saisi toujours foncé, même si l'iPhone est en mode sombre */
input, textarea, select { color: var(--ink); -webkit-text-fill-color: var(--ink); }
input::placeholder, textarea::placeholder { color: #b5a79f; -webkit-text-fill-color: #b5a79f; opacity: 1; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ===== Bandeau du haut ===== */
.topbar {
  background:
    repeating-linear-gradient(118deg, rgba(255,255,255,.045) 0 2px, transparent 2px 26px),
    linear-gradient(150deg, #ec3c2e 0%, #c41d31 52%, #8c1028 100%);
  color: #fff;
  padding: calc(18px + var(--safe-top)) calc(20px + var(--safe-right)) 56px calc(20px + var(--safe-left));
}
.topbar-inner { max-width: 960px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: #fff; box-shadow: 0 2px 8px rgba(80,10,20,.25);
}
.brand-mark svg { width: 30px; height: 30px; }
.topbar h1 { margin: 26px 0 6px; font-size: clamp(26px, 5vw, 34px); line-height: 1.15; letter-spacing: -.01em; }
.topbar p { margin: 0; color: rgba(255,255,255,.78); font-size: 16px; }

/* ===== Contenu ===== */
.content {
  max-width: 960px;
  margin: -36px auto 0;
  padding: 0 calc(16px + var(--safe-right)) calc(32px + var(--safe-bottom)) calc(16px + var(--safe-left));
}

/* ===== Grille des profils ===== */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 14px;
}
.profile-card {
  position: relative;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 14px 18px;
  text-align: center;
  transition: transform .12s ease, border-color .12s ease;
}
.profile-card:active { transform: scale(.98); }
.profile-card .select-area {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 100%; background: none; border: 0; padding: 0;
}
.profile-card:hover { border-color: var(--line); }
.profile-name { font-weight: 650; font-size: 16px; line-height: 1.25; }
.badge {
  display: inline-block; font-size: 12.5px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: #fbe8e2; color: var(--primary-2);
}
.badge.kine { background: #e4f0fb; color: #1f5f99; }
.badge.prep { background: #fdf0e0; color: #9a5a10; }
.badge.coach { background: #eef6dc; color: #4d6a12; }
.edit-btn {
  position: absolute; top: 8px; right: 8px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: transparent; color: var(--ink-soft);
  display: grid; place-items: center;
}
.edit-btn:hover { background: var(--bg); }
.edit-btn svg { width: 18px; height: 18px; }

.add-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 182px;
  border: 2px dashed #dccbc1; border-radius: var(--radius);
  background: rgba(255,255,255,.55); color: var(--primary);
  font-weight: 650;
}
.add-card:hover { background: #fff; border-color: var(--primary-2); }
.add-icon {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: var(--accent); font-size: 30px; line-height: 1;
}

/* ===== Avatar ===== */
.avatar {
  width: 84px; height: 84px; border-radius: 50%;
  object-fit: cover; display: grid; place-items: center;
  background: linear-gradient(140deg, #f7ded4, #eec0b0);
  color: var(--primary); font-weight: 700; font-size: 28px;
  overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 44px; height: 44px; font-size: 16px; }

/* ===== Écran vide ===== */
.empty {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 34px 22px; text-align: center;
}
.empty h2 { margin: 12px 0 6px; font-size: 20px; }
.empty p { margin: 0 0 20px; color: var(--ink-soft); }

/* ===== Formulaire ===== */
.form-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 20px; max-width: 620px; margin: 0 auto;
}
.photo-picker { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.photo-picker .avatar { width: 112px; height: 112px; font-size: 36px; position: relative; }
.photo-btn {
  position: relative; border: 0; background: none; padding: 0; border-radius: 50%;
}
.photo-btn .cam {
  position: absolute; right: 2px; bottom: 2px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: var(--accent);
  display: grid; place-items: center; border: 3px solid #fff;
}
.photo-btn .cam svg { width: 17px; height: 17px; }
.link-btn { background: none; border: 0; color: var(--primary-2); font-weight: 600; padding: 6px; }
.link-btn.danger { color: var(--danger); }

.field { margin-bottom: 18px; }
.field label, .field .label {
  display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px; color: var(--ink);
}
.field .req { color: var(--danger); }
.field input[type="text"], .field input[type="tel"], .field input[type="email"] {
  width: 100%; height: 50px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fdfaf8;
  font-size: 17px; /* 16px minimum : évite le zoom automatique sur iPhone */
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.field input:focus { border-color: #4a3530; box-shadow: 0 0 0 4px rgba(74,53,48,.12); background: #fff; }
.field.invalid input { border-color: var(--danger); }
.field .error { color: var(--danger); font-size: 13.5px; margin-top: 6px; display: none; }
.field.invalid .error { display: block; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .row-2 { grid-template-columns: 1fr; gap: 0; } }

/* Choix du titre (boutons segmentés) */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 420px) { .segmented { grid-template-columns: 1fr; } }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 50px; padding: 8px 10px; margin: 0;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fdfaf8;
  font-weight: 600; font-size: 15px; cursor: pointer; transition: all .12s;
}
.segmented input:checked + label { border-color: var(--primary); background: var(--primary); color: #fff; }
.segmented input:focus-visible + label { box-shadow: 0 0 0 4px rgba(74,53,48,.2); }
.field.invalid .segmented label { border-color: var(--danger); }

.form-actions { display: flex; gap: 10px; margin-top: 26px; }
.form-actions .btn { flex: 1; }
.form-footer { text-align: center; margin-top: 18px; }

/* ===== Boutons ===== */
.btn {
  height: 52px; padding: 0 22px; border-radius: 14px; border: 0;
  font-weight: 650; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: #a1172a; }
.btn-ghost { background: #f2ebe6; color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-light { background: rgba(255,255,255,.14); color: #fff; height: 42px; padding: 0 16px; font-size: 15px; }

/* ===== Accueil après sélection ===== */
.user-chip { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.user-chip .avatar { border: 2px solid rgba(255,255,255,.4); }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.action-card {
  display: flex; align-items: center; gap: 16px; width: 100%;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; border: 0; text-align: left; margin-bottom: 14px;
}
.action-card .ic {
  width: 52px; height: 52px; border-radius: 14px; flex: none; display: grid; place-items: center;
  background: var(--primary); color: var(--accent);
}
.action-card .ic svg { width: 26px; height: 26px; }
.action-card h3 { margin: 0 0 3px; font-size: 17px; }
.action-card p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }
.action-card .soon {
  margin-left: auto; font-size: 12px; font-weight: 700; color: var(--ink-soft);
  background: var(--bg); padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin: 26px 4px 10px; }

/* ===== Choix de l'analyse ===== */
.analysis-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 820px) { .analysis-grid { grid-template-columns: repeat(4, 1fr); } }
.analysis-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  background: var(--surface); border: 2px solid transparent; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 16px 20px; text-align: left; min-height: 170px;
  transition: transform .12s ease, border-color .12s ease;
}
.analysis-card:hover { border-color: var(--tint); }
.analysis-card:active { transform: scale(.98); }
.analysis-ic {
  width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center;
  background: var(--tint); font-size: 30px; margin-bottom: 8px;
}
.analysis-ic.big { width: 84px; height: 84px; font-size: 44px; border-radius: 22px; }
.analysis-title { font-weight: 700; font-size: 18px; color: var(--ink); text-transform: uppercase; letter-spacing: .03em; }
.analysis-sub { font-size: 13.5px; color: var(--ink-soft); line-height: 1.35; }
.user-mini { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.avatar.xs { width: 32px; height: 32px; font-size: 13px; border: 2px solid rgba(255,255,255,.4); }

/* ===== Boîte de dialogue ===== */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(35, 24, 22, .45);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.dialog { background: #fff; border-radius: 20px; padding: 24px; max-width: 380px; width: 100%; }
.dialog h3 { margin: 0 0 8px; font-size: 19px; }
.dialog p { margin: 0 0 20px; color: var(--ink-soft); line-height: 1.45; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; }

/* ===== Message temporaire ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-weight: 600; font-size: 15px; transition: all .25s; pointer-events: none; z-index: 60;
  max-width: calc(100% - 40px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.fade-in { animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== Formulaire de bilan ===== */
.bilan-form { max-width: 760px; margin: 0 auto; }
.form-section {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 20px 6px; margin-bottom: 14px;
}
.form-section h2 {
  margin: 0 0 16px; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--primary-2); display: flex; align-items: center; gap: 8px;
}
.form-section h2::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--primary-2); }
.section-hint { margin: -8px 0 14px; color: var(--ink-soft); font-size: 14px; }

.fgrid { display: grid; grid-template-columns: repeat(6, 1fr); column-gap: 14px; }
.fgrid > .field { grid-column: span 6; }
.fgrid > .w-half { grid-column: span 3; }
.fgrid > .w-third { grid-column: span 2; }
@media (max-width: 560px) {
  .fgrid > .m-full { grid-column: span 6; }
  .fgrid > .m-half { grid-column: span 3; }
}
.field input[type="date"] {
  width: 100%; height: 50px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fdfaf8; font-size: 17px; outline: none; -webkit-appearance: none; appearance: none;
  display: flex; align-items: center; min-width: 0;
}
.field input[type="date"]:focus { border-color: #4a3530; box-shadow: 0 0 0 4px rgba(74,53,48,.12); }
.field.invalid input[type="date"], .field.invalid .input-suffix { border-color: var(--danger); }

.input-suffix {
  display: flex; align-items: center; height: 50px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fdfaf8; overflow: hidden; transition: border-color .12s, box-shadow .12s;
}
.input-suffix:focus-within { border-color: #4a3530; box-shadow: 0 0 0 4px rgba(74,53,48,.12); background: #fff; }
.field .input-suffix input[type="text"] { border: 0; height: 100%; background: transparent; box-shadow: none; min-width: 0; }
.input-suffix span { padding: 0 14px 0 4px; color: var(--ink-soft); font-weight: 600; }

/* Choix sous forme de pastilles */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices input { position: absolute; opacity: 0; pointer-events: none; }
.choices label {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  min-height: 46px; padding: 10px 16px; margin: 0;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fdfaf8;
  font-weight: 600; font-size: 15px; cursor: pointer; transition: all .12s; line-height: 1.25;
}
.choices label small { font-weight: 500; font-size: 13px; color: var(--ink-soft); }
.choices input:checked + label { border-color: var(--primary); background: var(--primary); color: #fff; }
.choices input:checked + label small { color: rgba(255,255,255,.75); }
.choices input:focus-visible + label { box-shadow: 0 0 0 4px rgba(74,53,48,.2); }
.field.invalid .choices label { border-color: #e6b4b0; }
/* Liste verticale (options longues) */
.choices.list, .choices.list-2 { display: grid; grid-template-columns: 1fr; }
@media (min-width: 640px) { .choices.list-2 { grid-template-columns: 1fr 1fr; } }
.choices.list label, .choices.list-2 label { text-align: left; }
.choices.inline label { min-width: 90px; align-items: center; }

/* Oui / Non à côté de la question sur grand écran */
@media (min-width: 640px) {
  .field[data-field="antecedents"], .field[data-field="antecedentsCheville"] { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
  .field[data-field="antecedents"] .label, .field[data-field="antecedentsCheville"] .label { margin: 0; }
  .field[data-field="antecedents"] .error, .field[data-field="antecedentsCheville"] .error { flex-basis: 100%; margin-top: -10px; }
}

.computed {
  display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 18px; padding: 12px 14px;
  background: #fcefe9; border-radius: 12px; color: var(--primary-ink); font-size: 14.5px;
}
.computed b { font-weight: 700; }

.btn-block { width: 100%; }
.sticky-actions {
  position: sticky; bottom: 0; margin: 10px -16px 0; padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(243,246,246,0));
}

/* Étapes du bilan */
.stepper { list-style: none; display: flex; gap: 6px; padding: 0; margin: 20px 0 0; }
.stepper li {
  display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600;
  color: rgba(255,255,255,.6); padding: 6px 12px 6px 6px; border-radius: 999px; background: rgba(255,255,255,.08);
}
.stepper li span {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.15); font-size: 12.5px;
}
.stepper li.active { color: #fff; background: rgba(255,255,255,.16); }
.stepper li.active span { background: var(--accent); color: var(--primary); }
.stepper li.done span { background: rgba(255,217,196,.38); color: #fff; }
.save-state { font-size: 13.5px; color: rgba(255,255,255,.75); font-weight: 600; }

/* Récapitulatif */
.recap { padding-bottom: 14px; }
.recap dl { margin: 0; }
.recap dl div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.recap dl div:first-child { border-top: 0; padding-top: 0; }
.recap dt { color: var(--ink-soft); font-size: 14.5px; }
.recap dd { margin: 0; font-weight: 650; text-align: right; font-size: 15px; }
.field .input-suffix input:focus { box-shadow: none; background: transparent; }

/* ===== CAIT ===== */
.info-dot {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.18); color: #fff; font: italic 700 15px Georgia, serif;
  vertical-align: middle; margin-left: 6px; padding: 0;
}
.info-dot.small { width: 22px; height: 22px; font-size: 13px; background: #f8e1d8; color: var(--primary-2); margin-left: 2px; }
.dialog.info { max-width: 460px; }
.info-body { color: var(--ink-soft); line-height: 1.5; font-size: 15px; max-height: 60vh; overflow: auto; margin-bottom: 18px; }
.info-body p { margin: 0 0 10px; }
.info-body b { color: var(--ink); }

.side-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 760px; margin: 0 auto 14px; }
.side-tab {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow); font-weight: 650; color: var(--ink-soft);
}
.side-tab span {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); font-size: 13px; flex: none;
}
.side-tab.active { color: var(--ink); outline: 2px solid var(--primary); }
.side-tab.active span { background: var(--primary); color: var(--accent); }
.side-tab.done:not(.active) span { background: #dff3d0; color: #3b6a12; }

.cait-intro {
  background: #fcefe9; color: var(--primary-ink); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; font-size: 15px;
}
.cait .form-section h2 { margin-bottom: 8px; }
.cait .field .label { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.sticky-actions .progress-count { align-self: center; font-weight: 650; color: var(--ink-soft); font-size: 14.5px; flex: 0 0 auto; }

.score-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.score-card { background: var(--bg); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.score-card span { color: var(--ink-soft); font-size: 14px; font-weight: 600; }
.score-card b { font-size: 30px; color: var(--primary); }
.score-card small { font-size: 15px; color: var(--ink-soft); font-weight: 600; }

/* Étapes : sur petit écran, seul l'intitulé de l'étape en cours est affiché */
@media (max-width: 520px) {
  .stepper li:not(.active) { font-size: 0; gap: 0; padding: 6px; }
  .stepper li:not(.active) span { font-size: 12.5px; }
}

/* ===== Morphostatique ===== */
.label .hint { font-style: normal; font-weight: 500; color: var(--ink-soft); font-size: 13px; }
.choices.multi label { padding-left: 42px; position: relative; }
.choices.multi label::before {
  content: ""; position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; border-radius: 5px; border: 2px solid #dccbc1; background: #fff;
}
.choices.multi input:checked + label::before {
  border-color: #fff; background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c81f30' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center/14px no-repeat;
}

/* ===== Bilan de force (HHD) ===== */
.hhd { padding-bottom: 14px; }
.hhd .section-hint b { text-transform: capitalize; color: var(--ink); }
.hhd-head, .hhd-row {
  display: grid; grid-template-columns: 1.2fr 1.1fr 1.1fr 1fr .8fr; gap: 10px; align-items: center;
}
.hhd-head {
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft);
  padding: 0 0 8px; border-bottom: 1px solid var(--line);
}
.hhd-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.hhd-row:last-child { border-bottom: 0; }
.hhd-mvt { font-weight: 700; font-size: 15.5px; }
.hhd-mvt small { display: block; font-weight: 500; color: var(--ink-soft); font-size: 12.5px; }
.hhd-mlabel { display: none; }
.hhd-input .input-suffix { height: 46px; }
.hhd-input .input-suffix input { font-size: 17px; font-weight: 650; }
.hhd-input.is-lese .input-suffix { border-color: #e6c6ba; background: #fdf6f3; }
.hhd-input.invalid .input-suffix { border-color: var(--danger); }
.hhd-out b { display: block; font-size: 15.5px; }
.hhd-out small { display: block; color: var(--ink-soft); font-size: 12.5px; }
.hhd-norme { grid-column: span 2; color: var(--ink-soft); font-size: 13.5px; }
.muted { color: #bcafa8; }
.side-badge { display: inline-block; font-size: 10.5px; padding: 2px 7px; border-radius: 999px; vertical-align: 1px; letter-spacing: .02em; }
.side-badge.lese { background: #f4e1da; color: #8a2a1d; }
.side-badge.sain { background: #e1f1d6; color: #3f6a14; }
.pill { display: inline-block; padding: 5px 10px; border-radius: 999px; font-weight: 700; font-size: 15px; white-space: nowrap; }
.pill.ok { background: #e1f1d6; color: #2f5a0c; }
.pill.warn { background: #fdecd2; color: #94540a; }
.pill.bad { background: #fadcd8; color: #a3261d; }

/* Sur téléphone : une carte par mouvement */
@media (max-width: 640px) {
  .hhd-head { display: none; }
  .hhd-row { grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 14px 0; }
  .hhd-mvt { grid-column: span 2; }
  .hhd-mlabel { display: block; font-size: 12.5px; font-weight: 650; color: var(--ink-soft); margin-bottom: 5px; }
  .hhd-out { background: var(--bg); border-radius: 12px; padding: 8px 12px; min-height: 58px; }
  .hhd-norme { grid-column: span 2; }
}

/* Tableau du récapitulatif */
.table-wrap { overflow-x: auto; margin: 0 -4px 6px; }
.recap-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.recap-table th, .recap-table td { padding: 9px 6px; text-align: center; border-top: 1px solid var(--line); white-space: nowrap; }
.recap-table thead th { border-top: 0; color: var(--ink-soft); font-size: 12.5px; text-transform: uppercase; }
.recap-table tbody th { text-align: left; font-weight: 650; white-space: normal; }
.recap-table .pill { font-size: 13.5px; padding: 3px 8px; }

/* Corrections de mise en page (champs avec unité, grilles) */
.input-suffix input {
  border: 0; outline: none; background: transparent; width: 100%; height: 100%;
  padding: 0 4px 0 14px; font-size: 17px; min-width: 0; box-shadow: none;
}
.hhd-head, .hhd-row { grid-template-columns: minmax(0,1.1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1.15fr) minmax(0,.8fr); }
.hhd-row > * { min-width: 0; }
@media (max-width: 640px) {
  .hhd-row { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
}
.recap-table th, .recap-table td { padding: 8px 4px; }
.recap-table thead th { font-size: 11.5px; line-height: 1.25; white-space: normal; }
@media (max-width: 520px) {
  .recap-table { font-size: 13.5px; }
  .recap-table tbody th { font-size: 13.5px; }
}

/* ===== Heel Rise ===== */
.hhd .field[data-field="hrProtocole"] { margin-bottom: 14px; }
.metronome { display: flex; align-items: center; gap: 14px; margin: 0 0 12px; flex-wrap: wrap; }
.metronome .btn { height: 44px; font-size: 15px; }
.metronome .btn.on { background: var(--primary); color: var(--accent); }
.metro-beat { font-weight: 800; font-size: 18px; min-width: 120px; }
.metro-beat.up { color: var(--primary-2); }
.metro-beat.down { color: #9a5a10; }
.hr-ref { margin-top: 10px; padding: 12px 14px; background: #fcefe9; border-radius: 12px; font-size: 14px; color: var(--primary-ink); line-height: 1.45; }
.muted-ink { color: var(--ink-soft); font-size: 13px; }
.info-body h4 { margin: 14px 0 4px; font-size: 14px; color: var(--primary-2); text-transform: uppercase; letter-spacing: .05em; }
.info-body h4:first-child { margin-top: 0; }
.info-body ul { margin: 0 0 10px; padding-left: 18px; }
.info-body li { margin-bottom: 4px; }
.info-body .refs { font-size: 12.5px; }
.recap-table tbody th small { display: block; font-weight: 500; color: var(--ink-soft); font-size: 11.5px; }
.warn-ink { color: #94540a; font-size: 13px; }
.hr-comp { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 10px 0 4px; font-weight: 600; color: var(--ink); }
.hr-comp .pill { font-size: 13.5px; margin-left: 4px; }
.recap-table tr.sub th, .recap-table tr.sub td { border-top: 0; padding-top: 0; }
.recap-table tr.sub .pill { white-space: normal; font-size: 11.5px; line-height: 1.2; }
/* Ratio I/E : sur téléphone, droit/gauche puis déficit/LSI */
@media (max-width: 640px) { .hhd-row.ratio .hhd-out { min-height: 58px; } }

/* ===== Tests fonctionnels ===== */
.fonc-card { padding-bottom: 16px; }
.fonc-card.invalid { outline: 2px solid var(--danger); }
.fonc-card.is-nr .fonc-body { opacity: .35; pointer-events: none; }
.fonc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.fonc-head h2 { margin-bottom: 14px; }
.fonc-pts { white-space: nowrap; font-size: 14px; color: var(--ink-soft); background: var(--bg); padding: 5px 10px; border-radius: 999px; }
.fonc-pts b { font-size: 16px; color: var(--primary); }
.fonc-pts.full { background: #e1f1d6; }
.fonc-q { margin-bottom: 16px; }
.fonc-q .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.w-sm { max-width: 170px; }
.time-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tool-row { margin-bottom: 14px; }
.btn.tool { height: 46px; font-size: 15px; min-width: 130px; }
.btn.tool.on { background: var(--primary); color: var(--accent); }
.nr-check { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--ink-soft); font-weight: 600; padding-top: 6px; border-top: 1px dashed var(--line); cursor: pointer; }
.nr-check input { width: 20px; height: 20px; accent-color: var(--primary); }

.sebt-grid {
  display: grid; grid-template-columns: minmax(0,1.3fr) repeat(3, minmax(0,1fr)) minmax(0,.9fr);
  gap: 8px; align-items: center; margin-bottom: 16px;
}
.sebt-grid > span:not(.sebt-dir):not(.sebt-res) { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; text-align: center; }
.sebt-grid .input-suffix { height: 44px; }
.sebt-grid .input-suffix input { padding-left: 10px; font-size: 16px; }
.sebt-grid .input-suffix span { padding-right: 8px; font-size: 13px; }
.sebt-dir { font-weight: 650; font-size: 14.5px; }
.sebt-res { text-align: center; font-weight: 700; font-size: 15px; border-radius: 999px; padding: 5px 4px; background: var(--bg); }
.sebt-res.ok { background: #e1f1d6; color: #2f5a0c; }
.sebt-res.mid { background: #fdecd2; color: #94540a; }
.sebt-res.warn { background: #fadcd8; color: #a3261d; }
@media (max-width: 560px) {
  .sebt-grid { grid-template-columns: repeat(3, minmax(0,1fr)); row-gap: 6px; }
  .sebt-grid > * { order: var(--o, 0); }
  .sebt-grid > span:nth-child(-n+5), .sebt-empty { display: none; }
  .sebt-dir { grid-column: span 2; padding-top: 8px; }
  .sebt-res { margin-top: 8px; }
}
.side-tab em.side-badge { margin-left: auto; font-style: normal; }

.fonc-total {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  background: var(--primary); color: #fff; border-radius: var(--radius); padding: 16px 20px; margin-bottom: 6px;
}
.fonc-total span { font-weight: 600; color: rgba(255,255,255,.8); }
.fonc-total b { font-size: 30px; color: var(--accent); margin-left: auto; }
.fonc-total small { font-size: 15px; color: rgba(255,255,255,.7); }
.fonc-total em { font-style: normal; font-size: 12.5px; background: rgba(255,255,255,.15); padding: 3px 8px; border-radius: 999px; }
.recap-table td small { display: block; color: var(--ink-soft); font-size: 11.5px; }
.recap-table tr.total th, .recap-table tr.total td { font-size: 15.5px; background: #fcefe9; }
.fonc-total b { white-space: nowrap; }
.trials { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .trials { grid-template-columns: 1fr; } }
.trial > span { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; margin-bottom: 5px; }
.trial .w-sm { max-width: 140px; }
.best-time { margin-top: 10px; font-size: 14.5px; color: var(--primary); }
.fonc-q .label .hint { font-weight: 500; }
.trial .opt { font-style: normal; font-weight: 500; text-transform: none; }

/* ===== Repères normatifs ===== */
.pill.mid { background: #fdecd2; color: #94540a; }
.niveau-line { margin: -4px 0 14px; font-size: 14.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.niveau-line:empty { display: none; }
.niveau-line .pill { font-size: 13.5px; }
.computed .pill { font-size: 13px; padding: 3px 9px; margin-left: 4px; }
.recap-table tr.group th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--primary-2); padding-top: 14px; }
.recap-table td .pill { white-space: nowrap; }

/* ===== Questionnaire Ankle-GO ===== */
.q-card { padding-bottom: 10px; }
.q-card.is-nr { opacity: .35; pointer-events: none; }
.faam-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-soft); background: var(--bg); padding: 8px 12px; border-radius: 10px; margin-bottom: 8px; position: sticky; top: 0; z-index: 2; }
.faam-legend b { color: var(--primary); }
.faam-row, .alr-row { padding: 10px 0; border-top: 1px solid var(--line); }
.faam-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 14px; align-items: center; }
@media (max-width: 640px) { .faam-row { grid-template-columns: 1fr; } }
.faam-row.invalid, .alr-row.invalid { background: #fdf1ef; box-shadow: inset 3px 0 0 var(--danger); padding-left: 8px; }
.faam-label { font-size: 15px; line-height: 1.35; }
.faam-label b { color: var(--ink-soft); font-weight: 600; margin-right: 2px; }
.faam-opts, .alr-scale { display: flex; gap: 5px; }
.faam-opts input, .alr-scale input { position: absolute; opacity: 0; pointer-events: none; }
.faam-opts label, .alr-scale label {
  min-width: 42px; height: 40px; display: grid; place-items: center; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fdfaf8; font-weight: 700; font-size: 15px; cursor: pointer; transition: all .1s;
}
.faam-opts label:last-of-type { font-size: 12.5px; }
.faam-opts input:checked + label, .alr-scale input:checked + label { background: var(--primary); border-color: var(--primary); color: #fff; }
.alr-scale { margin-top: 8px; display: grid; grid-template-columns: repeat(11, minmax(0,1fr)); }
.alr-scale label { min-width: 0; height: 40px; font-size: 14.5px; }
.alr-anchors { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }
.q-nr { margin: 4px 4px 14px; border-top: 0; }
.fonc-total { flex-wrap: wrap; }
.fonc-total .ag-sub { display: flex; align-items: baseline; gap: 8px; }
.fonc-total .ag-sub b { font-size: 18px; color: #fff; margin-left: 0; }
.fonc-total .ag-main { flex-basis: 100%; display: flex; align-items: center; gap: 12px; border-top: 1px solid rgba(255,255,255,.18); padding-top: 10px; }
.fonc-total .ag-main b { margin-left: auto; }
.recap-table tr.total.ag th, .recap-table tr.total.ag td { background: #f9e2d9; font-size: 16px; }
.q-card .fonc-head { margin-bottom: 8px; } .q-card .fonc-head h2 { margin-bottom: 0; padding-top: 6px; }
.fonc-total .ag-sub em { color: rgba(255,255,255,.75); font-size: 14px; background: none; padding: 0; }

/* ===== Synthèse Ankle-GO (radar) ===== */
.synth-ag h2 { justify-content: flex-start; }
.radar-wrap { max-width: 560px; margin: 0 auto; }
.radar-ag { width: 100%; height: auto; display: block; font-family: inherit; }
.radar-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 22px; font-weight: 650; font-size: 14.5px; margin: 4px 0 16px; }
.radar-legend span { display: flex; align-items: center; gap: 8px; }
.radar-legend i { width: 22px; height: 4px; border-radius: 2px; display: inline-block; }
.ag-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .ag-cards { grid-template-columns: 1fr; } }
.ag-card { border: 1.5px solid var(--line); border-left: 5px solid var(--c); border-radius: 14px; padding: 14px 16px; }
.ag-card-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.ag-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.ag-card-score { margin: 8px 0 6px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.ag-card-score b { font-size: 34px; color: var(--c); line-height: 1; }
.ag-card-score small { font-size: 16px; color: var(--ink-soft); font-weight: 600; margin-right: 6px; }
.ag-card p { margin: 0; font-size: 14px; color: var(--ink-soft); line-height: 1.45; }
.radar-abbr { font-size: 12px; color: var(--ink-soft); line-height: 1.5; margin: 14px 0 0; }
.synth-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.synth-head h2 { margin: 0; }
.seg-mini { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 3px; }
.seg-mini button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 650; color: var(--ink-soft); }
.seg-mini button.on { background: var(--primary); color: #fff; }

/* ===== WBLT ===== */
.wblt-head, .wblt-row { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,.8fr) minmax(0,.8fr); gap: 10px; align-items: center; }
.wblt-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.wblt-head small { text-transform: none; font-weight: 600; }
.wblt-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.wblt-row > * { min-width: 0; }
.wblt-row .hhd-mvt small { color: var(--ink-soft); font-weight: 500; }
@media (max-width: 640px) {
  .wblt-head { display: none; }
  .wblt-row { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px 12px; }
  .wblt-row .hhd-mvt { grid-column: span 2; }
  .wblt-row .hhd-out { background: var(--bg); border-radius: 12px; padding: 8px 12px; min-height: 58px; }
  .wblt-row .hhd-out:last-child { grid-column: span 2; min-height: 0; }
  .wblt-row .hhd-mlabel small { font-weight: 500; }
}
.recap-table.compact th, .recap-table.compact td { padding: 8px 3px; }
@media (max-width: 520px) { .recap-table.compact { font-size: 13px; } .recap-table.compact .pill { font-size: 12px; padding: 3px 6px; } }

/* ===== Synthèse ===== */
.synth-form textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; background: #fdfaf8; padding: 12px 14px;
  font: inherit; font-size: 16px; line-height: 1.45; resize: vertical; outline: none; margin-bottom: 14px;
}
.synth-form textarea:focus { border-color: #4a3530; box-shadow: 0 0 0 4px rgba(74,53,48,.12); background: #fff; }
.synth-form { padding-bottom: 18px; }
.synth-form .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.kinvent-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.kinvent-row .btn { height: 46px; font-size: 15px; }
.edit-anam { margin: -6px 4px 16px; }
#gen-pdf:disabled { opacity: .6; }
.btn-propose { width: 100%; height: 48px; font-size: 15px; background: #fcefe9; color: var(--primary); border: 1.5px dashed #eab2a2; }
.proposition { margin-top: 14px; border: 1.5px solid #eab2a2; border-radius: 14px; padding: 14px; background: #fef8f5; }
.prop-head { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.prop-head b { color: var(--primary); font-size: 15px; }
.proposition textarea { margin-bottom: 10px; background: #fff; }
.prop-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.prop-actions .btn { height: 44px; font-size: 14.5px; }

/* ===== Verrou d'accès ===== */
.verrou { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, var(--primary) 0%, var(--primary-2) 100%); }
.verrou-card { background: #fff; border-radius: 22px; padding: 30px 24px; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow); }
.verrou-ic { font-size: 44px; margin-bottom: 6px; }
.verrou-card h1 { margin: 0 0 10px; font-size: 22px; }
.verrou-card p { color: var(--ink-soft); line-height: 1.5; margin: 0 0 20px; }
.verrou-contact { margin-top: 16px !important; font-size: 14.5px; }
.verrou-note { font-size: 13px; margin: 10px 0 0 !important; }

/* ===== Échauffement ===== */
.echauf-liste { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 10px; }
.echauf-liste li { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--bg); border-radius: 14px; font-size: 16px; line-height: 1.35; }
.echauf-num { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 800; font-size: 15px; }

/* ===== Minuteur de l'échauffement ===== */
.echauf-txt { display: flex; flex-direction: column; gap: 10px; }
.minuteur { display: flex; gap: 8px; align-items: center; }
.minuteur .btn.tool { min-width: 170px; font-variant-numeric: tabular-nums; background: #fff; }
.minuteur .btn.tool.on { background: var(--primary); color: #fff; }
.minuteur .btn.tool.fini { background: #e1f1d6; color: #2f5a0c; }
.tool-reset { height: 46px; width: 46px; padding: 0; font-size: 20px; background: #fff; }

/* ===== Métronome du Heel Rise ===== */
.metro { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0 0 16px; padding: 12px 14px; border-radius: 14px; background: var(--bg); }
.metro .btn.tool { min-width: 190px; background: #fff; }
.metro .btn.tool.on { background: var(--ink); color: #fff; }
.metro-phase { display: flex; align-items: center; gap: 10px; min-width: 150px; font-weight: 700; color: var(--ink-soft); }
.metro-fleche { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: #fff; color: var(--ink-soft); transition: background .08s, color .08s, transform .08s; font-variant-numeric: tabular-nums; }
.metro.haut .metro-fleche { background: var(--primary); color: #fff; transform: translateY(-3px); }
.metro.bas .metro-fleche { background: var(--ink); color: #fff; transform: translateY(3px); }
.metro.haut .metro-txt { color: var(--primary); }
.metro.bas .metro-txt { color: var(--ink); }
.metro-cpt { margin-left: auto; display: flex; align-items: baseline; gap: 6px; }
.metro-cpt b { font-size: 26px; font-variant-numeric: tabular-nums; }
.metro-cpt small { color: var(--ink-soft); }

/* ===== Tests fonctionnels : deux chevilles par test ===== */
.fonc-ordre b { color: var(--ink); }
.fonc-ordre span { display: block; margin-top: 4px; }
.fonc-card .fonc-head { align-items: center; margin-bottom: 12px; }
.fonc-card .fonc-head h2 { margin-bottom: 0; }
.fonc-sides { display: grid; gap: 10px; }
.fonc-side { border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 14px 12px; background: #fff; position: relative; }
.fonc-side::before { content: ""; position: absolute; left: -1.5px; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; }
.fonc-side.cote-droite::before { background: #2563eb; }
.fonc-side.cote-gauche::before { background: #f08a24; }
.fonc-side.fait { border-color: #cfe5bf; }
.fonc-side.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(142,26,26,.12); }
.fonc-side.is-nr .fonc-body { opacity: .35; pointer-events: none; }
.fonc-side-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.fonc-rang { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #fff; font-weight: 800; font-size: 14px; }
.fonc-side + .fonc-puis + .fonc-side .fonc-rang { background: #fff; color: var(--ink); border: 2px solid var(--ink); }
.fonc-side.fait .fonc-rang { background: #3f7d16; border-color: #3f7d16; color: #fff; }
.fonc-side-nom { font-weight: 750; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fonc-side-head .fonc-pts { margin-left: auto; }
.fonc-puis { text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
@media (min-width: 900px) {
  .fonc-card:not([data-carte=sebt]) .fonc-sides { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; }
  .fonc-card:not([data-carte=sebt]) .fonc-puis { align-self: center; writing-mode: vertical-rl; transform: rotate(180deg); }
}

/* Niveau sous le meilleur temps : pas de chevauchement */
.best-time + .niveau-line { margin: 8px 0 0; }
.best-time:empty + .niveau-line { margin-top: 10px; }
