/* Psychos — identité « studio clinique ». Couche visuelle sans impact métier. */
:root {
  --bg: #f5f1ea;
  --surface: #fffdf9;
  --surface-2: #faf6ef;
  --surface-3: #eee8df;
  --border: #e5ddd2;
  --border-strong: #cec2b4;
  --text: #2c2038;
  --text-2: #50455c;
  --muted: #7b7083;
  --primary: #6646a3;
  --primary-dark: #38264f;
  --primary-soft: #eee6fa;
  --primary-softer: #f8f3ff;
  --coral: #ff7163;
  --coral-dark: #c94b43;
  --coral-soft: #ffe8e2;
  --mint: #70d6b3;
  --mint-dark: #237a61;
  --mint-soft: #def7ee;
  --butter: #f4c95d;
  --success: #237a61;
  --success-soft: #def7ee;
  --danger: #b74449;
  --danger-soft: #fbe8e8;
  --warn: #91640d;
  --warn-soft: #fff2cf;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow-sm: 0 2px 0 rgba(56,38,79,.04), 0 8px 24px rgba(56,38,79,.055);
  --shadow-md: 0 3px 0 rgba(56,38,79,.05), 0 20px 50px rgba(56,38,79,.1);
  --ring: 0 0 0 4px rgba(102,70,163,.18);
}

html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  font-family: "Segoe UI Variable", "Aptos", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% 8%, rgba(112,214,179,.13), transparent 26rem),
    radial-gradient(circle at 94% 35%, rgba(255,113,99,.1), transparent 25rem),
    var(--bg);
  letter-spacing: -.005em;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .22;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}

h1, h2, h3 { letter-spacing: -.035em; }
h1 { font-size: clamp(2rem, 4vw, 3.15rem); font-weight: 780; }
h2 { font-size: 1.45rem; font-weight: 760; }
h3 { font-size: 1.08rem; }
a { transition: color .2s ease; }
::selection { color: var(--primary-dark); background: var(--mint); }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.15em; height: 1.15em; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow { display: block; color: var(--butter); font-size: .72rem; font-weight: 800; letter-spacing: .13em; line-height: 1.2; text-transform: uppercase; }
.eyebrow--coral { color: var(--coral-dark); }
.eyebrow--mint { color: var(--mint-dark); }

/* Navigation */
.topnav {
  width: min(1380px, calc(100% - 2rem));
  min-height: 68px;
  margin: .75rem auto 0;
  padding: .55rem .65rem .55rem 1rem;
  border: 1px solid rgba(229,221,210,.85);
  border-radius: 20px;
  background: rgba(255,253,249,.82);
  box-shadow: 0 12px 38px rgba(56,38,79,.08);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}
.topnav__brand { display: inline-flex; align-items: center; gap: .7rem; font-size: 1.16rem; font-weight: 800; color: var(--primary-dark); }
.brand-mark { position: relative; display: inline-flex; align-items: end; gap: 3px; width: 32px; height: 32px; padding: 6px; border-radius: 11px 11px 13px 9px; background: var(--primary-dark); transform: rotate(-3deg); box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.brand-mark i { display: block; width: 6px; border-radius: 6px; transform-origin: bottom; animation: brand-breathe 4s ease-in-out infinite; }
.brand-mark i:nth-child(1) { height: 10px; background: var(--coral); }
.brand-mark i:nth-child(2) { height: 18px; background: var(--mint); animation-delay: -.3s; }
.brand-mark i:nth-child(3) { height: 14px; background: var(--butter); animation-delay: -.6s; }
.topnav__links { gap: .25rem; }
.topnav__links .nav-link { display: inline-flex; align-items: center; gap: .45rem; min-height: 42px; padding: .55rem .75rem; border-radius: 12px; color: var(--text-2); font-size: .88rem; font-weight: 650; }
.topnav__links .nav-link { justify-content: center; }
.topnav__links .nav-link:hover { color: var(--primary-dark); background: var(--primary-softer); transform: translateY(-1px); }
.topnav__links .nav-link.is-active { color: var(--primary-dark); background: var(--primary-soft); }
.topnav__links .nav-link.is-active .icon { color: var(--primary); }
.topnav__user { display: grid; place-items: center; width: 38px; height: 38px; margin-left: .35rem; border: 2px solid var(--surface); border-radius: 50% 46% 48% 44%; color: #fff; background: var(--coral); box-shadow: 0 0 0 2px var(--coral-soft); font-size: .8rem; font-weight: 800; }
.topnav__logout { display: inline-flex; margin: 0; }

.container { max-width: 1120px; padding: 2.25rem 1.75rem 4rem; animation: page-in .55s cubic-bezier(.2,.8,.2,1) both; }
.container--wide { max-width: 1480px; }
.container--dashboard { max-width: 1320px; }

/* Composants globaux */
.card { border-color: rgba(206,194,180,.72); padding: 1.55rem 1.65rem; box-shadow: var(--shadow-sm); }
.card:hover { border-color: rgba(102,70,163,.24); }
.toolbar h1, .toolbar h2, .page-head h1 { margin-block: 0; }
.page-head { margin-bottom: 1.8rem; }
.page-head__sub { font-size: 1rem; }

.btn {
  min-height: 42px;
  padding: .62rem 1.05rem;
  border: 0;
  border-radius: 13px 13px 15px 11px;
  background: var(--primary);
  box-shadow: 0 3px 0 var(--primary-dark), 0 8px 18px rgba(102,70,163,.18);
  transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s ease, background .2s ease, color .2s ease;
}
.btn:hover { background: #7655b4; transform: translateY(-2px); box-shadow: 0 5px 0 var(--primary-dark), 0 12px 24px rgba(102,70,163,.2); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--primary-dark); }
.btn--secondary { border: 1px solid var(--border-strong); color: var(--primary-dark); background: var(--surface); box-shadow: 0 2px 0 var(--border-strong); }
.btn--secondary:hover { color: var(--primary-dark); border-color: var(--primary); background: var(--primary-softer); box-shadow: 0 4px 0 var(--primary-soft), 0 9px 18px rgba(56,38,79,.08); }
.btn--ghost { color: var(--text-2); background: transparent; box-shadow: none; }
.btn--ghost:hover { color: var(--primary-dark); background: var(--primary-soft); box-shadow: none; }
.btn--danger { background: var(--danger); box-shadow: 0 3px 0 #7f2e32; }
.btn--icon { width: 40px; min-height: 40px; padding: 0; border-radius: 12px; }
.btn--sm { min-height: 34px; padding: .42rem .68rem; border-radius: 10px; }
.btn--block { display: flex; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], select, textarea,
.form-row input, .form-row select, .form-row textarea {
  min-height: 45px;
  border-color: var(--border-strong);
  border-radius: 12px;
  background: rgba(255,253,249,.92);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
/* Chevron dessiné plutôt que celui du navigateur : le natif se colle à la
   bordure (aucun navigateur ne laisse le placer) et n'a ni la couleur ni le
   trait arrondi de la charte. `background-image` et non le raccourci
   `background`, qui effacerait la couleur de fond posée juste au-dessus.
   ⚠️ `.form-row select` doit figurer ici : la règle ci-dessus le vise par ce
   sélecteur-là, et son raccourci `background` l'emporterait sur un simple
   `select` — le chevron disparaîtrait de tous les formulaires. */
select, .form-row select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1.5 1.5 6 6l4.5-4.5' stroke='%2350455c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.95rem center;
  background-size: 12px 8px;
}
/* Le sélecteur multiple déroule ses options : pas de chevron à dessiner. */
select[multiple], .form-row select[multiple] { background-image: none; padding-right: 0.65rem; }
input:hover, select:hover, textarea:hover { border-color: #a99ab7; }
input:focus, select:focus, textarea:focus { transform: translateY(-1px); }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; border-radius: 5px; }

table { border-collapse: separate; border-spacing: 0; }
th { color: var(--muted); letter-spacing: .08em; }
td { border-color: var(--border); }
.table-hover tbody tr { transition: background .18s ease, transform .18s ease; }
.table-hover tbody tr:hover { background: var(--primary-softer); }
.badge { padding: .24rem .62rem; font-weight: 700; }
.badge--active { color: var(--mint-dark); }
.badge--archived { color: var(--warn); }
.messages li { border-radius: 13px; box-shadow: var(--shadow-sm); }

/* Tableau de bord */
.dashboard-hero { position: relative; display: grid; grid-template-columns: minmax(0,1.1fr) minmax(340px,.9fr); min-height: 350px; overflow: hidden; margin-bottom: 2.2rem; padding: 3rem 3.2rem; border-radius: 34px 29px 38px 26px; color: #fff; background: var(--primary-dark); box-shadow: 0 8px 0 #261936, 0 28px 70px rgba(56,38,79,.2); isolation: isolate; }
.dashboard-hero::before { content: ""; position: absolute; width: 320px; height: 320px; left: -110px; bottom: -230px; border: 70px solid rgba(112,214,179,.15); border-radius: 46% 54% 45% 55%; transform: rotate(24deg); }
.dashboard-hero::after { content: ""; position: absolute; width: 90px; height: 90px; right: 38%; top: -38px; border-radius: 42% 58% 62% 38%; background: var(--coral); opacity: .88; }
.dashboard-hero__copy { position: relative; z-index: 2; align-self: center; max-width: 610px; }
.dashboard-hero h1 { margin: .55rem 0 .45rem; color: #fff; font-size: clamp(2.8rem,5vw,4.8rem); line-height: .98; overflow-wrap: anywhere; }
.dashboard-hero p { max-width: 520px; margin: 0; color: rgba(255,255,255,.72); font-size: 1.14rem; }
.dashboard-hero__actions { display: flex; gap: .7rem; margin-top: 1.65rem; }
.btn--light { color: var(--primary-dark); background: var(--butter); box-shadow: 0 4px 0 #bd8e27; }
.btn--light:hover { color: var(--primary-dark); background: #ffd878; box-shadow: 0 6px 0 #bd8e27; }
.btn--hero-ghost { color: #fff; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); box-shadow: none; }
.btn--hero-ghost:hover { color: #fff; background: rgba(255,255,255,.15); box-shadow: none; }
.dashboard-hero__art { position: absolute; right: -1.5%; bottom: -4%; z-index: 1; width: min(48%, 570px); }
.dashboard-hero__art img { position: relative; z-index: 2; display: block; width: 100%; filter: drop-shadow(0 22px 18px rgba(20,10,30,.24)); animation: mascot-float 6s ease-in-out infinite; }
.orbit { position: absolute; display: block; border-radius: 50%; }
.orbit--one { width: 280px; height: 280px; right: 9%; bottom: 6%; border: 1px solid rgba(255,255,255,.18); }
.orbit--two { width: 24px; height: 24px; left: 10%; top: 20%; background: var(--mint); box-shadow: 190px -50px 0 -7px var(--butter), 250px 90px 0 -4px var(--coral); animation: orbit-shift 8s ease-in-out infinite; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0,1fr) 290px; gap: 2rem; align-items: start; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1rem; }
.section-head h2 { margin: .25rem 0 0; }
.section-head--spaced { margin-top: 2.3rem; }
.count-pill { display: grid; place-items: center; min-width: 30px; height: 30px; border-radius: 40% 60% 52% 48%; color: #fff; background: var(--coral); font-size: .8rem; font-weight: 800; }
.text-link { display: inline-flex; align-items: center; gap: .3rem; color: var(--primary); font-size: .86rem; font-weight: 700; }
.text-link:hover { text-decoration: none; gap: .5rem; }
.resume-list { display: grid; gap: .7rem; }
.resume-card { display: flex; align-items: center; gap: .9rem; min-height: 82px; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: 17px 14px 19px 15px; color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s ease, border-color .22s ease; }
.resume-card:hover { border-color: rgba(255,113,99,.5); text-decoration: none; transform: translateX(5px) rotate(-.15deg); box-shadow: var(--shadow-md); }
.resume-card__mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px 17px 12px 16px; color: var(--coral-dark); background: var(--coral-soft); transform: rotate(-3deg); }
.resume-card__body { display: grid; min-width: 0; flex: 1; }
.resume-card__body small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.resume-card__action { display: inline-flex; align-items: center; gap: .35rem; color: var(--primary); font-size: .84rem; font-weight: 750; }
.recent-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; }
.patient-card { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: .75rem; padding: .9rem; border: 1px solid var(--border); border-radius: 17px; color: var(--text); background: rgba(255,253,249,.7); transition: transform .2s ease, background .2s ease, box-shadow .2s ease; }
.patient-card:hover { text-decoration: none; background: var(--surface); box-shadow: var(--shadow-sm); transform: translateY(-3px); }
.patient-card__avatar { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 48% 52% 43% 57%; color: var(--primary-dark); background: var(--mint); font-size: .74rem; font-weight: 850; }
.patient-card:nth-child(3n+2) .patient-card__avatar { background: var(--butter); transform: rotate(3deg); }
.patient-card:nth-child(3n) .patient-card__avatar { background: var(--coral-soft); transform: rotate(-3deg); }
.patient-card__body { display: grid; min-width: 0; }
.patient-card__body strong, .patient-card__body small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.patient-card__body small { color: var(--muted); }
.dashboard-side { display: grid; gap: 1rem; }
.metric-card { position: relative; overflow: hidden; padding: 1.35rem; border-radius: 24px 20px 27px 19px; }
.metric-card { color: var(--text); background: var(--mint); box-shadow: 0 6px 0 #49ab8d; }
.metric-card__top { display: flex; justify-content: space-between; align-items: center; }
.metric-card__icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 15px; color: #fff; background: var(--primary-dark); transform: rotate(-4deg); }
.metric-card__value { display: block; margin-top: 1rem; font-size: 3.4rem; line-height: .95; letter-spacing: -.06em; }
.metric-card__label { font-weight: 650; }
.metric-card__spark { display: flex; align-items: end; gap: 5px; height: 32px; margin-top: 1.2rem; }
.metric-card__spark i { width: 12px; height: 35%; border-radius: 6px; background: rgba(56,38,79,.3); }
.metric-card__spark i:nth-child(2) { height: 55%; }.metric-card__spark i:nth-child(3) { height: 42%; }.metric-card__spark i:nth-child(4) { height: 80%; }.metric-card__spark i:nth-child(5) { height: 100%; background: var(--primary-dark); }
.empty-state { display: flex; align-items: center; gap: 1rem; padding: 1.2rem; border: 1px dashed var(--border-strong); border-radius: 18px; color: var(--muted); background: rgba(255,253,249,.5); }
.empty-state p { margin: .15rem 0 0; }.empty-state__shape { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--mint-dark); background: var(--mint-soft); font-weight: 900; }

/* Connexion */
.auth-shell { background: var(--primary-dark); }
.auth-shell::before { opacity: .1; }
.container--auth { max-width: none; min-height: 100vh; margin: 0; padding: 0; }
.auth-layout { display: grid; grid-template-columns: minmax(420px,1.1fr) minmax(400px,.9fr); min-height: 100vh; }
.auth-story { position: relative; display: flex; flex-direction: column; overflow: hidden; padding: 2rem clamp(2rem,5vw,5rem); color: #fff; background: var(--primary-dark); isolation: isolate; }
.auth-story::before { content: ""; position: absolute; width: 420px; height: 420px; right: -220px; top: -220px; border: 80px solid rgba(112,214,179,.12); border-radius: 42% 58%; transform: rotate(30deg); }
.auth-story::after { content: ""; position: absolute; width: 80px; height: 80px; left: 8%; bottom: 8%; border-radius: 44% 56% 60% 40%; background: var(--butter); transform: rotate(18deg); }
.auth-brand { position: relative; z-index: 2; display: inline-flex; align-items: center; gap: .7rem; width: max-content; color: #fff; font-size: 1.25rem; font-weight: 800; }
.auth-brand:hover { color: #fff; text-decoration: none; }
.auth-story__copy { position: relative; z-index: 2; max-width: 620px; margin-top: clamp(3rem,9vh,7rem); }
.auth-story h1 { margin: .8rem 0 1rem; color: #fff; font-size: clamp(3rem,6vw,6rem); line-height: .92; }
.auth-story p { max-width: 550px; color: rgba(255,255,255,.7); font-size: 1.16rem; }
.auth-story__art { position: absolute; z-index: 1; right: -3%; bottom: 0; width: min(62%,700px); filter: drop-shadow(0 28px 22px rgba(0,0,0,.2)); animation: mascot-float 6s ease-in-out infinite; }
.auth-panel { display: grid; place-items: center; padding: 2.5rem; background: var(--bg); }
.auth-card { width: min(440px,100%); }
.auth-card h2 { margin: .35rem 0 .3rem; font-size: 2.4rem; }
.auth-card > .muted { margin: 0 0 2rem; }
.auth-card .form-row { margin-bottom: 1.1rem; }
.auth-card .btn { margin-top: .6rem; }
.auth-card__forgot { display: block; margin-top: 1.2rem; text-align: center; font-size: .88rem; font-weight: 700; }
.auth-panel__foot { position: absolute; bottom: 1rem; color: var(--muted); font-size: .75rem; }

/* Cahier et écrans métier */
.booklet-layout { grid-template-columns: 286px minmax(0,1fr); gap: 1.5rem; }
.booklet-nav { top: 6rem; }
.booklet-nav__card { border-radius: 22px; }
.booklet-nav__item { border-radius: 12px; }
/* Le sous-test courant se signale par son fond seul : pas de barre de couleur
   à gauche (ni ici, ni sur les cartes de consignes plus bas). */
.booklet-nav__item.is-current { background: var(--primary-soft); box-shadow: none; }
.booklet-nav__link { border-radius: 11px; transition: transform .18s ease, background .18s ease; }
.booklet-nav__link:hover { transform: translateX(3px); }
.booklet { border-radius: 24px; }
.booklet-guide { border-radius: 18px; background: linear-gradient(135deg, var(--mint-soft), #fff8e7); }
.booklet-guide__summary { padding: 1rem 1.2rem; }
.booklet-guide__icon { border: 3px solid #fff; border-radius: 19px 15px 21px 14px; box-shadow: 0 5px 0 var(--border), 0 13px 25px rgba(56,38,79,.1); transform: rotate(-2deg); transition: transform .3s ease; }
.booklet-guide:hover .booklet-guide__icon { transform: rotate(2deg) scale(1.035); }
.rule-picto { border-radius: 9px; }
.booklet-guide__section { border-radius: 14px; border-top-width: 0; box-shadow: none; }
.chip { border-radius: 10px; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.chip:hover { transform: translateY(-2px); }
.chip:has(input:checked) { box-shadow: 0 3px 0 var(--primary-dark); }
.folder-card { border-radius: 16px; background: var(--surface-2); transition: transform .2s ease, box-shadow .2s ease; }
.folder-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.capture-modal {
  align-items: start;
  justify-items: center;
  padding: clamp(1rem, 5vh, 3rem) 1rem;
  background: rgba(44, 32, 56, .72);
  backdrop-filter: blur(8px);
}
.capture-modal__panel.card {
  width: min(700px, 100%);
  max-height: calc(100vh - 2rem);
  margin: 0 auto;
  padding: 0;
  overflow: hidden auto;
  border: 0;
  border-radius: 26px;
  text-align: left;
  animation: modal-in .28s cubic-bezier(.2,.9,.2,1) both;
}
.capture-modal__head {
  position: sticky;
  top: 0;
  z-index: 3;
  align-items: center;
  padding: 1.25rem 1.4rem;
  color: #fff;
  background: var(--primary-dark);
}
.capture-modal__head h2 { color: #fff; font-size: 1.45rem; }
.capture-modal__head p { color: rgba(255,255,255,.7); }
.capture-modal__eyebrow { display: block; margin-bottom: .25rem; color: var(--butter); font-size: .68rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.capture-modal__close { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid rgba(255,255,255,.22); border-radius: 12px; color: #fff; background: rgba(255,255,255,.09); cursor: pointer; font: inherit; font-size: 1.35rem; }
.capture-modal__close:hover { background: rgba(255,255,255,.18); }
.capture-modal__body { padding: 1.25rem 1.4rem 1.35rem; }
.capture-pairing { display: grid; grid-template-columns: 250px minmax(0,1fr); align-items: center; gap: 1.5rem; }
.capture-qr {
  display: grid;
  place-items: center;
  width: fit-content;
  margin: 0 auto;
  padding: .65rem;
  line-height: 0;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 0 var(--border);
}
.capture-qr svg {
  display: block;
  width: min(220px, calc(100vw - 6rem));
  height: auto;
  margin-inline: auto;
}
.capture-pairing__instructions h3 { margin: 0 0 .45rem; font-size: 1.2rem; }
.capture-pairing__instructions p { margin: .4rem 0; line-height: 1.45; }
.capture-pairing__fallback { margin-top: .85rem !important; padding-top: .8rem; border-top: 1px solid var(--border); font-size: .82rem; }
.capture-pairing__ttl { font-size: .78rem; }
.capture-qr__url { max-width: 100%; font-size: .68rem !important; }
.capture-received { margin-top: 1.35rem; padding-top: 1.1rem; }
.capture-received__head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: .8rem; }
.capture-received__head h3 { margin: .2rem 0 0; color: var(--text); font-size: 1rem; letter-spacing: -.01em; text-transform: none; }
.capture-received__head > .muted { font-size: .75rem; }
.capture-received__eyebrow { color: var(--mint-dark); font-size: .68rem; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }
.capture-received__empty { display: flex; align-items: center; gap: .75rem; padding: .9rem; border: 1px dashed var(--border-strong); border-radius: 14px; color: var(--muted); background: var(--surface-2); }
.capture-received__empty span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: var(--mint-dark); background: var(--mint-soft); font-size: 1.2rem; }
.capture-received__empty p { margin: 0; }
.capture-pages { display: grid; grid-template-columns: repeat(auto-fill,minmax(128px,1fr)); gap: .75rem; }
.capture-page { position: relative; min-width: 0; padding: .55rem; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow-sm); cursor: grab; transition: transform .16s ease, border-color .16s ease, opacity .16s ease; }
.capture-page:hover { border-color: var(--primary); transform: translateY(-2px); }
.capture-page.is-dragging { opacity: .42; transform: scale(.97); }
.capture-page__preview { position: relative; display: grid; place-items: center; overflow: hidden; aspect-ratio: 4/5; border-radius: 10px; background: var(--surface-3); }
.capture-page__preview img { width: 100%; height: 100%; object-fit: cover; }
.capture-page__fallback { color: var(--muted); font-size: .74rem; font-weight: 800; letter-spacing: .08em; }
.capture-page__number { position: absolute; left: .4rem; top: .4rem; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 9px; color: #fff; background: var(--primary-dark); font-size: .72rem; font-weight: 850; box-shadow: 0 2px 8px rgba(44,32,56,.2); }
.capture-page__handle { position: absolute; right: .35rem; top: .35rem; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 8px; color: var(--primary-dark); background: rgba(255,253,249,.88); font-size: 1rem; }
.capture-page__meta { display: flex; justify-content: space-between; align-items: center; gap: .4rem; padding: .5rem .1rem .25rem; font-size: .76rem; }
.capture-page__meta a { font-weight: 700; }
.capture-page__moves { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin: 0; }
.capture-page__moves button { min-height: 30px; border: 1px solid var(--border); border-radius: 9px; color: var(--primary-dark); background: var(--surface-2); cursor: pointer; font-weight: 800; }
.capture-page__moves button:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.capture-page__moves button:disabled { opacity: .3; cursor: default; }
.capture-pages.has-order-error::after { content: "La réorganisation n’a pas pu être enregistrée."; grid-column: 1/-1; color: var(--danger); font-size: .78rem; }
.capture-modal__actions { display: flex; justify-content: flex-end; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.capture-modal__actions form { margin: 0; }

/* Le polling ne doit animer ni la modale ni le fragment reçu : les animations
   HTMX globales produisaient un trait violet à chaque actualisation. */
#capture-modal.htmx-swapping,
#capture-modal.htmx-settling,
.capture-modal .htmx-swapping,
.capture-modal .htmx-settling { opacity: 1 !important; transform: none !important; transition: none !important; animation: none !important; }

/* Les boutons de dépôt explicites sont exclusivement le repli sans JS. La
   variante .btn--block de la DA ne doit pas les rendre visibles sur mobile. */
.upload-actions__go.btn--block { display: none; }
.capture-mobile > h1 { color: #fff; }
.capture-mobile > .muted { color: rgba(255,255,255,.66); }
.capture-mobile form { margin: .85rem 0; }
.capture-mobile .capture-mobile__action { min-height: 58px; }
.capture-mobile-pages { margin: 1rem 0 1.35rem; padding: 1rem; border-radius: 20px; background: rgba(255,253,249,.96); box-shadow: 0 5px 0 rgba(20,10,30,.18); }
.capture-mobile-pages__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.capture-mobile-pages__head h2 { margin: 0; font-size: 1.1rem; }
.capture-mobile-pages__head span { color: var(--muted); font-size: .8rem; font-weight: 700; }
.capture-mobile-pages__grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .65rem; }
.capture-mobile-page { min-width: 0; padding: .35rem; border: 1px solid var(--border); border-radius: 13px; background: #fff; }
.capture-mobile-page__preview { position: relative; display: grid; place-items: center; overflow: hidden; aspect-ratio: 4/5; border-radius: 9px; color: var(--muted); background: var(--surface-3); font-size: .65rem; font-weight: 800; }
.capture-mobile-page__preview img { width: 100%; height: 100%; object-fit: cover; }
.capture-mobile-page__preview strong { position: absolute; left: .3rem; top: .3rem; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 8px; color: #fff; background: var(--primary-dark); font-size: .7rem; }
.capture-mobile-page form { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; margin: .35rem 0 0; }
.capture-mobile-page form button { min-height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 8px; color: var(--primary-dark); background: var(--surface-2); font-weight: 850; }
.capture-mobile-page form button:disabled { opacity: .3; }
.capture-mobile-pages__hint { margin: .75rem 0 0; color: var(--muted); font-size: .75rem; text-align: center; }

/* Animations HTMX et apparition progressive */
.htmx-swapping { opacity: 0; transform: translateY(5px); transition: opacity .15s ease, transform .15s ease; }
.htmx-settling { animation: settle-in .28s ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes settle-in { from { opacity: .6; transform: translateY(5px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.97); } }
@keyframes mascot-float { 0%,100% { transform: translateY(0) rotate(-.3deg); } 50% { transform: translateY(-9px) rotate(.5deg); } }
@keyframes orbit-shift { 50% { transform: translate(12px,-8px) rotate(30deg); } }
@keyframes brand-breathe { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(.82); } }

@media (max-width: 1000px) {
  .topnav__links .nav-link span { display: none; }
  .topnav__links .nav-link { padding-inline: .7rem; }
  .dashboard-hero { grid-template-columns: 1fr; }
  .dashboard-hero__art { opacity: .78; width: 48%; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-side { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .auth-story__art { width: 75%; right: -14%; }
}
@media (max-width: 760px) {
  .topnav { width: calc(100% - 1rem); margin-top: .5rem; padding-left: .7rem; }
  .topnav__brand > span:last-child { display: none; }
  .topnav__user { display: none; }
  .container { padding: 1.5rem 1rem 3rem; }
  .dashboard-hero { min-height: 430px; padding: 2rem 1.5rem; border-radius: 26px; }
  .dashboard-hero__art { right: -10%; width: 75%; opacity: .5; }
  .dashboard-hero__copy { align-self: start; }
  .dashboard-hero__actions { align-items: flex-start; flex-direction: column; }
  .recent-grid, .dashboard-side { grid-template-columns: 1fr; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-story { min-height: 44vh; padding: 1.5rem; }
  .auth-story__copy { margin-top: 2.5rem; }
  .auth-story h1 { font-size: clamp(2.7rem,13vw,4rem); }
  .auth-story__art { width: 50%; opacity: .62; }
  .auth-panel { padding: 2.5rem 1.3rem 4rem; }
  .auth-panel__foot { display: none; }
  .checklist { min-width: 900px; }
  .card:has(.checklist) { overflow-x: auto; }
  .capture-modal { padding: .75rem .65rem; }
  .capture-modal__panel.card { max-height: calc(100vh - 1.5rem); }
  .capture-pairing { grid-template-columns: 1fr; }
  .capture-pairing__instructions { text-align: center; }
  .capture-modal__body { padding: 1rem; }
}
@media (max-width: 520px) {
  .topnav__links { gap: 0; }
  .topnav__links .nav-link { padding-inline: .5rem; }
  .topnav__logout { display: none; }
  .resume-card__action { font-size: 0; }.resume-card__action .icon { font-size: 1rem; }
  .patient-card { grid-template-columns: auto minmax(0,1fr); }.patient-card .badge { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Responsive system: final overrides shared by desktop, tablet and mobile. */
@media (max-width: 1100px) {
  .container { padding-inline: 1.25rem; }
  .topnav { width: calc(100% - 1.5rem); }
  .dashboard-hero { grid-template-columns: minmax(0, 1fr) minmax(260px, .7fr); padding-inline: 2.25rem; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr) 250px; gap: 1.25rem; }
  .booklet-layout { grid-template-columns: 250px minmax(0, 1fr); gap: 1rem; }
  .capture-modal__panel.card { width: min(680px, 100%); }
  .card:has(.checklist) { overflow-x: auto; }
  .checklist { min-width: 880px; }
}

@media (max-width: 960px) {
  .topnav__links .nav-link span { display: none; }
  .topnav__links .nav-link { padding-inline: .7rem; }
  .dashboard-hero { grid-template-columns: 1fr; min-height: 390px; }
  .dashboard-hero__art { width: 42%; opacity: .72; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-layout { grid-template-columns: minmax(320px, 1fr) minmax(340px, .9fr); }
  .auth-story__art { width: 75%; right: -14%; }
  .booklet-layout { grid-template-columns: 1fr; }
  .booklet-nav { position: static; max-height: none; }
  .booklet-nav__card { margin-bottom: 1.25rem; }
  .booklet-nav__list { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .35rem; overflow: visible; }
  .booklet-nav__add { grid-column: 1 / -1; }
  .booklet-grid thead th { top: 0; }
}

@media (max-width: 760px) {
  .topnav { width: calc(100% - 1rem); min-height: 58px; margin-top: .5rem; padding: .45rem .5rem .45rem .7rem; border-radius: 16px; }
  .topnav__brand > span:last-child, .topnav__user { display: none; }
  .topnav__links { gap: 0; }
  .topnav__links .nav-link { min-width: 40px; padding-inline: .55rem; }
  .topnav__logout { display: none; }
  .container { width: 100%; padding: 1.25rem .75rem 3rem; }
  .card { padding: 1.1rem; border-radius: 16px; }
  .page-head { align-items: stretch; gap: .75rem; margin-bottom: 1.15rem; }
  .page-head__title { font-size: clamp(1.55rem, 7vw, 2.1rem); }
  .page-head__actions { display: flex; width: 100%; flex-direction: row; align-items: stretch; gap: .5rem; }
  .page-head__actions > form,
  .page-head__actions > .btn { width: auto; min-width: 0; flex: 1; }
  .page-head__actions > form .btn { width: 100%; }
  .page-head__actions .btn { min-width: 0; padding-inline: .55rem; }
  .toolbar { align-items: stretch; }
  .toolbar > *, .toolbar form { max-width: 100%; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions .btn { width: 100%; }
  .dashboard-hero { min-height: 440px; margin-bottom: 1.4rem; padding: 1.65rem 1.2rem; border-radius: 24px; }
  .dashboard-hero h1 { font-size: clamp(2.35rem, 13vw, 4rem); }
  .dashboard-hero p { font-size: 1rem; }
  .dashboard-hero__art { right: -12%; bottom: -2%; width: 78%; opacity: .46; }
  .dashboard-hero__actions { align-items: stretch; flex-direction: column; }
  .dashboard-hero__actions .btn { width: 100%; }
  .recent-grid, .dashboard-side { grid-template-columns: 1fr; }
  .section-head { align-items: flex-start; flex-direction: column; gap: .5rem; }
  .resume-card { min-height: 72px; padding: .75rem; }
  .resume-card__action { font-size: 0; }
  .resume-card__action .icon { font-size: 1rem; }
  .patient-card { grid-template-columns: auto minmax(0, 1fr); }
  .patient-card .badge { display: none; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-story { min-height: 43vh; padding: 1.25rem; }
  .auth-story__copy { margin-top: 2rem; }
  .auth-story h1 { font-size: clamp(2.65rem, 13vw, 4rem); }
  .auth-story__art { width: 52%; opacity: .58; }
  .auth-panel { padding: 2rem .85rem 3rem; }
  .auth-card h2 { font-size: 2rem; }
  .booklet__head { align-items: flex-start; flex-direction: column; gap: .65rem; }
  .booklet__head form, .booklet__skip-action { width: 100%; }
  .booklet-guide__summary { grid-template-columns: 54px minmax(0, 1fr) auto; gap: .65rem; padding: .75rem; }
  .booklet-guide__icon { width: 54px; height: 54px; }
  .booklet-guide__sections { grid-template-columns: 1fr; }
  .booklet-guide__toggle { width: 2.25rem; height: 2.25rem; flex-basis: 2.25rem; }
  .booklet__grid-wrap, .symbol-bonus { margin-inline: -.15rem; }
  .booklet-grid { min-width: 680px; }
  .checklist { min-width: 880px; }
  .capture-modal { padding: .75rem .65rem; }
  .capture-modal__panel.card { max-height: calc(100vh - 1.5rem); border-radius: 20px; }
  .capture-pairing { grid-template-columns: 1fr; }
  .capture-pairing__instructions { text-align: center; }
  .capture-modal__body { padding: 1rem; }
  .capture-pages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.3rem; }
  .topnav__links .nav-link { padding-inline: .42rem; }
  .topnav__links .icon { width: 1.05rem; height: 1.05rem; }
  .topnav__brand .brand-mark { width: 29px; height: 29px; }
  .booklet-nav__list { grid-template-columns: 1fr 1fr; }
  .booklet-nav__link { min-height: 42px; }
  .booklet-nav__link { display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; align-items: start; gap: .3rem; min-width: 0; }
  .booklet-nav__label { min-width: 0; overflow-wrap: anywhere; }
  .booklet-nav__meta { max-width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  .booklet-guide__summary { grid-template-columns: 46px minmax(0, 1fr) auto; }
  .booklet-guide__icon { width: 46px; height: 46px; }
  .booklet-guide__eyebrow { font-size: .62rem; }
  .booklet-guide__summary strong { font-size: .95rem; }
  .capture-pages { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .capture-modal__head { padding: 1rem; }
  .capture-modal__head h2 { font-size: 1.2rem; }
  .capture-modal__body { padding: .8rem; }
}

@media (max-width: 600px) {
  body { overflow-x: hidden; }
  .card:has(> table) { overflow-x: auto; }
  .casefile-index { display: block; width: 100%; }
  .casefile-index thead { display: none; }
  .casefile-index tbody, .casefile-index tr { display: block; }
  .casefile-index tbody tr:not(:has(td[colspan])) {
    margin: 0 0 .7rem;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
  }
  .casefile-index tbody tr:not(:has(td[colspan])):last-child { margin-bottom: 0; }
  .casefile-index td {
    display: grid;
    grid-template-columns: minmax(7.5rem, .8fr) minmax(0, 1.2fr);
    gap: .65rem;
    align-items: baseline;
    padding: .45rem 0;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
  }
  .casefile-index td:last-child { border-bottom: 0; }
  .casefile-index td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
  }
  .casefile-index td[colspan] { display: block; padding: .5rem; }
  .casefile-index td[colspan]::before { content: none; }
  .casefile-index .muted { overflow-wrap: anywhere; }

  /* Les tableaux métier deviennent des fiches verticales : aucune colonne
     ne pousse la page hors écran, et chaque valeur garde son contexte. */
  .mobile-stack-table {
    display: block;
    width: 100%;
    min-width: 0 !important;
    table-layout: auto;
  }
  .mobile-stack-table thead { display: none; }
  .mobile-stack-table tbody,
  .mobile-stack-table tbody tr { display: block; }
  .mobile-stack-table tbody tr:not(:has(td[colspan])) {
    margin: 0 0 .7rem;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
  }
  .mobile-stack-table tbody tr:last-child { margin-bottom: 0; }
  .mobile-stack-table td {
    display: grid;
    grid-template-columns: minmax(6.5rem, .8fr) minmax(0, 1.2fr);
    gap: .65rem;
    align-items: center;
    width: 100%;
    min-width: 0;
    padding: .5rem 0;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
  }
  .mobile-stack-table td:last-child { border-bottom: 0; }
  .mobile-stack-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .07em;
    line-height: 1.25;
    text-transform: uppercase;
  }
  .mobile-stack-table td[colspan] { display: block; padding: .5rem; }
  .mobile-stack-table td[colspan]::before { content: none; }
  .mobile-stack-table input[type="text"],
  .mobile-stack-table input[type="date"],
  .mobile-stack-table textarea,
  .mobile-stack-table select { min-width: 0; width: 100%; }
  .mobile-stack-table .upload-actions { justify-content: flex-start; }
  .mobile-stack-table .upload-actions form { min-width: 0; }

  /* Les lignes d'items du cahier suivent la même logique, avec les libellés
     propres à chaque type de grille. */
  .booklet-grid {
    display: block;
    width: 100%;
    min-width: 0 !important;
    table-layout: auto;
  }
  .booklet-grid thead { display: none; }
  .booklet-grid tbody,
  .booklet-grid tbody tr { display: block; }
  .booklet-grid tbody tr:not(.booklet-row--intro):not(.booklet-row--example) {
    margin: 0 0 .65rem;
    padding: .7rem;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-2);
  }
  .booklet-grid td {
    display: grid;
    grid-template-columns: minmax(6.5rem, .75fr) minmax(0, 1.25fr);
    gap: .6rem;
    align-items: center;
    width: 100%;
    min-width: 0;
    padding: .45rem 0;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
  }
  .booklet-grid td:last-child { border-bottom: 0; }
  .booklet-grid td::before {
    color: var(--muted);
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .06em;
    line-height: 1.2;
    text-transform: uppercase;
  }
  .booklet-grid td:nth-child(1)::before { content: "Item"; }
  .booklet-grid--verbal td:nth-child(2)::before,
  .booklet-grid--image-memory td:nth-child(3)::before { content: "Réponse"; }
  .booklet-grid--verbal td:nth-child(3)::before,
  .booklet-grid--image-memory td:nth-child(4)::before { content: "Note"; }
  .booklet-grid--image-memory td:nth-child(2)::before { content: "Réponse correcte"; }
  .booklet-grid--arithmetic td:nth-child(2)::before { content: "Temps"; }
  .booklet-grid--arithmetic td:nth-child(3)::before { content: "Réponse donnée"; }
  .booklet-grid--arithmetic td:nth-child(4)::before { content: "Répétition"; }
  .booklet-grid--arithmetic td:nth-child(5)::before { content: "Note"; }
  .booklet-grid--construction td:nth-child(2)::before { content: "Modèle"; }
  .booklet-grid--construction td:nth-child(3)::before { content: "Présentation"; }
  .booklet-grid--construction td:nth-child(4)::before { content: "Cubes"; }
  .booklet-grid--construction td:nth-child(5)::before { content: "Limite"; }
  .booklet-grid--construction td:nth-child(6)::before { content: "Temps"; }
  .booklet-grid--construction td:nth-child(7)::before { content: "Note partielle"; }
  .booklet-grid--construction td:nth-child(8)::before { content: "Construction"; }
  .booklet-grid--construction td:nth-child(9)::before { content: "Note"; }
  .booklet-grid--letter-number td:nth-child(2)::before { content: "Essai"; }
  .booklet-grid--letter-number td:nth-child(3)::before { content: "Réponse correcte"; }
  .booklet-grid--letter-number td:nth-child(4)::before { content: "Réponse"; }
  .booklet-grid--letter-number td:nth-child(5)::before { content: "Note d'essai"; }
  .booklet-grid--letter-number td:nth-child(6)::before { content: "Note"; }
  .booklet-grid--mcq td:nth-child(2)::before { content: "Réponse de l'enfant"; }
  .booklet-grid--mcq td:nth-child(3)::before { content: "Note"; }
  .booklet-grid--mcq-timed td:nth-child(2)::before { content: "Temps"; }
  .booklet-grid--mcq-timed td:nth-child(3)::before { content: "Réponse de l'enfant"; }
  .booklet-grid--mcq-timed td:nth-child(4)::before { content: "Note"; }
  .booklet-grid--multi-choice td:nth-child(2)::before { content: "Réponse de l'enfant"; }
  .booklet-grid--multi-choice td:nth-child(3)::before { content: "Réponse attendue"; }
  .booklet-grid--multi-choice td:nth-child(4)::before { content: "Note"; }
  .booklet-grid--memory td:not(:first-child):not(:last-child)::before { content: "Essai"; }
  .booklet-grid--memory td:last-child::before { content: "Note"; }
  .booklet-grid--prereq td:nth-child(2)::before { content: "Réponse correcte"; }
  .booklet-grid--prereq td:nth-child(3)::before { content: "Réussi"; }
  .booklet-grid--prereq td:nth-child(4)::before { content: "Échoué"; }
  .booklet-grid td[colspan] { display: block; }
  .booklet-grid td[colspan]::before { content: none; }
  .booklet-grid .col-note,
  .booklet-grid .col-timer { white-space: normal; }
  .booklet-grid input[type="text"],
  .booklet-grid textarea { min-width: 0; width: 100%; }
  .booklet-grid .chips { justify-content: flex-start; }
}
