/* ============================================================
   Design tokens
   ============================================================ */
:root {
  /* Base palette (dark) */
  --bg-app: #0a0c10;
  --bg-1: #11141a;
  --bg-2: #181c24;
  --bg-3: #21262f;
  --bg-hover: #262b36;
  --border: #2a2f3a;
  --border-strong: #3a4150;
  --border-soft: #1c2028;

  /* Text */
  --text: #e8ebf0;
  --text-2: #b4bcc8;
  --text-dim: #7d8693;
  --text-faint: #8a92a0;   /* ≥ 4,5:1 sur --bg-1 : lisible pour les indications et les placeholders */

  /* Brand / accent */
  --accent: #5b8def;
  --accent-hover: #7aa3ff;
  --accent-soft: rgba(91, 141, 239, 0.15);

  /* Semantic */
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --error: #f87171;
  --error-soft: rgba(248, 113, 113, 0.12);

  /* Type colors for placeholders */
  --c-person-h: #5b9bd5;
  --c-person-f: #e07abd;
  --c-person-u: #9aa3b2;
  --c-email: #b19cd9;
  --c-phone: #4db6ac;
  --c-address: #ffb74d;
  --c-iban: #81c784;
  --c-credit: #66bb6a;
  --c-tax: #fff176;
  --c-id: #ffd54f;
  --c-org: #ba68c8;
  --c-job: #a1887f;
  --c-date: #90caf9;
  --c-dob: #64b5f6;
  --c-ip: #f06292;
  --c-mac: #f48fb1;
  --c-api: #ef5350;
  --c-url: #4fc3f7;
  --c-medical: #ff8a65;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);

  /* Échelle typographique : sept tailles, pas vingt. */
  --fs-xs: 10px;
  --fs-sm: 11px;
  --fs-base: 12px;
  --fs-md: 13px;
  --fs-lg: 14px;
  --fs-xl: 16px;
  --fs-2xl: 22px;

  color-scheme: dark;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', Monaco, Menlo, ui-monospace, monospace;
}

/* ============================================================
   Reset & base
   ============================================================ */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-app);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Style de base des champs. Sans lui, un <input> posé hors d'un .auth-field
   gardait le fond blanc natif du navigateur sur une carte sombre. */
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px var(--sp-3);
  color: var(--text);
  font-size: var(--fs-lg);
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }
::placeholder { color: var(--text-faint); }

/* Le focus clavier est visible partout, et invisible à la souris. Les
   `outline: none` posés au cas par cas sont retirés plus bas. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

a { color: var(--accent); }
a.btn-primary, a.btn-ghost, a.btn-secondary, a.btn-danger, a.btn-lg { text-decoration: none; }

/* Icônes SVG (cf. public/icons.js). Héritent de la couleur du texte. */
.icon { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 40px; height: 40px; }

/* Un seul mécanisme de masquage. L'attribut `hidden` est préféré ; la classe
   reste pour les bascules faites en JS avec classList. */
.hidden, 
button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================================
   Header
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-5);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 56px;
  flex-wrap: wrap;
}
.app-header .brand { margin-right: var(--sp-2); }
.app-header .spacer { flex: 1; }
/* Pages de compte : une rangée de liens fantômes, identique sur le profil,
   l'abonnement et la console. */
.header-nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.header-nav a { white-space: nowrap; }
.header-nav a.is-current { color: var(--text); background: var(--bg-2); }

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: inherit;
  text-decoration: none;
}
.brand-icon {
  width: 26px; height: 26px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--bg-app);
}
.brand-icon .icon { width: 15px; height: 15px; vertical-align: 0; }
.brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand h1 small { font-weight: 400; color: var(--text-dim); }

.health {
  display: flex;
  gap: var(--sp-2);
  flex: 1;
  justify-content: center;
}
/* Une seule pastille d'état pour l'utilisateur : « Prêt », ou ce qui manque.
   Les noms de services et les numéros de version restent dans l'infobulle. */
.status-pill {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 4px var(--sp-3);
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-2); font-size: var(--fs-base); color: var(--text-2);
  white-space: nowrap;
}
.status-pill .health-dot { width: 7px; height: 7px; }
.status-pill.ok .health-dot { background: var(--success); box-shadow: 0 0 8px var(--success-soft); }
.status-pill.warn .health-dot { background: var(--warn); box-shadow: 0 0 8px var(--warn-soft); }
.status-pill.err .health-dot { background: var(--error); box-shadow: 0 0 8px var(--error-soft); }
.status-pill.loading .health-dot { background: var(--warn); animation: pulse 1.5s ease-in-out infinite; }

.health-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px var(--sp-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  transition: background 0.15s;
}
.health-badge:hover { background: var(--bg-3); }

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
  transition: background 0.2s;
}
.health-badge.ok .health-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success-soft);
}
.health-badge.err .health-dot {
  background: var(--error);
  box-shadow: 0 0 8px var(--error-soft);
}
.health-badge.loading .health-dot {
  background: var(--warn);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.health-label { font-weight: 500; color: var(--text-2); }
.health-detail { color: var(--text-dim); font-size: 11px; }

.header-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  margin-left: auto;
}
.header-actions .btn-primary { white-space: nowrap; }

/* Segmented control mode (Anonymisation | Conversation) */
.mode-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.mode-btn {
  padding: 5px var(--sp-4);
  font-size: 13px;
  color: var(--text-dim);
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.15s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  background: var(--accent);
  color: var(--bg-app);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.mode-btn .icon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }

/* ============================================================
   Body layout
   ============================================================ */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: 240px;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar.hidden { display: none; }

.sidebar-section-header {
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-section-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}
.sidebar-section-action {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.sidebar-section-action:hover { background: var(--accent-soft); color: var(--accent); }

.sidebar-search {
  padding: 0 var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.sidebar-search { position: relative; }
.sidebar-search .icon {
  position: absolute; left: calc(var(--sp-3) + 9px); top: 9px;
  color: var(--text-dim); pointer-events: none;
}
.sidebar-search input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3) var(--sp-2) 30px;
  font-size: var(--fs-md);
}
.sidebar-search input:focus {
  border-color: var(--accent);
  background: var(--bg-3);
}

.session-list {
  list-style: none;
  margin: 0;
  padding: var(--sp-2) 0;
  overflow-y: auto;
  flex: 1;
}

.session-item {
  padding: var(--sp-2) var(--sp-3);
  margin: 2px var(--sp-2);
  cursor: pointer;
  border-radius: var(--radius);
  position: relative;
  transition: background 0.1s;
}
.session-item:hover { background: var(--bg-2); }
.session-item.active {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

.session-title {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  margin-bottom: 2px;
}
.session-meta {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  gap: var(--sp-2);
}
.session-meta .chip, .session-item .conv-count {
  background: var(--bg-3);
  color: var(--text-2);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: var(--fs-xs);
}

.session-delete {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
}
.session-delete .icon { width: 13px; height: 13px; vertical-align: 0; }
/* Révélé au survol ET au clavier : en display:none il sortait de la tabulation. */
.session-item:hover .session-delete,
.session-item:focus-within .session-delete,
.session-delete:focus-visible { opacity: 1; pointer-events: auto; }
.session-delete:hover { color: var(--error); background: var(--bg-3); }

.session-list .empty-state {
  padding: var(--sp-5);
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* ============================================================
   Main
   ============================================================ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding: var(--sp-4) var(--sp-5);
  gap: var(--sp-3);
}
.main.hidden { display: none; }

/* ============================================================
   Presets bar
   ============================================================ */
.presets-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.presets {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex-wrap: wrap;
}
.presets-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: var(--sp-2);
}

.preset-btn {
  padding: 5px var(--sp-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-2);
  transition: all 0.15s;
}
.preset-btn:hover {
  background: var(--bg-3);
  color: var(--text);
}
.preset-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

/* ============================================================
   Types avancés (collapsible)
   ============================================================ */
.types-advanced {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
}
.types-advanced.hidden { display: none; }

#entity-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--sp-2);
}

.entity-checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px var(--sp-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  user-select: none;
  transition: background 0.1s;
}
.entity-checkbox:hover { background: var(--bg-2); }

.entity-checkbox input { cursor: pointer; accent-color: var(--accent); }

.entity-checkbox-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================================
   Workspace : 2 panels + action column
   ============================================================ */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--sp-3);
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.panel-icon { color: var(--text-dim); }
.panel-hint {
  font-size: 11px;
  color: var(--text-dim);
}

.panel textarea {
  flex: 1;
  background: transparent;
  color: var(--text);
  border: none;
  padding: var(--sp-4);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  resize: none;
  min-height: 0;
}
.panel textarea::placeholder { color: var(--text-faint); white-space: pre-wrap; }

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border);
  background: var(--bg-1);
  min-height: 36px;
}

.char-counter, .output-stats, .status {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.status.ok, .char-counter.ok { color: var(--success); }
.status.warn, .char-counter.warn { color: var(--warn); }
.status.err, .char-counter.err { color: var(--error); font-weight: 600; }

/* ============================================================
   Action column : bouton run + progress
   ============================================================ */
.action-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-2);
}

.btn-run {
  background: var(--accent);
  color: var(--bg-app);
  padding: var(--sp-4) var(--sp-4);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 130px;
  box-shadow: var(--shadow);
  transition: all 0.15s;
  font-weight: 500;
}
.btn-run:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.btn-run:disabled {
  background: var(--bg-3);
  color: var(--text-dim);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.btn-run-label { font-size: var(--fs-lg); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn-run-sublabel { font-size: var(--fs-sm); opacity: 0.8; font-weight: 400; }

.progress {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: 100%;
  margin-top: var(--sp-2);
}
.progress[hidden] { display: none; }

.progress-step {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 11px;
  color: var(--text-dim);
}
.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
}
.progress-step.active .progress-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: pulse 1.5s ease-in-out infinite;
}
.progress-step.done .progress-dot {
  background: var(--success);
  border-color: var(--success);
}
.progress-step.active, .progress-step.done { color: var(--text); }

/* ============================================================
   Rich text (zone d'affichage avec placeholders coloriés)
   ============================================================ */
.rich-text {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.rich-text:empty::before {
  content: attr(data-empty);
  color: var(--text-faint);
  font-style: italic;
}
/* La réponse rendue en Markdown ne doit pas hériter du pre-wrap du conteneur :
   les retours à la ligne du source doubleraient chaque paragraphe. */
.rich-text.markdown { white-space: normal; }
.rich-text .ph { white-space: nowrap; }
.rich-text-error {
  color: var(--error); padding: var(--sp-3); background: var(--error-soft);
  border-radius: var(--radius); font-size: var(--fs-md); white-space: normal;
}

/* Placeholders coloriés */
.ph {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: help;
  border: 1px solid currentColor;
  background: color-mix(in srgb, currentColor 10%, transparent);
  transition: all 0.15s;
  vertical-align: baseline;
}
.ph:hover {
  background: color-mix(in srgb, currentColor 25%, transparent);
  transform: translateY(-1px);
}
.ph.ph-highlight {
  animation: ph-flash 1.5s ease;
}
@keyframes ph-flash {
  0%, 100% { background: color-mix(in srgb, currentColor 10%, transparent); }
  30%, 70% { background: color-mix(in srgb, currentColor 50%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 20%, transparent); }
}

/* Couleurs par type */
.ph-PERSON, .ph-PERSON_H_ { color: var(--c-person-h); }
.ph-PERSON_F_ { color: var(--c-person-f); }
.ph-PERSON_U_ { color: var(--c-person-u); }
.ph-EMAIL_ { color: var(--c-email); }
.ph-PHONE_ { color: var(--c-phone); }
.ph-ADDRESS_ { color: var(--c-address); }
.ph-IBAN_ { color: var(--c-iban); }
.ph-CREDIT_CARD_ { color: var(--c-credit); }
.ph-TAX_ID_ { color: var(--c-tax); }
.ph-ID_NUMBER_ { color: var(--c-id); }
.ph-ORG_ { color: var(--c-org); }
.ph-JOB_TITLE_ { color: var(--c-job); }
.ph-DATE_ { color: var(--c-date); }
.ph-DATE_OF_BIRTH_ { color: var(--c-dob); }
.ph-IP_ADDRESS_ { color: var(--c-ip); }
.ph-MAC_ADDRESS_ { color: var(--c-mac); }
.ph-API_KEY_ { color: var(--c-api); }
.ph-URL_ { color: var(--c-url); }
.ph-MEDICAL_CONDITION_ { color: var(--c-medical); }
.ph-orphan {
  color: var(--error);
  background: var(--error-soft);
  border-style: dashed;
  text-decoration: line-through;
  text-decoration-color: var(--error);
}

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 1000;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-3);
  font-size: 12px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  max-width: 320px;
  word-wrap: break-word;
}
.tooltip.hidden { display: none; }
.tooltip-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.tooltip-value {
  font-family: var(--font-mono);
  color: var(--text);
}
.tooltip-type {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* ============================================================
   Alerts
   ============================================================ */
.alerts-zone {
  background: var(--bg-1);
  border: 1px solid var(--warn-soft);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  flex-shrink: 0;
}
.alerts-zone[hidden] { display: none; }

.alerts-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.alerts-icon { color: var(--warn); font-size: 14px; }
.alerts-title {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
}

.alerts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-3);
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warn);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.alert-item:hover { background: var(--bg-3); }
.alert-item.severity-error { border-left-color: var(--error); }
.alert-item.severity-warn { border-left-color: var(--warn); }

.alert-kind {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: 1px 6px;
  background: var(--bg-3);
  border-radius: 3px;
  color: var(--text-2);
  flex-shrink: 0;
}
.alert-message { flex: 1; color: var(--text); }
.alert-locate { font-size: 11px; color: var(--text-dim); }

/* ============================================================
   Details zone (collapsible technical view)
   ============================================================ */
.details-zone {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.details-zone summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  font-size: 13px;
  list-style: none;
  user-select: none;
}
.details-zone summary::-webkit-details-marker { display: none; }
.details-zone summary:hover { background: var(--bg-2); }

.details-chevron {
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.15s;
}
.details-zone[open] .details-chevron { transform: rotate(180deg); }

.details-title { color: var(--text-2); font-weight: 500; }
.details-summary { color: var(--text-dim); font-size: 12px; margin-left: auto; }

.details-content { border-top: 1px solid var(--border); }

.details-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.details-tab {
  padding: var(--sp-2) var(--sp-4);
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.details-tab:hover { color: var(--text); }
.details-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.details-panel {
  padding: var(--sp-3);
  max-height: 280px;
  overflow-y: auto;
}
.details-panel.hidden { display: none; }
.details-panel .rich-text {
  padding: var(--sp-3);
  background: var(--bg-2);
  border-radius: var(--radius);
  font-size: 13px;
  max-height: 220px;
}

.mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--font-mono);
}
.mapping-table td {
  padding: 5px var(--sp-2);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.mapping-table tr:last-child td { border-bottom: none; }
.mapping-table .cell-ph {
  width: 1%;
  white-space: nowrap;
}
.mapping-table .cell-arrow {
  width: 20px;
  color: var(--text-faint);
  text-align: center;
}
.mapping-table .cell-value { color: var(--text); word-break: break-all; }

/* ============================================================
   Buttons (généraux)
   ============================================================ */
.btn-primary {
  background: var(--accent);
  color: var(--bg-app);
  padding: 6px var(--sp-3);
  border-radius: var(--radius);
  font-size: var(--fs-md);
  font-weight: 600;
  transition: background 0.15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled {
  background: var(--bg-3);
  color: var(--text-dim);
  cursor: not-allowed;
}

.btn-ghost {
  color: var(--text-2);
  padding: 5px var(--sp-3);
  border-radius: var(--radius);
  font-size: var(--fs-base);
  transition: background 0.1s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-ghost.danger:hover { color: var(--error); background: var(--error-soft); }

.btn-secondary {
  background: var(--bg-3); color: var(--text-2);
  border: 1px solid var(--border-strong);
  padding: 5px var(--sp-3); border-radius: var(--radius); font-size: var(--fs-md);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn-secondary:disabled { opacity: .5; cursor: not-allowed; }

.btn-danger {
  background: var(--error); color: var(--bg-app);
  padding: 6px var(--sp-3); border-radius: var(--radius); font-size: var(--fs-md); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn-danger:hover { filter: brightness(1.1); }

/* Bouton carré à icône seule. Un aria-label est OBLIGATOIRE sur chacun. */
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); color: var(--text-2);
}
.btn-icon:hover { background: var(--bg-3); color: var(--text); }
.btn-icon.danger:hover { color: var(--error); background: var(--error-soft); }

.btn-small { padding: 3px var(--sp-2); font-size: var(--fs-sm); }
.btn-primary:disabled, .btn-ghost:disabled { opacity: .55; cursor: not-allowed; }

/* ============================================================
   Vue Conversation (chat anonymisé multi-tours)
   ============================================================ */
.conv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.conv-header-main h2 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 600;
}
.conv-header-main .hint { font-size: 12px; color: var(--text-dim); }
.conv-header-actions { display: flex; gap: var(--sp-2); align-items: center; }

/* Layout chat avec panneau mapping latéral */
.chat-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-3);
  min-height: 0;
  transition: grid-template-columns 0.2s ease;
}
.chat-layout.with-mapping {
  grid-template-columns: 1fr 280px;
}

.chat-area {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: var(--sp-3);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 0;
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
  max-width: 460px;
  padding: var(--sp-5);
}
.chat-empty-icon { color: var(--text-faint); margin-bottom: var(--sp-3); }
.chat-empty h3 { color: var(--text); font-size: 16px; margin: 0 0 var(--sp-3); font-weight: 600; }
.chat-empty p { font-size: 13px; line-height: 1.6; margin: 0 0 var(--sp-3); }
.chat-empty-hint { color: var(--text-faint); font-size: 12px; }

.chat-bubble {
  max-width: 75%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  font-size: var(--fs-md);
  line-height: 1.55;
  word-wrap: break-word;
  position: relative;
  animation: bubble-in 0.2s ease-out;
}
/* Le texte brut de l'utilisateur garde ses retours à la ligne ; le Markdown
   rendu de l'assistant gère les siens — pre-wrap les doublait. */
.chat-bubble.user .chat-bubble-content { white-space: pre-wrap; }
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-bottom-right-radius: var(--radius-sm);
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}

/* Auteur en haut de chaque bulle */
.chat-bubble-author {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: 0.2px;
}
.chat-bubble.user .chat-bubble-author { color: var(--accent); }
.chat-bubble.assistant .chat-bubble-author { color: var(--text-2); }
.chat-bubble-author-name { flex-shrink: 0; }
.chat-bubble-author-date {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.chat-bubble-content {
  word-wrap: break-word;
}

/* ---- Markdown rendering (bulles assistant) — compact ---- */
.chat-bubble-content.markdown { font-size: 14px; line-height: 1.45; }
.chat-bubble-content.markdown > *:first-child { margin-top: 0; }
.chat-bubble-content.markdown > *:last-child { margin-bottom: 0; }

.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 {
  margin: 10px 0 3px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.3;
}
.markdown h1 { font-size: 17px; }
.markdown h2 { font-size: 15px; }
.markdown h3 { font-size: 14px; }
.markdown h4 { font-size: 14px; }

.markdown p { margin: 0 0 6px; }
.markdown p:last-child { margin-bottom: 0; }

.markdown strong { font-weight: 600; color: var(--text); }
.markdown em { font-style: italic; }
.markdown del { color: var(--text-dim); text-decoration: line-through; }

.markdown a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.markdown a:hover { color: var(--accent-hover); }

.markdown ul, .markdown ol { margin: 4px 0 6px; padding-left: 22px; }
.markdown li { margin: 0; padding: 1px 0; }
.markdown li > p { margin: 0; }
.markdown li > ul, .markdown li > ol { margin: 2px 0 2px; }

.markdown blockquote {
  border-left: 3px solid var(--accent);
  padding: 2px 10px;
  margin: 6px 0;
  color: var(--text-2);
  background: var(--bg-2);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.markdown blockquote p { margin: 2px 0; }

.markdown code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-3);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text);
}

.markdown pre {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 6px 0;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.4;
}
.markdown pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 12px;
  color: var(--text);
}

.markdown table {
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 13px;
  width: 100%;
}
.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
}
.markdown th {
  background: var(--bg-3);
  font-weight: 600;
  color: var(--text);
}
.markdown tr:nth-child(even) td { background: var(--bg-2); }

.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

.markdown img { max-width: 100%; height: auto; border-radius: var(--radius); }
.chat-bubble-actions {
  display: flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
  position: absolute;
  top: -10px;
  right: var(--sp-3);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 2px;
  gap: 0;
  box-shadow: var(--shadow);
  z-index: 5;
}
.chat-bubble:hover .chat-bubble-actions,
.chat-bubble:focus-within .chat-bubble-actions { opacity: 1; pointer-events: auto; }
.chat-bubble-action .icon { width: 14px; height: 14px; vertical-align: 0; }
.chat-bubble-action {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  transition: background 0.1s, color 0.1s;
}
.chat-bubble-action:hover { background: var(--bg-2); color: var(--text); }
.chat-bubble-action.danger:hover { color: var(--error); }

.chat-bubble-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}
.chat-bubble-meta .alert-pill {
  background: var(--warn-soft);
  color: var(--warn);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  cursor: pointer;
}

.chat-bubble.thinking {
  background: var(--bg-2);
  border: 1px dashed var(--border-strong);
  align-self: flex-start;
  color: var(--text-dim);
  font-style: italic;
}
.chat-bubble.thinking .chat-bubble-content::after {
  content: '▍';
  animation: blink 1s steps(2) infinite;
}
.chat-bubble.is-error { border-left: 3px solid var(--error); }
.chat-bubble.is-error .chat-bubble-author, .chat-bubble.is-error .chat-bubble-content { color: var(--error); }
@keyframes blink { 50% { opacity: 0; } }

.chat-input-bar {
  display: flex;
  gap: var(--sp-2);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-2);
}
.chat-input-bar textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  padding: var(--sp-2);
  min-height: 36px;
  max-height: 200px;
}
.chat-input-bar textarea::placeholder { color: var(--text-faint); white-space: pre; }

.chat-input-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}
.chat-input-wrap textarea { width: 100%; }
.chat-word-counter {
  align-self: flex-end;
  padding: 2px 8px 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chat-send-group {
  display: flex;
  gap: var(--sp-1);
  align-self: flex-end;
}
.chat-send {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-lg);
  height: 38px;
  min-width: 44px;
}
.chat-send .icon { width: 18px; height: 18px; vertical-align: 0; }
.chat-send-review {
  background: var(--bg-3);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  padding: var(--sp-2) var(--sp-3);
}
.chat-send-review:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

/* Mapping side panel */
.mapping-panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.mapping-panel.hidden { display: none; }

.mapping-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.mapping-panel-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}
.mapping-panel-count {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}
.mapping-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-3);
}
.mapping-panel-empty {
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
  text-align: center;
  margin: var(--sp-5) 0;
  padding: 0 var(--sp-3);
  line-height: 1.6;
}

/* Popup d'info message (raw anonymisé) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-close .icon { vertical-align: 0; }
.modal-help { font-size: var(--fs-sm); color: var(--text-dim); margin-top: 6px; line-height: 1.5; }
.modal-close:hover { background: var(--bg-3); color: var(--text); }
.modal-body { padding: var(--sp-4); }
.modal-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  background: var(--bg-2);
}
.modal-section { margin-bottom: var(--sp-4); }
.modal-section:last-child { margin-bottom: 0; }
.modal-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}
.modal-section-content {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
  font-size: 13px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.55;
  max-height: 280px;
  overflow-y: auto;
}


/* ============================================================
   Pages publiques (vitrine, sign-in, sign-up)
   ============================================================ */
body.page-public {
  display: block;
  overflow-y: auto;
}

.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
}
.public-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
}
.public-brand strong { font-weight: 600; }
.public-nav { display: flex; gap: var(--sp-2); }
.public-nav a { text-decoration: none; }

.btn-lg {
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--fs-lg);
  border-radius: var(--radius-md);
}
.btn-block { width: 100%; }

/* ===== Onboarding steps indicator ===== */
.onboarding-steps {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  font-size: 12px;
}
.onboarding-steps .step {
  padding: 4px 10px;
  color: var(--text-dim);
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
}
.onboarding-steps .step.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.onboarding-steps .step.done {
  color: var(--success);
  border-color: var(--success-soft);
}
.onboarding-steps .step.done::before { content: '✓ '; }

/* ===== Interrupteur (console) ===== */
.switch-row { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); white-space: nowrap; cursor: pointer; }
.switch-row .switch-label { color: var(--text-2); }
.switch-row input:checked ~ .switch-label { color: var(--text); }
.switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 999px; transition: background 0.2s;
}
.switch-slider::before {
  content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: var(--text-dim); border-radius: 50%; transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .switch-slider { background: var(--success-soft); border-color: var(--success); }
.switch input:checked + .switch-slider::before { transform: translateX(22px); background: var(--success); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.danger input:checked + .switch-slider { background: var(--error-soft); border-color: var(--error); }
.switch.danger input:checked + .switch-slider::before { background: var(--error); }

/* ===== Auth pages (sign-in, sign-up) ===== */
.page-auth { display: flex; flex-direction: column; min-height: 100vh; }
.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
}
/* L'attribut `hidden` du HTML ne pose qu'un `display: none` de faible priorité :
   toute règle posant un `display` sur le même élément l'annule silencieusement.
   C'est ce qui faisait apparaître EN MÊME TEMPS le formulaire d'inscription et
   l'écran « Bientôt disponible » (`.auth-card` est en `display: flex`).
   Deux règles ad hoc existaient déjà plus haut pour ce même motif — celle-ci les
   généralise à toute l'application. */
[hidden] { display: none !important; }

.auth-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.auth-card-inline { padding: 0; border: none; background: transparent; }
.auth-card h1 { margin: 0; font-size: 22px; }
.auth-subtitle { color: var(--text-2); font-size: 13px; margin: -8px 0 var(--sp-2); }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field span { font-size: 12px; color: var(--text-2); font-weight: 500; }
.auth-field input, .auth-field select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px var(--sp-3);
  color: var(--text);
  font-size: 14px;
}
.auth-field input:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-hint { color: var(--text-dim); font-size: 11px; }
/* Messages d'état des formulaires et des pages. Un seul jeu pour tout le monde :
   `.auth-success` n'existait que dans un <style> local du profil, et la page
   d'abonnement l'appelait dans le vide. */
.auth-error, .notice-error, .auth-success, .notice-success, .notice-info, .notice-warn {
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-md);
  margin: 0;
  line-height: 1.5;
}
.auth-error, .notice-error { background: var(--error-soft); color: var(--error); }
.auth-success, .notice-success { background: var(--success-soft); color: var(--success); }
.notice-info { background: var(--accent-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.notice-warn { background: var(--warn-soft); color: var(--warn); }
.auth-check { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-md); color: var(--text-2); }
.auth-check input { margin-top: 3px; }
.auth-check a { color: var(--accent); }
.auth-card--center { text-align: center; }
.auth-stack { display: flex; flex-direction: column; gap: var(--sp-4); width: 100%; max-width: 420px; }
.auth-stack .auth-card { max-width: none; }
.public-brand .brand-icon { width: 24px; height: 24px; }

/* Pages légales */
.page-legal { display: block; overflow-y: auto; }
.legal { max-width: 760px; margin: 0 auto; padding: var(--sp-7) var(--sp-5) var(--sp-6); font-size: 15px; line-height: 1.7; color: var(--text-2); }
.legal h1 { color: var(--text); font-size: 28px; margin: 0 0 4px; letter-spacing: -.02em; }
.legal h2 { color: var(--text); font-size: 17px; margin: var(--sp-6) 0 var(--sp-2); }
.legal p { margin: 0 0 var(--sp-3); }
.legal strong { color: var(--text); }
.legal-meta { color: var(--text-dim); font-size: var(--fs-md); margin-bottom: var(--sp-5); }
.legal-footer { text-align: center; padding: var(--sp-5); color: var(--text-dim); font-size: var(--fs-md); border-top: 1px solid var(--border); }
.auth-icon { color: var(--accent); margin: 0 auto var(--sp-2); display: block; }
.auth-field .optional { font-weight: 400; color: var(--text-dim); }
.auth-alt {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}
.auth-alt a { color: var(--accent); text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }


/* ===== Console superadmin ===== */
.console-main {
  padding: var(--sp-5);
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  overflow-y: auto;
}
.console-section {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  /* Sans ceci, les sections sont des éléments flex COMPRESSIBLES : dès que leur
     total dépasse la hauteur de `.console-main`, chacune est écrasée à quelques
     pixels et son contenu disparaît derrière `overflow: hidden`. Le défaut ne se
     voyait pas tant que la console tenait dans un écran ; il est apparu en
     ajoutant les sections Usage, Fonctionnalités, Réglages et Audit. */
  flex-shrink: 0;
}
.console-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.console-section-header h2 { margin: 0; font-size: var(--fs-lg); font-weight: 600; }
.section-desc { font-size: var(--fs-base); color: var(--text-dim); margin: 4px 0 0; line-height: 1.5; max-width: 72ch; }
.console-body { padding: var(--sp-4) var(--sp-5); }
.console-body--grid { display: grid; gap: var(--sp-4); }
.console-note { padding: 0 var(--sp-5); font-size: var(--fs-md); color: var(--text-dim); margin: var(--sp-3) 0 var(--sp-2); line-height: 1.55; max-width: 80ch; }
.console-select { padding: 4px var(--sp-2); font-size: var(--fs-base); }
.console-empty { padding: var(--sp-5); text-align: center; color: var(--text-dim); font-size: var(--fs-md); }
.console-card { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--sp-4) var(--sp-5); }
.console-card-head { display: flex; align-items: flex-start; gap: var(--sp-4); }
.console-card-title { font-weight: 600; font-size: var(--fs-lg); }
.console-card-row { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.console-card-row input { flex: 1; }
.feature-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.feature-row:last-child { border-bottom: none; }
.feature-row-label { flex: 1; }
.feature-row-title { font-weight: 600; font-size: var(--fs-md); }
.feature-row-key { font-size: var(--fs-base); color: var(--text-dim); }
.form-actions { display: flex; gap: var(--sp-2); align-items: center; }
.fieldset-plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset-plain:disabled { opacity: .6; }
.console-section > .auth-card-inline { padding: var(--sp-5); max-width: 620px; }
.table-scroll { overflow-x: auto; }
.table-scroll .console-table th, .table-scroll .console-table td { white-space: nowrap; }
.table-scroll .console-table td.wrap { white-space: normal; }
.field-row-2-1 { grid-template-columns: 2fr 1fr; }
.field-row-1-2 { grid-template-columns: 1fr 2fr; }
.muted { color: var(--text-dim); }
.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.console-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
  padding: var(--sp-4);
}
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  text-align: center;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

.console-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.console-table th, .console-table td {
  text-align: left;
  padding: 10px var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.console-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  background: var(--bg-2);
}
.console-table tr:last-child td { border-bottom: none; }
.console-table tr:hover td { background: var(--bg-2); }
.row-actions { display: flex; gap: var(--sp-1); justify-content: flex-end; }
.row-actions .danger:hover { color: var(--error); }

.role-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.role-pill.role-superadmin { background: var(--error-soft); color: var(--error); }
.role-pill.role-admin { background: var(--warn-soft); color: var(--warn); }
.role-pill.role-user { background: var(--accent-soft); color: var(--accent); }

/* Pastilles d'état : une sémantique de couleur commune à toute l'application. */
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .3px; text-transform: uppercase;
}
.pill.ok { background: var(--success-soft); color: var(--success); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--error-soft); color: var(--error); }
.pill.muted { background: var(--bg-3); color: var(--text-dim); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

.badge-self {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 4px var(--sp-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: var(--fs-base);
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
}
.user-chip span { overflow: hidden; text-overflow: ellipsis; }
.user-chip-link {
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.user-chip-link:hover {
  background: var(--bg-3);
  border-color: var(--accent);
  color: var(--text);
}

/* ============================================================
   Responsive
   ============================================================ */
/* Trois seuils, réutilisés partout : 1100 (plan de travail), 768 (tablette),
   560 (téléphone). */
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: 1fr auto 1fr; }
  .action-column { flex-direction: row; }
  .progress { flex-direction: row; }
  .brand h1 small { display: none; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .health { display: none; }
  .app-header { padding: var(--sp-2) var(--sp-3); }
  .console-main { padding: var(--sp-3); }
  .header-nav a span { display: none; }
  .header-nav a .icon { margin: 0; }
  .user-chip { max-width: 140px; }
}

/* ============================================================
   Inscription : sélecteur de type de compte, grille de champs,
   autocomplétion d'adresse
   ============================================================ */

.signup-card { max-width: 560px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.segmented-opt { cursor: pointer; }
.segmented-opt input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-opt span {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  transition: border-color .12s, background .12s;
}
.segmented-opt strong { font-size: var(--fs-md); color: var(--text); }
.segmented-opt small { font-size: var(--fs-sm); color: var(--text-dim); }
.segmented-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
/* Le focus clavier doit rester visible : l'input réel est masqué. */
.segmented-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.field-stack { display: flex; flex-direction: column; gap: var(--sp-4); }

.addr-search { position: relative; }
.addr-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  margin: 4px 0 0; padding: 4px; list-style: none;
  max-height: 240px; overflow-y: auto;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
.addr-item {
  padding: var(--sp-2) 10px; font-size: var(--fs-md); line-height: 1.4;
  color: var(--text-2); border-radius: var(--radius-sm); cursor: pointer;
}
.addr-item:hover, .addr-item.is-active { background: var(--bg-3); color: var(--text); }

@media (max-width: 560px) {
  .segmented, .field-row, .field-row-2-1, .field-row-1-2 { grid-template-columns: 1fr; }
  .mode-btn span { display: none; }
  .mode-btn .icon { margin: 0; }
}

/* ============================================================
   Bandeau démo (rappel de l'essai + passage à l'abonnement)
   ============================================================ */

.trial-banner {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: 10px var(--sp-4);
  background: linear-gradient(90deg, var(--accent-soft), transparent);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-md); color: var(--text-2);
}
.trial-banner .icon { color: var(--accent); }
.trial-banner.is-urgent .icon { color: var(--warn); }
.trial-banner strong { color: var(--text); }
/* Le bouton du bandeau est un <a> : sans cela il hérite du soulignement des liens. */
.trial-banner a.btn-primary { text-decoration: none; }
.trial-banner .spacer { flex: 1; }
.trial-banner.is-urgent {
  background: linear-gradient(90deg, var(--warn-soft), transparent);
}
.trial-banner-close {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: 4px; border-radius: var(--radius-sm); display: inline-flex;
}
.trial-banner-close .icon { vertical-align: 0; }
.trial-banner-close:hover { color: var(--text); }

/* ============================================================
   Page abonnement
   ============================================================ */

.billing-grid { display: grid; gap: var(--sp-4); }
.billing-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--sp-5);
}
/* Dans une section déjà encadrée, la carte perd son cadre : pas de boîte
   bordée dans une boîte bordée de la même couleur. */
.console-section .billing-card { background: transparent; border: 0; border-radius: 0; }
.billing-card h2 { margin: 0 0 var(--sp-3); font-size: 15px; }
.billing-kv { display: grid; grid-template-columns: auto 1fr; gap: 8px var(--sp-4); font-size: 13px; }
.billing-kv dt { color: var(--text-dim); }
.billing-kv dd { margin: 0; color: var(--text); }
.billing-price { font-size: 26px; font-weight: 600; color: var(--text); }
.billing-price small { font-size: 13px; font-weight: 400; color: var(--text-dim); }
.billing-detail { margin-top: var(--sp-4); font-size: var(--fs-md); color: var(--text-2); line-height: 1.55; }
.billing-actions { margin-top: var(--sp-4); display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.billing-features { margin: var(--sp-4) 0 0; padding-left: 20px; color: var(--text-2); font-size: var(--fs-md); line-height: 1.9; }
.billing-table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.billing-table th {
  text-align: left; font-weight: 500; color: var(--text-dim);
  padding: 6px 10px 6px 0; border-bottom: 1px solid var(--border);
}
.billing-table td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--border-soft); }
.billing-table tr:last-child td { border-bottom: none; }
.billing-table a { color: var(--accent); text-decoration: none; }
.billing-table a:hover { text-decoration: underline; }

.badge-ok      { color: var(--success); }
.badge-warn    { color: var(--warn); }
.badge-muted   { color: var(--text-dim); }

/* ============================================================
   Toasts et dialogues (cf. public/ui.js)
   ============================================================ */
.toast-host {
  position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: 200;
  display: flex; flex-direction: column; gap: var(--sp-2); max-width: min(420px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-3); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); font-size: var(--fs-md); color: var(--text);
  opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .18s;
  cursor: pointer;
}
.toast.is-in { opacity: 1; transform: none; }
.toast-icon { margin-top: 1px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-warning .toast-icon { color: var(--warn); }
.toast-info .toast-icon { color: var(--accent); }

.dialog { max-width: 460px; }
.dialog-message { margin: 0; font-size: var(--fs-md); line-height: 1.6; color: var(--text-2); white-space: pre-line; }
.dialog .auth-field { margin-top: var(--sp-3); }

/* ============================================================
   Coquille de l'application : rail + zone principale
   ============================================================ */
/* Une seule coquille pour tout ce qui suit la connexion. Le rail porte
   « Nouveau », l'historique unifié et le bloc compte ; la zone principale montre
   UN fil à la fois. Sous 900 px, le rail devient un tiroir. */
body.app-shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.shell { flex: 1; display: flex; min-height: 0; }
.mobile-bar { display: none; }

.rail {
  width: 268px; flex-shrink: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--bg-1); border-right: 1px solid var(--border);
}
.rail-top { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-3) var(--sp-4); }
.rail-close { display: none; }
.rail-new { padding: 0 var(--sp-3) var(--sp-3); position: relative; }
.rail-new .btn-block { justify-content: center; }
.menu-caret { margin-left: auto; opacity: .7; }
.rail-search { position: relative; padding: 0 var(--sp-3) var(--sp-2); }
.rail-search .icon { position: absolute; left: calc(var(--sp-3) + 10px); top: 50%; transform: translateY(-60%); color: var(--text-dim); pointer-events: none; }
.rail-search input { width: 100%; padding: 7px var(--sp-3) 7px 30px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: var(--fs-md); }
.rail-search input:focus { outline: none; border-color: var(--accent); }
.rail-history { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: var(--sp-3); }
.rail-history .empty-state { padding: var(--sp-5) var(--sp-4); color: var(--text-dim); font-size: var(--fs-md); text-align: center; line-height: 1.5; }
.history-group-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); padding: var(--sp-3) var(--sp-4) var(--sp-1); }
.history-item { display: flex; gap: var(--sp-2); align-items: flex-start; padding-right: 30px; }
.history-kind { color: var(--text-dim); margin-top: 3px; flex-shrink: 0; }
.history-text { min-width: 0; flex: 1; }
.history-text .session-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Bloc compte, en bas du rail */
.rail-account { border-top: 1px solid var(--border); padding: var(--sp-2); position: relative; }
.account-btn {
  width: 100%; display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-md);
  color: var(--text); cursor: pointer; text-align: left; font: inherit;
}
.account-btn:hover, .account-btn[aria-expanded="true"] { background: var(--bg-2); }
.account-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: var(--fs-md);
}
.account-text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.account-name { font-size: var(--fs-md); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-plan { font-size: var(--fs-sm); color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-plan.is-warn { color: var(--warn); }
.account-status { display: inline-flex; padding: 4px; }
.account-status .health-dot, .menu-status .health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); display: inline-block; }
.account-status.ok .health-dot, .menu-status.ok .health-dot { background: var(--success); }
.account-status.warn .health-dot, .menu-status.warn .health-dot { background: var(--warn); }
.account-status.err .health-dot, .menu-status.err .health-dot { background: var(--error); }

/* Menus (Nouveau, compte, actions du fil) */
.menu {
  position: absolute; z-index: 60; min-width: 240px;
  background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: var(--sp-1);
}
.rail-new .menu { left: var(--sp-3); right: var(--sp-3); top: calc(100% - var(--sp-2)); }
.menu-up { bottom: calc(100% + 2px); left: var(--sp-2); right: var(--sp-2); }
.menu-right { right: 0; top: calc(100% + 4px); }
.menu-item {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  padding: var(--sp-2) var(--sp-3); background: transparent; border: 0; border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: var(--fs-md); text-align: left; cursor: pointer; text-decoration: none;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-3); color: var(--text); }
.menu-item .icon { color: var(--text-dim); flex-shrink: 0; }
.menu-item > span { display: flex; flex-direction: column; min-width: 0; }
.menu-item small { color: var(--text-dim); font-size: var(--fs-sm); }
.menu-item.danger, .menu-item.danger .icon { color: var(--error); }
.menu-sep { height: 1px; background: var(--border); margin: var(--sp-1) 0; }
.menu-status { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); color: var(--text-dim); }

/* Zone principale et vues */
.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: var(--sp-4) var(--sp-5); gap: var(--sp-3); }
.view[hidden] { display: none; }
.view-home { overflow-y: auto; }
.thread-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.thread-title-wrap { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.thread-title-wrap h2 { margin: 0; font-size: var(--fs-xl); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.thread-meta { font-size: var(--fs-base); color: var(--text-dim); }
.thread-actions { display: flex; align-items: center; gap: var(--sp-2); position: relative; flex-shrink: 0; }
.mask-btn b { font-weight: 600; }
.mask-btn.is-warn { border-color: var(--warn); color: var(--warn); }

/* Composeur : la ligne d'avertissement au-dessus, la carte de blocage à la place */
.composer { display: flex; flex-direction: column; gap: var(--sp-2); }
.composer-notice { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-base); color: var(--text-2); padding: 0 var(--sp-1); }
.notice-part { display: inline-flex; align-items: center; gap: 6px; }
.notice-part.warn .icon { color: var(--warn); }
.notice-part.err .icon { color: var(--error); }
.blocked-card {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
  padding: var(--sp-4); background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.blocked-card-body { display: flex; gap: var(--sp-3); align-items: flex-start; min-width: 0; }
.blocked-card-body .icon { color: var(--warn); flex-shrink: 0; margin-top: 2px; }
.blocked-card strong { font-size: var(--fs-lg); }
.blocked-card p { margin: 4px 0 0; color: var(--text-2); font-size: var(--fs-md); line-height: 1.5; }
.blocked-card .btn-primary { text-decoration: none; }

/* Accueil */
.home { max-width: 880px; margin: 0 auto; width: 100%; padding-top: var(--sp-6); }
.home h2 { font-size: 26px; margin: 0 0 var(--sp-2); letter-spacing: -.01em; }
.home-sub { color: var(--text-2); font-size: var(--fs-lg); margin: 0 0 var(--sp-5); max-width: 64ch; line-height: 1.55; }
.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.home-card {
  text-align: left; display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-5);
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  color: var(--text); cursor: pointer; font: inherit; transition: border-color .15s, background .15s;
}
.home-card:hover { border-color: var(--accent); background: var(--bg-2); }
.home-card .icon { color: var(--accent); }
.home-card strong { font-size: var(--fs-lg); }
.home-card span { color: var(--text-2); font-size: var(--fs-md); line-height: 1.55; }
.home-card.is-disabled { opacity: .5; pointer-events: none; }
.home-starters { margin-top: var(--sp-6); }
.home-starters h3 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin: 0 0 var(--sp-3); }
.home-starters h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: inherit; }
.starters { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.starter {
  text-align: left; padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: 4px;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text); cursor: pointer; font: inherit;
}
.starter:hover { border-color: var(--accent); }
.starter:disabled { opacity: .5; cursor: default; }
.starter strong { font-size: var(--fs-md); }
.starter span { color: var(--text-dim); font-size: var(--fs-sm); }
.home .blocked-card { margin-top: var(--sp-5); }

/* Mon compte : onglets */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tab {
  padding: var(--sp-2) var(--sp-4); background: transparent; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--text-dim); font: inherit; font-size: var(--fs-md); cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.compte-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.compte-panel { display: flex; flex-direction: column; gap: var(--sp-5); max-width: 900px; }

/* Ce qui est masqué : popover ancrée sous le bouton du fil */
.popover {
  position: fixed; z-index: 70; background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: var(--sp-3);
}
.popover[hidden] { display: none; }
.popover-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-1); }
.popover-header h3 { margin: 0; font-size: var(--fs-md); }
.popover-hint { font-size: var(--fs-sm); color: var(--text-dim); margin: 0 0 var(--sp-3); }
.popover .presets { flex-wrap: wrap; margin-bottom: var(--sp-3); }
.types-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px var(--sp-3); max-height: 280px; overflow-y: auto; }
.popover-footer { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); }
.popover-footer .spacer { flex: 1; }

/* Modèle et niveau de réponse : deux listes de choix, un choix par ligne.
   Le coût relatif est montré en points plutôt qu'en tarif au token : ce qui
   compte pour l'utilisateur, c'est qu'Opus consomme son plafond cinq fois plus
   vite que Haiku, pas le prix du million de tokens. */
.llm-section + .llm-section { margin-top: var(--sp-3); }
.llm-section h4 {
  margin: 0 0 var(--sp-2); font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em;
}
.llm-options { display: flex; flex-direction: column; gap: 4px; }
.llm-option {
  display: flex; flex-direction: column; gap: 2px; width: 100%;
  padding: var(--sp-2) var(--sp-3); text-align: left; cursor: pointer;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-1); font: inherit; transition: background .15s, border-color .15s;
}
.llm-option:hover:not(:disabled) { background: var(--bg-2); border-color: var(--border-strong); }
.llm-option.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.llm-option:disabled { opacity: .45; cursor: default; }
.llm-option-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.llm-option-head b { font-weight: 600; font-size: var(--fs-sm); }
.llm-option-desc { font-size: 12px; color: var(--text-dim); line-height: 1.35; }
.llm-cost { color: var(--text-faint); letter-spacing: 2px; font-size: 14px; }
.llm-option.is-selected .llm-cost { color: var(--accent); }
.llm-note { margin: var(--sp-2) 0 0; font-size: 12px; color: var(--text-dim); }
.llm-budget { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.llm-budget.is-warn { color: var(--warn); }

/* Console : un plafond proche ou dépassé doit sauter aux yeux dans le tableau */
.console-table td.is-warn { color: var(--warn); }
.console-table td.is-error { color: var(--error); font-weight: 600; }

/* Paiements : le reçu ILYGO et la facture Stripe, côte à côte */
.paiement-actions { display: flex; gap: var(--sp-3); align-items: baseline; white-space: nowrap; }
.lien-bouton {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
}
.lien-bouton:hover:not(:disabled) { color: var(--text-1); }
.lien-bouton:disabled { color: var(--text-faint); cursor: progress; text-decoration: none; }
.llm-btn .menu-caret { color: var(--text-faint); }

/* Sous chaque message : le geste central, en toutes lettres */
.chat-bubble-foot { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--text-dim); }
.chat-bubble-link { background: none; border: 0; padding: 0; color: var(--text-dim); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font: inherit; font-size: var(--fs-sm); }
.chat-bubble-link:hover { color: var(--accent); }
.chat-bubble-time { color: var(--text-faint); }
.rail-backdrop { display: none; }
.btn-ghost.danger { color: var(--error); }

@media (max-width: 900px) {
  .mobile-bar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); background: var(--bg-1); border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .mobile-bar .brand { flex: 1; }
  .rail {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 80;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .shell.rail-open .rail { transform: none; }
  .rail-close { display: inline-flex; }
  .rail-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 75; }
  .rail-backdrop[hidden] { display: none; }
  .view { padding: var(--sp-3); }
  .home { padding-top: var(--sp-4); }
  .home-cards, .starters { grid-template-columns: 1fr; }
  .thread-actions { width: 100%; flex-wrap: wrap; }
  .types-grid { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
  .workspace { grid-template-columns: 1fr; }
  .action-column { flex-direction: row; justify-content: center; }
}
