/* ============================================================
   VARIABLES ET BASE
   ============================================================ */

:root {
  --color-bg:          #f4f6f9;
  --color-surface:     #ffffff;
  --color-border:      #e2e8f0;
  --color-border-light:#f1f5f9;

  --color-primary:     #2563eb;
  --color-primary-dim: #dbeafe;
  --color-primary-dark:#1d4ed8;

  --color-text:        #1e293b;
  --color-text-muted:  #64748b;
  --color-text-light:  #94a3b8;

  --color-success:     #059669;
  --color-success-dim: #d1fae5;
  --color-warning:     #d97706;
  --color-warning-dim: #fef3c7;
  --color-error:       #dc2626;
  --color-error-dim:   #fee2e2;

  /* Couleurs de stratégie */
  --color-serial:      #7c3aed;
  --color-serial-dim:  #ede9fe;
  --color-parallel:    #059669;
  --color-parallel-dim:#d1fae5;
  --color-mixed:       #d97706;
  --color-mixed-dim:   #fef3c7;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.1);

  --transition: 200ms ease;
  --font:       'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ============================================================
   LAYOUT
   ============================================================ */

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ============================================================
   EN-TÊTE
   ============================================================ */

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 20px 0;
  margin-bottom: 32px;
}

.header-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo svg {
  width: 28px;
  height: 28px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.3px;
}

.header-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-left: 38px;
}

/* ============================================================
   CARTES GÉNÉRIQUES
   ============================================================ */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-header { margin-bottom: 20px; }

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
}

.card-desc {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* ============================================================
   FORMULAIRE DE SAISIE
   ============================================================ */

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.label-optional {
  font-weight: 400;
  color: var(--color-text-muted);
}

.form-textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.6;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-dim);
}

.form-textarea::placeholder { color: var(--color-text-light); }

/* Documents */

.docs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.btn-add-doc {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-dim);
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-add-doc svg { width: 13px; height: 13px; }
.btn-add-doc:hover { background: #bfdbfe; }

.documents-list { display: flex; flex-direction: column; gap: 10px; }

.doc-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.doc-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-border-light);
  border-bottom: 1px solid var(--color-border);
}

.doc-item-header input[type="text"] {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font);
}

.doc-item-header input[type="text"]:focus { outline: none; }

.btn-remove-doc {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-light);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--transition);
}

.btn-remove-doc:hover { color: var(--color-error); }

.doc-item textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--color-text);
  border: none;
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.doc-item textarea:focus { outline: none; }

/* Actions */

.form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

/* ============================================================
   BOUTONS
   ============================================================ */

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.btn-primary svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-border-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
}

.btn-secondary:hover { background: var(--color-border); }

/* ============================================================
   ZONE WORKFLOW
   ============================================================ */

.workflow-zone {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 20px;
}

/* --- Connecteur vertical entre étapes --- */
.step-connector {
  width: 2px;
  height: 24px;
  background: var(--color-border);
  margin: 0 auto;
}

/* ============================================================
   CARTE D'ÉTAPE
   ============================================================ */

.step-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.step-card.is-active  { border-color: var(--color-primary); box-shadow: 0 0 0 2px var(--color-primary-dim); }
.step-card.is-done    { border-color: #86efac; }
.step-card.is-error   { border-color: #fca5a5; }

.step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  gap: 12px;
}

.step-header:hover .step-name { color: var(--color-primary); }

.step-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.step-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: var(--color-border-light);
  border: 2px solid var(--color-border);
  transition: all var(--transition);
}

.step-card.is-active .step-icon  { background: var(--color-primary-dim); border-color: var(--color-primary); }
.step-card.is-done   .step-icon  { background: var(--color-success-dim); border-color: #6ee7b7; }
.step-card.is-error  .step-icon  { background: var(--color-error-dim);   border-color: #fca5a5; }

.step-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.step-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
  transition: color var(--transition);
}

.step-summary {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.step-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.badge-pending  { background: var(--color-border-light); color: var(--color-text-muted); }
.badge-running  { background: var(--color-primary-dim); color: var(--color-primary); }
.badge-done     { background: var(--color-success-dim); color: var(--color-success); }
.badge-error    { background: var(--color-error-dim); color: var(--color-error); }
.badge-waiting  { background: var(--color-warning-dim); color: var(--color-warning); }

.step-toggle {
  font-size: 11px;
  color: var(--color-text-light);
  transition: transform var(--transition);
}

.step-card.is-expanded .step-toggle { transform: rotate(180deg); }

/* Bouton de relancement d'étape */
.btn-retry-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  /* Évite que le survol de la carte masque le bouton */
  position: relative;
  z-index: 1;
}

.btn-retry-step:hover {
  background: var(--color-primary-dim);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.step-detail {
  border-top: 1px solid var(--color-border-light);
  animation: fadeInDown 200ms ease;
}

.step-detail-inner { padding: 18px 20px; }

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   ANIMATION DE CHARGEMENT (PULSE)
   ============================================================ */

.pulse-dot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--color-primary);
  font-weight: 600;
}

.pulse-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--color-primary);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}

.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: 4px;
  height: 14px;
  margin-bottom: 6px;
}

@keyframes skeleton {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ============================================================
   CLARIFICATION
   ============================================================ */

.clarification-block {
  padding: 4px 0;
}

.clarif-intro {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 14px;
  font-style: italic;
}

.clarif-questions { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }

.clarif-item label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 5px;
}

.clarif-item textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  resize: vertical;
  min-height: 64px;
  transition: border-color var(--transition);
}

.clarif-item textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-dim);
}

/* ============================================================
   CONFIRMATION DU PLAN
   ============================================================ */

.plan-confirm-block { padding: 4px 0; }

.plan-confirm-intro {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.plan-agents-preview {
  margin-bottom: 16px;
}

/* ---- Plan flow graphique ---- */

.plan-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Flèche de liaison entre groupes sériels */
.plan-flow-arrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 600;
}

.plan-flow-arrow::before,
.plan-flow-arrow::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* Groupe d'agents (1 colonne = serial, N colonnes = parallel) */
.plan-flow-group {
  display: grid;
  gap: 10px;
}

.plan-flow-group[data-count="1"] { grid-template-columns: 1fr; }
.plan-flow-group[data-count="2"] { grid-template-columns: 1fr 1fr; }
.plan-flow-group[data-count="3"] { grid-template-columns: 1fr 1fr 1fr; }

/* Bloc d'un agent dans le plan */
.plan-flow-agent {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--color-surface);
}

.plan-flow-agent-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}

.plan-flow-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.plan-flow-name  { font-size: 13px; font-weight: 700; color: var(--color-text); }
.plan-flow-score { font-size: 11px; font-weight: 600; color: var(--color-primary); }

.plan-flow-inputs-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-text-muted);
  margin-bottom: 5px;
}

.plan-flow-inputs { display: flex; flex-wrap: wrap; gap: 4px; }

/* Badges d'entrée */
.flow-input-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--color-primary-dim);
  color: var(--color-primary);
}

.flow-input-tag-ctx {
  background: var(--color-warning-dim);
  color: var(--color-warning);
}

.plan-flow-reason {
  margin-top: 8px;
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.4;
  font-style: italic;
  border-top: 1px solid var(--color-border-light);
  padding-top: 7px;
}

.plan-agent-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-border-light);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.plan-agent-chip .chip-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.plan-agent-chip .chip-score {
  font-size: 11px;
  color: var(--color-text-muted);
}

.plan-strategy-badge {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: var(--color-border-light);
  border-radius: var(--radius-md);
  margin-bottom: 18px;
}

.strategy-label {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.strategy-serial   .strategy-label { background: var(--color-serial-dim);   color: var(--color-serial); }
.strategy-parallel .strategy-label { background: var(--color-parallel-dim); color: var(--color-parallel); }
.strategy-mixed    .strategy-label { background: var(--color-mixed-dim);    color: var(--color-mixed); }

.strategy-reason {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.plan-actions { display: flex; align-items: center; gap: 10px; }

/* Bloc affiché quand aucun agent n'a été sélectionné */
.no-agents-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--color-warning-dim);
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 12px 0;
}

.no-agents-icon { font-size: 20px; flex-shrink: 0; }

.no-agents-notice p {
  font-size: 13px;
  color: #92400e;
  line-height: 1.6;
}

/* ============================================================
   ZONE D'EXÉCUTION DES AGENTS
   ============================================================ */

.execution-zone { padding: 4px 0; }

/* --- Mode parallèle : colonnes côte à côte --- */
.agents-parallel {
  display: grid;
  gap: 14px;
}

.agents-parallel[data-count="1"] { grid-template-columns: 1fr; }
.agents-parallel[data-count="2"] { grid-template-columns: 1fr 1fr; }
.agents-parallel[data-count="3"] { grid-template-columns: 1fr 1fr 1fr; }

/* --- Mode sériel : enchaînement vertical --- */
.agents-serial {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.serial-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  color: var(--color-text-muted);
  font-size: 18px;
  position: relative;
}

.serial-connector::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--color-border);
  transform: translateX(-50%);
}

.serial-connector span {
  background: var(--color-surface);
  padding: 0 6px;
  position: relative;
  z-index: 1;
  font-size: 14px;
  color: var(--color-text-muted);
}

/* ============================================================
   CARTE D'AGENT
   ============================================================ */

.agent-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition);
}

.agent-card.is-running { border-color: var(--color-primary); box-shadow: 0 0 0 2px var(--color-primary-dim); }
.agent-card.is-done    { border-color: #86efac; }

.agent-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--color-border-light);
}

.agent-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.agent-card.is-done .agent-avatar { background: var(--color-success); }

.agent-info { flex: 1; min-width: 0; }

.agent-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}

.agent-specialty {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  flex-shrink: 0;
  background: var(--color-border-light);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.agent-card.is-running .agent-status-badge { background: var(--color-primary-dim); color: var(--color-primary); border-color: transparent; }
.agent-card.is-done    .agent-status-badge { background: var(--color-success-dim); color: var(--color-success); border-color: transparent; }

/* --- Entrée / Sortie de l'agent --- */

.agent-io { border-top: 1px solid var(--color-border-light); }

.io-section { border-bottom: 1px solid var(--color-border-light); }
.io-section:last-child { border-bottom: none; }

.io-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: background var(--transition);
}

.io-toggle:hover { background: var(--color-border-light); }

.io-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.io-input  .io-label::before { content: '↘ '; color: var(--color-primary); }
.io-output .io-label::before { content: '↗ '; color: var(--color-success); }

.io-arrow {
  font-size: 10px;
  color: var(--color-text-light);
  transition: transform var(--transition);
}

.io-toggle[aria-expanded="true"] .io-arrow { transform: rotate(180deg); }

.io-content {
  padding: 10px 14px 14px;
  font-size: 12px;
  color: var(--color-text);
  line-height: 1.6;
  background: #fafbfc;
  max-height: 300px;
  overflow-y: auto;
}

/* ============================================================
   RÉSUMÉ D'ENTRÉE DES AGENTS
   ============================================================ */

.input-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 0;
}

.input-summary-section { }

.input-summary-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.input-summary-value {
  font-size: 12px;
  color: var(--color-text);
  background: var(--color-border-light);
  border-left: 3px solid var(--color-primary-dim);
  padding: 6px 10px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.5;
  font-style: italic;
}

.input-summary-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.input-summary-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.input-summary-tag-ctx {
  background: var(--color-warning-dim);
  color: var(--color-warning);
  border-color: #fcd34d;
}

.input-summary-none {
  font-size: 12px;
  color: var(--color-text-light);
  font-style: italic;
}

/* ============================================================
   RENDU MARKDOWN (utilisé dans io-content et résultat)
   ============================================================ */

.md-render h1, .md-render h2, .md-render h3 {
  color: var(--color-text);
  margin: 14px 0 6px;
  font-weight: 700;
}

.md-render h2 { font-size: 15px; }
.md-render h3 { font-size: 14px; }

.md-render p  { margin-bottom: 8px; font-size: 13px; }

.md-render ul, .md-render ol {
  padding-left: 20px;
  margin-bottom: 8px;
  font-size: 13px;
}

.md-render li { margin-bottom: 3px; }

.md-render strong { font-weight: 700; }
.md-render em     { font-style: italic; }

.md-render code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 11.5px;
  background: #f1f5f9;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 5px;
}

.md-render table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 10px 0;
}

.md-render th, .md-render td {
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  text-align: left;
}

.md-render th {
  background: var(--color-border-light);
  font-weight: 700;
  color: var(--color-text);
}

.md-render td { background: var(--color-surface); }

.md-render tr:nth-child(even) td { background: #f8f9fb; }

.md-render blockquote {
  border-left: 3px solid var(--color-primary);
  padding: 6px 14px;
  color: var(--color-text-muted);
  background: var(--color-border-light);
  border-radius: 0 6px 6px 0;
  margin: 8px 0;
  font-style: italic;
  font-size: 13px;
}

/* ============================================================
   RÉSULTAT FINAL
   ============================================================ */

.result-zone { border-color: #86efac; }

.result-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-success);
}

.icon-check { width: 18px; height: 18px; flex-shrink: 0; }

.result-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text);
}

.result-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border-light);
}

/* ============================================================
   MÉTADONNÉES D'ANALYSE (dans step-detail)
   ============================================================ */

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--color-border-light);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  flex: 1;
  min-width: 120px;
}

.meta-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-text-muted);
}

.meta-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}

.clarity-bar {
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 3px;
}

.clarity-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 600ms ease;
}

/* Couleur de la barre de clarté selon le score */
.clarity-fill.low    { background: var(--color-error); }
.clarity-fill.medium { background: var(--color-warning); }
.clarity-fill.high   { background: var(--color-success); }

/* Sous-titre du sujet identifié */
.analysis-subject {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

/* Ligne score + badge côte à côte */
.analysis-score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Badge inline (suffisant / précisions) */
.analysis-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 2px 7px;
  border-radius: 99px;
}

.analysis-badge.badge-ok   { background: var(--color-success-dim); color: var(--color-success); }
.analysis-badge.badge-warn { background: var(--color-warning-dim); color: var(--color-warning); }

/* Pastilles de complexité */
.complexity-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.complexity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.complexity-dot.dot-low    { background: var(--color-success); }
.complexity-dot.dot-medium { background: var(--color-warning); }
.complexity-dot.dot-high   { background: var(--color-error); }
.complexity-dot.dot-empty  { background: var(--color-border); }

.meta-value-sm {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
}

/* Badges de domaines */
.analysis-domains {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 3px;
}

.analysis-domain-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: capitalize;
}

/* Grille des 5 dimensions d'analyse (nouveau format de prompt) */
.meta-item-full { grid-column: 1 / -1; }

.dimensions-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.dimension-row {
  display: grid;
  grid-template-columns: 140px 1fr 48px;
  align-items: center;
  gap: 10px;
}

.dimension-label {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.dimension-bar {
  height: 6px;
  background: var(--color-border-light);
  border-radius: 99px;
  overflow: hidden;
}

.dimension-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
}

.dimension-fill.high   { background: var(--color-success); }
.dimension-fill.medium { background: #f59e0b; }
.dimension-fill.low    { background: var(--color-error); }

.dimension-value {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: right;
}

/* Agent score dans la sélection */
.agent-score-list { display: flex; flex-direction: column; gap: 8px; }

.agent-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.agent-score-name { font-weight: 600; min-width: 100px; }
.agent-score-reason { color: var(--color-text-muted); flex: 1; font-size: 12px; }
.agent-score-value { font-weight: 700; font-size: 12px; color: var(--color-primary); flex-shrink: 0; }

/* ============================================================
   GRAPHE INTERACTIF SVG
   ============================================================ */

.graph-zone {
  margin-bottom: 20px;
}

.graph-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.graph-svg {
  display: block;
  width: 100%;
}

/* --- Nœuds --- */

.graph-node { transition: opacity .2s; }
.graph-node:focus { outline: none; }

.node-circle {
  fill: var(--color-border-light);
  stroke: var(--color-border);
  stroke-width: 2;
  transition: fill .25s, stroke .25s;
}

/* Orchestrateur */
.node-orchestrator .node-circle {
  fill: var(--color-primary);
  stroke: none;
}

/* États des agents */
.node-pending .node-circle {
  fill: var(--color-border-light);
  stroke: var(--color-border);
}

.node-running .node-circle {
  fill: var(--color-primary-dim);
  stroke: var(--color-primary);
  stroke-width: 2.5;
}

.node-done .node-circle {
  fill: var(--color-success-dim);
  stroke: var(--color-success);
  stroke-width: 2.5;
}

.node-error .node-circle {
  fill: var(--color-error-dim);
  stroke: var(--color-error);
  stroke-width: 2.5;
}

.node-selected .node-circle {
  stroke-width: 3;
  filter: drop-shadow(0 0 6px var(--color-primary-dim));
}

/* Anneau de pulsation (visible en état running) */
.node-ring {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 2;
  opacity: .5;
  animation: graphPulse 1.4s ease-in-out infinite;
}

@keyframes graphPulse {
  0%, 100% { opacity: .5; transform: scale(1); }
  50%       { opacity: .1; transform: scale(1.15); }
}

/* Texte dans les nœuds */
.node-letter {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.node-pending .node-letter  { fill: var(--color-text-muted); }
.node-running .node-letter  { fill: var(--color-primary); }
.node-done    .node-letter  { fill: var(--color-success); }
.node-error   .node-letter  { fill: var(--color-error); }

.node-label {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  fill: var(--color-text);
  text-anchor: middle;
  pointer-events: none;
}

.node-orchestrator .node-label { fill: var(--color-text-muted); font-weight: 400; }

.node-score {
  font-family: var(--font);
  font-size: 10px;
  fill: var(--color-primary);
  text-anchor: middle;
  font-weight: 600;
  pointer-events: none;
}

.node-status-icon {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  fill: var(--color-text-muted);
}

.node-done  .node-status-icon { fill: var(--color-success); }
.node-error .node-status-icon { fill: var(--color-error); }

/* --- Nœud de synthèse (couleur ambrée, distinct des agents bleus) --- */

.node-synthesis .node-circle {
  fill: #fef3c7;
  stroke: #d97706;
  stroke-width: 2;
}

/* En attente : cercle vide ambre clair */
.node-synthesis.node-pending .node-circle {
  fill: #fef9ee;
  stroke: #d9770640;
}

/* En cours : fond ambré plein + anneau pulsant */
.node-synthesis.node-running .node-circle {
  fill: #fef3c7;
  stroke: #d97706;
}

.node-synthesis.node-running .node-ring {
  stroke: #d97706;
}

/* Terminé : fond vert doux */
.node-synthesis.node-done .node-circle {
  fill: var(--color-success-dim);
  stroke: var(--color-success);
}

/* Lettres et labels */
.node-synthesis.node-pending .node-letter { fill: #d97706; }
.node-synthesis.node-running .node-letter { fill: #92400e; }
.node-synthesis.node-done    .node-letter { fill: var(--color-success); }
.node-synthesis .node-label               { fill: #92400e; font-weight: 600; }

/* --- Arêtes --- */

.graph-edge {
  stroke: var(--color-border);
  stroke-width: 1.5;
}

.graph-edge-dashed {
  stroke-dasharray: 5 4;
  stroke: var(--color-border);
}

.arrow-poly {
  fill: var(--color-border);
}

/* --- Panneau de détail --- */

.graph-detail-panel {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.graph-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--color-border-light);
  border-bottom: 1px solid var(--color-border);
}

.graph-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--color-text);
}

.graph-panel-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition);
  line-height: 1;
}

.graph-panel-close:hover { color: var(--color-error); }

.graph-panel-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.graph-panel-section { }

.graph-panel-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.graph-panel-output {
  max-height: 320px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
}

/* ============================================================
   MESSAGES D'ERREUR
   ============================================================ */

.error-banner {
  background: var(--color-error-dim);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--color-error);
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.error-banner::before { content: '⚠'; font-size: 14px; flex-shrink: 0; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 620px) {
  .card { padding: 18px; }
  .agents-parallel[data-count="2"],
  .agents-parallel[data-count="3"] { grid-template-columns: 1fr; }
  .docs-header { flex-direction: column; align-items: flex-start; gap: 6px; }
}
