/* ============================================================
   TimeEcosModal — système de modale unique (socle V3)
   ------------------------------------------------------------
   Basé sur l'élément <dialog> natif. S'appuie sur les variables
   de theme.css (--surface, --text, --line, --shadow-lg…) afin de
   fonctionner automatiquement en thème clair ET sombre.
   Préfixe de classe dédié `tem-` (Time-Ecos Modal) pour éviter
   toute collision avec .modal-* (admin) et .te-modal-* (sujets).
   ============================================================ */

/* Verrouillage du défilement du fond pendant l'ouverture */
html.tem-modal-open,
html.tem-modal-open body { overflow: hidden; }

/* Le <dialog> occupe tout l'écran et centre le cadre.
   Sa zone vide (hors cadre) sert de fond cliquable. */
dialog.tem-dialog {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 16px;
  border: 0;
  background: transparent;
  overflow: hidden;
  box-sizing: border-box;
}
dialog.tem-dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
dialog.tem-dialog::backdrop {
  background: rgba(2, 8, 23, 0.55);
  backdrop-filter: blur(2px);
}
dialog.tem-dialog.tem-nonmodal {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 23, 0.55);
  backdrop-filter: blur(2px);
}

/* Cadre visible de la modale */
.tem-frame {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;                 /* taille md par défaut */
  max-height: min(90vh, 760px);
  background: var(--surface, #f9fafb);
  color: var(--text, #04151f);
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.15));
  overflow: hidden;
  animation: tem-frame-in 0.2s ease-out;
}
dialog.tem-dialog.tem-size-sm .tem-frame { max-width: 420px; }
dialog.tem-dialog.tem-size-lg .tem-frame { max-width: 820px; }
dialog.tem-dialog.tem-size-xl .tem-frame { max-width: 1040px; }
dialog.tem-dialog.tem-size-workspace .tem-frame {
  max-width: min(1180px, calc(100vw - 32px));
  height: min(860px, calc(100vh - 32px));
}
dialog.tem-dialog.tem-size-creation .tem-frame {
  max-width: min(1120px, calc(100vw - 32px));
  height: min(900px, calc(100vh - 32px));
}
dialog.tem-dialog.tem-size-import .tem-frame {
  max-width: min(1080px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 32px));
}
dialog.tem-dialog.tem-size-station .tem-frame {
  max-width: min(1180px, calc(100vw - 32px));
  height: min(880px, calc(100vh - 32px));
}

@keyframes tem-frame-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tem-frame { animation: none; }
}

/* En-tête (reste visible quand le corps défile) */
.tem-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line, #e5e7eb);
  background: var(--surface, #f9fafb);
}
.tem-title {
  margin: 0;
  min-width: 0;
  font-size: var(--text-lg, 1.125rem);
  font-weight: 700;
  color: var(--title-card, var(--brand, #004777));
}
.tem-title-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.tem-header-meta {
  display: flex;
  align-items: center;
  min-width: 0;
}
.tem-header-meta[hidden] { display: none; }
.tem-heading {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}
.tem-subtitle {
  margin: 0;
  color: var(--muted, #6b7280);
  font-size: var(--text-sm, 0.875rem);
  line-height: 1.35;
}

/* Métadonnée compacte « promotions ciblées » utilisée par les assistants Station/Épreuve. */
.tem-promotion-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.tem-promotion-meta__separator {
  width: 1px;
  height: 1.15rem;
  background: var(--line, #e5e7eb);
  flex: 0 0 auto;
}
.tem-promotion-meta__desktop {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
.tem-promotion-meta .promo-epreuve-chip {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tem-promotion-meta .tem-promotion-meta__mobile { display: none; }
.tem-promotion-meta__edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 999px;
  background: transparent;
  color: var(--muted, #6b7280);
  cursor: pointer;
  flex: 0 0 auto;
}
.tem-promotion-meta__edit:hover {
  border-color: var(--accent, #00afb5);
  color: var(--accent, #00afb5);
  background: color-mix(in srgb, var(--accent, #00afb5) 8%, transparent);
}
.tem-promotion-meta__edit:focus-visible {
  outline: 2px solid var(--accent, #00afb5);
  outline-offset: 2px;
}
.tem-promotion-meta__edit:disabled { opacity: 0.55; cursor: wait; }
.tem-promotion-meta__edit .lucide-icon,
.tem-promotion-meta__edit svg { width: 14px; height: 14px; }

@media (max-width: 640px) {
  .tem-title-row { gap: 0.4rem; }
  .tem-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tem-header-meta { flex: 0 0 auto; }
  .tem-promotion-meta { gap: 0.3rem; }
  .tem-promotion-meta__separator { display: none; }
  .tem-promotion-meta__desktop { display: none; }
  .tem-promotion-meta .tem-promotion-meta__mobile { display: inline-flex; }
  .tem-promotion-meta .promo-epreuve-chip { max-width: 8rem; }
}

/* Pastille d'icône optionnelle dans l'en-tête (option `icon` du socle). */
.tem-header-lead {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}
.tem-header-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--accent, #00afb5);
  background: color-mix(in srgb, var(--accent, #00afb5) 15%, transparent);
}
.tem-header-icon .lucide-icon,
.tem-header-icon svg { width: 20px; height: 20px; }
.tem-header-icon--info {
  color: var(--info, #3b82f6);
  background: color-mix(in srgb, var(--info, #3b82f6) 15%, transparent);
}
.tem-header-icon--warning {
  color: var(--warning, #ff7700);
  background: color-mix(in srgb, var(--warning, #ff7700) 15%, transparent);
}
.tem-header-icon--danger {
  color: var(--danger, #a30000);
  background: color-mix(in srgb, var(--danger, #a30000) 15%, transparent);
}
.tem-header-icon--success {
  color: var(--success, #16a34a);
  background: color-mix(in srgb, var(--success, #16a34a) 15%, transparent);
}
.tem-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius, 6px);
  background: transparent;
  color: var(--muted, #6b7280);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition, 0.2s ease);
}
.tem-close:hover { background: rgba(180, 35, 24, 0.12); color: var(--danger, #b42318); }
.tem-close:focus-visible { outline: 2px solid var(--accent, #00afb5); outline-offset: 2px; }

/* Corps (zone défilante) */
.tem-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  line-height: var(--leading-normal, 1.5);
}
.tem-body p { margin: 0 0 0.75rem 0; }
.tem-body p:last-child { margin-bottom: 0; }

/* Pied (reste visible quand le corps défile) */
.tem-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--line, #e5e7eb);
  background: var(--surface, #f9fafb);
}
.tem-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.tem-actions .btn {
  width: auto !important;
}

/* Champs de formulaire à l'intérieur d'une modale */
.tem-field { margin-bottom: 0.85rem; }
.tem-field:last-child { margin-bottom: 0; }
.tem-label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
  font-size: var(--text-sm, 0.875rem);
}
.tem-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius, 6px);
  background: var(--bg, #ffffff);
  color: var(--text, #04151f);
  font: inherit;
}
.tem-input:focus-visible { outline: 2px solid var(--accent, #00afb5); outline-offset: 1px; }
.tem-help { margin-top: 0.3rem; font-size: var(--text-xs, 0.75rem); color: var(--muted, #6b7280); }
.tem-error { margin-top: 0.3rem; font-size: var(--text-xs, 0.75rem); color: var(--danger, #a30000); }

/* État « champ requis non rempli » : rendu orange aligné sur le socle
   TimeEcosPrompt (`.te-prompt__input--error`, modals.css). Un champ oublié n'est
   pas une vraie erreur : on invite à compléter en orange (--warning) plutôt que
   de dramatiser en rouge. À poser/retirer en JS via la classe `tem-input--error`,
   avec un message `tem-error--warning` sous le champ. */
.tem-input--error,
.tem-input--error:focus-visible {
  border-color: var(--warning, #FF7700);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning, #FF7700) 22%, transparent);
  outline: none;
}
.tem-error--warning { color: var(--warning, #FF7700); font-weight: 600; }

/* Contenus standards réutilisables dans les modales V3 */
.tem-stack {
  display: grid;
  gap: 0.85rem;
}
.tem-summary {
  padding: 0.85rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius, 6px);
  background: color-mix(in srgb, var(--surface, #f9fafb) 72%, var(--accent, #00afb5) 8%);
}
.tem-summary strong { color: var(--text, #04151f); }
.tem-list {
  margin: 0;
  padding-left: 1.2rem;
}
.tem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}
.tem-tile {
  padding: 0.8rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius, 6px);
  background: var(--bg, #fff);
}
.tem-tile-title {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 700;
}
.tem-stepper {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tem-stepper li {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.6rem;
  align-items: start;
}
.tem-stepper span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--brand, #004777);
  color: #fff;
  font-weight: 700;
}
.tem-station-preview {
  padding: 1rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius, 6px);
  background: var(--bg, #fff);
}
.tem-station-preview h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}
.tem-eval-grid {
  display: grid;
  gap: 0.7rem;
}
.tem-eval-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius, 6px);
  background: var(--bg, #fff);
}
.tem-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  min-height: 2rem;
  border-radius: var(--radius, 6px);
  background: color-mix(in srgb, var(--accent, #00afb5) 16%, transparent);
  color: var(--brand, #004777);
  font-weight: 700;
}
/* En preset workspace, le corps s'étire (flex-column) pour que le plan occupe
   la hauteur fixe et que le pied reste collé en bas (voir .tem-body { flex }). */
dialog.tem-dialog.tem-size-workspace .tem-body {
  display: flex;
  flex-direction: column;
}
dialog.tem-dialog.tem-size-creation .tem-body {
  display: flex;
  flex-direction: column;
  padding: 0;
}
dialog.tem-dialog.tem-size-import .tem-body {
  display: flex;
  flex-direction: column;
  padding: 0;
}
.tem-creation {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}
.tem-creation-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line, #e5e7eb);
  background: color-mix(in srgb, var(--surface, #f9fafb) 88%, var(--accent, #00afb5) 4%);
}
.tem-creation-progress {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}
.tem-creation-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}
.tem-creation-progress-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text, #04151f);
  font-size: var(--text-sm, 0.875rem);
  font-weight: 700;
}
.tem-creation-progress-percent {
  flex: 0 0 auto;
  color: var(--brand, #004777);
  font-size: var(--text-sm, 0.875rem);
}
.tem-creation-progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line, #e5e7eb) 72%, var(--surface, #f9fafb) 28%);
}
.tem-creation-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent, #00afb5);
  transition: width 0.2s ease;
}
.tem-creation-status {
  min-width: 9rem;
  margin: 0;
  justify-content: flex-end;
}
.tem-creation-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}
.tem-creation-body > * {
  flex: 1 1 auto;
  min-height: 0;
}
.tem-creation.is-initializing .tem-creation-body > *:not(.tem-creation-initializing) {
  display: none !important;
}
.tem-creation-initializing {
  display: flex;
  flex: 1 1 auto;
  /* 14rem suffisaient pour trois lignes ; avec la liste d'étapes le contenu s'allonge, mais le
     panneau ne doit pas pour autant étirer la modale de création sur toute sa hauteur pour si peu.
     `justify-content: center` garde le bloc centré quel que soit le nombre d'étapes. */
  min-height: 18rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  text-align: center;
}
.tem-creation-initializing[hidden] {
  display: none !important;
}
.tem-creation-initializing-title {
  color: var(--text, #04151f);
  font-size: var(--text-lg, 1.125rem);
  font-weight: 800;
}
.tem-creation-initializing-message {
  max-width: 28rem;
  margin: 0;
  color: var(--text-muted, #64748b);
  font-size: var(--text-sm, 0.875rem);
}
/* Liste d'étapes de l'écran d'initialisation (traitements longs : import IA d'une station).
   Alignée à gauche dans un panneau centré : une liste centrée se lit mal, l'oeil perd la colonne
   des marqueurs. */
.tem-creation-initializing-steps {
  width: 100%;
  max-width: 22rem;
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
/* ⚠️ Le gap VERTICAL interne (libellé → détail, 1re valeur) doit rester NETTEMENT plus petit que
   le gap entre étapes de la liste ci-dessus : à 0.6rem contre 0.5rem, le détail était plus proche
   de l'étape SUIVANTE que de la sienne et se lisait comme une étape en plus. */
.tem-creation-step {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.6rem;
  font-size: var(--text-sm, 0.875rem);
  color: var(--text-muted, #64748b);
}
.tem-creation-step-marker {
  flex: 0 0 1rem;
  width: 1rem;
  text-align: center;
  line-height: 1;
}
/* Marqueur de l'étape EN COURS : le socle `.spinner` se dimensionne par variables. 14px tient dans
   la colonne des marqueurs sans décaler les libellés des autres étapes. */
.tem-creation-step-marker.spinner {
  --spinner-size: 14px;
  --spinner-stroke: 2px;
  align-self: center;
  /* ⚠️ `.spinner` porte `margin: 8px auto` (disposition « bloc centré » historique, spinner.css).
     Dans un conteneur flex, une marge auto ABSORBE tout l'espace libre : le spinner restait collé
     à gauche et poussait le libellé de l'étape au centre, alors que les autres étapes s'alignaient
     normalement. */
  margin: 0;
}
.tem-creation-initializing-spinner {
  --spinner-size: 22px;
  /* Panneau en flex column : `margin: auto` verticale absorberait l'espace et décollerait le
     spinner du titre. Marge explicite, indépendante du réglage global de `.spinner`. */
  margin: 0;
}
/* Étape à venir : pastille creuse — l'état reste lisible sans dépendre de la couleur seule. */
.tem-creation-step.is-todo .tem-creation-step-marker::before {
  content: '○';
}
.tem-creation-step.is-done {
  color: var(--text, #04151f);
}
.tem-creation-step.is-done .tem-creation-step-marker {
  color: var(--success, #0f766e);
}
.tem-creation-step.is-current {
  color: var(--text, #04151f);
  font-weight: 600;
}
/* Le détail décrit l'étape : il passe SOUS son libellé, aligné sur lui. Placé à côté, il volait la
   largeur au libellé, qui se cassait alors sur deux lignes. En text-xs : à la même taille que les
   libellés, il était indiscernable d'une étape à venir (elle aussi grise en text-sm). */
.tem-creation-step-detail {
  flex: 1 0 100%;
  margin-left: 1.6rem;
  color: var(--text-muted, #64748b);
  font-weight: 400;
  font-size: var(--text-xs, 0.8125rem);
}
/* Marge haute franche : collé à la liste, le hint semblait être le détail de la dernière étape. */
.tem-creation-initializing-hint {
  max-width: 28rem;
  margin: 0.75rem 0 0;
  color: var(--text-muted, #64748b);
  font-size: var(--text-xs, 0.8125rem);
}
.tem-creation-initializing-hint--warning {
  padding: 0.7rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--warning, #d97706) 45%, var(--line, #dbe3ea));
  border-radius: 0.6rem;
  background: color-mix(in srgb, var(--warning, #d97706) 11%, var(--surface, #fff));
  color: color-mix(in srgb, var(--warning, #d97706) 78%, var(--text, #0f172a));
  font-size: var(--text-sm, 0.875rem);
  font-weight: 650;
  line-height: 1.4;
  text-align: left;
}
.tem-creation-initializing-hint--warning::before {
  content: '⚠ ';
}
.tem-creation-initializing-hint[hidden],
.tem-creation-initializing-steps[hidden] {
  display: none !important;
}
.tem-creation-body .te-form-stepper {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line, #e5e7eb);
  background: var(--surface, #f9fafb);
}
.tem-creation-body .te-form-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius, 6px);
  background: var(--bg, #fff);
  color: var(--muted, #6b7280);
  font: inherit;
  font-size: var(--text-sm, 0.875rem);
  font-weight: 700;
}
.tem-creation-body .te-form-step.is-complete {
  border-color: color-mix(in srgb, var(--success, #15803d) 55%, var(--line, #e5e7eb));
  background: color-mix(in srgb, var(--success, #15803d) 11%, var(--bg, #fff));
  color: var(--success, #15803d);
}
.tem-creation-body .te-form-step.is-incomplete {
  border-color: var(--warning, #d97706);
  background: color-mix(in srgb, var(--warning, #d97706) 14%, var(--bg, #fff));
  color: color-mix(in srgb, var(--warning, #d97706) 88%, #7c2d12);
}
/* [2026-08-06] Étape porteuse d'une INCOHÉRENCE (ex. répartition étudiante au-delà de la capacité
   après avoir raccourci une session). Distinct de `is-incomplete` (orange = étape non remplie, qui
   gouverne la navigation) : ici l'étape est bien remplie, mais son contenu est faux. Signale sans
   bloquer — la création reste possible, l'alerte dure vient à la publication. */
.tem-creation-body .te-form-step.has-issue {
  border-color: var(--danger, #dc2626);
  background: color-mix(in srgb, var(--danger, #dc2626) 12%, var(--bg, #fff));
  color: color-mix(in srgb, var(--danger, #dc2626) 85%, #450a0a);
}

.tem-creation-body .te-form-step.is-active {
  font-weight: 900;
  box-shadow: inset 0 0 0 1px currentColor, 0 0 0 1px currentColor;
}
.tem-creation-body .te-form-step.is-active:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
.tem-creation-body .te-form-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 24px;
  overflow-y: auto;
}
.tem-creation-body .te-form-panel {
  max-width: 100%;
}
.tem-creation-body .te-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 16px;
}
.tem-creation-body .te-form-field--full {
  grid-column: 1 / -1;
}

/* Champ en erreur (form-engine) : encadré rouge + message visible, pour repérer
   immédiatement quel champ corriger (le moteur pose déjà la classe is-invalid). */
.te-form-field.is-invalid input:not([type="radio"]):not([type="checkbox"]),
.te-form-field.is-invalid select,
.te-form-field.is-invalid textarea,
.te-form-field.is-invalid .form-input,
.te-form-field.is-invalid .form-select,
.te-form-field.is-invalid [contenteditable="true"] {
  border-color: var(--danger, #dc2626) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger, #dc2626) 18%, transparent);
}
.te-form-field.is-invalid .form-label {
  color: var(--danger, #dc2626);
}
.te-form-error {
  margin: 4px 0 0;
  color: var(--danger, #dc2626);
  font-size: 0.85rem;
  font-weight: 600;
}
.tem-creation-body .te-form-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--line, #e5e7eb);
  background: var(--surface, #f9fafb);
}
.tem-creation-body .te-form {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  flex-direction: column;
}
.tem-creation-body > div {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}
.tem-creation-body .te-form-status {
  margin-top: 0.75rem;
  color: var(--danger, #b42318);
  font-weight: 600;
}
.tem-creation-body .timer-profile-phase-row {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) auto auto auto auto;
  gap: 0.75rem;
  align-items: center;
}
.tem-creation-body .timer-profile-phase-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tem-creation-body .timer-profile-duration-field {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted, #6b7280);
  font-size: var(--text-sm, 0.875rem);
}
.tem-creation-body .timer-profile-duration-field .form-input {
  width: 4.25rem;
  text-align: center;
}
.tem-creation-body .timer-profile-color-picker {
  position: relative;
  display: inline-flex;
  justify-content: center;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.tem-creation-body .timer-profile-color-picker .phase-color-trigger {
  width: 32px;
  height: 32px;
  border: 2px solid var(--surface, #fff);
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--line, #e5e7eb);
  cursor: pointer;
}
.tem-creation-body .timer-profile-color-picker .phase-color-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
  background: var(--surface, #fff);
  box-shadow: var(--shadow-md, 0 12px 24px rgba(15, 23, 42, 0.14));
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.tem-creation-body .timer-profile-color-picker .phase-color-menu[hidden] {
  display: none;
}
.tem-creation-body .timer-profile-color-picker .phase-color-swatch {
  width: 24px;
  height: 24px;
  border: 2px solid var(--surface, #fff);
  border-radius: 7px;
  box-shadow: 0 0 0 1px var(--line, #e5e7eb);
  cursor: pointer;
}
.tem-creation-body .timer-profile-color-picker .phase-color-swatch.is-active {
  box-shadow: 0 0 0 2px var(--text, #111827);
}

/* Preset `importFlow` — grand flux d'import avec contenu métier libre
   (CSV, panier, aperçu, résultats) et progression serveur optionnelle. */
.tem-import-flow {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}
.tem-import-flow-top {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line, #e5e7eb);
  background: color-mix(in srgb, var(--surface, #f9fafb) 92%, var(--accent, #00afb5) 3%);
}
.tem-import-flow-top[hidden] {
  display: none !important;
}
.tem-import-flow-progress {
  display: grid;
  gap: 0.4rem;
}
.tem-import-flow-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}
.tem-import-flow-progress-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text, #04151f);
  font-size: var(--text-sm, 0.875rem);
  font-weight: 700;
}
.tem-import-flow-progress-percent {
  flex: 0 0 auto;
  color: var(--muted, #6b7280);
  font-size: var(--text-sm, 0.875rem);
}
.tem-import-flow-progress-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line, #e5e7eb) 72%, var(--surface, #f9fafb) 28%);
}
.tem-import-flow-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent, #00afb5);
  transition: width 0.2s ease;
}
.tem-import-flow-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}
.tem-import-flow-body > * {
  flex: 1 1 auto;
  min-height: 0;
}

/* Indicateur de sauvegarde partage par les assistants de creation. Il vit ici
   car le preset `creation` peut etre utilise hors admin.css, notamment owner-config. */
.te-save-status {
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted, #6b7280);
}
.te-save-status:empty { display: none; }
.te-save-status-txt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.te-save-status-ico {
  display: inline-flex;
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
}
.te-save-status-ico svg {
  width: 14px;
  height: 14px;
}
.te-save-status.is-success { color: var(--muted, #6b7280); font-weight: 500; }
.te-save-status.is-success .te-save-status-ico { color: var(--success, #15803d); }
.te-save-status.is-loading .te-save-status-ico svg { animation: te-save-status-spin 0.8s linear infinite; }
.te-save-status.is-unsaved { color: var(--muted, #6b7280); }
.te-save-status.is-unsaved .te-save-status-ico { color: var(--warning, #d97706); }
.te-save-status.is-error { color: var(--danger, #a30000); font-weight: 700; }
@keyframes te-save-status-spin {
  to { transform: rotate(360deg); }
}
.tem-workspace {
  display: grid;
  grid-template-columns: minmax(180px, 0.3fr) minmax(0, 1fr);
  gap: 1rem;
  flex: 1 1 auto;
  min-height: 420px;
}
.tem-workspace-sidebar,
.tem-workspace-canvas {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius, 6px);
  background: var(--bg, #fff);
}
.tem-workspace-sidebar {
  padding: 0.8rem;
}
.tem-workspace-canvas {
  min-height: 420px;
  background:
    linear-gradient(var(--line, #e5e7eb) 1px, transparent 1px),
    linear-gradient(90deg, var(--line, #e5e7eb) 1px, transparent 1px),
    var(--surface, #f9fafb);
  background-size: 32px 32px;
  position: relative;
  overflow: hidden;
}
.tem-workspace-zone {
  position: absolute;
  left: 14%;
  top: 18%;
  width: 38%;
  height: 34%;
  border: 2px solid var(--brand, #004777);
  border-radius: var(--radius, 6px);
  background: color-mix(in srgb, var(--brand, #004777) 12%, transparent);
}
.tem-workspace-room {
  position: absolute;
  right: 14%;
  bottom: 18%;
  width: 24%;
  height: 22%;
  border: 2px solid var(--accent, #00afb5);
  border-radius: var(--radius, 6px);
  background: color-mix(in srgb, var(--accent, #00afb5) 16%, transparent);
}

/* ------------------------------------------------------------
   Preset `station` — cadre de la modale d'affichage de station
   (barre de vues + contenu principal + rail visio/PJ + slot chrono).
   Le contenu métier est injecté par l'appelant (station-display.js).
   ------------------------------------------------------------ */
dialog.tem-dialog.tem-size-station .tem-body {
  display: flex;
  flex-direction: column;
  padding: 0;
}
.tem-station {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}
/* Barre de vues par rôle (Aperçu / Médecin / PS-PSS / Évaluateur) */
.tem-station-views {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 12px 18px;
  /* Pas de border-bottom : le fond gris sépare déjà des onglets ; la bordure pleine
     largeur réapparaissait sous le bandeau de progression (inset) de l'onglet Évaluateur. */
  background: var(--surface, #f9fafb);
}
.tem-station-views[hidden] { display: none; }
.tem-station-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius, 6px);
  background: var(--bg, #fff);
  color: var(--muted, #6b7280);
  font: inherit;
  font-weight: 700;
  font-size: var(--text-sm, 0.875rem);
  cursor: pointer;
  transition: var(--transition, 0.2s ease);
}
.tem-station-view-btn:hover { border-color: var(--accent, #00afb5); }
.tem-station-view-btn.is-active {
  border-color: var(--accent, #00afb5);
  background: color-mix(in srgb, var(--accent, #00afb5) 14%, var(--bg, #fff));
  color: var(--brand, #004777);
}
.tem-station-view-btn:focus-visible { outline: 2px solid var(--accent, #00afb5); outline-offset: 2px; }

/* Barre de disposition station (en-tête) */
dialog.tem-dialog.tem-size-station .tem-heading {
  flex: 1 1 auto;
}
.tem-station-layout-tools {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius, 6px);
  background: var(--bg, #fff);
}
.tem-station-layout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius, 6px);
  background: transparent;
  color: var(--muted, #6b7280);
  cursor: pointer;
}
.tem-station-layout-btn:hover {
  color: var(--brand, #004777);
  background: color-mix(in srgb, var(--accent, #00afb5) 10%, transparent);
}
.tem-station-layout-btn.is-active {
  color: var(--brand, #004777);
  background: color-mix(in srgb, var(--accent, #00afb5) 18%, var(--bg, #fff));
}
.tem-station-layout-btn:focus-visible { outline: 2px solid var(--accent, #00afb5); outline-offset: 2px; }
.tem-station-layout-btn .lucide-icon,
.tem-station-layout-btn svg {
  width: 17px;
  height: 17px;
}

/* Corps : contenu principal (gauche) + rail latéral (droite) */
.tem-station-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.36fr);
  gap: 1rem;
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px;
  overflow: hidden;
}
dialog.tem-dialog.tem-size-station.tem-station-layout--half .tem-station-layout {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
dialog.tem-dialog.tem-size-station.tem-station-layout--focus .tem-station-layout {
  grid-template-columns: minmax(0, 0.36fr) minmax(0, 1fr);
}
/* [2026-07-25] « Pleine largeur » : une seule colonne, le rail retombe SOUS le contenu — le
   rendu déjà appliqué d'office sous 900px, ici offert comme choix sur grand écran.
   ⚠️ Volontairement 100 % CSS : les blocs ne sont PAS déménagés dans le DOM. `setupBlockDocking`
   (station-display.js) tient des ancres de retour et un placeholder de glisser-déposer ; les
   déplacer ici perdrait les ancres et casserait « Réinitialiser la disposition ». Revenir à
   « standard » suffit donc à tout remettre en place, et le drag & drop marche dans les 2 rendus. */
dialog.tem-dialog.tem-size-station.tem-station-layout--full .tem-station-layout {
  display: block;
  overflow-y: auto;
}
dialog.tem-dialog.tem-size-station.tem-station-layout--full .tem-station-main,
dialog.tem-dialog.tem-size-station.tem-station-layout--full .tem-station-rail {
  overflow: visible;
}
dialog.tem-dialog.tem-size-station.tem-station-layout--full .tem-station-rail {
  margin-top: 0.85rem;
}
.tem-station-main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}
.tem-station-view[hidden] { display: none; }
.tem-station-rail {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}
.tem-station-rail[hidden] { display: none; }
.tem-station-visio,
.tem-station-psia,
.tem-station-attachments {
  padding: 0.85rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: var(--radius, 6px);
  background: var(--bg, #fff);
}
.tem-station-visio[hidden],
.tem-station-psia[hidden],
.tem-station-attachments[hidden] { display: none; }

/* Capsule chrono lecture seule, posée dans l'en-tête (branchée au lot chrono) */
.tem-station-chrono {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  margin-left: auto;
}
.tem-station-chrono[hidden] { display: none; }

/* Capsule chrono réelle (station-chrono-capsule.js) : pastille « temps + phase »
   dans le slot d'en-tête. États pilotés par data-state (running/pause/waiting/ended). */
.tem-chrono-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent, #00afb5) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #00afb5) 40%, transparent);
  color: var(--brand, #004777);
  font-size: var(--text-sm, 0.875rem);
  white-space: nowrap;
}
.tem-chrono-pill[hidden] { display: none; }
.tem-chrono-pill-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.tem-chrono-pill-label { font-weight: 600; }
.tem-chrono-pill-time[hidden],
.tem-chrono-pill-label[hidden] { display: none; }
.tem-chrono-pill[data-state="pause"] {
  background: color-mix(in srgb, var(--warning, #f59e0b) 16%, transparent);
  border-color: color-mix(in srgb, var(--warning, #f59e0b) 45%, transparent);
}
.tem-chrono-pill[data-state="waiting"],
.tem-chrono-pill[data-state="ended"] {
  background: color-mix(in srgb, var(--muted, #6b7280) 12%, transparent);
  border-color: var(--line, #e5e7eb);
  color: var(--muted, #6b7280);
}
/* Petits écrans : l'en-tête est serré → on ne garde que le temps. */
@media (max-width: 640px) {
  .tem-chrono-pill-label { display: none; }
}

/* Helpers d'aperçu (galerie owner « Affichage des modales ») : capsule chrono
   factice + titres de section. Le rendu réel viendra de station-display.js. */
.tem-station-chrono-demo {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent, #00afb5) 16%, transparent);
  color: var(--brand, #004777);
  font-weight: 700;
  font-size: var(--text-sm, 0.875rem);
  white-space: nowrap;
}
.tem-station-demo-title { margin: 0 0 0.4rem; font-size: 1rem; }

/* Tablette portrait / mobile : passage en une seule colonne, le corps défile en entier */
@media (max-width: 899px) {
  /* Barres (rôles + Fiche/Visio/PJ) fixes en tête : seul le panneau de contenu
     actif défile en interne → les barres restent toujours visibles. Le corps de
     la modale ne défile pas lui-même (sinon les barres partiraient au scroll). */
  dialog.tem-dialog.tem-size-station .tem-body { overflow: hidden; }
  .tem-station-layout {
    display: block;
    overflow-y: auto;
  }
  .tem-station-main,
  .tem-station-rail { overflow: visible; }
  .tem-station-rail { margin-top: 0.85rem; }
  /* Plus de sticky par barre : c'est l'enveloppe .station-sticky-head qui se fige
     (les deux barres se chevauchaient quand chacune visait le même top:0). */
  .tem-station-views {
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .tem-station-layout-tools [data-station-layout-mode="half"] { display: none; }
  /* Sous-titre (présent uniquement sur la vue Aperçu) : 1 ligne tronquée pour
     gagner de la hauteur sur mobile/tablette ; le détail reste dans l'Aperçu. */
  dialog.tem-dialog.tem-size-station .tem-subtitle {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Petits écrans : cadre quasi plein écran, boutons tactiles sans étirement forcé */
@media (max-width: 560px) {
  dialog.tem-dialog { padding: 8px; }
  .tem-frame { max-width: 100%; max-height: 94vh; }
  dialog.tem-dialog.tem-size-creation .tem-frame {
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
  }
  dialog.tem-dialog.tem-size-import .tem-frame {
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
  }
  /* Station : collée en haut (sous la status bar), hauteur dynamique + safe-area */
  dialog.tem-dialog.tem-size-station[open] { align-items: flex-start; }
  dialog.tem-dialog.tem-size-station {
    padding:
      max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
  dialog.tem-dialog.tem-size-station .tem-frame {
    height: auto;
    max-height: 96dvh;
  }
  .tem-station-layout { padding: 14px; }
  .tem-header {
    align-items: flex-start;
    padding: 14px 14px;
  }
  .tem-title { font-size: 1rem; }
  .tem-subtitle { font-size: 0.8rem; }
  .tem-creation-top {
    grid-template-columns: 1fr;
    gap: 0.65rem;
    padding: 10px 14px;
  }
  .tem-creation-status {
    justify-content: flex-start;
    min-width: 0;
  }
  .tem-import-flow-top {
    padding: 10px 14px;
  }
  .tem-actions {
    justify-content: flex-end;
    align-items: center;
  }
  .tem-actions .btn {
    width: auto !important;
    flex: 0 0 auto;
    min-width: 112px;
    min-height: 44px;
    max-width: 100%;
  }
  .tem-eval-row { grid-template-columns: 1fr; }
  .tem-workspace { grid-template-columns: 1fr; }
  .tem-workspace-canvas { min-height: 320px; }
}
