/* ===== Tokens — Charte C4RBON GROUP ===== */
:root {
  --primary: #0A0A0A;
  --primary-hover: #1a1a1a;
  --accent: #00E087;
  --accent-soft: #d1fae5;
  --accent-dark: #059669;
  --carbon: #0A0A0A;
  --bg: #F7F8F7;
  --surface: #ffffff;
  --surface-alt: #0A0A0A;
  --border: #E5E7EB;
  --border-card: #EAECEF;
  --text: #0A0A0A;
  --text-muted: #6B7280;
  --text-on-dark: #F7F8F7;
  --success: #00E087;
  --warning: #F59E0B;
  --danger: #EF4444;
  --radius-card: 14px;
  --radius-btn: 12px;
  --radius-input: 10px;
  --shadow-card: 0 1px 2px rgba(10, 10, 10, 0.04), 0 8px 24px rgba(10, 10, 10, 0.04);
  --shadow-hover: 0 12px 32px rgba(10, 10, 10, 0.1);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-head: 'Space Grotesk', 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; color: var(--text); }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }

.mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.02em; }

/* ===== Topbar ===== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  padding-left: calc(32px + env(safe-area-inset-left, 0px));
  padding-right: calc(32px + env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--carbon);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(10, 10, 10, 0.18);
  padding: 8px;
}
.logo-mark svg { width: 100%; height: 100%; display: block; }
.brand-text { line-height: 1.15; }
.brand-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  display: flex; align-items: baseline; gap: 6px;
}
.brand-name .brand-accent { color: var(--accent-dark); }
.brand-sub { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; margin-top: 2px; }

.topnav { display: flex; gap: 6px; }
.nav-btn {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13px;
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.nav-btn:hover:not(:disabled) { background: #f2f3f2; color: var(--primary); }
.nav-btn.active { background: var(--carbon); color: var(--accent); }
.nav-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== Main layout ===== */
main { padding: 28px 32px 60px; max-width: 1600px; margin: 0 auto; }

/* ===== Page header ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-header .subtitle { color: var(--text-muted); margin: 4px 0 0; font-size: 13px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.block { margin-bottom: 18px; }
.block-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* ===== Buttons ===== */
.btn {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--carbon); color: var(--accent); box-shadow: 0 4px 12px rgba(10, 10, 10, 0.2); }
.btn-primary:hover { background: #1a1a1a; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(10, 10, 10, 0.26); }
.btn-accent { background: var(--accent); color: var(--carbon); border-color: var(--accent); box-shadow: 0 4px 12px rgba(0, 224, 135, 0.28); }
.btn-accent:hover { background: #00c876; transform: translateY(-1px); }
.btn-secondary { background: white; color: var(--carbon); border-color: var(--carbon); }
.btn-secondary:hover { background: var(--carbon); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: #f2f3f2; color: var(--text); }
.btn-ghost.danger:hover { background: #fef2f2; color: var(--danger); }
.btn.full { width: 100%; }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn.xs { padding: 4px 10px; font-size: 11px; border-radius: 8px; }

.icon-btn {
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  transition: all 0.15s;
}
.icon-btn:hover { background: #f2f3f2; color: var(--text); }
.icon-btn.danger:hover { background: #fef2f2; color: var(--danger); }

/* ===== Inputs ===== */
.input, .title-input, .meta-input, .phase-title, .module-title {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 9px 12px;
  border: 1.5px solid var(--border-card);
  border-radius: var(--radius-input);
  background: white;
  outline: none;
  transition: all 0.15s;
  width: 100%;
}
.input:focus, .title-input:focus, .meta-input:focus, .phase-title:focus, .module-title:focus {
  border-color: var(--carbon);
  box-shadow: 0 0 0 3px rgba(0, 224, 135, 0.18);
}
.textarea { resize: vertical; min-height: 60px; font-family: var(--font-body); }
.title-input { font-family: var(--font-head); font-weight: 800; font-size: 22px; border: none; padding: 4px 0; background: transparent; }
.title-input:focus { box-shadow: none; border-bottom: 2px solid var(--accent); border-radius: 0; }

.form-field { margin-bottom: 12px; }
.form-field label {
  display: block;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 400; padding-top: 26px; color: var(--text); }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
}

/* ===== KPIs ===== */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-top: 3px solid var(--carbon);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.kpi-value { font-family: var(--font-head); font-weight: 700; font-size: 28px; color: var(--carbon); letter-spacing: -0.03em; }
.kpi-label { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: var(--text-muted); margin-top: 4px; letter-spacing: 0.04em; }

/* ===== Liste CDC ===== */
.table-card { padding: 0; overflow: hidden; }
.cdc-table { width: 100%; border-collapse: collapse; }
.cdc-table thead th {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: #fafbfd;
}
.cdc-table tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cdc-table tbody tr { cursor: pointer; transition: background 0.1s; }
.cdc-table tbody tr:hover { background: #ecfdf5; }
.cdc-table tbody tr:last-child td { border-bottom: none; }
.cdc-title-cell { font-family: var(--font-head); font-weight: 600; color: var(--text); letter-spacing: -0.01em; }

.status-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}
.status-badge.draft { background: #f2f3f2; color: var(--text-muted); }
.status-badge.review { background: #fef3c7; color: #92400e; }
.status-badge.validated { background: var(--accent-soft); color: var(--accent-dark); }
.status-badge.signed { background: var(--carbon); color: var(--accent); }

.empty-state { padding: 60px 20px; text-align: center; }
.empty-icon { font-size: 42px; margin-bottom: 12px; }
.empty-title { font-family: var(--font-head); font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.empty-desc { color: var(--text-muted); font-size: 13px; }

/* ===== Éditeur ===== */
.editor-header-left { flex: 1; min-width: 300px; }
.meta-row { display: flex; gap: 10px; margin-top: 8px; }
.meta-input { max-width: 240px; }
.meta-small { max-width: 140px; }

.save-indicator {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-dark);
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent-soft);
}
.save-indicator.saving { background: #fef3c7; color: var(--warning); }
.save-indicator.error { background: #fee2e2; color: var(--danger); }

.editor-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  align-items: flex-start;
}
@media (max-width: 960px) {
  .editor-grid { grid-template-columns: 1fr; }
  .side-nav { position: static !important; }
}

.side-nav {
  padding: 16px;
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.side-section { margin-bottom: 18px; }
.side-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge.mono {
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
}
.side-link {
  display: block;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  text-align: left;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.side-link:hover { background: #ecfdf5; color: var(--primary); }
.side-link.active { background: var(--carbon); color: var(--accent); }

/* ===== Phase & module cards ===== */
.phase-card { border-left: 4px solid var(--accent); }
.phase-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.phase-index {
  background: var(--carbon);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
}
.input-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 16px;
  flex: 1;
  min-width: 200px;
  border: none;
  background: transparent;
}
.input-title:focus { border-bottom: 2px solid var(--accent); border-radius: 0; }
.phase-duration { max-width: 200px; }
.phase-tools { display: flex; gap: 4px; margin-left: auto; }

.modules-container { margin: 16px 0 10px; display: flex; flex-direction: column; gap: 12px; }
.module-card {
  background: #fafbfd;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
}
.module-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.module-title { flex: 1; font-family: var(--font-head); font-weight: 600; font-size: 14px; border: none; background: transparent; }
.module-title:focus { border-bottom: 2px solid var(--accent); border-radius: 0; }
.module-tools { display: flex; gap: 2px; }

.providers-section { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.subhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.providers-container { display: flex; flex-direction: column; gap: 6px; }
.provider-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1.5fr auto;
  gap: 6px;
  align-items: center;
}
.provider-row .input { padding: 7px 10px; font-size: 12px; }

/* ===== Inline tables (intégrations, risques) ===== */
.inline-table { width: 100%; border-collapse: collapse; }
.inline-table th {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 6px 8px;
  letter-spacing: 0.04em;
}
.inline-table td { padding: 4px 6px; }
.inline-table td .input { padding: 7px 10px; font-size: 12px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 84px;
  right: 24px;
  left: auto;
  bottom: auto;
  transform: translateX(calc(100% + 40px));
  background: var(--surface);
  color: var(--text);
  padding: 14px 18px;
  border-radius: var(--radius-card);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 13px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.16);
  border: 1px solid var(--border-card);
  border-left: 4px solid var(--text-muted);
  z-index: 1000;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
  opacity: 0;
  max-width: min(420px, calc(100vw - 48px));
  line-height: 1.45;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.toast::before {
  content: '';
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  margin-top: 6px;
  opacity: 0.6;
}
.toast.visible { transform: translateX(0); opacity: 1; }
.toast.error { border-left-color: var(--danger); color: var(--danger); }
.toast.success { border-left-color: var(--success); color: var(--success); }
.toast.info { border-left-color: var(--primary); color: var(--primary); }
.toast strong { font-weight: 700; color: var(--text); margin-right: 4px; }
@media (max-width: 640px) {
  .toast { right: 16px; top: 74px; max-width: calc(100vw - 32px); }
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal {
  background: white;
  border-radius: var(--radius-card);
  padding: 26px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.modal h3 { margin-bottom: 6px; }
.modal-desc { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }
.modal-body { margin-bottom: 18px; min-height: 20px; }
.modal-body .share-link {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: #ecfdf5;
  border: 1px solid #f3d4de;
  border-radius: 10px;
  margin-bottom: 8px;
}
.modal-body .share-link code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--primary);
  word-break: break-all;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===== Priorité & statut colorés ===== */
select[data-module-field="priority"] option[value="critical"] { color: var(--danger); }
select[data-module-field="priority"] option[value="high"] { color: var(--warning); }

/* ===== Click-to-edit cards (pattern synthèse) ===== */
.ce-card {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.12s;
  display: grid;
  gap: 4px;
}
.ce-card:hover { border-color: var(--carbon); background: #fafbfa; }
.ce-card.editing { cursor: default; background: var(--surface); border-color: var(--accent); border-left-width: 3px; box-shadow: 0 2px 8px rgba(0,224,135,0.1); }
.ce-card-display { display: grid; gap: 4px; }
.ce-card-editing { display: grid; gap: 8px; }
.ce-card .ce-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ce-card .ce-main { font-family: var(--font-head); font-weight: 600; font-size: 13px; color: var(--text); line-height: 1.35; word-break: break-word; }
.ce-card .ce-meta { font-size: 11.5px; color: var(--text-muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ce-card .ce-meta .chip { background: #f2f3f2; border: 1px solid var(--border); padding: 1px 8px; border-radius: 10px; font-size: 10.5px; font-family: var(--font-mono); color: var(--text-muted); }
.ce-card .ce-meta .chip.assignee { background: var(--accent-soft); color: var(--accent-dark); border-color: #a7f3d0; }
.ce-card .ce-meta .chip.team { font-family: var(--font-head); font-weight: 600; }
.ce-card .ce-placeholder { color: var(--text-muted); font-style: italic; font-size: 12px; }
.ce-card .ce-edit-hint {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.12s;
  margin-left: auto;
}
.ce-card:hover .ce-edit-hint { opacity: 1; }
.ce-card .ce-del {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px; opacity: 0;
  transition: opacity 0.12s;
  padding: 2px 6px; border-radius: 6px;
}
.ce-card:hover .ce-del { opacity: 1; }
.ce-card .ce-del:hover { background: #fef2f2; color: var(--danger); }
.ce-card-editing .ce-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.ce-card-editing .ce-actions .btn { padding: 4px 10px; font-size: 11px; }
.ce-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 12px;
  border: 1.5px dashed var(--border);
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  transition: all 0.12s;
}
.ce-add-btn:hover { border-color: var(--carbon); color: var(--carbon); background: #fafbfa; }
.ce-list { display: flex; flex-direction: column; gap: 6px; }
.md-wysiwyg-host { margin-top: 4px; border-radius: 10px; overflow: hidden; }
.md-wysiwyg-host .toastui-editor-defaultUI { border-radius: 10px; border-color: var(--border-card) !important; }
.md-wysiwyg-host .toastui-editor-toolbar { background: #fafbfa !important; border-bottom-color: var(--border) !important; }

/* Linked items panel */
.nap-linked { padding: 6px 10px; max-height: 200px; overflow-y: auto; }
.nap-linked-item {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11.5px;
  background: #fafbfa;
  margin-bottom: 3px;
}
.nap-linked-item:hover { background: var(--accent-soft); }
.nap-linked-type { font-family: var(--font-mono); font-size: 9px; padding: 1px 6px; border-radius: 4px; background: var(--carbon); color: var(--accent); }
.nap-linked-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nap-section-title { font-family: var(--font-head); font-weight: 700; font-size: 10px; text-transform: uppercase; color: var(--text-muted); margin: 8px 12px 4px; letter-spacing: 0.04em; }

/* Statut pill pour task/question cards */
.ce-card .pill-status {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.ce-card .pill-status.todo { background: #f2f3f2; color: var(--text-muted); }
.ce-card .pill-status.in_progress { background: #fef3c7; color: #92400e; }
.ce-card .pill-status.blocked { background: #fee2e2; color: var(--danger); }
.ce-card .pill-status.done { background: var(--accent-soft); color: var(--accent-dark); }
.ce-card .pill-status.open { background: #fef3c7; color: #92400e; }
.ce-card .pill-status.answered { background: var(--accent-soft); color: var(--accent-dark); }
.ce-card .pill-status.deferred { background: #f2f3f2; color: var(--text-muted); }

/* ===== Markdown field ===== */
.md-field { position: relative; }
.md-field .md-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  align-items: center;
}
.md-field .md-tabs { display: flex; gap: 2px; background: #f1f2f7; padding: 3px; border-radius: 8px; }
.md-tab {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 11px;
  background: transparent;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.md-tab:hover { color: var(--text); }
.md-tab.active { background: var(--carbon); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.md-hint { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-left: auto; }
.md-preview {
  padding: 12px 14px;
  background: #fafbfd;
  border: 1.5px solid var(--border-card);
  border-radius: var(--radius-input);
  min-height: 60px;
  font-size: 13px;
  line-height: 1.6;
}
.md-preview.empty { color: var(--text-muted); font-style: italic; }
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4 {
  font-family: var(--font-head);
  margin: 14px 0 8px;
  color: var(--text);
}
.md-preview h1 { font-size: 18px; font-weight: 800; }
.md-preview h2 { font-size: 16px; font-weight: 700; }
.md-preview h3 { font-size: 14px; font-weight: 700; }
.md-preview p { margin: 0 0 10px; }
.md-preview p:last-child { margin-bottom: 0; }
.md-preview strong { font-weight: 700; color: var(--text); }
.md-preview em { font-style: italic; color: var(--text-muted); }
.md-preview code {
  font-family: var(--font-mono);
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}
.md-preview pre {
  background: #1a1f36;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 11px;
}
.md-preview pre code { background: transparent; color: inherit; padding: 0; }
.md-preview ul, .md-preview ol { margin: 6px 0 10px; padding-left: 22px; }
.md-preview li { margin-bottom: 3px; }
.md-preview blockquote {
  border-left: 3px solid var(--accent);
  padding: 6px 14px;
  margin: 10px 0;
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 0 8px 8px 0;
}
.md-preview a { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 2px; }
.md-preview a:hover { color: var(--carbon); }
.md-preview table { border-collapse: collapse; margin: 10px 0; width: 100%; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: 6px 10px; font-size: 12px; text-align: left; }
.md-preview th { background: #fafbfd; font-family: var(--font-head); font-weight: 700; }
.md-preview hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ===== Synthèse ===== */
.summary-block { border-top: 3px solid var(--accent); }
.block-desc { color: var(--text-muted); font-size: 13px; margin: -6px 0 18px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat-card {
  background: linear-gradient(135deg, var(--accent-soft) 0%, #fcfcfd 100%);
  border: 1px solid #d1fae5;
  border-radius: var(--radius-card);
  padding: 14px 16px;
}
.stat-value { font-family: var(--font-head); font-weight: 700; font-size: 24px; color: var(--carbon); letter-spacing: -0.03em; }
.stat-label { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; color: var(--text-muted); margin-top: 3px; letter-spacing: 0.04em; }
.stat-breakdown { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.stat-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  background: white;
  border: 1px solid var(--border-card);
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--text);
}
.stat-chip.critical { background: #fee2e2; border-color: #fecaca; color: var(--danger); }
.stat-chip.high { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.stat-chip.medium { background: #dbeafe; border-color: #bfdbfe; color: #1e40af; }
.stat-chip.low { background: #f2f3f2; border-color: var(--border); color: var(--text-muted); }
.stat-chip.done { background: var(--accent-soft); border-color: #a7f3d0; color: var(--accent-dark); }
.stat-chip.planned { background: #f2f3f2; border-color: var(--border); color: var(--text-muted); }
.stat-chip.in-progress { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.stat-chip.blocked { background: #fee2e2; border-color: #fecaca; color: var(--danger); }
.provider-pill {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 11px;
  background: white;
  border: 1px solid var(--border-card);
  padding: 4px 10px;
  border-radius: 14px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.provider-pill .count {
  font-family: var(--font-mono);
  background: var(--carbon);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
}
.provider-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  letter-spacing: -0.01em;
  padding: 4px 10px;
  background: var(--accent-soft);
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  color: var(--accent-dark);
}

.list-editor { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.list-item { display: flex; gap: 8px; align-items: center; }
.list-item .input { flex: 1; }

/* ===== Editor Tabs ===== */
.editor-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.editor-tabs::-webkit-scrollbar, .w-tabs::-webkit-scrollbar, .drawer-tabs::-webkit-scrollbar { display: none; height: 0; width: 0; }
.w-tabs, .drawer-tabs { scrollbar-width: none; -ms-overflow-style: none; }
.editor-tab {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13px;
  padding: 10px 18px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.editor-tab:hover { background: #f2f3f2; color: var(--text); }
.editor-tab.active { background: var(--carbon); color: var(--accent); }
.editor-tab .tab-icon { font-size: 14px; opacity: 0.9; }
.editor-tab .tab-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
}
.editor-tab.active .tab-badge { background: var(--accent); color: var(--carbon); }

.tab-pane { animation: fadeIn 0.18s ease-out; }

/* ===== Canvas ===== */
.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  border-bottom: none;
  flex-wrap: wrap;
}
.canvas-toolbar-left, .canvas-toolbar-right { display: flex; align-items: center; gap: 8px; }
.canvas-zoom-label { padding: 4px 10px; background: #f2f3f2; border-radius: 8px; font-size: 11px; color: var(--text-muted); }
.canvas-hint { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); letter-spacing: 0.02em; }
.canvas-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 280px);
  min-height: 560px;
  background:
    radial-gradient(circle, rgba(10,10,10,0.06) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.flow-canvas-wrap { touch-action: none; }
.canvas-wrap.dragging { cursor: grabbing; }
.canvas-svg { width: 100%; height: 100%; display: block; user-select: none; }

/* Phase header rect */
.node-phase-header {
  fill: var(--carbon);
}
.node-phase-title {
  fill: var(--accent);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 14px;
}
.node-phase-subtitle {
  fill: rgba(247, 248, 247, 0.7);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}
.node-phase-usableby {
  fill: rgba(0, 224, 135, 0.9);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  font-weight: 500;
}
.node-phase-col { fill: rgba(10,10,10,0.02); stroke: var(--border-card); stroke-width: 1; }

.node-module > rect:first-of-type {
  fill: var(--surface);
  stroke: var(--border-card);
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 6px rgba(10,10,10,0.06));
  transition: all 0.15s;
}
.node-module:hover > rect:first-of-type { stroke: var(--accent); stroke-width: 2; filter: drop-shadow(0 4px 12px rgba(0,224,135,0.22)); cursor: pointer; }
.node-module.selected > rect:first-of-type { stroke: var(--accent); stroke-width: 2.5; filter: drop-shadow(0 4px 16px rgba(0,224,135,0.35)); }
.node-module text { pointer-events: none; }
.node-module .mod-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 12.5px;
  fill: var(--text);
}
.node-module .mod-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  fill: var(--text-muted);
}
.node-module .mod-accent { stroke-width: 3; }
.node-module .mod-accent.completion-done { stroke: var(--accent-dark); }
.node-module .mod-accent.completion-ready { stroke: var(--accent); }
.node-module .mod-accent.completion-pending-q { stroke: #3b82f6; }
.node-module .mod-accent.completion-pending { stroke: var(--warning); }
.node-module .mod-status-dot { }
.node-module .badge-rect { fill: var(--accent-soft); }
.node-module .badge-rect-q { fill: #fef3c7; }
.node-module .badge-text { font-family: 'JetBrains Mono', monospace; font-size: 9px; fill: var(--accent-dark); font-weight: 700; }
.node-module .badge-text-q { fill: #92400e; }

.phase-link { stroke: var(--border); stroke-width: 1.5; fill: none; stroke-dasharray: 4 3; }

/* ===== Drawer ===== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.35);
  z-index: 300;
  animation: fadeIn 0.15s ease-out;
}
.drawer {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 40px rgba(10, 10, 10, 0.2);
  animation: slideInRight 0.2s ease-out;
}
@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--carbon);
  color: var(--text-on-dark);
}
.drawer-phase-chip {
  background: var(--accent);
  color: var(--carbon);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
}
.drawer-title {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 16px;
  padding: 4px 0;
  outline: none;
  min-width: 0;
}
.drawer-title::placeholder { color: rgba(247,248,247,0.4); }
.drawer-header .icon-btn { color: var(--accent); }
.drawer-header .icon-btn:hover { background: rgba(0,224,135,0.15); color: var(--accent); }

.drawer-tabs {
  display: flex;
  gap: 2px;
  padding: 0 10px;
  background: #fafbfa;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.drawer-tab {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.drawer-tab:hover { color: var(--text); }
.drawer-tab.active { color: var(--carbon); border-bottom-color: var(--accent); }
.dtab-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  background: #f2f3f2;
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 8px;
}
.drawer-tab.active .dtab-badge { background: var(--accent-soft); color: var(--accent-dark); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.drawer-pane .subhead {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin: 10px 0 8px;
}

/* ===== Related (équipe) ===== */
.related-row {
  display: grid;
  grid-template-columns: 130px 1fr 1fr auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.related-row .input { padding: 7px 10px; font-size: 12px; }

/* ===== Questions ===== */
.question-row {
  background: #fafbfa;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.question-head { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.question-head .question-status { max-width: 130px; }
.question-row .input { padding: 7px 10px; font-size: 12px; }
.question-row textarea { margin-top: 6px; }
.question-row select.question-status[data-q-field="status"] + input { flex: 1; }
.question-status option[value="open"] { color: var(--warning); }
.question-status option[value="answered"] { color: var(--accent-dark); }
.question-status option[value="deferred"] { color: var(--text-muted); }

.questions-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.question-card {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}
.question-card.answered { border-left-color: var(--accent-dark); }
.question-card.deferred { border-left-color: var(--text-muted); }
.question-card .qc-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.question-card .qc-phase { font-family: var(--font-mono); font-size: 10px; background: var(--carbon); color: var(--accent); padding: 2px 8px; border-radius: 6px; }
.question-card .qc-module { font-family: var(--font-head); font-weight: 600; font-size: 13px; }
.question-card .qc-askto { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.question-card .qc-askto strong { color: var(--text); font-weight: 600; }
.question-card .qc-question { font-size: 14px; line-height: 1.5; margin-bottom: 8px; }
.question-card .qc-answer { font-size: 13px; color: var(--text-muted); padding: 8px 10px; background: var(--accent-soft); border-radius: 8px; line-height: 1.5; }

/* ===== Tasks / Kanban ===== */
.tasks-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tasks-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}
.tasks-filters .input { width: 100%; min-width: 0; max-width: 260px; padding: 8px 12px; font-size: 13px; }
/* Le champ recherche peut prendre plus de place */
.tasks-filters input[type="text"].input, .tasks-filters input:not([type]).input { max-width: none; }
.tasks-stats { color: var(--text-muted); font-size: 11px; }

.task-row {
  display: grid;
  grid-template-columns: 130px 1fr 140px 140px auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.task-row .input { padding: 7px 10px; font-size: 12px; }
.task-status option[value="done"] { color: var(--accent-dark); }
.task-status option[value="blocked"] { color: var(--danger); }
.task-status option[value="in_progress"] { color: var(--warning); }

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 10px;
}
.kanban-col {
  background: #fafbfa;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 10px;
  min-height: 200px;
}
.kanban-col.drop-target { background: var(--accent-soft); border-color: var(--accent); }
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 4px 6px;
  border-bottom: 2px solid var(--border);
}
.kanban-col-header.todo { border-bottom-color: var(--text-muted); }
.kanban-col-header.in_progress { border-bottom-color: var(--warning); }
.kanban-col-header.blocked { border-bottom-color: var(--danger); }
.kanban-col-header.done { border-bottom-color: var(--accent); }
.kanban-col-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}
.kanban-col-count {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-muted);
}

.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(10,10,10,0.06);
  cursor: grab;
  transition: all 0.15s;
}
.kanban-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(10,10,10,0.1); }
.kanban-card.dragging { opacity: 0.5; cursor: grabbing; }
.kanban-card-title { font-family: var(--font-head); font-weight: 600; font-size: 13px; margin-bottom: 6px; line-height: 1.35; }
.kanban-card-meta { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.kanban-card-meta .chip-phase { background: var(--carbon); color: var(--accent); padding: 1px 6px; border-radius: 4px; font-weight: 700; }
.kanban-card-meta .chip-mod { background: var(--accent-soft); color: var(--accent-dark); padding: 1px 6px; border-radius: 4px; }
.kanban-card-footer { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-muted); }
.kanban-card-assignee { font-weight: 500; }
.kanban-card-date { font-size: 10px; }

/* ===== Users table (style GIE) ===== */
.view-users .cdc-table td { padding: 12px 16px; vertical-align: middle; }
.user-who { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--carbon), #2a2a2a);
  color: var(--accent);
  display: grid; place-items: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 12px;
  flex: 0 0 auto;
  box-shadow: 0 2px 4px rgba(10,10,10,0.12);
}
.user-name { font-family: var(--font-head); font-weight: 600; font-size: 13.5px; color: var(--text); }
.user-email-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.role-badge, .status-badge, .team-badge {
  display: inline-block;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}
.role-badge.admin { background: var(--carbon); color: var(--accent); }
.role-badge.user { background: #f2f3f2; color: var(--text-muted); }
.status-pill.active { background: var(--accent-soft); color: var(--accent-dark); }
.status-pill.invited { background: #fef3c7; color: #92400e; }
.status-pill.blocked { background: #fee2e2; color: var(--danger); }
.team-badge.juridique { background: #e9d5ff; color: #6b21a8; }
.team-badge.comptable { background: #dbeafe; color: #1e40af; }
.team-badge.commercial { background: var(--accent-soft); color: var(--accent-dark); }
.team-badge.technique { background: #f2f3f2; color: var(--text); }
.team-badge.rh { background: #fef3c7; color: #92400e; }
.team-badge.direction { background: var(--carbon); color: var(--accent); }
.team-badge.marketing { background: #fce7f3; color: #be185d; }
.team-badge.support { background: #f0fdf4; color: #166534; }

.user-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: flex-end; min-width: 0; max-width: 340px; }
.user-actions .btn { padding: 5px 10px; font-size: 11px; border-radius: 7px; white-space: nowrap; line-height: 1.2; }
.user-actions .btn.danger { color: var(--danger); }
.user-actions .btn.danger:hover { background: #fef2f2; }

/* ============================================================ */
/* ================= CDC COPILOT ============================= */
/* ============================================================ */
.copilot-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 12px;
  height: calc(100vh - 240px);
  min-height: 520px;
}
.copilot-sidebar {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 12px;
  overflow-y: auto;
}
.copilot-conv-list { display: flex; flex-direction: column; gap: 4px; }
.copilot-conv-item {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  border: 1px solid transparent;
  transition: all 0.12s;
}
.copilot-conv-item:hover { background: var(--accent-soft); border-color: #a7f3d0; }
.copilot-conv-item.active { background: var(--carbon); color: var(--accent); }
.copilot-conv-item .conv-title { font-family: var(--font-head); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.copilot-conv-item .conv-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }
.copilot-conv-item.active .conv-meta { color: rgba(0, 224, 135, 0.7); }

.copilot-main {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.copilot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbfa;
}
.copilot-title-bar { display: flex; gap: 10px; align-items: baseline; }
.copilot-scope { font-family: var(--font-mono); font-size: 10px; background: var(--accent-soft); color: var(--accent-dark); padding: 2px 8px; border-radius: 10px; }
.copilot-title { font-family: var(--font-head); font-weight: 700; font-size: 14px; }
.copilot-messages { flex: 1; overflow-y: auto; padding: 16px; background: #fafbfa; }
.copilot-welcome {
  max-width: 620px;
  margin: 20px auto;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius-card);
  border: 1px solid var(--border-card);
}
.copilot-welcome h3 { margin: 0 0 10px 0; color: var(--text); }
.copilot-welcome ul { padding-left: 20px; font-size: 13px; color: var(--text); line-height: 1.6; }
.copilot-welcome .copilot-hint { font-size: 12px; color: var(--text-muted); font-style: italic; margin-top: 14px; }

.cop-msg { margin-bottom: 16px; display: flex; gap: 10px; }
.cop-msg.user { flex-direction: row-reverse; }
.cop-msg .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 11px;
  flex: 0 0 30px;
}
.cop-msg.user .avatar { background: var(--accent); color: var(--carbon); }
.cop-msg.assistant .avatar { background: var(--carbon); color: var(--accent); }
.cop-msg .bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
}
.cop-msg.user .bubble { background: var(--accent-soft); color: var(--text); border: 1px solid #a7f3d0; }
.cop-msg.assistant .bubble { background: var(--surface); color: var(--text); border: 1px solid var(--border-card); }
.cop-msg .bubble p { margin: 0 0 8px; }
.cop-msg .bubble p:last-child { margin-bottom: 0; }
.cop-msg .bubble code { background: #fdf2f5; color: var(--carbon); padding: 1px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 11px; }
.cop-msg .bubble pre { background: var(--carbon); color: var(--accent); padding: 10px; border-radius: 8px; overflow-x: auto; font-family: var(--font-mono); font-size: 11px; }

/* Tool call card — Claude Code style */
.cop-turn { flex: 1; min-width: 0; }
.cop-text { font-size: 13px; line-height: 1.55; color: var(--text); }
.cop-text p { margin: 0 0 8px; }
.cop-text p:last-child { margin-bottom: 0; }
.cop-text code { background: #f3f4f6; color: var(--carbon); padding: 1px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 11px; }
.cop-text pre { background: var(--carbon); color: var(--accent); padding: 10px; border-radius: 8px; overflow-x: auto; font-family: var(--font-mono); font-size: 11px; margin: 8px 0; }
.cop-tools { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

.cop-tool {
  background: #fafbfb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0;
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--text);
  overflow: hidden;
  transition: border-color 0.2s;
}
.cop-tool.running { border-color: #c7d2fe; background: #f5f7ff; }
.cop-tool.done { border-color: #d1fae5; background: #f0fdf4; }

.cop-tool-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid transparent;
}
.cop-tool.running .cop-tool-head,
.cop-tool.done .cop-tool-head { border-bottom-color: rgba(0,0,0,0.05); }
.cop-tool-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  border-radius: 5px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 20px;
}
.cop-tool.done .cop-tool-icon { background: #d1fae5; color: #047857; }
.cop-tool-name {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.cop-tool-status {
  font-family: var(--font-mono);
  font-size: 10px;
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--text-muted);
}
.cop-tool-ok { color: #047857; }
.cop-tool-err { color: var(--danger); }
.cop-spinner {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid #c7d2fe; border-top-color: #4338ca;
  animation: copSpin 0.7s linear infinite;
}
@keyframes copSpin { to { transform: rotate(360deg); } }

.cop-tool-args {
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: transparent;
}
.cop-tool-hint { color: var(--text-muted); font-style: italic; }
.cop-tool-partial {
  display: block;
  background: transparent;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 10px;
}
.cop-arg-row {
  display: flex; gap: 8px; align-items: baseline;
  padding: 2px 0;
}
.cop-arg-k {
  color: #6b7280;
  min-width: 80px;
  font-weight: 600;
}
.cop-arg-v { color: var(--text); word-break: break-word; }
.cop-arg-v.str { color: #065f46; }
.cop-arg-v.num { color: #7c2d12; }
.cop-arg-v.arr, .cop-arg-v.obj { color: #4338ca; font-style: italic; }

.cop-tool-result {
  padding: 6px 10px 8px;
  font-size: 11px;
}
.cop-tool-summary {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}
.cop-tool-summary code {
  background: #e0e7ff;
  color: #3730a3;
  padding: 1px 5px;
  border-radius: 3px;
}

.cop-patch {
  background: #eff6ff;
  border: 1.5px solid #3b82f6;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 8px 0 8px 40px;
  font-size: 12px;
}
.cop-patch .cop-patch-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cop-patch .cop-patch-title { font-family: var(--font-head); font-weight: 700; color: #1e40af; }
.cop-patch .cop-patch-actions { display: flex; gap: 6px; }
.cop-patch-details { font-family: var(--font-mono); font-size: 10.5px; color: var(--text); background: var(--surface); padding: 8px; border-radius: 6px; max-height: 240px; overflow: auto; }

.copilot-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
}
.copilot-input {
  flex: 1;
  border: 1.5px solid var(--border-card);
  border-radius: var(--radius-input);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  resize: vertical;
  max-height: 200px;
  outline: none;
}
.copilot-input:focus { border-color: var(--carbon); box-shadow: 0 0 0 3px rgba(0,224,135,0.18); }

.copilot-patches {
  max-height: 180px;
  overflow-y: auto;
  padding: 0 16px;
}

/* Audit tab */
.audit-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.audit-finding {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.12s;
}
.audit-finding:hover { background: #fafbfa; transform: translateX(2px); }
.audit-severity {
  width: 8px; height: 8px; border-radius: 50%;
  flex: 0 0 8px; margin-top: 5px;
}
.audit-severity.red { background: var(--danger); }
.audit-severity.orange { background: var(--warning); }
.audit-severity.yellow { background: #facc15; }
.audit-severity.blue { background: #3b82f6; }
.audit-path { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-bottom: 2px; }
.audit-detail { font-size: 12.5px; color: var(--text); }
.audit-suggestion { font-size: 11px; color: var(--accent-dark); margin-top: 4px; font-style: italic; }

.cop-bar-copilot-btn {
  position: absolute;
  top: 12px;
  right: 130px;
  background: var(--carbon);
  color: var(--accent);
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 11px;
}
.cop-bar-copilot-btn:hover { background: #1a1a1a; }

/* Dialog Phase */
.phase-dialog-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,10,10,0.45);
  z-index: 900;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease-out;
}
.phase-dialog {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 1400px;
  height: calc(100vh - 60px);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.phase-dialog-header {
  background: var(--carbon);
  color: var(--text-on-dark);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.phase-dialog-header h2 { color: var(--accent); margin: 0; font-size: 20px; }
.phase-dialog-body { flex: 1; overflow: auto; padding: 20px; }

/* ===== Auth overlay ===== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--carbon) 0%, #1a1a1a 100%);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 440px;
  padding: 32px;
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.auth-title { font-family: var(--font-head); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--text); }
.auth-sub { font-size: 10px; color: var(--text-muted); margin-top: 2px; letter-spacing: 0.04em; }
.auth-mode-tabs { display: flex; gap: 2px; background: #f2f3f2; padding: 3px; border-radius: 10px; margin-bottom: 20px; }
.auth-mode-tab {
  flex: 1;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
}
.auth-mode-tab.active { background: var(--carbon); color: var(--accent); }
.auth-error { color: var(--danger); font-size: 12px; margin: 8px 0; padding: 8px 10px; background: #fef2f2; border-radius: 8px; }
.auth-hint { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 12px; }
.auth-form .form-field label { color: var(--text); }

/* ===== User chip ===== */
.user-chip {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: auto;
  top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 20px;
  padding: 4px 4px 4px 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 40;
}
.user-chip-name { font-family: var(--font-head); font-weight: 600; font-size: 12px; color: var(--text); }
.user-chip-logout {
  background: var(--carbon);
  color: var(--accent);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
}
.user-chip-logout:hover { background: var(--danger); color: white; }

@media (max-width: 600px) {
  .user-chip { top: auto; bottom: 16px; left: 16px; right: auto; }
  .auth-card { padding: 22px; }
}

/* ===== Journal ===== */
.journal-list { background: var(--surface); border: 1px solid var(--border-card); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow-card); }
.journal-entry {
  display: grid;
  grid-template-columns: 110px 90px 1fr 110px;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 12.5px;
}
.journal-entry:last-child { border-bottom: none; }
.journal-entry:hover { background: #fafbfa; }
.je-time { color: var(--text-muted); font-size: 10.5px; white-space: nowrap; }
.je-type {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
  background: var(--carbon);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.je-type.type-task { background: #dbeafe; color: #1e40af; }
.je-type.type-question { background: #fef3c7; color: #92400e; }
.je-type.type-feature { background: var(--accent-soft); color: var(--accent-dark); }
.je-type.type-team { background: #e9d5ff; color: #6b21a8; }
.je-type.type-provider { background: #fee2e2; color: var(--danger); }
.je-type.type-flow { background: #f2f3f2; color: var(--text); }
.je-summary { line-height: 1.4; }
.je-path { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.je-actor { font-family: var(--font-head); font-weight: 600; font-size: 11.5px; color: var(--text); text-align: right; white-space: nowrap; }

@media (max-width: 900px) {
  .journal-entry { grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; }
  .je-time { grid-column: 1 / -1; }
  .je-type { grid-column: 1; justify-self: start; }
  .je-actor { grid-column: 2; }
  .je-summary { grid-column: 1 / -1; }
}

/* ============================================================ */
/* ================= UI COMPACTE & RESPONSIVE ================== */
/* ============================================================ */

/* Questions compactes */
.questions-list { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--border-card); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow-card); }
.question-row-compact {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.question-row-compact:hover { background: #fafbfa; }
.question-row-compact:last-child { border-bottom: none; }
.qrc-status { font-family: var(--font-mono); font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 700; }
.qrc-status.open { background: #fef3c7; color: #92400e; }
.qrc-status.answered { background: var(--accent-soft); color: var(--accent-dark); }
.qrc-status.deferred { background: #f2f3f2; color: var(--text-muted); }
.qrc-question { font-size: 13px; line-height: 1.4; }
.qrc-meta { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); display: flex; gap: 6px; flex-wrap: wrap; }
.qrc-chip { background: var(--carbon); color: var(--accent); padding: 1px 6px; border-radius: 4px; font-weight: 700; }
.qrc-askto { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.qrc-askto strong { color: var(--text); }

/* Kanban cards compactes */
.kanban-card { padding: 8px 10px; }
.kanban-card-title { font-size: 12.5px; margin-bottom: 4px; }
.kanban-card-meta { font-size: 9.5px; margin-bottom: 4px; }
.kanban-card-footer { font-size: 10.5px; }

/* Tasks toolbar compact */
.tasks-toolbar { margin-bottom: 12px; }
.tasks-filters .input { min-width: 150px; padding: 7px 10px; font-size: 12px; }

/* ===== Window Manager ===== */
.cdc-window {
  position: fixed;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 18px 54px rgba(10, 10, 10, 0.28);
  border: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 360px;
  min-height: 280px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 80px);
  animation: winFadeIn 0.16s ease-out;
  z-index: 500;
}
.cdc-window.focused { box-shadow: 0 20px 64px rgba(10, 10, 10, 0.36); }
.cdc-window.dragging { opacity: 0.92; cursor: grabbing; }
.cdc-window-header {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--carbon);
  color: var(--text-on-dark);
  cursor: move;
  user-select: none;
  flex: 0 0 auto;
}
.cdc-window-phase {
  background: var(--accent);
  color: var(--carbon);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.cdc-window-title {
  flex: 1;
  color: var(--text-on-dark);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cdc-window-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 6px;
}
.cdc-window-close,
.cdc-window-actions .cdc-window-btn {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  color: transparent;
  line-height: 0;
  transition: filter 0.12s;
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.15);
  flex: 0 0 13px;
}
.cdc-window-close { background: #EF4444; order: 3; }
.cdc-window-btn.minimize { background: #F59E0B; order: 1; }
.cdc-window-btn.maximize { background: #10B981; order: 2; }
.cdc-window-close:hover,
.cdc-window-btn:hover { filter: brightness(1.1); }
.cdc-window-actions:hover .cdc-window-close,
.cdc-window-actions:hover .cdc-window-btn {
  font-size: 9px;
  color: rgba(0, 0, 0, 0.55);
}
.cdc-window-close::before { content: '×'; font-size: 13px; font-weight: 700; }
.cdc-window-btn.minimize::before { content: '−'; font-weight: 700; }
.cdc-window-btn.maximize::before { content: '+'; font-weight: 700; }
.cdc-window-close::before,
.cdc-window-btn::before {
  opacity: 0;
  transition: opacity 0.12s;
  line-height: 1;
}
.cdc-window-actions:hover .cdc-window-close::before,
.cdc-window-actions:hover .cdc-window-btn::before { opacity: 1; }
.cdc-window-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
/* Resize handles 8 directions (style macOS) */
.cdc-window-resize { position: absolute; z-index: 20; }
.cdc-window-resize.n { top: -4px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.cdc-window-resize.s { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.cdc-window-resize.e { top: 8px; bottom: 8px; right: -4px; width: 8px; cursor: ew-resize; }
.cdc-window-resize.w { top: 8px; bottom: 8px; left: -4px; width: 8px; cursor: ew-resize; }
.cdc-window-resize.nw { top: -4px; left: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
.cdc-window-resize.ne { top: -4px; right: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
.cdc-window-resize.sw { bottom: -4px; left: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
.cdc-window-resize.se { bottom: -4px; right: -4px; width: 14px; height: 14px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 0%, transparent 50%, var(--border-card) 50%, var(--border-card) 100%); border-bottom-right-radius: 14px; }

/* Boutons header Mac-style (minimize + maximize) */
.cdc-window-btn {
  width: 14px; height: 14px; border-radius: 50%;
  border: none; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.cdc-window-btn.minimize { background: #fbbf24; }
.cdc-window-btn.maximize { background: var(--accent); }
.cdc-window-btn:hover { opacity: 0.85; }

/* Snap preview overlay */
.snap-preview {
  position: fixed;
  background: rgba(0, 224, 135, 0.18);
  border: 2px solid var(--accent);
  border-radius: 12px;
  pointer-events: none;
  z-index: 499;
  transition: all 0.14s ease-out;
  box-shadow: 0 0 30px rgba(0, 224, 135, 0.4);
}

/* Splitter entre 2 fenêtres snappées */
.snap-splitter {
  position: fixed;
  top: 70px;
  bottom: 0;
  width: 6px;
  background: var(--carbon);
  cursor: ew-resize;
  z-index: 498;
  border-radius: 3px;
  transition: background 0.12s;
}
.snap-splitter:hover, .snap-splitter.dragging { background: var(--accent); width: 8px; }

/* Barre de fenêtres minimisées en bas */
.window-minimize-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 600;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 6px 10px;
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.38);
}
.window-minimized {
  background: var(--surface);
  color: var(--text);
  padding: 6px 8px 6px 8px;
  border-radius: 8px;
  font-family: var(--font-head);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  max-width: 260px;
  min-width: 0;
  height: 30px;
  border: 1px solid var(--border);
  transition: all 0.15s;
  white-space: nowrap;
  flex: 0 0 auto;
}
.window-minimized:hover { background: var(--accent-soft); border-color: var(--accent); transform: translateY(-2px); }
.window-minimized .wm-phase {
  background: var(--carbon);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9.5px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
  flex: 0 0 auto;
  font-weight: 700;
}
.window-minimized .wm-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
  max-width: 140px;
}
.window-minimized .wm-close {
  width: 16px; height: 16px; border-radius: 50%;
  background: #EF4444; color: white; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; line-height: 1; padding: 0;
  margin-left: 4px;
  opacity: 0.7;
  transition: all 0.12s;
}
.window-minimized:hover .wm-close { opacity: 1; }
.window-minimized .wm-close:hover { filter: brightness(1.15); transform: scale(1.1); }

.cdc-window.minimized { display: none !important; }

/* Window tabs */
.w-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--border);
  background: #fafbfa;
  overflow-x: auto;
  flex: 0 0 auto;
}
.w-tab {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.12s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.w-tab:hover { color: var(--text); }
.w-tab.active { color: var(--carbon); border-bottom-color: var(--accent); }
.w-tab .w-count { font-family: var(--font-mono); font-size: 10px; background: #f2f3f2; color: var(--text-muted); padding: 1px 5px; border-radius: 8px; }
.w-tab.active .w-count { background: var(--accent-soft); color: var(--accent-dark); }
.w-panes { flex: 1; overflow: hidden; position: relative; min-height: 0; }
.w-pane { padding: 16px; overflow: auto; height: 100%; box-sizing: border-box; }
.w-pane[hidden] { display: none !important; }
.w-pane[data-wpane="flow"]:not([hidden]) { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.w-pane .subhead {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin: 10px 0 6px;
}

/* Summary pane inside window */
.summary-mod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.sm-card {
  background: #fafbfa;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 10px 12px;
}
.sm-v { font-family: var(--font-head); font-weight: 700; font-size: 20px; color: var(--carbon); letter-spacing: -0.02em; }
.sm-l { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }
.sm-section { margin-bottom: 16px; }
.sm-section h4 { font-family: var(--font-head); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 8px; }
.sm-feat-list { display: grid; grid-template-columns: 1fr; gap: 4px; }
.sm-deps { font-size: 12px; line-height: 1.6; color: var(--text); }
.sm-deps strong { font-family: var(--font-head); font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.04em; margin-right: 8px; }
.deps-pill { display: inline-block; background: #f2f3f2; border: 1px solid var(--border); padding: 2px 8px; border-radius: 12px; margin: 2px 4px 2px 0; font-size: 11px; }
.deps-pill.used { background: var(--accent-soft); border-color: #a7f3d0; color: var(--accent-dark); }
.deps-pill em { font-style: normal; color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; margin-left: 3px; }
.sm-feat {
  padding: 8px 10px;
  background: #fafbfa;
  border: 1px solid var(--border);
  border-left: 3px solid var(--carbon);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: all 0.12s;
}
.sm-feat:hover { border-left-color: var(--accent); background: var(--surface); transform: translateX(2px); }
.sm-feat-title { font-family: var(--font-head); font-weight: 600; font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-feat-stats { color: var(--text-muted); font-size: 10px; white-space: nowrap; }
.sm-q-list, .sm-t-list { display: flex; flex-direction: column; gap: 4px; }
.sm-q-card, .sm-t-card {
  padding: 6px 10px;
  background: #fafbfa;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
}
.sm-q-card strong, .sm-t-card strong { font-family: var(--font-head); font-size: 11px; color: var(--carbon); margin-right: 4px; }
.sm-q-card em, .sm-t-card em { font-style: normal; color: var(--text-muted); font-size: 11px; }
.empty-inline { font-size: 12px; color: var(--text-muted); font-style: italic; padding: 8px 0; }

/* ===== Feature card dans tab "Fonctionnalités" ===== */
.feature-list { display: flex; flex-direction: column; gap: 8px; }
.feature-card {
  background: #fafbfa;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  transition: all 0.12s;
}
.feature-card:hover { border-color: var(--carbon); background: var(--surface); }
.feature-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.feature-title {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13px;
  padding: 2px 0;
  outline: none;
  color: var(--text);
  min-width: 0;
}
.feature-title:focus { border-bottom: 2px solid var(--accent); }
.feature-badges { display: flex; gap: 4px; }
.feat-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
}
.feature-desc {
  font-size: 12px;
  padding: 6px 8px;
  margin-bottom: 6px;
}
.feature-actions { display: flex; gap: 6px; align-items: center; }
.feature-hint { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-muted); margin-left: auto; }

/* ===== Canvas : feature chips sous module ===== */
.node-module .feat-chip-rect { fill: #fafbfa; stroke: var(--border); stroke-width: 0.5; }
.mod-completion-dot { stroke: var(--surface); stroke-width: 2; }
.mod-completion-dot.done { fill: var(--accent-dark); }
.mod-completion-dot.ready { fill: var(--accent); }
.mod-completion-dot.pending { fill: var(--warning); }
.mod-completion-dot.pending-q { fill: #3b82f6; }
.node-module .feat-chip-rect:hover { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; cursor: pointer; }
.node-module .feat-chip-text { font-family: 'Inter', sans-serif; font-size: 10px; fill: var(--text); }
.node-module .feat-chip-count { font-family: 'JetBrains Mono', monospace; font-size: 9px; fill: var(--text-muted); }

/* Boutons ajout module/feature dans canvas */
.add-mod-btn rect { fill: transparent; stroke: var(--carbon); stroke-width: 1.5; stroke-dasharray: 4 3; transition: all 0.15s; }
.add-mod-btn text { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 12px; fill: var(--text-muted); pointer-events: none; }
.add-mod-btn:hover rect { fill: var(--carbon); stroke: var(--accent); stroke-dasharray: 0; cursor: pointer; }
.add-mod-btn:hover text { fill: var(--accent); }
.add-feat-btn rect { fill: transparent; stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 2; transition: all 0.15s; }
.add-feat-btn text { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; fill: var(--text-muted); pointer-events: none; }
.add-feat-btn:hover rect { fill: var(--accent-soft); stroke: var(--accent-dark); stroke-dasharray: 0; cursor: pointer; }
.add-feat-btn:hover text { fill: var(--accent-dark); }

/* ===== Flow editor ===== */
.flow-toolbar {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
  background: #fafbfa;
  flex: 0 0 auto;
}
.flow-toolbar .btn.small { padding: 5px 10px; font-size: 11px; cursor: grab; }
.flow-toolbar .btn.small.dragging { cursor: grabbing; opacity: 0.6; }
.flow-toolbar .btn.active { background: var(--accent); color: var(--carbon); }
.flow-toolbar .btn-type-start { background: var(--carbon); color: var(--accent); border-color: var(--carbon); }
.flow-toolbar .btn-type-start:hover { background: #1a1a1a; color: var(--accent); }
.flow-toolbar .btn-type-end { background: var(--carbon); color: var(--accent); border-color: var(--carbon); }
.flow-toolbar .btn-type-end:hover { background: #1a1a1a; color: var(--accent); }
.flow-toolbar .btn-type-action { background: white; color: var(--text); border-color: var(--border-card); }
.flow-toolbar .btn-type-action:hover { border-color: var(--carbon); background: #fafbfa; }
.flow-toolbar .btn-type-decision { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
.flow-toolbar .btn-type-decision:hover { background: #fde68a; }
.flow-toolbar .btn-type-error { background: #fee2e2; color: var(--danger); border-color: var(--danger); }
.flow-toolbar .btn-type-error:hover { background: #fecaca; }

/* Edge contextual menu */
.flow-edge-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(10, 10, 10, 0.22);
  padding: 6px;
  z-index: 1200;
  min-width: 180px;
  animation: fadeIn 0.12s ease-out;
}
.flow-edge-menu-input {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border-card);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font-body);
  margin-bottom: 6px;
  outline: none;
  box-sizing: border-box;
}
.flow-edge-menu-input:focus { border-color: var(--carbon); }
.flow-edge-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 12.5px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
}
.flow-edge-menu-btn:hover { background: #f2f3f2; }
.flow-edge-menu-btn.danger { color: var(--danger); }
.flow-edge-menu-btn.danger:hover { background: #fef2f2; }
.flow-edge-menu-btn kbd { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-left: auto; }

/* Node inline rename */
.node-rename-input {
  position: absolute;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  outline: none;
  box-shadow: 0 6px 18px rgba(0, 224, 135, 0.3);
  z-index: 1100;
}

/* Drag ghost when dragging node type from toolbar */
.flow-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1500;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  padding: 6px 14px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  box-shadow: 0 8px 20px rgba(0, 224, 135, 0.32);
  color: var(--carbon);
}
.flow-hint { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-muted); margin-left: auto; }
.flow-canvas-wrap {
  flex: 1;
  min-height: 0;
  background:
    radial-gradient(circle, rgba(10,10,10,0.05) 0.8px, transparent 0.8px) 0 0 / 18px 18px,
    var(--surface);
  overflow: hidden;
  cursor: grab;
  position: relative;
}
.flow-canvas-wrap.dragging { cursor: grabbing; }
.flow-canvas-wrap.linking { cursor: crosshair; }
.flow-canvas { width: 100%; height: 100%; display: block; user-select: none; }
.flow-zoom-label { position: absolute; bottom: 8px; left: 8px; font-family: var(--font-mono); font-size: 10px; background: rgba(10,10,10,0.8); color: var(--accent); padding: 3px 8px; border-radius: 6px; pointer-events: none; }

/* Flow handles (input/output) */
.flow-handle { cursor: crosshair; stroke-width: 1.5; stroke: var(--carbon); transition: all 0.12s; }
.flow-handle-in { fill: #94a3b8; }
.flow-handle-out { fill: var(--accent); }
.flow-handle:hover { r: 7; stroke-width: 2; }
.flow-node.linking-from .flow-handle-out { fill: var(--carbon); r: 7; }
.flow-edge { pointer-events: stroke; transition: stroke 0.12s; }
.flow-edge:hover { stroke: var(--danger); stroke-width: 2.5; cursor: pointer; }

.flow-node { cursor: grab; }
.flow-node.dragging { cursor: grabbing; }
.flow-node rect {
  fill: var(--surface);
  stroke: var(--border-card);
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 4px rgba(10,10,10,0.08));
  transition: all 0.12s;
}
.flow-node:hover rect { stroke: var(--accent); filter: drop-shadow(0 3px 8px rgba(0,224,135,0.28)); }
.flow-node.flow-linking rect { stroke: var(--accent); stroke-width: 2.5; fill: var(--accent-soft); }
.flow-node.selected rect { stroke: var(--carbon); stroke-width: 3; filter: drop-shadow(0 4px 14px rgba(0,224,135,0.45)); }
.flow-node .flow-node-team { font-family: 'JetBrains Mono', monospace; font-weight: 500; font-size: 9.5px; fill: var(--accent-dark); pointer-events: none; }
.flow-node .flow-node-provider { font-family: 'JetBrains Mono', monospace; font-weight: 500; font-size: 9.5px; fill: var(--warning); pointer-events: none; }
.flow-node.type-start .flow-node-team, .flow-node.type-end .flow-node-team { fill: #9fe8a7; }
.flow-node.type-start .flow-node-provider, .flow-node.type-end .flow-node-provider { fill: #fbbf24; }
.flow-node-badge { fill: var(--carbon); stroke: var(--accent); stroke-width: 1.5; }
.flow-node-badge-text { font-family: 'JetBrains Mono', monospace; font-size: 10px; fill: var(--accent); font-weight: 700; pointer-events: none; }

/* Panel d'actions sur node sélectionné */
.node-action-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(10,10,10,0.18);
  z-index: 10;
  overflow: hidden;
  animation: fadeIn 0.14s ease-out;
}
.nap-header {
  background: var(--carbon);
  color: var(--accent);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
}
.nap-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nap-close {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  padding: 0 6px;
  border-radius: 6px;
}
.nap-close:hover { background: rgba(0,224,135,0.12); }
.nap-body { padding: 6px; }
.nap-btn {
  display: flex;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--text);
  text-align: left;
  transition: background 0.12s;
}
.nap-btn:hover { background: #f2f3f2; }
.nap-btn.danger { color: var(--danger); }
.nap-btn.danger:hover { background: #fef2f2; }
.nap-sep { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.flow-node text { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 11.5px; fill: var(--text); pointer-events: none; }

.flow-node.type-start rect { fill: var(--carbon); }
.flow-node.type-start text { fill: var(--accent); }
.flow-node.type-end rect { fill: var(--carbon); }
.flow-node.type-end text { fill: var(--accent); }
.flow-node.type-decision rect { fill: #fef3c7; stroke: #f59e0b; }
.flow-node.type-error rect { fill: #fee2e2; stroke: #ef4444; }
.flow-node.type-action rect { fill: var(--surface); }

.flow-edge { stroke: var(--text-muted); stroke-width: 1.5; fill: none; }
.flow-edge-label { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; fill: var(--text); font-weight: 500; }

/* ===== Markdown preview-first ===== */
.md-field.preview-first .md-toolbar { display: none; }
.md-preview-clickable {
  position: relative;
  padding: 10px 12px;
  background: #fafbfa;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-input);
  min-height: 44px;
  font-size: 13px;
  line-height: 1.55;
  cursor: pointer;
  transition: all 0.12s;
}
.md-preview-clickable:hover { border-color: var(--carbon); background: var(--surface); }
.md-preview-clickable.empty { color: var(--text-muted); font-style: italic; }
.md-preview-clickable .md-edit-hint {
  position: absolute;
  top: 6px; right: 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.12s;
}
.md-preview-clickable:hover .md-edit-hint { opacity: 1; }
.md-editor-actions { display: flex; gap: 6px; margin-top: 6px; justify-content: flex-end; }

/* ===== Responsive ===== */
/* ===== Users responsive ===== */
@media (max-width: 900px) {
  .view-users .cdc-table { display: block; }
  .view-users .cdc-table thead { display: none; }
  .view-users .cdc-table tbody { display: block; }
  .view-users .cdc-table tr {
    display: block;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }
  .view-users .cdc-table tr:last-child { border-bottom: none; }
  .view-users .cdc-table td {
    display: block;
    padding: 0;
    border: none;
    margin-bottom: 8px;
  }
  .view-users .cdc-table td:last-child { margin-bottom: 0; }
  .view-users .user-who { margin-bottom: 4px; }
  .view-users .user-actions {
    width: 100%;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
  }
  .view-users .user-actions .btn { flex: 1 1 auto; padding: 8px 10px; font-size: 12px; }
  .view-users .role-badge,
  .view-users .team-badge,
  .view-users .status-pill { font-size: 10.5px; margin-right: 4px; }
  /* Afficher ligne "Équipe / Rôle / Statut" côte à côte */
  .view-users .cdc-table td:nth-child(2),
  .view-users .cdc-table td:nth-child(3),
  .view-users .cdc-table td:nth-child(4) { display: inline-block; margin-right: 6px; margin-bottom: 4px; }
  .view-users .cdc-table td:nth-child(5) {
    display: block;
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 4px;
  }
  .view-users .cdc-table td:nth-child(5)::before {
    content: 'Dernière connexion : ';
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 4px;
  }
  /* Modales plein écran mobile */
  .modal { max-width: none; width: 100%; border-radius: 12px; padding: 20px; max-height: 90vh; overflow-y: auto; }
  .modal-actions { flex-direction: column-reverse; gap: 8px; }
  .modal-actions .btn { width: 100%; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .cdc-window {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none;
    max-height: none;
    border-radius: 0;
    min-width: 0;
  }
  .cdc-window-header { cursor: default; padding: 14px 16px; }
  .cdc-window-resize { display: none; }
  main { padding: 16px; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .actions { width: 100%; }
  .editor-header-left { min-width: 0; }
  .meta-row { flex-wrap: wrap; }
  .meta-input, .meta-small { max-width: none; width: 100%; }
  .title-input { font-size: 18px; }
  h1 { font-size: 20px; }
  .editor-tabs { margin-bottom: 12px; padding: 3px; }
  .editor-tab { font-size: 12px; padding: 8px 10px; }
  .canvas-wrap {
    height: calc(100dvh - 140px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    min-height: auto;
    max-height: none;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  /* Respect safe-area iOS sur les FAB du canvas */
  .canvas-fab-stack { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .canvas-sel-bar { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .kanban { grid-template-columns: 1fr; }
  .tasks-toolbar { align-items: stretch; flex-direction: column; gap: 10px; }
  .tasks-filters { grid-template-columns: repeat(2, 1fr); width: 100%; }
  .tasks-filters .input { width: 100%; max-width: none; min-width: 0; font-size: 12px; }
  .tasks-filters input[type="text"].input, .tasks-filters input:not([type]).input { grid-column: 1 / -1; }
  .tasks-stats { text-align: center; }
  .questions-list { gap: 0; }
  .question-row-compact { grid-template-columns: auto 1fr; grid-template-rows: auto auto; }
  .question-row-compact .qrc-meta { grid-column: 1 / -1; }
  .question-row-compact .qrc-askto { grid-column: 1 / -1; }
  .provider-row { grid-template-columns: 1fr 1fr; }
  .provider-row > *:nth-child(4), .provider-row > *:nth-child(5) { grid-column: span 2; }
  .task-row { grid-template-columns: 1fr 1fr; }
  .task-row > *:nth-child(2) { grid-column: span 2; }
  .related-row { grid-template-columns: 1fr 1fr; }
  .related-row > *:nth-child(3) { grid-column: span 2; }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .side-nav { position: static; max-height: none; }
  .flow-editor { height: calc(100vh - 250px); max-height: none; }
  .toast { top: 70px; right: 12px; left: 12px; max-width: none; }
  .cdc-table { font-size: 12px; }
  .cdc-table thead { display: none; }
  .cdc-table, .cdc-table tbody, .cdc-table tr, .cdc-table td { display: block; width: 100%; }
  .cdc-table tbody tr { padding: 10px; border-bottom: 1px solid var(--border); }
  .cdc-table tbody td { padding: 3px 0; border: none; }
  .cdc-table tbody td.cdc-title-cell { font-size: 14px; margin-bottom: 4px; }
}

@media (max-width: 600px) {
  /* Users : 1 colonne de boutons plus confortable */
  .view-users .user-actions .btn { flex: 1 1 100%; }
  .view-users .cdc-table td:nth-child(2),
  .view-users .cdc-table td:nth-child(3),
  .view-users .cdc-table td:nth-child(4) { display: block; margin-right: 0; }
  /* Auth overlay compact */
  .auth-card { padding: 20px 18px; }
  .auth-brand { gap: 10px; margin-bottom: 20px; }
  .auth-title { font-size: 15px; }
  /* Canvas plein écran sur mobile (avec safe-area iOS) */
  .canvas-wrap {
    height: calc(100dvh - 180px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    min-height: 400px;
  }
  /* User chip plus petit */
  .user-chip { padding: 3px 3px 3px 10px; }
  .user-chip-name { font-size: 11px; }
}

@media (max-width: 600px) {
  .topbar {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topnav { flex-wrap: wrap; gap: 2px; width: 100%; }
  .topnav .nav-btn { flex: 1; padding: 8px 10px; font-size: 11.5px; }
  .brand-name { font-size: 13px; }
  .brand-sub { display: none; }
  main { padding: 12px; }
  h1 { font-size: 18px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-card { padding: 10px 12px; }
  .kpi-value { font-size: 20px; }
  .editor-tab .tab-icon { display: none; }
  .w-tab { padding: 7px 10px; font-size: 11px; }
  .w-panes { padding: 12px; }
  .summary-mod-grid { grid-template-columns: repeat(2, 1fr); }
}

@keyframes winFadeIn { from { opacity: 0; transform: scale(0.97) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.view { animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ===================== COPILOT — Ajouts extras ===================== */
.cop-conv-empty { padding: 16px; color: var(--text-muted); font-size: 12px; text-align: center; font-style: italic; }

#copilotSendBtn.streaming { background: var(--danger); color: #fff; }
#copilotSendBtn.streaming:hover { background: #b91c1c; }

#copilotMicBtn.recording {
  background: var(--danger); color: #fff;
  animation: micPulse 1s infinite;
}
@keyframes micPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

.cop-patch.applied { border-color: #10b981; background: #ecfdf5; }
.cop-patch.rejected { border-color: var(--text-muted); background: #f9fafb; opacity: 0.6; }
.cop-patch-done { color: #047857; font-weight: 700; font-size: 12px; }
.cop-patch-rejected { color: var(--text-muted); font-size: 12px; }

.cop-patch-op {
  padding: 6px 0;
  border-bottom: 1px dashed rgba(0,0,0,0.08);
}
.cop-patch-op:last-child { border-bottom: none; }
.cop-patch-op-name {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  margin-right: 6px;
}
.cop-patch-op code {
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
}
.cop-patch-op-reason { font-size: 11px; color: var(--text); margin: 4px 0 0 6px; font-family: var(--font-body); font-style: italic; }
.cop-patch-op-val { margin: 4px 0 0; padding: 6px; background: var(--carbon); color: var(--accent); border-radius: 4px; font-size: 10px; overflow-x: auto; white-space: pre; }

/* ======= FLOW — sélection edge ======= */
.flow-edge {
  cursor: pointer;
  transition: stroke 0.15s, stroke-width 0.15s;
}
.flow-edge:hover { stroke: #4338ca !important; stroke-width: 2.5 !important; }
.flow-edge.selected { stroke: var(--accent-dark) !important; stroke-width: 3 !important; }

/* ===================== QUESTION CARD (dédiée) ===================== */
.qc-card {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s, background 0.15s;
}
.qc-card.answered { border-color: #a7f3d0; background: #f0fdf4; }
.qc-card.deferred { border-color: #e5e7eb; background: #fafafa; opacity: 0.88; }
.qc-card.editing { border-color: var(--carbon); box-shadow: 0 0 0 3px rgba(0,224,135,0.15); }

.qc-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.qc-status-badge {
  flex: 0 0 28px;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-mono);
  margin-top: 1px;
}
.qc-status-badge.ok { background: #10b981; color: #fff; }
.qc-status-badge.open { background: #fbbf24; color: #78350f; }
.qc-status-badge.deferred { background: #9ca3af; color: #fff; }

.qc-question {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font-head);
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
  padding-top: 4px;
}

.qc-actions {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.qc-btn {
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-card);
  background: var(--surface);
  font-size: 11px;
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.qc-btn:hover { border-color: var(--carbon); background: #fafbfb; }
.qc-btn.primary { background: var(--carbon); color: var(--accent); border-color: var(--carbon); }
.qc-btn.primary:hover { background: #000; }
.qc-btn.lea { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.qc-btn.lea:hover { background: #e0e7ff; border-color: #818cf8; }
.qc-btn.danger { background: #fee2e2; color: var(--danger); border-color: #fecaca; padding: 5px 8px; }
.qc-btn.danger:hover { background: #fecaca; }

.qc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  padding-left: 38px;
  font-size: 11px;
}
.qc-placeholder { color: var(--text-muted); font-style: italic; font-size: 11px; }
.qc-status-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 3px;
  background: #f3f4f6;
  color: var(--text-muted);
}
.qc-status-lbl.answered { background: #d1fae5; color: #047857; }
.qc-status-lbl.open { background: #fef3c7; color: #92400e; }
.qc-status-lbl.deferred { background: #e5e7eb; color: #4b5563; }

.qc-answer {
  margin-left: 38px;
  background: #f0fdf4;
  border-left: 3px solid #10b981;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text);
}
.qc-answer-lbl {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  color: #047857;
  font-weight: 700;
  margin-bottom: 3px;
  letter-spacing: 0.06em;
}
.qc-answer-txt { line-height: 1.5; white-space: pre-wrap; }

.qc-quick {
  margin-left: 38px;
  background: #fafbfb;
  border: 1px dashed var(--carbon);
  padding: 10px;
  border-radius: 8px;
}
.qc-quick-input {
  width: 100%;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  resize: vertical;
  outline: none;
}
.qc-quick-input:focus { border-color: var(--carbon); box-shadow: 0 0 0 2px rgba(0,224,135,0.18); }
.qc-quick-actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}
.qc-ask-lea {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #4338ca;
  font-weight: 600;
  cursor: pointer;
}
.qc-ask-lea-check { accent-color: #4338ca; }

.qc-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Question list globale — symbole statut + Léa inline */
.question-row-compact {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 10px;
  align-items: center;
}
.qrc-status {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
}
.qrc-status.open { background: #fef3c7; color: #92400e; }
.qrc-status.answered { background: #d1fae5; color: #047857; }
.qrc-status.deferred { background: #e5e7eb; color: #4b5563; }
.qrc-answer-inline { color: #047857; font-style: italic; }
.qrc-lea {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
}
.qrc-lea:hover { background: #e0e7ff; border-color: #818cf8; transform: scale(1.08); }

/* ===================== ICONS SVG ===================== */
.ic {
  display: inline-block;
  vertical-align: -2px;
  flex-shrink: 0;
}
.ic-slot, .ic-resolved { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
.tab-icon-svg { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; vertical-align: middle; }
.tab-icon-svg .ic { width: 14px; height: 14px; }

/* Bouton "icon-only" — carré pour mic, etc. */
.btn.icon-only {
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
}
.btn .ic { vertical-align: middle; }

/* Question card : icônes dans les boutons */
.qc-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}
.qc-btn .ic { width: 13px; height: 13px; }
.qc-btn.danger { padding: 5px 7px; }
.qc-btn.danger .ic { width: 14px; height: 14px; }

/* Badges statut question : svg centré */
.qc-status-badge .ic { width: 15px; height: 15px; }
.qrc-status .ic { width: 13px; height: 13px; }

/* Question list — bouton Léa + flèche */
.qrc-lea { display: inline-flex; align-items: center; justify-content: center; }
.qrc-lea .ic { width: 14px; height: 14px; }
.qrc-arrow { color: var(--text-muted); display: inline-flex; align-items: center; }
.qrc-answer-inline { display: inline-flex; align-items: center; gap: 4px; }
.qrc-answer-inline .ic { width: 11px; height: 11px; }

/* Copilot avatars : svg centré */
.cop-msg .avatar { display: inline-flex; align-items: center; justify-content: center; }
.cop-msg .avatar .ic { width: 15px; height: 15px; }

/* Copilot tool icons */
.cop-tool-icon .ic { width: 12px; height: 12px; }
.cop-tool-status .ic { width: 11px; height: 11px; vertical-align: -1px; }

/* Copilot patch titre + actions */
.cop-patch-title { display: inline-flex; align-items: center; gap: 6px; }
.cop-patch-title .ic { width: 14px; height: 14px; }
.cop-patch-done, .cop-patch-rejected { display: inline-flex; align-items: center; gap: 4px; }
.cop-patch-done .ic, .cop-patch-rejected .ic { width: 13px; height: 13px; }

/* Copilot send/stop buttons */
#copilotSendBtn { display: inline-flex; align-items: center; gap: 6px; }
#copilotSendBtn .ic { width: 14px; height: 14px; }

/* Accept Léa checkbox row layout */
.qc-ask-lea .ic { width: 12px; height: 12px; vertical-align: -1px; margin-right: 2px; }

/* ===================== COPILOT — Pills compactes + Group ===================== */
.cop-tools-group { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }

.cop-tg-header {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 2px 0;
  transition: color 0.12s;
}
.cop-tg-header:hover { color: var(--text); }
.cop-tg-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  color: var(--text-muted);
}
.cop-tg-chevron .ic { width: 12px; height: 12px; }
.cop-tg-summary { font-weight: 600; }

.cop-tg-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-left: 4px;
}

.cop-pill {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 7px;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  background: var(--surface);
  font-size: 11.5px;
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1;
  transition: all 0.12s;
  user-select: none;
}
.cop-pill:hover { border-color: #9ca3af; background: #fafbfb; }
.cop-pill.active { border-color: var(--carbon); background: var(--carbon); color: var(--accent); }
.cop-pill.active .cop-pill-ic { color: var(--accent); }
.cop-pill.running { border-color: #c7d2fe; background: #f5f7ff; color: #4338ca; }
.cop-pill.done { border-color: #d1fae5; background: #f0fdf4; color: #047857; }
.cop-pill.failed { border-color: #fecaca; background: #fef2f2; color: var(--danger); }

.cop-pill-ic { display: inline-flex; align-items: center; justify-content: center; color: currentColor; }
.cop-pill-ic .ic { width: 12px; height: 12px; }
.cop-pill-name { font-weight: 600; }
.cop-pill-spin { display: inline-flex; align-items: center; justify-content: center; color: currentColor; }
.cop-pill-spin .cop-spinner { width: 9px; height: 9px; border-width: 1.5px; }
.cop-pill-spin .ic { width: 11px; height: 11px; }

/* Panneau détail de la pill sélectionnée */
.cop-tg-detail {
  margin-top: 4px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafbfb;
  padding: 0;
  overflow: hidden;
}
.cop-pd-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: var(--surface);
  font-size: 12px;
}
.cop-pd-ic { color: #4338ca; display: inline-flex; align-items: center; justify-content: center; }
.cop-pd-name { font-family: var(--font-head); font-weight: 600; color: var(--text); flex: 1; }
.cop-pd-status { font-size: 10.5px; color: var(--text-muted); font-family: var(--font-mono); }
.cop-pd-args {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: transparent;
}
.cop-pd-result {
  padding: 6px 12px 10px;
  border-top: 1px dashed rgba(0,0,0,0.08);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}

/* Back-to-bottom floating button (sticky dans la zone messages, pas sur l'input) */
.copilot-main { position: relative; }
.copilot-messages { position: relative; }
.cop-back-bottom {
  position: sticky;
  bottom: 12px;
  float: right;
  margin-right: 12px;
  margin-top: -48px;
  z-index: 5;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--carbon);
  color: var(--accent);
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.22);
  animation: copFade 0.15s ease-out;
  transition: transform 0.12s, background 0.12s;
}
.cop-back-bottom:hover { background: #000; transform: scale(1.08); }
.cop-back-bottom .ic { width: 16px; height: 16px; transform: rotate(90deg); }
@keyframes copFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Masque l'ancien cop-tool si jamais vestige */
.cop-tool { display: none; }

/* ===================== PATCH — Rendu humain + Modale ===================== */
.cop-patch-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  padding: 2px 0 0;
}
.cop-patch-header { gap: 10px; }
.cop-patch-actions .btn { display: inline-flex; align-items: center; gap: 4px; }
.cop-patch-actions .btn .ic { width: 13px; height: 13px; }

/* Modale plein écran pour voir le patch en détail */
.cop-patch-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  animation: copFade 0.15s ease-out;
}
.cop-patch-modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  width: min(900px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cop-patch-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--carbon);
  color: var(--accent);
}
.cop-patch-modal-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 17px;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cop-patch-modal-title .ic { width: 18px; height: 18px; }
.cop-patch-modal-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(0, 224, 135, 0.7);
  margin-top: 3px;
}
.cop-patch-modal-close {
  all: unset;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  transition: background 0.12s;
}
.cop-patch-modal-close:hover { background: rgba(0, 224, 135, 0.2); }
.cop-patch-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafbfb;
}
.cop-patch-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.cop-patch-modal-foot .btn { display: inline-flex; align-items: center; gap: 6px; }
.cop-patch-modal-foot .btn .ic { width: 14px; height: 14px; }

/* Patch op — rendu lisible */
.cop-patch-op {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-left: 4px solid #9ca3af;
  border-radius: 8px;
  padding: 12px 14px;
}
.cop-patch-op.add { border-left-color: #10b981; }
.cop-patch-op.update { border-left-color: #3b82f6; }
.cop-patch-op.remove { border-left-color: var(--danger); background: #fef2f2; }

.cop-patch-op-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cop-patch-op-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cop-patch-op-badge.add { background: #d1fae5; color: #065f46; }
.cop-patch-op-badge.update { background: #dbeafe; color: #1e40af; }
.cop-patch-op-badge.remove { background: #fee2e2; color: #991b1b; }

.cop-patch-op-where {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.cop-patch-op-reason {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 8px;
  padding: 7px 10px;
  background: #eff6ff;
  border-radius: 6px;
  font-size: 12px;
  color: #1e40af;
  font-style: italic;
}
.cop-patch-op-reason .ic { width: 12px; height: 12px; flex-shrink: 0; margin-top: 2px; }

.cop-patch-op-body {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
}
.cop-patch-op-body.muted { color: var(--text-muted); font-style: italic; font-size: 12px; }

.cop-patch-obj {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fafbfb;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.cop-patch-kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px dashed #e5e7eb;
  font-size: 12.5px;
}
.cop-patch-kv:last-child { border-bottom: none; }
.cop-patch-k {
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11.5px;
}
.cop-patch-v { color: var(--text); word-break: break-word; }
.cop-patch-v strong { font-family: var(--font-mono); color: var(--carbon); }
.cop-patch-val-list {
  margin: 2px 0 2px 18px;
  padding: 0;
  font-size: 12.5px;
}
.cop-patch-val-list li { margin-bottom: 3px; }

/* Responsive modale */
@media (max-width: 768px) {
  .cop-patch-modal-overlay { padding: 0; }
  .cop-patch-modal { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .cop-patch-kv { grid-template-columns: 1fr; gap: 2px; }
}

/* ===================== Liens — état cassé ===================== */
.deps-pill.broken {
  background: #fef2f2;
  color: var(--danger);
  border: 1px dashed var(--danger);
  text-decoration: line-through;
}
.ce-card-display.broken {
  border-color: #fecaca;
  background: #fef2f2;
}

/* ===================== MINI-COPILOT embarqué ===================== */
.w-tab.lea {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #4338ca;
}
.w-tab.lea:hover { background: #eef2ff; }
.w-tab.lea.active { background: #4338ca; color: #fff; }
.w-tab.lea.active .ic { color: #fff; }
.w-tab.lea .ic { width: 12px; height: 12px; }

.mc-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fafbfb;
}
.mc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.mc-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.mc-title .ic { color: #4338ca; }
.mc-scope { font-size: 10px; color: var(--text-muted); padding: 2px 8px; background: #f3f4f6; border-radius: 4px; }

.mc-msgs {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 12px 14px;
  min-height: 0;
}

.mc-patches, .mc-examples, .mc-input-bar { flex-shrink: 0; }

.mc-patches { padding: 0 14px; display: flex; flex-direction: column; gap: 6px; }
.mc-patch { margin: 0; padding: 10px 12px; }
.mc-patch .cop-patch-title { font-size: 12px; }
.mc-patch .btn.small { padding: 4px 8px; font-size: 11px; }
.mc-patch .btn .ic { width: 11px; height: 11px; }

.mc-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 14px 0;
}
.mc-ex {
  all: unset;
  cursor: pointer;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  background: var(--surface);
  transition: all 0.12s;
}
.mc-ex:hover { border-color: #4338ca; background: #eef2ff; color: #4338ca; }

.mc-input-bar {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
}
.mc-input {
  flex: 1;
  border: 1.5px solid var(--border-card);
  border-radius: 10px;
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  resize: vertical;
  max-height: 150px;
  outline: none;
}
.mc-input:focus { border-color: #4338ca; box-shadow: 0 0 0 2px rgba(67,56,202,0.15); }
.mc-send {
  all: unset;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--carbon);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.mc-send:hover { background: #000; }
.mc-send.streaming { background: var(--danger); }
.mc-send .ic { width: 14px; height: 14px; }

/* Messages mini */
.mc-msg {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.mc-msg.user { flex-direction: row-reverse; }
.mc-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--carbon);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mc-msg.user .mc-avatar { background: var(--accent); color: var(--carbon); }
.mc-bubble {
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.45;
  background: var(--surface);
  border: 1px solid var(--border);
  max-width: 75%;
}
.mc-msg.user .mc-bubble { background: var(--accent-soft); border-color: #a7f3d0; }
.mc-turn { flex: 1; min-width: 0; }
.mc-text { font-size: 12.5px; line-height: 1.5; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.mc-text:empty { padding: 0; border: none; }
.mc-text p { margin: 0 0 6px; }
.mc-text p:last-child { margin-bottom: 0; }
.mc-text code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-size: 11px; }

/* Provider chip sur les questions */
.provider-chip {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

/* Node action panel — unlink buttons */
.nap-linked-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11.5px;
  cursor: default;
  margin-bottom: 3px;
}
.nap-linked-item:hover { border-color: #9ca3af; }
.nap-linked-text { flex: 1; cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nap-linked-text:hover { color: #4338ca; }
.nap-linked-type { display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); }
.nap-unlink {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: all 0.12s;
}
.nap-unlink:hover { background: #fee2e2; color: var(--danger); }
.nap-unlink .ic { width: 11px; height: 11px; }

/* ===================== PATCH = message dans la conversation ===================== */
/* Ancien panneau bas du Copilot : caché (patches = messages maintenant) */
.copilot-patches { display: none; }

/* Espacement entre messages (assistant / user / system / patch) */
.cop-msg, .cop-system, .cop-patch-message { margin-bottom: 16px; }
.cop-msg:last-child, .cop-system:last-child, .cop-patch-message:last-child { margin-bottom: 10px; }
.mc-msg { margin-bottom: 14px; }

/* Message système (patch appliqué / rejeté) */
.cop-system {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 16px 40px;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  font-weight: 600;
}
.cop-system.applied { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.cop-system.rejected { background: #f3f4f6; color: var(--text-muted); border: 1px solid var(--border); }
.cop-system-ic { display: inline-flex; align-items: center; }
.cop-system .ic { width: 12px; height: 12px; }

/* Carte patch in-message */
.cop-patch-message .avatar { background: #eef2ff; color: #4338ca; }
.cop-patch-card {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid #c7d2fe;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 4px 14px rgba(67, 56, 202, 0.08);
}
.cop-patch-card .cop-patch-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  border-bottom: 1px dashed rgba(67, 56, 202, 0.2);
  padding-bottom: 10px;
}
.cop-patch-card .cop-patch-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.cop-patch-card .cop-patch-title .ic { color: #4338ca; }
.cop-patch-meta-sm {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #4338ca;
  font-weight: 600;
  background: #eef2ff;
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* Liste compacte des ops */
.cop-patch-ops {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 10px 0 12px;
}
.cop-patch-op-compact {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  background: #fafbfb;
  border-radius: 6px;
  border-left: 3px solid #9ca3af;
  font-size: 12px;
}
.cop-patch-op-compact.add { border-left-color: #10b981; }
.cop-patch-op-compact.update { border-left-color: #3b82f6; }
.cop-patch-op-compact.remove { border-left-color: var(--danger); }
.cop-patch-op-inline {
  flex: 1;
  min-width: 0;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}
.cop-patch-more {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
}

/* Actions patch : alignées proprement en bas */
.cop-patch-card .cop-patch-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.cop-patch-card .cop-patch-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cop-patch-card .cop-patch-actions .btn .ic { width: 12px; height: 12px; }

/* Aperçu flow dans patch */
.cop-patch-flow-preview {
  background: #fafbfb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 10px;
}
.cop-flow-mini-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}
.cop-flow-mini-svg {
  width: 100%;
  height: auto;
  max-height: 300px;
  display: block;
}

/* Espacement vertical entre tous les messages de la conversation */
.copilot-messages { display: flex; flex-direction: column; gap: 14px; padding: 20px 16px; }
.copilot-messages > * { margin-bottom: 0 !important; }
.mc-msgs { display: flex; flex-direction: column; gap: 12px; }
.mc-msgs > * { margin-bottom: 0 !important; }

/* Loading dots — en attente de la 1re réponse */
.cop-loading {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  width: fit-content;
}
.cop-loading span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: copDot 1.2s infinite ease-in-out both;
}
.cop-loading span:nth-child(1) { animation-delay: -0.32s; }
.cop-loading span:nth-child(2) { animation-delay: -0.16s; }
@keyframes copDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); background: #4338ca; }
}
/* Masquer le loading dès que du contenu apparaît (texte ou tools) */
.cop-turn:has(.cop-segments > *) .cop-loading,
.cop-turn:has(.cop-seg-text) .cop-loading,
.cop-turn:has(.cop-tools-group) .cop-loading { display: none; }
.mc-turn:has(.cop-segments > *) .mc-loading,
.mc-turn:has(.cop-seg-text) .mc-loading,
.mc-turn:has(.cop-tools-group) .mc-loading { display: none; }

/* ===================== Segments alternés (texte ⇄ tools) ===================== */
.cop-segments { display: flex; flex-direction: column; gap: 10px; }
.cop-seg-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 10px 14px;
}
.cop-seg-text:empty { display: none; }
.cop-seg-text p { margin: 0 0 8px; }
.cop-seg-text p:last-child { margin-bottom: 0; }
.cop-seg-text code { background: #f3f4f6; color: var(--carbon); padding: 1px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 11px; }
.cop-seg-text pre { background: var(--carbon); color: var(--accent); padding: 10px; border-radius: 8px; overflow-x: auto; font-family: var(--font-mono); font-size: 11px; margin: 8px 0; }
.cop-seg.cop-tools-group { margin: 0; }

/* ===================== CANVAS — FAB + SELECTION + CHAT MODAL ===================== */
.canvas-wrap { position: relative; }

.canvas-fab-stack {
  position: absolute;
  right: 20px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 20;
}
.canvas-fab {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.canvas-fab:hover { transform: scale(1.08); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18); }
.canvas-fab.primary { background: var(--carbon); color: var(--accent); }
.canvas-fab.primary:hover { background: #000; }
.canvas-fab.on { background: #4338ca; color: #fff; }
.canvas-fab .ic { width: 20px; height: 20px; }
#canvasSelToggle.on { background: #4338ca; color: #fff; box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.25); }

/* Barre de sélection (bottom fixed, visible si count > 0) */
.canvas-sel-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--carbon);
  color: #fff;
  border-radius: 28px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  z-index: 21;
  transition: all 0.18s;
  font-size: 12.5px;
}
.canvas-sel-bar.visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.csb-count { color: rgba(255, 255, 255, 0.75); font-family: var(--font-mono); }
.csb-count strong { color: var(--accent); font-weight: 700; margin-right: 4px; }
.csb-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #fff;
  font-size: 12px;
  font-family: var(--font-head);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.csb-btn:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.4); }
.csb-btn.primary { background: var(--accent); color: var(--carbon); border-color: var(--accent); }
.csb-btn.primary:hover { background: #00c476; }
.csb-btn .ic { width: 13px; height: 13px; }

/* État visuel "sélectionné" sur phase/module/feat-chip */
body.canvas-select-mode .node-module,
body.canvas-select-mode .node-phase,
body.canvas-select-mode .feat-chip { cursor: cell !important; }
body.canvas-select-mode .node-module:hover rect:first-of-type,
body.canvas-select-mode .feat-chip:hover .feat-chip-rect { stroke: #4338ca; stroke-width: 2; }

.node-module.sel-on > rect { stroke: #4338ca !important; stroke-width: 3 !important; filter: drop-shadow(0 0 0 rgba(67,56,202,0.35)); }
.node-phase.sel-on .node-phase-header { stroke: #4338ca !important; stroke-width: 3 !important; }
.feat-chip.sel-on .feat-chip-rect { fill: #eef2ff !important; stroke: #4338ca !important; stroke-width: 2 !important; }

/* Modale Chat Léa depuis le canvas */
.canvas-lea-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.55);
  backdrop-filter: blur(4px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  animation: copFade 0.15s ease-out;
}
.canvas-lea-modal {
  width: min(760px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.canvas-lea-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--carbon);
  color: var(--accent);
  border-bottom: 1px solid rgba(0, 224, 135, 0.2);
}
.canvas-lea-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.canvas-lea-close {
  all: unset;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.canvas-lea-close:hover { background: rgba(0, 224, 135, 0.18); }

.canvas-lea-context {
  padding: 10px 18px;
  background: #eef2ff;
  border-bottom: 1px solid #c7d2fe;
}
.canvas-lea-ctx-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #4338ca;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.canvas-lea-ctx-items { display: flex; flex-wrap: wrap; gap: 5px; }
.canvas-lea-ctx-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid #c7d2fe;
  font-size: 11px;
  color: var(--text);
}
.canvas-lea-ctx-chip.phase { border-color: #fbbf24; }
.canvas-lea-ctx-chip.module { border-color: #4338ca; }
.canvas-lea-ctx-chip.feature { border-color: #10b981; }
.canvas-lea-ctx-chip .ic { color: var(--text-muted); }

.canvas-lea-body {
  flex: 1;
  min-height: 400px;
  overflow: hidden;
  display: flex;
}
.canvas-lea-body > .mc-root { flex: 1; min-height: 0; }

/* ===================== Léa WINDOW (via WM) ===================== */
.lea-win {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
  background: #fafbfb;
}
.lea-win .canvas-lea-context {
  padding: 10px 16px;
  background: #eef2ff;
  border-bottom: 1px solid #c7d2fe;
  flex-shrink: 0;
}
.lea-win-body { flex: 1 1 0; min-height: 0; display: flex; overflow: hidden; }
.lea-win-body > .mc-root { flex: 1 1 0; min-height: 0; height: auto; }

/* Masque l'ancienne modale overlay (gardée pour compat mais plus utilisée) */
.canvas-lea-modal-overlay { display: none !important; }

/* Badge "Canvas" sur les items de conversation */
.conv-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-right: 6px;
  vertical-align: middle;
}
.conv-badge.canvas { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }
.conv-badge .ic { width: 9px; height: 9px; }

/* Léa window — context header avec actions */
.canvas-lea-ctx-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.canvas-lea-ctx-top .canvas-lea-ctx-label { flex: 1; }
.lea-ctx-btn {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid #c7d2fe;
  color: #4338ca;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 11px;
  transition: all 0.12s;
}
.lea-ctx-btn:hover { background: #eef2ff; }
.lea-ctx-btn.danger { border-color: #fecaca; color: var(--danger); }
.lea-ctx-btn.danger:hover { background: #fef2f2; }
.lea-ctx-btn .ic { width: 11px; height: 11px; }

body.canvas-select-mode .lea-ctx-btn[data-lea-act="toggle-sel"] {
  background: #4338ca;
  color: #fff;
  border-color: #4338ca;
}
body.canvas-select-mode .lea-ctx-btn[data-lea-act="toggle-sel"] .ic { color: #fff; }

.canvas-lea-ctx-empty {
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
}

/* Léa history panel */
.lea-history-panel {
  margin-top: 8px;
  border: 1px solid #c7d2fe;
  background: var(--surface);
  border-radius: 8px;
  max-height: 240px;
  overflow-y: auto;
}
.lea-history-empty, .lea-history-loading {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}
.lea-history-list { display: flex; flex-direction: column; }
.lea-history-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.lea-history-item:last-child { border-bottom: none; }
.lea-history-item:hover { background: #eef2ff; }
.lea-history-item[data-has-sel="1"] { border-left: 3px solid #4338ca; padding-left: 9px; }
.lhi-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.lhi-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); }

/* Spinner dans les boutons auth */
.btn-spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: btnSpin 0.7s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}
@keyframes btnSpin { to { transform: rotate(360deg); } }

button:disabled { opacity: 0.7; cursor: wait; }

/* Info lookup invitation */
.invite-info {
  margin-top: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.invite-info.ok { color: #047857; }
.invite-info.err { color: var(--danger); }
.invite-info code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; }
.invite-info-loading { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }

/* Journal — détails enrichis */
.je-details {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.je-details code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
}
.je-type { white-space: nowrap; }

/* ===================== KINN CREDITS — Badge solde + coût conversation ===================== */
.user-credit-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px 3px 10px;
  margin-right: 8px;
  border-radius: 12px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #6ee7b7;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  transition: all 0.2s;
}
.user-credit-badge .ucb-unit {
  font-size: 9.5px;
  opacity: 0.7;
  margin-left: 2px;
  text-transform: uppercase;
}
.user-credit-badge.alert { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.user-credit-badge.negative { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.user-credit-badge.negative::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 4px;
  animation: negBlink 1.2s infinite;
}
@keyframes negBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Badge coût par TURN — petit, en bas du turn */
.cop-turn-cost {
  margin-top: 6px;
  padding: 3px 9px;
  border-radius: 10px;
  background: #f3f4f6;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  align-self: flex-start;
}
.cop-turn-cost .ccc-ic { color: #4338ca; display: inline-flex; }
.cop-turn-cost .ccc-credits { color: #4338ca; font-weight: 700; }
.cop-turn-cost .ccc-cost { color: #b45309; }
.cop-turn-cost .ccc-margin { color: #047857; font-weight: 600; }
.cop-turn-cost .ccc-sep { opacity: 0.4; }

/* Footer GLOBAL — cumul de la conversation, sticky sous les messages */
.copilot-main, .lea-win, .mc-root { position: relative; }
.cop-conv-footer {
  flex-shrink: 0;
  padding: 6px 16px;
  background: var(--carbon);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(0, 224, 135, 0.15);
}
.cop-conv-footer .ccf-lbl { color: rgba(0, 224, 135, 0.6); text-transform: uppercase; letter-spacing: 0.05em; font-size: 9.5px; font-weight: 700; margin-right: auto; }
.cop-conv-footer .ccf-credits { color: var(--accent); font-weight: 700; }
.cop-conv-footer .ccf-cost { color: #fbbf24; }
.cop-conv-footer .ccf-margin { color: #34d399; font-weight: 600; }
.cop-conv-footer .ccf-sep { opacity: 0.3; }

/* Popover solde crédits (depuis header badge) */
.credit-popover {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  padding: 14px 16px;
  width: 260px;
  animation: copFade 0.15s ease-out;
}
.credit-popover .cp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.credit-popover .cp-title { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-head); font-weight: 700; font-size: 12px; }
.credit-popover .cp-title .ic { color: #4338ca; }
.credit-popover .cp-link, .credit-popover .cp-admin-link {
  all: unset;
  cursor: pointer;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: #4338ca;
}
.credit-popover .cp-link:hover, .credit-popover .cp-admin-link:hover { text-decoration: underline; }
.credit-popover .cp-admin-link { display: block; text-align: center; padding: 6px; background: #eef2ff; border-radius: 6px; margin-top: 4px; }
.credit-popover .cp-balance { font-family: var(--font-head); font-weight: 800; font-size: 26px; line-height: 1.1; color: #047857; }
.credit-popover .cp-balance.neg { color: var(--danger); }
.credit-popover .cp-balance small { font-size: 12px; font-weight: 600; opacity: 0.6; }
.credit-popover .cp-sub { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin-bottom: 6px; }
.credit-popover .cp-alert { color: var(--danger); font-weight: 700; }
.credit-popover .cp-divider { height: 1px; background: var(--border); margin: 10px -16px; }
.credit-popover .cp-rows { display: flex; flex-direction: column; gap: 4px; }
.credit-popover .cp-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text); }
.credit-popover .cp-row span { color: var(--text-muted); }
.credit-popover .cp-row strong { font-family: var(--font-mono); }
.credit-popover .cp-sect-lbl { font-size: 9.5px; font-family: var(--font-mono); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.credit-popover .cp-loading { padding: 20px; text-align: center; color: var(--text-muted); font-size: 12px; }
.credit-popover .cp-error { padding: 12px; color: var(--danger); font-size: 11px; }

/* ===================== BILLING VIEW ===================== */
.billing-view { padding: 20px 24px; max-width: 1400px; margin: 0 auto; }
.billing-header { margin-bottom: 24px; }
.billing-header h1 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 26px;
  margin: 0;
}
.billing-header h1 .ic { color: #4338ca; }
.billing-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.billing-loading { padding: 40px; text-align: center; color: var(--text-muted); }
.billing-error { padding: 40px; text-align: center; color: var(--danger); }

.billing-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.billing-kpis.admin { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.bkpi {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 16px 18px;
  border-left: 4px solid #e5e7eb;
}
.bkpi.primary { border-left-color: var(--carbon); background: linear-gradient(135deg, #fff 0%, #f5f6fa 100%); }
.bkpi.primary.neg { border-left-color: var(--danger); background: linear-gradient(135deg, #fff 0%, #fef2f2 100%); }
.bkpi.pos { border-left-color: #10b981; }
.bkpi.alert { border-left-color: #f59e0b; background: #fffbeb; }
.bkpi-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.bkpi-value {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 26px;
  color: var(--text);
  line-height: 1.1;
}
.bkpi-value small { font-size: 13px; font-weight: 600; opacity: 0.6; }
.bkpi-value.small { font-size: 14px; }
.bkpi-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; font-family: var(--font-mono); }

.billing-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
}
@media (max-width: 900px) { .billing-grid { grid-template-columns: 1fr; } }
.billing-grid .card { padding: 16px; }
.billing-grid .card h3 { margin: 0 0 12px; font-family: var(--font-head); font-size: 14px; }

.billing-spark { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.bs-bar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bs-bar .bs-fill { width: 80%; background: linear-gradient(180deg, #4338ca 0%, #8b5cf6 100%); border-radius: 3px 3px 0 0; min-height: 2px; transition: height 0.3s; margin-top: auto; }
.bs-lbl { font-size: 9px; color: var(--text-muted); margin-top: 4px; transform: rotate(-45deg); transform-origin: right; white-space: nowrap; }

.lx-type {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 700;
}
.lx-recharge { background: #d1fae5; color: #065f46; }
.lx-debit { background: #fee2e2; color: #991b1b; }
.lx-adjust { background: #fef3c7; color: #92400e; }
.lx-opening { background: #e0e7ff; color: #3730a3; }
.lx-llm { background: #eef2ff; color: #4338ca; }
.lx-embedding { background: #fce7f3; color: #9f1239; }
.lx-audio { background: #e0f2fe; color: #0369a1; }

.billing-ledger table, .billing-view .cdc-table { width: 100%; border-collapse: collapse; }
.billing-ledger th, .billing-ledger td, .billing-view .cdc-table th, .billing-view .cdc-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 12px; text-align: left; }
.billing-view .pos { color: #047857; font-weight: 700; }
.billing-view .neg { color: var(--danger); font-weight: 700; }

.billing-admin-section h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  border-top: 2px solid var(--border);
  padding-top: 20px;
}
.billing-admin-section h2 .ic { color: var(--carbon); }

/* Avatar utilisateur dans le user-chip */
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--carbon);
  color: #fff;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  margin-right: 6px;
  flex-shrink: 0;
}

/* Badge crédit dans la topnav (même niveau que les boutons) */
.nav-credit-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 12px 5px 14px;
  margin-left: 8px;
  border-radius: 14px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #6ee7b7;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-credit-badge:hover { background: #d1fae5; }
.nav-credit-badge .ucb-unit {
  font-size: 10px;
  opacity: 0.7;
  margin-left: 3px;
  text-transform: uppercase;
}
.nav-credit-badge.alert { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.nav-credit-badge.negative { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.nav-credit-badge.negative::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 5px;
  animation: negBlink 1.2s infinite;
}

/* Badge turn — compteurs I/O tokens + indicateur live */
.cop-turn-cost .ccc-io { color: var(--text-muted); font-size: 10px; }
.cop-turn-cost .ccc-live {
  background: #eef2ff;
  color: #4338ca;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-left: 4px;
  animation: liveBlink 1s infinite;
}
@keyframes liveBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.cop-turn-cost.live { background: #f5f7ff; border: 1px solid #c7d2fe; }

/* ===================== MOBILE — Hamburger + Credit badge ===================== */
.nav-hamburger {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 40px; height: 40px;
  padding: 10px;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
}
.nav-hamburger:hover { background: var(--border); }
.nav-hamburger span {
  display: block;
  width: 20px;
  height: 2.5px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.2s;
}
body.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
body.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; }
body.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* Badge crédit à droite du brand (mobile uniquement) */
.nav-credit-badge.mobile-credit {
  display: none;
  margin-left: 10px;
  padding: 4px 10px 4px 12px;
  font-size: 11px;
}

@media (max-width: 900px) {
  .nav-hamburger { display: inline-flex; }
  .nav-credit-badge.mobile-credit:not([hidden]) { display: inline-flex; }
  /* Cache le badge topnav desktop sur mobile */
  .topnav .nav-credit-badge:not(.mobile-credit) { display: none; }
  /* Topnav en drawer */
  #topnav {
    position: fixed;
    top: 56px;
    left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    padding: 8px;
    gap: 4px;
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s, opacity 0.2s;
    z-index: 50;
  }
  body.nav-open #topnav {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .topnav .nav-btn {
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border-radius: 8px;
  }
  /* Header mobile : logo seul, badge crédit à droite */
  .topbar { padding: 10px 14px; flex-wrap: nowrap; align-items: center; gap: 8px; }
  .brand {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .brand-text { display: none; }
  /* Badge crédit poussé à droite du brand (juste avant le hamburger) */
  .mobile-credit { margin-left: auto !important; margin-right: 4px; }
  /* Hamburger → bouton close quand menu ouvert (accent visuel) */
  body.nav-open .nav-hamburger {
    background: var(--carbon);
  }
  body.nav-open .nav-hamburger span { background: var(--accent); }
}

@media (min-width: 901px) {
  .nav-credit-badge.mobile-credit { display: none !important; }
}

/* ===================== QUESTION CARD — Mobile layout ===================== */
@media (max-width: 768px) {
  .qc-card { padding: 10px; gap: 6px; }

  /* Les actions passent sous la question en ligne horizontale, pleine largeur */
  .qc-head {
    flex-wrap: wrap;
    gap: 8px;
  }
  .qc-question {
    flex: 1 1 calc(100% - 40px);
    font-size: 13px;
  }
  .qc-actions {
    flex: 1 1 100%;
    justify-content: flex-start;
    padding-left: 38px;
    flex-wrap: wrap;
  }
  .qc-btn {
    font-size: 11.5px;
    padding: 6px 10px;
    min-height: 32px;
    flex: 0 1 auto;
  }
  /* En mobile, les labels textuels deviennent moins importants — on garde icône + 1 mot court */
  .qc-btn span { font-size: 11px; }

  /* Meta reflow */
  .qc-meta {
    padding-left: 38px;
    gap: 4px;
    font-size: 10.5px;
  }
  .qc-status-lbl { font-size: 9.5px; }

  /* Réponse rapide plus compacte */
  .qc-quick { margin-left: 0; padding: 8px; }
  .qc-quick-actions { flex-direction: column; align-items: stretch; gap: 6px; }
  .qc-quick-actions > div { justify-content: stretch; }
  .qc-quick-actions .qc-btn { flex: 1 1 auto; justify-content: center; }
  .qc-ask-lea { order: 2; font-size: 11px; padding: 4px 0; }

  /* Réponse affichée : pas de marge gauche */
  .qc-answer { margin-left: 0; padding: 6px 10px; font-size: 12px; }
}

@media (max-width: 480px) {
  /* Très petits écrans : pas de padding left sur les actions, labels masqués */
  .qc-actions { padding-left: 0; gap: 5px; }
  .qc-meta { padding-left: 0; }
  .qc-btn { padding: 6px 9px; }
  .qc-btn span:not(:only-child) { display: none; } /* garde juste l'icône */
  .qc-btn.danger { padding: 6px 8px; }
}

/* Résumé module — mobile : titre feature autorise retour à la ligne */
@media (max-width: 768px) {
  .sm-feat {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .sm-feat-title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    flex: 1 1 100%;
    width: 100%;
  }
  .sm-feat-stats { font-size: 10.5px; }

  /* Cards questions/tâches dans le résumé : mêmes règles */
  .sm-q-card, .sm-t-card {
    word-break: break-word;
    white-space: normal;
  }

  .summary-mod-grid { grid-template-columns: 1fr; }
}

/* ===================== MODAL OPEN — bloquer scroll body + canvas derrière ===================== */
/* Desktop : on NE bloque PAS le scroll global (permet de scroller le contenu sous la fenêtre),
   sauf si la fenêtre est en plein écran mobile. */
@media (max-width: 900px) {
  body.modal-open { overflow: hidden; touch-action: none; overscroll-behavior: none; }
  body.modal-open .canvas-wrap { touch-action: none; pointer-events: none; }
  body.modal-open .canvas-wrap .canvas-fab-stack,
  body.modal-open .canvas-wrap .canvas-sel-bar { pointer-events: auto; }
  body.modal-open .cdc-window,
  body.modal-open .cdc-window * { touch-action: auto; }
  body.modal-open .copilot-messages,
  body.modal-open .mc-msgs,
  body.modal-open .cdc-window-body,
  body.modal-open .w-pane { overscroll-behavior: contain; }
}

/* ===================== FEATURES-LIST — Mobile responsive ===================== */
@media (max-width: 768px) {
  .features-list-table th, .features-list-table td {
    padding: 8px 6px;
    font-size: 11.5px;
  }
  .fl-col-name { max-width: 60%; word-break: break-word; }
  .fl-col-name strong { font-size: 12.5px; }
  .fl-sub-mobile {
    display: block;
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 2px;
    font-family: var(--font-mono);
  }
  .fl-col-phase { text-align: center; }
  .fl-col-counts { white-space: nowrap; }
  .fl-counts { display: inline-flex; gap: 6px; }
  .fl-counts .fl-c { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }
  .fl-counts .fl-c.tasks { color: #4338ca; }
  .fl-counts .fl-c.qs { color: #b45309; }
  .fl-counts .fl-c.nodes { color: #047857; }
}
@media (min-width: 769px) {
  .fl-sub-mobile { display: none; }
  .fl-counts { display: inline-flex; gap: 10px; font-family: var(--font-mono); font-size: 11px; }
  .fl-counts .fl-c.tasks { color: #4338ca; }
  .fl-counts .fl-c.qs { color: #b45309; }
  .fl-counts .fl-c.nodes { color: #047857; }
}

/* ===================== ACTIONS EDITOR — Bouton MORE (3 points verticaux) mobile ===================== */
.actions-more {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  width: 38px; height: 38px;
  padding: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-left: auto;
}
.actions-more:hover { background: #fafbfb; border-color: var(--carbon); }
.actions-more span {
  display: block;
  width: 4px;
  height: 4px;
  background: var(--text);
  border-radius: 50%;
}

.actions-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

@media (max-width: 900px) {
  .actions { flex: 1; justify-content: flex-end; }
  .actions-more { display: inline-flex; }
  .actions-group {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
    padding: 6px;
    gap: 2px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: all 0.15s;
    min-width: 200px;
    z-index: 60;
  }
  .actions-group.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
  .actions-group .btn {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
  }
  .actions { position: relative; }
  .save-indicator { font-size: 11px; }
}
@media (min-width: 901px) {
  .actions-more { display: none !important; }
  .actions-group { display: flex !important; position: static !important; transform: none !important; opacity: 1 !important; pointer-events: auto !important; box-shadow: none !important; padding: 0 !important; background: transparent !important; border: none !important; }
}

/* Très petits écrans : 1 seul filtre par ligne */
@media (max-width: 480px) {
  .tasks-filters { grid-template-columns: 1fr; }
  .tasks-filters input[type="text"].input, .tasks-filters input:not([type]).input { grid-column: auto; }
}

/* ===================== iOS safe-area — main content ===================== */
@media (max-width: 900px) {
  main {
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .user-chip {
    left: calc(16px + env(safe-area-inset-left, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

/* Masquer le hint "Clic module = détails..." en mobile (pas de place) */
@media (max-width: 900px) {
  .canvas-hint { display: none; }
}

/* ===================== FEATURES-LIST mobile — table en cards ===================== */
@media (max-width: 768px) {
  .features-list-card { padding: 8px; }
  .features-list-table { border: none; }
  .features-list-table thead { display: none; }
  .features-list-table tbody { display: flex; flex-direction: column; gap: 8px; }
  .features-list-table tr.fl-row {
    display: block;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border-card);
    border-radius: 10px;
    transition: border-color 0.12s;
  }
  .features-list-table tr.fl-row:hover { border-color: var(--carbon); }
  .features-list-table tr.fl-row td {
    display: block;
    padding: 0;
    border: none;
  }
  .features-list-table tr.fl-row td.fl-col-name {
    margin-bottom: 6px;
  }
  .features-list-table tr.fl-row td.fl-col-name strong {
    display: block;
    font-size: 13.5px;
    line-height: 1.35;
    color: var(--text);
    margin-bottom: 3px;
  }
  /* Ligne meta compacte : phase + équipe + counts alignés */
  .features-list-table tr.fl-row td.fl-col-phase,
  .features-list-table tr.fl-row td.fl-col-counts {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-right: 10px;
  }
  .features-list-table tr.fl-row td.fl-col-phase { margin-right: 8px; }
  .features-list-table tr.fl-row .qrc-chip {
    background: var(--carbon);
    color: var(--accent);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10.5px;
  }
  .features-list-table tr.fl-row .fl-sub-mobile {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font-mono);
    margin-top: 0;
  }
  .features-list-table tr.fl-row .fl-sub-mobile .team-badge {
    font-family: var(--font-head);
    font-size: 10px;
    padding: 1px 7px;
  }
  .features-list-table tr.fl-row .fl-counts {
    display: inline-flex;
    gap: 8px;
    font-size: 10.5px;
    margin-top: 6px;
  }
}

/* ===================== MAIN — padding réduit mobile ===================== */
@media (max-width: 900px) {
  main { padding: 12px 10px 20px; }
}
@media (max-width: 768px) {
  main { padding: 10px 8px 18px; }
  .card { padding: 12px; }
  .table-card { padding: 8px; }
  h1 { font-size: 18px; margin-bottom: 12px; }
  .editor-header { margin-bottom: 10px; padding: 10px 12px; }
}
@media (max-width: 480px) {
  main { padding: 8px 6px 16px; }
  .card, .bkpi { padding: 10px; }
}

/* ===================== COPILOT — Mobile (sidebar en drawer) ===================== */
.copilot-sidebar-toggle { display: none; }

@media (max-width: 900px) {
  .copilot-layout {
    grid-template-columns: 1fr;
    height: calc(100dvh - 150px - env(safe-area-inset-bottom, 0px));
    min-height: auto;
    gap: 0;
    position: relative;
    overflow: hidden;
  }
  .copilot-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: min(280px, 85vw);
    height: 100%;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    box-shadow: 4px 0 20px rgba(0,0,0,0.14);
    background: var(--surface);
  }
  .copilot-layout.sidebar-open .copilot-sidebar { transform: translateX(0); }
  /* Backdrop */
  .copilot-layout.sidebar-open::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(10,10,10,0.35);
    z-index: 40;
  }
  .copilot-main { grid-column: 1 / -1; border-radius: 0; border: none; }
  .copilot-sidebar-toggle { display: inline-flex; }
  .copilot-header { padding: 10px 12px; gap: 8px; align-items: center; }
  .copilot-scope { font-size: 9.5px; }
  .copilot-title { font-size: 13px; }
  .copilot-header .hide-mobile { display: none; }
}

/* ===================== Bouton Envoyer Léa — carré icône seule ===================== */
#copilotSendBtn {
  width: 40px; height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
}
#copilotSendBtn .ic { width: 16px; height: 16px; }
.mc-send { width: 40px; height: 40px; border-radius: 10px; }

/* ===================== Mobile — edge-to-edge (UNIQUEMENT les vues pleine largeur) ===================== */
@media (max-width: 900px) {
  /* Seules les zones de travail pleine largeur (canvas, copilot, flow) perdent leur radius */
  .copilot-main, .copilot-layout, .canvas-wrap {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .copilot-layout { margin-left: calc(-1 * env(safe-area-inset-left, 0px) - 8px); margin-right: calc(-1 * env(safe-area-inset-right, 0px) - 8px); }
  /* Garantit que les listes (Mes CDC, Users) gardent leurs cards arrondies */
  .view-list .card, .view-list .cdc-card, .view-users .card, .view-users .user-card,
  .billing-view .card, .tab-pane .card:not(.canvas-wrap):not(.copilot-main),
  .table-card, .features-list-card {
    border-radius: var(--radius-card, 12px);
    border-left: 1px solid var(--border-card);
    border-right: 1px solid var(--border-card);
  }
}

/* ===================== User avatar mobile (dans topbar) ===================== */
.user-avatar.user-avatar-header {
  display: none;
  border: none;
  cursor: pointer;
  transition: transform 0.12s;
  flex-shrink: 0;
}
.user-avatar.user-avatar-header:hover { transform: scale(1.08); }

@media (max-width: 900px) {
  .user-avatar.user-avatar-header:not([hidden]) { display: inline-flex; }
  /* Masque le user-chip flottant bas-gauche en mobile (remplacé par l'avatar dans le header) */
  .user-chip { display: none !important; }
}

/* User popover (depuis avatar header) */
.user-popover {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  padding: 14px;
  width: 260px;
  animation: copFade 0.15s ease-out;
}
.user-popover .up-header { display: flex; align-items: center; gap: 10px; }
.user-popover .up-avatar { width: 36px; height: 36px; font-size: 13px; margin: 0; flex-shrink: 0; }
.user-popover .up-name { font-family: var(--font-head); font-weight: 700; font-size: 13px; color: var(--text); }
.user-popover .up-email { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; word-break: break-all; }
.user-popover .up-divider { height: 1px; background: var(--border); margin: 10px -14px; }
.user-popover .up-rows { display: flex; flex-direction: column; gap: 4px; }
.user-popover .up-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text); }
.user-popover .up-row span { color: var(--text-muted); }
.user-popover .up-logout {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef2f2;
  color: var(--danger);
  font-size: 12px;
  font-family: var(--font-head);
  font-weight: 600;
  width: 100%;
  justify-content: center;
}
.user-popover .up-logout:hover { background: #fee2e2; }
.user-popover .up-logout .ic { width: 13px; height: 13px; }

/* ===================== Back-to-bottom — rond (pas ovale) ===================== */
.cop-back-bottom {
  width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  min-width: 40px;
  aspect-ratio: 1 / 1;
  border-radius: 50% !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cop-back-bottom span { display: none; }
.cop-back-bottom .ic { width: 16px; height: 16px; margin: 0; }

/* ===================== BILLING — Mobile responsive ===================== */
@media (max-width: 900px) {
  .billing-view { padding: 10px 8px 20px; max-width: none; }
  .billing-header { margin-bottom: 14px; }
  .billing-header h1 { font-size: 20px; }
  .billing-header h1 .ic { width: 18px; height: 18px; }
  .billing-sub { font-size: 12px; }

  .billing-kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
  .billing-kpis.admin { grid-template-columns: repeat(2, 1fr); }
  .bkpi { padding: 10px 12px; }
  .bkpi-value { font-size: 19px; }
  .bkpi-value small { font-size: 11px; }
  .bkpi-label { font-size: 9.5px; margin-bottom: 3px; }
  .bkpi-sub { font-size: 10.5px; }

  .billing-grid { gap: 8px; }
  .billing-grid .card { padding: 10px; }
  .billing-grid .card h3 { font-size: 13px; margin-bottom: 8px; }

  /* Tableaux billing → cards stack (scroll horizontal serait cassé) */
  .billing-view .cdc-table { font-size: 11.5px; }
  .billing-view .cdc-table thead { display: none; }
  .billing-view .cdc-table tbody { display: flex; flex-direction: column; gap: 6px; }
  .billing-view .cdc-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
    padding: 8px 10px;
    background: #fafbfb;
    border: 1px solid var(--border);
    border-radius: 8px;
    align-items: center;
  }
  .billing-view .cdc-table td {
    display: block;
    padding: 0;
    border: none;
    font-size: 11.5px;
    word-break: break-word;
  }
  .billing-view .cdc-table td:first-child { font-weight: 600; }
  .billing-view .cdc-table td strong { display: block; font-size: 12px; }
  .billing-view .cdc-table td small { color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; }
  /* Chaque td sauf le premier est affiché avec un libellé (via data-label si on l'ajoute),
     sinon ils s'alignent à droite en mono */
  .billing-view .cdc-table td:not(:first-child) {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 10.5px;
  }
  /* Action (bouton recharger) en pleine ligne */
  .billing-view .cdc-table td:last-child .btn {
    width: 100%;
    justify-content: center;
    padding: 6px 10px;
    font-size: 11px;
  }

  .billing-admin-section h2 { font-size: 16px; padding-top: 14px; }
  .billing-admin-section h2 .ic { width: 16px; height: 16px; }

  .billing-ledger .lx-type { font-size: 9px; padding: 1px 5px; }

  .billing-spark { height: 110px; }
  .billing-spark .bs-lbl { font-size: 8px; }
}

@media (max-width: 480px) {
  .billing-kpis, .billing-kpis.admin { grid-template-columns: 1fr; }
  .billing-view .cdc-table tr { grid-template-columns: 1fr; }
  .billing-view .cdc-table td:not(:first-child) { text-align: left; }
}

/* ===================== BRIEF CLIENT — cahier des charges rendu ===================== */
.brief-view { padding: 20px 28px; max-width: 1100px; margin: 0 auto; }
.brief-loading, .brief-error, .brief-generating { padding: 60px 20px; text-align: center; color: var(--text-muted); }
.brief-generating h2 { margin: 18px 0 8px; color: var(--text); font-family: var(--font-head); }
.brief-generating p { max-width: 480px; margin: 0 auto; font-size: 13px; }

.brief-empty { padding: 50px 20px; text-align: center; max-width: 560px; margin: 40px auto; }
.brief-empty-icon { color: #c7d2fe; margin-bottom: 12px; }
.brief-empty h2 { margin: 0 0 10px; font-family: var(--font-head); font-size: 20px; }
.brief-empty p { color: var(--text-muted); font-size: 13px; line-height: 1.55; margin-bottom: 20px; }
.brief-empty .btn { margin: 0 auto; }

.brief-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.brief-header h1 {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-head); font-weight: 800; font-size: 22px; margin: 0;
}
.brief-header h1 .ic { color: #4338ca; }
.brief-sub { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 4px; }

.brief-stale-btn { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.brief-stale-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  color: #92400e;
  font-size: 13px;
  margin-bottom: 16px;
}
.brief-stale-banner .ic { flex-shrink: 0; color: #d97706; }

.brief-versions {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.brief-version-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  transition: all 0.12s;
}
.brief-version-btn:hover { border-color: #4338ca; color: #4338ca; }
.brief-version-btn.active { background: var(--carbon); color: var(--accent); border-color: var(--carbon); }

.brief-body { display: flex; flex-direction: column; gap: 28px; }

.brief-section {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card, 12px);
  padding: 24px 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  position: relative;
}
.brief-section-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent-soft);
}
.brief-section-body { color: var(--text); line-height: 1.6; font-size: 13.5px; }
.brief-md h2, .brief-md h3 { font-family: var(--font-head); color: var(--text); margin-top: 18px; }
.brief-md h2 { font-size: 15px; }
.brief-md h3 { font-size: 14px; }
.brief-md ul, .brief-md ol { padding-left: 22px; margin: 8px 0; }
.brief-md li { margin-bottom: 4px; }
.brief-md strong { color: var(--carbon); }
.brief-md blockquote { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 8px 14px; margin: 10px 0; border-radius: 0 6px 6px 0; font-style: italic; }

/* Page de garde */
.brief-cover {
  text-align: center;
  padding: 40px 20px;
  background: linear-gradient(135deg, var(--carbon) 0%, #1a1a1a 100%);
  color: #fff;
  border-radius: 10px;
}
.brief-cover-title { font-family: var(--font-head); font-weight: 800; font-size: 28px; color: var(--accent); margin-bottom: 10px; }
.brief-cover-client { font-size: 15px; color: rgba(255,255,255,0.8); margin-bottom: 6px; }
.brief-cover-meta { font-family: var(--font-mono); font-size: 11px; color: rgba(255,255,255,0.5); letter-spacing: 0.1em; text-transform: uppercase; }

/* Arborescence */
.brief-tree { display: flex; flex-direction: column; gap: 18px; }
.brief-tree-phase {
  padding: 14px 16px;
  background: #fafbfb;
  border-left: 4px solid var(--carbon);
  border-radius: 6px;
}
.brief-tree-phase-label { font-family: var(--font-head); font-weight: 700; color: var(--carbon); margin-bottom: 10px; }
.brief-tree-mods { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.brief-tree-mod {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  padding: 10px 12px;
}
.btm-head {
  font-family: var(--font-head); font-weight: 700; font-size: 12.5px;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.btm-team { font-size: 9.5px; padding: 1px 6px; border-radius: 3px; background: #eef2ff; color: #4338ca; font-family: var(--font-mono); font-weight: 600; }
.btm-feats { display: flex; flex-wrap: wrap; gap: 4px; }
.btm-feat { background: var(--accent-soft); color: var(--accent-dark); font-size: 10.5px; padding: 2px 7px; border-radius: 10px; }
.btm-more { font-size: 10px; color: var(--text-muted); font-style: italic; padding: 2px 6px; }

/* Flows */
.brief-flow { margin-bottom: 22px; padding: 14px; background: #fafbfb; border-radius: 8px; border: 1px solid var(--border); }
.brief-flow-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 13px; }
.brief-flow-head .mono { font-size: 10px; color: var(--text-muted); }
.brief-flow-svg { width: 100%; height: auto; max-height: 420px; display: block; }

/* Bouton discussion */
.brief-discuss-btn {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 14px;
  padding: 6px 12px;
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  border-radius: 14px;
  font-size: 11.5px;
  font-family: var(--font-head);
  font-weight: 600;
}
.brief-discuss-btn:hover { background: #e0e7ff; }
.brief-discuss-btn .ic { width: 12px; height: 12px; }

.brief-discuss-reply {
  margin-top: 14px;
  padding: 14px 16px;
  background: #f5f7ff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
}
.bd-reply-head { font-family: var(--font-head); font-weight: 700; color: #4338ca; margin-bottom: 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.bd-reply-head .ic { color: #4338ca; }

@media (max-width: 900px) {
  .brief-view { padding: 12px 10px; }
  .brief-section { padding: 16px 14px; }
  .brief-section-title { font-size: 16px; }
  .brief-header h1 { font-size: 18px; }
  .brief-cover { padding: 28px 16px; }
  .brief-cover-title { font-size: 20px; }
  .brief-tree-mods { grid-template-columns: 1fr; }
}

/* ===================== BRIEF JOB — streaming logs + preview ===================== */
.brief-job { padding: 16px 24px; max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; min-height: calc(100dvh - 180px); }
.brief-job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.brief-job-head h1 { font-family: var(--font-head); font-weight: 800; font-size: 20px; margin: 0; display: inline-flex; align-items: center; gap: 8px; }
.brief-job-head h1 .ic { color: #4338ca; }
.brief-job-actions .btn { font-size: 12px; }

.brief-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 6px 12px;
}
.brief-progress .bjp-bar {
  flex: 1;
  height: 6px;
  background: linear-gradient(90deg, #4338ca, #10b981);
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease;
}
.brief-progress .bjp-label { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); font-weight: 700; }

.brief-job-split {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 12px;
  min-height: 480px;
}
@media (max-width: 900px) { .brief-job-split { grid-template-columns: 1fr; } }

/* Logs en cards (pas terminal dark) */
.brief-logs {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 10px;
  overflow-y: auto;
  max-height: 70vh;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bjl {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfb;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.bjl-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bjl-time { color: var(--text-muted); font-family: var(--font-mono); font-size: 9.5px; margin-left: auto; }
.bjl-body { font-size: 12px; color: var(--text); word-break: break-word; }
.bjl-tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f3f4f6;
  color: var(--text-muted);
  gap: 4px;
}
.bjl-tag.start { background: #eef2ff; color: #4338ca; }
.bjl-tag.prompt { background: #fef3c7; color: #92400e; }
.bjl-tag.tool { background: #dbeafe; color: #1e40af; }
.bjl-tag.done { background: #d1fae5; color: #065f46; }
.bjl-tag.success { background: #10b981; color: #fff; }
.bjl-tag.score { background: #ede9fe; color: #6d28d9; }
.bjl-tag.usage { background: #f3f4f6; color: #4b5563; }
.bjl-tag.error { background: #fee2e2; color: #991b1b; }

.bjl-info { background: var(--surface); }
.bjl-section_start { border-color: #c7d2fe; background: #f5f7ff; }
.bjl-prompt { border-color: #fde68a; background: #fffbeb; }
.bjl-tool { border-color: #bfdbfe; background: #eff6ff; }
.bjl-section_done { border-color: #a7f3d0; background: #f0fdf4; }
.bjl-error { border-color: #fecaca; background: #fef2f2; }
.bjl-score { border-color: #ddd6fe; background: #faf5ff; }
.bjl-done { border-color: #10b981; background: #ecfdf5; }

.bjl-type { color: var(--text-muted); font-size: 10px; font-family: var(--font-mono); }
.bjl-details summary { cursor: pointer; color: #4338ca; font-size: 10.5px; font-family: var(--font-mono); outline: none; }
.bjl-details summary:hover { text-decoration: underline; }
.bjl-details pre { margin: 6px 0 0; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; font-size: 10px; color: var(--text); max-height: 180px; overflow: auto; white-space: pre-wrap; font-family: var(--font-mono); }
.bjl-lvl-success .bjl-body { color: #047857; }
.bjl-lvl-error .bjl-body { color: var(--danger); }
.bjl-lvl-warn .bjl-body { color: #b45309; }

/* Score card — bien visuel */
.bjl-score-card { display: flex; flex-direction: column; gap: 10px; }
.bjl-score-header { display: flex; align-items: center; gap: 12px; }
.bjl-score-big {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 32px;
  line-height: 1;
  color: var(--carbon);
}
.bjl-score-big small { font-size: 14px; color: var(--text-muted); font-weight: 600; }
.bjl-score-reco {
  padding: 6px 12px;
  border-radius: 14px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.bjl-score-reco.valider { background: #d1fae5; color: #065f46; }
.bjl-score-reco.relire { background: #fef3c7; color: #92400e; }
.bjl-score-reco.regenerer { background: #fee2e2; color: #991b1b; }
.bjl-score-bars { display: flex; flex-direction: column; gap: 5px; }
.bjl-score-bar { display: grid; grid-template-columns: 90px 1fr 30px; gap: 8px; align-items: center; font-size: 11px; }
.bjl-score-bar-label { color: var(--text); font-weight: 600; text-transform: capitalize; }
.bjl-score-bar-track { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
.bjl-score-bar-fill { height: 100%; background: linear-gradient(90deg, #4338ca, #10b981); border-radius: 3px; transition: width 0.4s; }
.bjl-score-bar-value { font-family: var(--font-mono); color: var(--text-muted); text-align: right; font-size: 10px; }
.bjl-score-list { font-size: 11.5px; }
.bjl-score-list strong { display: block; margin-bottom: 3px; color: var(--text); font-size: 11px; }
.bjl-score-list.positive strong { color: #047857; }
.bjl-score-list.negative strong { color: #b45309; }
.bjl-score-list ul { margin: 0; padding-left: 18px; color: var(--text); }
.bjl-score-list li { margin-bottom: 2px; }

/* Preview live des sections */
.brief-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bjpv-empty { color: var(--text-muted); font-style: italic; text-align: center; padding: 40px 10px; font-size: 12px; }
.bjpv-section {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fafbfb;
  transition: border-color 0.2s;
}
.bjpv-section.live { border-color: #4338ca; background: #f5f7ff; animation: bjpvPulse 1.5s ease-in-out infinite; }
.bjpv-section.done { border-color: #10b981; background: #f0fdf4; }
.bjpv-section.review { border-color: #7c3aed; background: #faf5ff; }
@keyframes bjpvPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(67,56,202,0.12); } 50% { box-shadow: 0 0 0 3px rgba(67,56,202,0.12); } }
.bjpv-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bjpv-badge { font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; text-transform: uppercase; padding: 2px 7px; border-radius: 3px; letter-spacing: 0.05em; }
.bjpv-badge.live { background: #4338ca; color: #fff; }
.bjpv-badge.done { background: #10b981; color: #fff; }
.bjpv-badge.review { background: #7c3aed; color: #fff; }
.bjpv-title { font-family: var(--font-head); font-weight: 700; font-size: 12px; color: var(--text); }
.bjpv-content { font-size: 12px; color: var(--text); line-height: 1.5; max-height: 200px; overflow-y: auto; padding-right: 4px; }
.bjpv-content pre { font-size: 10.5px; background: #fff; border: 1px solid var(--border); padding: 8px; border-radius: 4px; white-space: pre-wrap; word-break: break-word; }

@media (max-width: 900px) {
  .brief-job { padding: 10px 8px; height: calc(100dvh - 150px); }
  .brief-job-head h1 { font-size: 17px; }
  .brief-logs { font-size: 10.5px; }
  .bjl-tag { font-size: 9px; padding: 1px 5px; }
}

/* Masque scrollbar visuellement (garde fonctionnel) */
.brief-logs, .brief-preview, .bjpv-content {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.brief-logs::-webkit-scrollbar,
.brief-preview::-webkit-scrollbar,
.bjpv-content::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* Mobile — stack les 2 panneaux avec min-width propre */
@media (max-width: 900px) {
  .brief-job { padding: 10px; min-height: auto; }
  .brief-job-split { grid-template-columns: 1fr; min-height: 0; }
  .brief-logs, .brief-preview { max-height: 50vh; }
  .brief-progress { font-size: 10px; }
  .bjl { font-size: 11px; padding: 7px 9px; }
  .bjl-score-big { font-size: 26px; }
  .bjl-score-reco { font-size: 10px; }
  .bjl-score-bar { grid-template-columns: 70px 1fr 28px; }
}

/* Flow intégré dans la preview features */
.bjpv-content .brief-flow-svg {
  width: 100%;
  height: auto;
  max-height: 300px;
  margin: 8px 0;
  display: block;
}
.bjpv-content .embedded-flow {
  margin: 10px 0;
  padding: 10px;
  background: #fafbfb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.bjpv-content .embedded-flow-label {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

/* ===================== BRIEF — sélection de texte + chat WM ===================== */
.brief-sel-float {
  position: absolute;
  z-index: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--carbon);
  color: var(--accent);
  border: none;
  border-radius: 18px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 11.5px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  animation: briefSelFade 0.15s ease-out;
}
.brief-sel-float:hover { background: #000; transform: translateY(-1px); }
.brief-sel-float .ic { width: 12px; height: 12px; color: var(--accent); }
@keyframes briefSelFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Chat conversationnel brief (dans WM window) */
.brief-chat { display: flex; flex-direction: column; height: 100%; }
.bc-quote {
  padding: 10px 14px;
  margin: 10px 14px 0;
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  border-radius: 0 8px 8px 0;
  font-size: 12px;
  color: #78350f;
  font-style: italic;
}
.bc-quote-label { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; color: #b45309; margin-bottom: 4px; font-style: normal; font-weight: 700; }

.bc-msgs {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: none;
}
.bc-msgs::-webkit-scrollbar { display: none; }

.bc-msg { display: flex; gap: 10px; }
.bc-msg.bc-user { flex-direction: row-reverse; }
.bc-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--carbon);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bc-msg.bc-user .bc-avatar { background: var(--accent); color: var(--carbon); }
.bc-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.bc-msg.bc-user .bc-bubble { background: var(--accent-soft); border-color: #a7f3d0; }
.bc-bubble p { margin: 0 0 6px; }
.bc-bubble p:last-child { margin-bottom: 0; }
.bc-bubble code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono); font-size: 11px; }
.bc-bubble pre { background: var(--carbon); color: var(--accent); padding: 10px; border-radius: 6px; margin: 6px 0; font-size: 11px; overflow-x: auto; }
.bc-bubble blockquote { border-left: 3px solid var(--accent); padding: 4px 10px; margin: 6px 0; background: var(--accent-soft); border-radius: 0 6px 6px 0; }
.bc-thinking { color: var(--text-muted); font-style: italic; }
.bc-error { color: var(--danger); font-weight: 600; }

.bc-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
  flex-shrink: 0;
}
.bc-input {
  flex: 1;
  border: 1.5px solid var(--border-card);
  border-radius: 10px;
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  resize: vertical;
  max-height: 150px;
  outline: none;
}
.bc-input:focus { border-color: var(--carbon); box-shadow: 0 0 0 2px rgba(0, 224, 135, 0.18); }
.bc-send {
  all: unset;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--carbon);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.bc-send:hover { background: #000; }
.bc-send:disabled { opacity: 0.5; cursor: wait; }

/* Wrapper chat brief (contient le Mini-Copilot) */
.brief-chat-wrap { display: flex; flex-direction: column; height: 100%; }
.brief-chat-mount { flex: 1 1 0; min-height: 0; display: flex; }
.brief-chat-mount > .mc-root { flex: 1; min-height: 0; }

/* ===================== Fix overflow markdown dans bubbles / segments ===================== */
.mc-bubble, .bc-bubble, .cop-seg-text, .mc-text, .cop-text {
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;
  max-width: 100%;
}
.mc-bubble *, .bc-bubble *, .cop-seg-text *, .mc-text *, .cop-text * {
  max-width: 100%;
  box-sizing: border-box;
}
.mc-bubble pre, .bc-bubble pre, .cop-seg-text pre, .mc-text pre, .cop-text pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
  overflow-x: auto;
}
.mc-bubble h1, .mc-bubble h2, .mc-bubble h3,
.bc-bubble h1, .bc-bubble h2, .bc-bubble h3,
.cop-seg-text h1, .cop-seg-text h2, .cop-seg-text h3 {
  margin: 10px 0 6px;
  font-family: var(--font-head);
  color: var(--text);
  word-break: break-word;
  overflow-wrap: break-word;
}
.mc-bubble h1, .bc-bubble h1, .cop-seg-text h1 { font-size: 15px; }
.mc-bubble h2, .bc-bubble h2, .cop-seg-text h2 { font-size: 14px; }
.mc-bubble h3, .bc-bubble h3, .cop-seg-text h3 { font-size: 13px; }
.mc-bubble ul, .bc-bubble ul, .cop-seg-text ul,
.mc-bubble ol, .bc-bubble ol, .cop-seg-text ol { padding-left: 20px; margin: 6px 0; }
.mc-bubble blockquote, .bc-bubble blockquote, .cop-seg-text blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 10px;
  margin: 6px 0;
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
  font-style: italic;
}

/* Assure que les turns mini gardent la width contenue */
.mc-turn, .cop-turn { max-width: 100%; min-width: 0; overflow: hidden; }
.mc-msg, .cop-msg { max-width: 100%; min-width: 0; }
.cop-segments { max-width: 100%; min-width: 0; overflow: hidden; }

/* Scroll horizontal interdit au niveau container copilot / mini */
.copilot-messages, .mc-msgs { overflow-x: hidden; }

/* ===================== BRIEF — FAB historique + picker conversations ===================== */
[data-tab-pane="brief"] .brief-fab-stack {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
[data-tab-pane="brief"] .canvas-fab { cursor: pointer; }

/* Badge Brief (conversation) */
.conv-badge.brief {
  background: #faf5ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}
.conv-badge.brief .ic { color: #6d28d9; }

/* Picker modal */
.bcp-list {
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 8px;
}
.bcp-empty {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
}
.bcp-empty .ic { color: #c7d2fe; margin-bottom: 8px; display: inline-block; }
.bcp-empty p { font-size: 12.5px; line-height: 1.5; margin: 0; }
.bcp-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface);
  transition: all 0.12s;
}
.bcp-item:hover { border-color: #6d28d9; background: #faf5ff; transform: translateX(2px); }
.bcp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.bcp-date { font-size: 10px; color: var(--text-muted); }
.bcp-title { font-family: var(--font-head); font-weight: 600; font-size: 13px; color: var(--text); line-height: 1.3; }
.bcp-selected {
  margin-top: 6px;
  padding: 6px 10px;
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  border-radius: 0 6px 6px 0;
  font-size: 11.5px;
  font-style: italic;
  color: #78350f;
  line-height: 1.4;
}

/* ===================== BRIEF PATCH — diff card in chat ===================== */
.brief-patch-card .mc-avatar { background: #fef3c7; color: #b45309; }
.brief-patch-body {
  flex: 1 1 0;
  min-width: 0;
  background: var(--surface);
  border: 1.5px solid #fcd34d;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.08);
}
.bpc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.bpc-badge {
  background: #fef3c7; color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bpc-section { font-family: var(--font-head); font-weight: 700; font-size: 12.5px; color: var(--text); }
.bpc-kind { font-size: 10px; color: var(--text-muted); margin-left: auto; }
.bpc-reason {
  font-size: 11.5px;
  font-style: italic;
  color: var(--text-muted);
  padding: 6px 10px;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  border-radius: 0 6px 6px 0;
  margin-bottom: 8px;
}
.bpc-diff { margin: 8px 0; }
.bpc-diff summary { cursor: pointer; font-family: var(--font-mono); font-size: 11px; color: #4338ca; padding: 4px 0; outline: none; }
.bpc-diff summary:hover { text-decoration: underline; }
.bpc-diff-wrap {
  margin-top: 6px;
  padding: 10px;
  background: #fafbfb;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 300px;
  overflow-y: auto;
  font-family: var(--font-mono, Menlo, monospace);
  font-size: 11px;
  line-height: 1.5;
}
.bpc-diff-line { white-space: pre-wrap; word-break: break-word; padding: 1px 4px; border-radius: 2px; }
.bpc-diff-line.add { background: #dcfce7; color: #14532d; }
.bpc-diff-line.del { background: #fee2e2; color: #7f1d1d; text-decoration: line-through; }
.bpc-diff-line.eq { color: var(--text-muted); }

.bpc-actions { display: flex; gap: 6px; justify-content: flex-end; }
.bpc-actions .btn { display: inline-flex; align-items: center; gap: 4px; }
.bpc-actions .btn .ic { width: 12px; height: 12px; }
.bpc-done { color: #047857; font-weight: 700; font-size: 11.5px; display: inline-flex; align-items: center; gap: 4px; }
.bpc-rejected { color: var(--text-muted); font-weight: 600; font-size: 11.5px; display: inline-flex; align-items: center; gap: 4px; }
.brief-patch-card.applied .brief-patch-body { border-color: #10b981; background: #f0fdf4; }
.brief-patch-card.rejected .brief-patch-body { opacity: 0.6; }

/* ===================== MERMAID — schémas rendus en SVG ===================== */
.mermaid-placeholder {
  display: block;
  margin: 14px 0;
  padding: 12px;
  background: #fafbfb;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  text-align: center;
}
.mermaid-placeholder svg { max-width: 100%; height: auto; display: inline-block; }
.mermaid-placeholder.mermaid-rendered { background: #fff; }
.mermaid-fallback, .mermaid-error {
  background: #1f2937;
  color: #d1d5db;
  padding: 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.mermaid-error { background: #7f1d1d; color: #fca5a5; }

/* ===================== Mini-Copilot mic + loading Whisper ===================== */
.mc-mic {
  all: unset;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border-card);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.mc-mic:hover { border-color: var(--carbon); color: var(--text); }
.mc-mic.recording { background: var(--danger); color: #fff; border-color: var(--danger); animation: micPulse 1s infinite; }
.mc-mic.transcribing { background: #eef2ff; border-color: #c7d2fe; cursor: wait; }
.mc-mic .ic { width: 14px; height: 14px; }
.mc-mic-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #c7d2fe;
  border-top-color: #4338ca;
  border-radius: 50%;
  animation: copSpin 0.7s linear infinite;
}

/* ===================== BRIEF — Preview plan dynamique ===================== */
.bjpv-section.plan-preview { border-color: #c7d2fe; background: #f5f7ff; }
.bjpv-section.plan-preview.done { border-color: #10b981; background: #f0fdf4; }
.plan-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 12px;
}
.plan-loader-text {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  max-width: 240px;
  line-height: 1.4;
}

.plan-steps { display: flex; flex-direction: column; gap: 6px; }
.plan-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11.5px;
}
.plan-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #4338ca;
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10px;
  flex-shrink: 0;
}
.plan-step-body { flex: 1; min-width: 0; }
.plan-step-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 12px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  word-break: break-word;
}
.plan-step-title .ic { color: #4338ca; }
.plan-step-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
  font-style: italic;
  word-break: break-word;
}
.plan-step-focus {
  font-size: 10px;
  color: #7c3aed;
  font-family: var(--font-mono);
  margin-top: 3px;
}
.plan-step-type {
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding: 2px 7px;
  border-radius: 10px;
  background: #eef2ff;
  color: #4338ca;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  align-self: flex-start;
}

.plan-fallback-notice {
  padding: 10px 12px;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  border-radius: 0 6px 6px 0;
  font-size: 11.5px;
  color: #78350f;
  font-style: italic;
}
