/* ==========================================================================
   Analyse des compétences — TIM — Feuille de style principale
   Charte graphique de l'école (ÉSAT) :
     Oranges  : #e65300 · #f18919 · #f8a915 (à ne jamais superposer entre eux)
     Noirs    : #000000 · #333333
   Police de titres et de texte : Hanken Grotesk (alternative gratuite,
     proche de TT Forms) — Police technique : DM Mono (badges, horodatages)
   ========================================================================== */

:root {
  --header-height: 68px; /* valeur de secours ; mesurée précisément par app.js */
  --font-display: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Neutres (mode clair) */
  --bg: #FFFFFF;
  --bg-alt: #F5F5F5;
  --surface: #FFFFFF;
  --surface-2: #F5F5F5;
  --text: #000000;
  --text-muted: #333333;
  --border: #E0E0E0;
  --border-strong: #CCCCCC;

  /* Accent — dérivé du orange profond de la charte (#E65300), très légèrement
     assombri pour respecter un contraste de lecture AA sur fond blanc */
  --accent: #CF4A00;
  --accent-hover: #B84200;
  --accent-soft: rgba(207, 74, 0, 0.06);
  --accent-contrast: #FFFFFF;

  /* Chip / badge neutre à fort contraste (utilise les deux noirs de marque) */
  --ink: #000000;
  --ink-soft: #F0F0F0;
  --ink-contrast: #FFFFFF;

  --danger: #A5342B;
  --danger-soft: #F6E4E2;
  --success: #2E6E49;
  --success-soft: #E4EFE7;
  --warning: #8A5C0D;
  --warning-soft: #FBE9CE;

  --radius-s: 4px;
  --radius-m: 8px;
  --radius-l: 14px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-2: 0 6px 20px rgba(0, 0, 0, 0.12);

  --focus-ring: 0 0 0 3px rgba(207, 74, 0, 0.35);

  color-scheme: light;
}

html[data-theme="dark"] {
  /* Neutres (mode sombre) — ancrés sur les deux noirs de marque, avec un
     texte clair à fort contraste pour corriger les problèmes de lisibilité */
  --bg: #000000;
  --bg-alt: #1A1A1A;
  --surface: #171717;
  --surface-2: #333333;
  --text: #FFFFFF;
  --text-muted: #C2C2C2;
  --border: #333333;
  --border-strong: #4D4D4D;

  /* Accent (orange plus clair — meilleure lisibilité sur fond noir) */
  --accent: #F18919;
  --accent-hover: #F8A915;
  --accent-soft: rgba(241, 137, 25, 0.16);
  --accent-contrast: #141414;

  --ink: #FFFFFF;
  --ink-soft: #262626;
  --ink-contrast: #141414;

  --danger: #E29089;
  --danger-soft: #3B2320;
  --success: #8FCBA6;
  --success-soft: #1F3427;
  --warning: #F8A915;
  --warning-soft: #332708;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 10px 24px rgba(0, 0, 0, 0.6);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 .5em;
  color: var(--text);
}
h1 { font-size: clamp(1.7rem, 1.4rem + 1.2vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; font-weight: 700; }

p { margin: 0 0 1em; max-width: 72ch; }

a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-s);
}

code, .mono { font-family: var(--font-mono); font-size: .9em; }

/* ---------- Layout ---------- */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Bande utilitaire (au-dessus de l'en-tête) ---------- */
.utility-bar {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
}
.utility-bar__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: .45rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.utility-bar__user {
  display: flex;
  align-items: center;
  gap: .7rem;
  color: var(--text-muted);
}
.utility-bar__user a { font-weight: 600; text-decoration: none; }
.utility-bar__user a:hover { text-decoration: underline; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: .8rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand small {
  display: block;
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: .02em;
}
.nav {
  display: flex;
  justify-content: flex-end;
  gap: .25rem;
  flex-wrap: wrap;
  flex: 1;
}
.nav a {
  text-decoration: none;
  color: var(--text-muted);
  padding: .45rem .7rem;
  border-radius: var(--radius-s);
  font-size: .93rem;
}
.nav a:hover { background: var(--bg-alt); color: var(--text); }
.nav a.is-active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  width: 100%;
  flex: 1;
}
.container--tight { max-width: 760px; }

/* ---------- Mise en page avec table des matières (formulaire, vues admin) ---------- */
.layout-with-toc {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (min-width: 960px) {
  .layout-with-toc { grid-template-columns: 1fr 230px; }
  .layout-with-toc__main { min-width: 0; }
}

.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 1rem 1.1rem;
}
@media (min-width: 960px) {
  .toc {
    position: sticky;
    top: calc(var(--header-height) + 1.25rem);
    max-height: calc(100vh - var(--header-height) - 2.5rem);
    overflow-y: auto;
  }
}
.toc__title {
  font-family: var(--font-mono);
  font-size: .74rem;
  color: var(--text-muted);
  margin-bottom: .6rem;
}
.toc__list, .toc__sublist { list-style: none; margin: 0; padding: 0; }
.toc__sublist { margin: .25rem 0 .5rem .65rem; border-left: 1px solid var(--border); padding-left: .65rem; }
.toc__item { margin-bottom: .25rem; }
.toc__item a {
  display: block;
  padding: .3rem .4rem;
  border-radius: var(--radius-s);
  font-size: .87rem;
  text-decoration: none;
  color: var(--text);
  line-height: 1.3;
}
.toc__item a:hover { background: var(--bg-alt); }
.toc__item--sous a { font-size: .83rem; color: var(--text-muted); }
.toc__item a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.toc__item--sous a.is-active { color: var(--accent); }

/* Décalage de défilement pour que les ancres ne se cachent jamais sous
   le bandeau sticky du site (.topbar) */
.form-section__body, [id^="element-"] {
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

/* ---------- Modale ---------- */
dialog.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 0;
  width: min(680px, 92vw);
  max-height: min(80vh, 760px);
  box-shadow: var(--shadow-2);
  background: var(--surface);
  color: var(--text);
}
dialog.modal::backdrop { background: rgba(0,0,0,.45); }
.modal__inner { display: flex; flex-direction: column; max-height: min(80vh, 760px); }
.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.modal__header h2 { margin: 0; font-size: 1.2rem; }
.modal__close {
  border: none;
  background: var(--bg-alt);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}
.modal__close:hover { background: var(--border); color: var(--text); }
.modal__body { padding: 1.4rem; overflow-y: auto; }
.modal__meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem 1.2rem; margin: 0 0 1.4rem; }
.modal__meta dt { font-family: var(--font-mono); font-size: .72rem; color: var(--text-muted); margin-bottom: .15rem; }
.modal__meta dd { margin: 0; font-size: .95rem; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-header__eyebrow {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: .3rem;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .3rem;
  cursor: pointer;
}
.theme-toggle button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  width: 30px;
  height: 26px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
}
.theme-toggle button.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-1);
}

/* ---------- Cards / panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 1.5rem;
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 1.25rem; }
.card--flush { padding: 0; overflow: hidden; }

/* Élément de compétence — zone d'en-tête mise en avant dans le formulaire */
.element-card { margin-bottom: 1.75rem; }
/* Le conteneur ne doit PAS avoir overflow:hidden (il casserait le
   position:sticky du repère) : les coins arrondis sont portés par l'en-tête. */
.card--flush.element-card { overflow: visible; }
.element-card__header {
  background: var(--accent-soft);
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  border-radius: calc(var(--radius-l) - 1px) calc(var(--radius-l) - 1px) 0 0;
}
.element-card__eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--accent);
  margin-bottom: .2rem;
}
.element-card__title {
  margin: 0;
  font-size: 1.3rem;
}
.element-card__desc {
  margin: .5rem 0 0;
  font-size: .92rem;
  color: var(--text);
  opacity: .85;
}
.element-card__body { padding: 1.5rem; }

/* Repère compact « quel élément est en cours » : collé sous le bandeau du
   site une fois le grand en-tête sorti de l'écran. Sa hauteur nette dans le
   flux est nulle (marge négative) pour ne jamais déplacer le contenu. */
.element-card__pin {
  --pin-h: 2.6rem;
  position: sticky;
  top: var(--header-height);
  z-index: 6;
  height: var(--pin-h);
  margin-bottom: calc(var(--pin-h) * -1);
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 0 1.4rem;
  background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .12s ease;
}
.element-card__pin.is-visible { opacity: 1; visibility: visible; }
.element-card__pin-num {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--accent);
  white-space: nowrap;
}
.element-card__pin-title {
  font-weight: 700;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-l);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-2);
}
.panel-empty h3 { color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-body);
  font-size: .93rem;
  font-weight: 600;
  padding: .6rem 1.1rem;
  border-radius: var(--radius-m);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-alt); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: .38rem .7rem; font-size: .83rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1.3rem; }
.field label, .field legend {
  display: block;
  font-weight: 600;
  font-size: .92rem;
  margin-bottom: .4rem;
  color: var(--text);
}
.field .hint {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: .35rem;
}
.field .error { font-size: .82rem; color: var(--danger); margin-top: .35rem; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], textarea, select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  padding: .68rem .8rem;
  line-height: 1.45;
}
textarea { resize: vertical; min-height: 5.5rem; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
select { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem 1.3rem;
}
.form-row--split-1-2 {
  grid-template-columns: 1fr 2fr;
}
@media (max-width: 560px) {
  .form-row--split-1-2 { grid-template-columns: 1fr; }
}

.checkbox-row { display: flex; align-items: center; gap: .5rem; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 500; }

fieldset { border: none; padding: 0; margin: 0; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-family: var(--font-mono);
  font-size: .74rem;
  padding: .22rem .55rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge--neutre  { background: var(--bg-alt); color: var(--text-muted); }
.badge--actif   { background: var(--accent-soft); color: var(--accent); }
.badge--complete{ background: var(--success-soft); color: var(--success); }
.badge--role-admin { background: var(--ink); color: var(--ink-contrast); }
.badge--role-collab { background: var(--bg-alt); color: var(--text-muted); }
.badge--inactif { background: var(--danger-soft); color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-m); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .7rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-family: var(--font-mono); font-size: .72rem; text-transform: none; letter-spacing: .01em; color: var(--text-muted); background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
td.actions { text-align: right; white-space: nowrap; }

/* ---------- Flash messages ---------- */
.flash { border-radius: var(--radius-m); padding: .8rem 1rem; margin-bottom: 1rem; font-size: .93rem; border: 1px solid transparent; }
.flash--succes { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.flash--erreur { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.flash--info { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.flash--persistant { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.flash--persistant span { overflow-wrap: anywhere; user-select: text; }
.flash__close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: .1rem .3rem;
  border-radius: var(--radius-s);
  opacity: .75;
}
.flash__close:hover { opacity: 1; background: rgba(0, 0, 0, .08); }

/* ---------- Login / auth pages ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.5rem; }
.auth-card .brand-mark { font-family: var(--font-mono); font-size: .78rem; color: var(--text-muted); margin-bottom: .5rem; }
.auth-foot { text-align: center; margin-top: 1.2rem; font-size: .88rem; color: var(--text-muted); }

/* ---------- Dropdown-driven view selectors ---------- */
.selector-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1.75rem;
}
.selector-bar .field { margin-bottom: 0; min-width: 240px; flex: 1; }

/* ---------- Competence form ---------- */
.competence-meta {
  display: flex;
  gap: .6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: .3rem;
}
.section-banner {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-m);
  padding: 1.1rem 1.4rem;
  margin: 3rem 0 1.75rem;
}
.section-banner--first { margin-top: 0; }
.section-banner__eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--accent);
  margin-bottom: .25rem;
}
.section-banner__title {
  margin: 0;
  font-size: 1.4rem;
  color: var(--text);
}

/* ---------- Sections repliables pleine largeur (formulaire d'analyse) ---------- */
.section-toggle__heading { margin: 3rem 0 0; }
.section-toggle__heading:first-child { margin-top: 0; }

.section-toggle {
  display: block;
  width: 100vw;
  position: relative;
  left: 50%;
  margin-left: -50vw;
  border: none;
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.section-toggle:hover { background: var(--accent-soft); }
.section-toggle__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.3rem 1.25rem;
}
.section-toggle__eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--accent);
  margin-bottom: .25rem;
}
.section-toggle__title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}
.section-toggle__chevron {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
  transition: transform .2s ease;
  margin-right: .3rem;
}
.section-toggle[aria-expanded="false"] .section-toggle__chevron { transform: rotate(-45deg); }

.form-section__body {
  overflow: hidden; /* repli pour les très vieux navigateurs */
  overflow: clip;   /* n'empêche pas position:sticky des enfants */
  transition: max-height .3s ease, opacity .25s ease, margin .25s ease;
  opacity: 1;
  padding-top: 1.75rem;
}
.form-section__body.is-collapsed {
  max-height: 0 !important;
  opacity: 0;
  padding-top: 0;
  pointer-events: none;
}

.question-block { margin-bottom: 2rem; }
.question-block__desc { color: var(--text-muted); font-size: .9rem; margin-top: -.4rem; margin-bottom: .9rem; }

/* Répéteur de blocs de texte */
.repeater { display: flex; flex-direction: column; gap: .6rem; }
.repeater-item {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}
.repeater-item > .wysiwyg { flex: 1; min-width: 0; }
.repeater-item .wysiwyg__editable { min-height: 3.6rem; }
.repeater-item--select { align-items: flex-start; }
.select-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .75rem; }
.repeater-item--select .select-field { width: 100%; max-width: 360px; }

/* Texte descriptif de l'option choisie (ex. niveau taxonomique) */
.select-desc__item {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  padding: .7rem 1rem;
  font-size: .93rem;
  max-width: 62ch;
}
.select-desc__item[hidden] { display: none; }
.select-niveaux summary {
  cursor: pointer;
  font-size: .85rem;
  color: var(--accent);
  font-weight: 600;
  width: fit-content;
}
.select-niveaux[open] summary { margin-bottom: .6rem; }
.select-niveaux dl { margin: 0; max-width: 62ch; }
.select-niveaux dt { font-weight: 700; font-size: .9rem; margin-top: .7rem; }
.select-niveaux dt:first-child { margin-top: 0; }
.select-niveaux dd { margin: .15rem 0 0; font-size: .88rem; color: var(--text-muted); }
.repeater-item__controls {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.repeater-item__controls button {
  width: 28px; height: 24px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: .8rem;
  line-height: 1;
}
.repeater-item__controls button:hover { color: var(--accent); border-color: var(--accent); }
.repeater-item__controls button:disabled { opacity: .35; cursor: not-allowed; }
.repeater-item__controls button.repeater-item__delete:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.repeater-add {
  align-self: flex-start;
  margin-top: .2rem;
}

.autosave-indicator {
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.autosave-indicator.is-saving { color: var(--accent); }
.autosave-indicator.is-error { color: var(--danger); }
.autosave-dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--success);
}
.autosave-indicator.is-saving .autosave-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.autosave-indicator.is-error .autosave-dot { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.form-sticky-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: .9rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: 0 -6px 20px rgba(0,0,0,.05);
  margin-top: 2rem;
}

/* ---------- WYSIWYG minimal ---------- */
.wysiwyg { border: 1px solid var(--border-strong); border-radius: var(--radius-m); overflow: hidden; background: var(--surface); }
.wysiwyg__toolbar { display: flex; gap: .2rem; padding: .4rem; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.wysiwyg__toolbar button {
  border: 1px solid transparent;
  background: transparent;
  width: 30px; height: 30px;
  border-radius: var(--radius-s);
  cursor: pointer;
  color: var(--text);
  font-size: .85rem;
}
.wysiwyg__toolbar button:hover { background: var(--bg-alt); }
.wysiwyg__editable { padding: .8rem; min-height: 8rem; outline: none; font-size: 1rem; line-height: 1.6; }
.wysiwyg__editable:empty::before { content: attr(data-placeholder); color: var(--text-muted); }

/* ---------- Vue globale groupings ---------- */
.reponse-group { margin-bottom: 1.75rem; }
.reponse-group__user {
  font-weight: 700;
  font-size: .9rem;
  margin-bottom: .4rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.reponse-group__meta { font-family: var(--font-mono); font-size: .74rem; color: var(--text-muted); font-weight: 400; }
.bloc-readonly {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: .65rem .8rem;
  margin-bottom: .5rem;
  font-size: .93rem;
}
.bloc-readonly p:last-child { margin-bottom: 0; }
.bloc-readonly:last-child { margin-bottom: 0; }

/* ---------- Utility ---------- */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); font-weight: 600; }
.mt-0 { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.cluster { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

@media (max-width: 680px) {
  .utility-bar__inner { flex-wrap: wrap; gap: .5rem; }
  .topbar__inner { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; }
  .container { padding: 1.25rem 1rem 3rem; }
  .card { padding: 1.1rem; }
}

/* ========================================================================
   Impression (vue globale, vue par personne)
   ======================================================================== */
@media print {
  .utility-bar, .topbar, .selector-bar, .toc, .btn, button,
  .form-sticky-bar, dialog.modal,
  .element-card__pin, .no-print { display: none !important; }

  .layout-with-toc { display: block; }
  .layout-with-toc__main { width: 100%; }

  /* Les sections repliées doivent toujours s'imprimer dépliées, et sans
     overflow (qui perturbe le découpage en pages) */
  .section-toggle__chevron { display: none; }
  .form-section__body, .form-section__body.is-collapsed {
    max-height: none !important;
    opacity: 1 !important;
    padding-top: 1.25rem !important;
    display: block !important;
    overflow: visible !important;
  }
  .section-toggle { width: 100%; left: 0; margin-left: 0; border-top-width: 2px; cursor: default; }
  .section-toggle__inner { max-width: none; }

  body { background: #FFFFFF; color: #000000; }
  a { text-decoration: none; color: inherit; }

  /* Découpage en pages : on laisse volontairement les longues réponses et
     les éléments se couper d'une page à l'autre (sinon un bloc long est
     repoussé à la page suivante et laisse un grand blanc). On évite
     seulement qu'un titre reste seul en bas de page. */
  .card, .element-card, .question-block, .bloc-readonly {
    box-shadow: none;
    break-inside: auto;
  }
  h2, h3, h4, .section-toggle__heading, .element-card__header, .reponse-group__user {
    break-after: avoid;
    page-break-after: avoid;
  }
  p, li { orphans: 3; widows: 3; }
  li { break-inside: avoid; }
  .page-break { break-after: page; }
}
