/* DoIT AI — design system */
:root {
  color-scheme: dark;
  /* Système de surfaces 3 couches : canevas > panneaux > cartes/inputs > survol.
     Un seul accent (bleu aviation) pour tous les éléments interactifs ; le dégradé
     reste réservé au logo. */
  --bg: #0A0E17;
  --bg-panel: #0F1522;
  --bg-surface: #151C2B;
  --bg-panel2: #1C2435;
  --bg-input: #151C2B;
  --border-subtle: #1E2736;
  --border: #2B3647;
  --text: #E7ECF5;
  --text-dim: #9AA7BC;
  --text-faint: #677087;
  --accent: #5B8CFF;
  --accent-hover: #6E9BFF;
  --accent-soft: rgba(91, 140, 255, .14);
  --ok: #36C692;
  --warn: #F3B74E;
  --err: #F05A4F;
  --radius: 12px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; background: var(--bg); }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; overflow: hidden; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 1px var(--accent); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.dp-head .ws-tool-btn { padding: 6px 8px; }
.dp-head .ws-tool-btn svg { width: 15px; height: 15px; display: block; }

#app { display: flex; height: 100vh; height: 100dvh; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 272px; min-width: 272px; background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle); display: flex; flex-direction: column;
  transition: margin-left .22s ease;
}
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(91,140,255,.35); }
.brand-name { font-size: 17.5px; font-weight: 600; letter-spacing: .2px; }
.brand-name b { color: var(--accent); font-weight: 700; }
.vna-strip { display: none; }
#topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-vna { height: 30px; width: auto; border-radius: 6px; box-shadow: 0 1px 6px rgba(0,0,0,.35); flex-shrink: 0; }
.icon-btn { background: none; border: none; color: var(--text-dim); font-size: 15px; padding: 6px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg-panel2); color: var(--text); }

.welcome-cobrand { display: none; }
.welcome h1 {
  font-size: 40px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 14px; color: var(--text);
}
.msg-time { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--text-faint); white-space: nowrap; padding-left: 8px; }
.typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Boutons jumeaux « Nouvelle conversation » / « Documents » : même gabarit, icônes SVG. */
.new-chat, .docs-btn {
  margin: 0 12px 10px; height: 40px; padding: 0 13px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-dim); font-size: 13.5px; font-weight: 500; text-align: left;
  display: flex; align-items: center; gap: 10px;
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}
.new-chat { margin-top: 6px; color: var(--text); font-weight: 600; }
.new-chat svg, .docs-btn svg { width: 16px; height: 16px; flex: none; color: var(--text-faint); transition: color .18s ease; }
.new-chat svg { color: var(--accent); }
.new-chat:hover, .docs-btn:hover { border-color: rgba(91,140,255,.55); background: var(--accent-soft); color: var(--text); }
.new-chat:hover svg, .docs-btn:hover svg { color: var(--accent); }

.sb-section { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px 4px; }
.sb-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); }
.sb-count { font-size: 11px; color: var(--text-faint); }

#conv-list { flex: 1; overflow-y: auto; padding: 2px 8px 12px; }
#ws-zone { display: none; }
.ws-tool-btn {
  background: none; border: 1px solid transparent; color: var(--text-faint); font-size: 12px;
  padding: 3px 6px; border-radius: 6px; transition: all .15s;
}
.ws-tool-btn:hover { color: var(--text); background: var(--bg-panel2); border-color: var(--border); }

/* ---------- bouton Documents (sidebar, jumeau de .new-chat) ---------- */
.docs-btn .badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }

/* ---------- panneau Documents (rail coulissant) ---------- */
#docs-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 94vw;
  background: var(--bg-panel); border-left: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; z-index: 40;
  transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility .25s;
  box-shadow: -16px 0 44px rgba(0,0,0,.38);
}
body.docs-open #docs-panel { transform: none; visibility: visible; }
.dp-head { display: flex; align-items: center; gap: 4px; padding: 16px 14px 10px; }
.dp-title { font-size: 15.5px; font-weight: 700; margin-right: auto; }
.dp-search-wrap { padding: 0 14px 10px; display: flex; gap: 8px; }
.dp-sort {
  flex: none; min-width: 48px; background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 10px; font-size: 11.5px; font-weight: 600; padding: 0 10px;
  transition: border-color .15s, color .15s;
}
.dp-sort:hover { border-color: var(--accent); color: var(--text); }
.dp-search {
  width: 100%; background: var(--bg-surface) url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23677087' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.5' y2='16.5'/%3E%3C/svg%3E") no-repeat 12px center;
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 13px; padding: 9px 12px 9px 34px; transition: border-color .15s, box-shadow .15s;
}
.dp-search:focus { outline: none; border-color: rgba(91,140,255,.55); box-shadow: 0 0 0 3px rgba(91,140,255,.12); }
.dp-breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; padding: 0 14px 10px; }
.dp-breadcrumb .crumb {
  background: none; border: none; color: var(--text-dim); font-size: 12px; padding: 3px 6px;
  border-radius: 6px; font-family: var(--mono); cursor: pointer; max-width: 180px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dp-breadcrumb .crumb:hover { color: var(--text); background: var(--bg-panel2); }
.dp-breadcrumb .crumb:last-child { color: var(--accent); font-weight: 600; }
.dp-list { flex: 1; overflow-y: auto; padding: 0 10px 12px; }
.doc-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 2px 0;
  border-radius: 8px; color: var(--text-dim); cursor: pointer;
  border: 1px solid transparent; user-select: none; min-height: 46px;
  transition: background .15s, border-color .15s;
}
.doc-row:hover { background: var(--bg-panel2); }
.doc-row .doc-ic { font-size: 17px; flex-shrink: 0; width: 24px; text-align: center; }
.doc-row .doc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-row .doc-name { color: var(--text); font-size: 12.5px; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-row .doc-meta { font-size: 11px; color: var(--text-faint); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-group {
  display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: none;
  color: var(--text-faint); font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; padding: 14px 8px 6px; cursor: pointer; text-align: left;
}
.doc-group:first-child { padding-top: 4px; }
.doc-group svg { width: 12px; height: 12px; flex: none; transition: transform .15s; }
.doc-group.closed svg { transform: rotate(-90deg); }
.doc-group:hover { color: var(--text-dim); }
.doc-row .doc-del { opacity: 0; background: none; border: none; color: var(--text-faint); font-size: 12px; padding: 4px 6px; border-radius: 6px; flex-shrink: 0; }
.doc-row:hover .doc-del { opacity: 1; }
.doc-row .doc-del:hover { color: var(--err); }
.doc-row.file.sel { background: var(--accent-soft); border-color: rgba(91,140,255,.4); }
.doc-chk {
  flex-shrink: 0; width: 17px; height: 17px; border: 1px solid var(--border); border-radius: 5px;
  background: none; color: transparent; font-size: 11px; font-weight: 700; padding: 0;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.doc-chk:hover { border-color: var(--accent); }
.doc-chk.part { border-color: var(--accent); color: var(--accent); }
.doc-chk.all { background: var(--accent); border-color: var(--accent); color: #fff; }
.dp-empty { font-size: 12.5px; color: var(--text-faint); padding: 18px 14px; }
.dp-foot { border-top: 1px solid var(--border-subtle); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.dp-selcount { font-size: 12px; color: var(--text-dim); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-add {
  border: none; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
  border-radius: 10px; padding: 9px 16px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.22);
  transition: background .15s, transform .15s;
}
.dp-add:hover { background: var(--accent-hover); transform: translateY(-1px); }
.conv-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 11px; margin: 1px 0;
  border-radius: 8px; font-size: 13.5px; color: var(--text-dim); cursor: pointer;
  border: 1px solid transparent; position: relative;
  transition: background .15s, color .15s;
}
.conv-item:hover { background: var(--bg-panel2); color: var(--text); }
.conv-item.active { background: var(--accent-soft); color: var(--text); }
.conv-item.active::before {
  content: ''; position: absolute; left: 0; top: 9px; bottom: 9px; width: 2px;
  border-radius: 2px; background: var(--accent);
}
.conv-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); padding: 14px 10px 5px; }
.conv-group:first-child { padding-top: 4px; }
.conv-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-del { opacity: 0; background: none; border: none; color: var(--text-faint); font-size: 12px; padding: 2px 5px; border-radius: 5px; }
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--err); background: rgba(239,107,107,.12); }

.sb-foot { border-top: 1px solid var(--border-subtle); padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.sel-wrap { display: flex; flex-direction: column; gap: 6px; font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .7px; font-weight: 600; }
#model-select {
  appearance: none; -webkit-appearance: none;
  background: var(--bg-input) url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239aa1b5' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 32px 9px 12px; font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 500; width: 100%;
  cursor: pointer; transition: border-color .15s;
}
#model-select:hover { border-color: #3a415a; }
#model-select:focus { outline: none; border-color: rgba(91,140,255,.55); box-shadow: 0 0 0 3px rgba(91,140,255,.12); }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 8px; padding: 8px 0; font-size: 12px; font-weight: 600; letter-spacing: .4px;
  transition: all .15s;
}
.seg button:hover { border-color: #3a415a; color: var(--text); }
.seg button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sb-foot-note { margin-top: 10px; font-size: 11px; color: var(--text-faint); line-height: 1.5; }

/* ---------- main ---------- */
#main {
  flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative;
  /* Fond opaque explicite : la colonne de chat ne doit jamais dépendre de la cascade
     du body (extension navigateur / thème forcé clair = texte clair sur fond clair). */
  background: radial-gradient(1100px 380px at 50% -80px, rgba(91,140,255,.09), transparent 65%), var(--bg);
}
#topbar {
  height: 54px; display: flex; align-items: center; gap: 12px; padding: 0 18px;
  border-bottom: 1px solid var(--border-subtle); background: rgba(10,14,23,.82); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
#topbar-title { font-size: 14px; font-weight: 600; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sb-open { display: none; }
#sb-backdrop { display: none; }

#chat-scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
#chat-scroll::-webkit-scrollbar, #conv-list::-webkit-scrollbar, .dp-list::-webkit-scrollbar { width: 6px; }
#chat-scroll::-webkit-scrollbar-thumb, #conv-list::-webkit-scrollbar-thumb, .dp-list::-webkit-scrollbar-thumb { background: #2a3044; border-radius: 5px; }

/* ---------- welcome ---------- */
.welcome { max-width: 720px; margin: 8vh auto 40px; padding: 0 24px; text-align: center; }
.welcome p { color: var(--text-dim); font-size: 15px; line-height: 1.65; margin: 0 auto 34px; max-width: 540px; }

/* ---------- messages ---------- */
#messages { max-width: 780px; margin: 0 auto; padding: 24px 24px 40px; }
.msg { margin-bottom: 26px; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-role { font-size: 11.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.msg.user .msg-role { color: var(--text-faint); }
.msg.assistant .msg-role { color: var(--accent); }
.role-avatar { width: 22px; height: 22px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; }
.msg.user .role-avatar { background: #333a4f; color: var(--text-dim); }
.msg.assistant .role-avatar { background: var(--accent); color: #fff; }
.msg-content { line-height: 1.7; font-size: 15px; }
.msg.user .msg-content {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 17px; white-space: pre-wrap;
}
/* Réponse assistant : pas de bulle, filet accent à gauche (les deux locuteurs se lisent différemment). */
.msg.assistant .msg-content { border-left: 2px solid rgba(91,140,255,.32); padding-left: 14px; min-height: 22px; }

/* markdown */
.msg-content h1, .msg-content h2, .msg-content h3 { margin: 18px 0 8px; line-height: 1.3; }
.msg-content h1 { font-size: 20px; } .msg-content h2 { font-size: 17.5px; } .msg-content h3 { font-size: 15.5px; }
.msg-content p { margin: 8px 0; }
.msg-content ul, .msg-content ol { margin: 8px 0 8px 22px; }
.msg-content li { margin: 4px 0; }
.msg-content a { color: #7da2ff; }
.msg-content strong { color: #fff; }
.msg-content code:not(pre code) { background: #262b3d; padding: 2px 6px; border-radius: 5px; font-family: var(--mono); font-size: 13px; color: #ffb4a0; }
.msg-content table { border-collapse: collapse; margin: 12px 0; width: 100%; font-size: 13.5px; }
.msg-content th, .msg-content td { border: 1px solid var(--border); padding: 8px 11px; text-align: left; }
.msg-content th { background: var(--bg-panel2); font-weight: 600; }
.msg-content tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.code-block { position: relative; margin: 12px 0; }
.code-block pre {
  background: #0b0d13; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.55;
}
.copy-btn {
  position: absolute; top: 8px; right: 8px; background: var(--bg-panel2); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 7px; font-size: 11px; padding: 4px 10px; opacity: 0; transition: opacity .15s;
}
.code-block:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.msg-content blockquote { border-left: 3px solid var(--accent); padding: 2px 0 2px 14px; color: var(--text-dim); margin: 10px 0; }
.msg-content hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* tool chips */
.tool-chip {
  display: flex; align-items: center; gap: 8px; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; margin: 6px 0 14px; font-size: 12.5px; color: var(--text-dim);
}
.tool-chip .tool-icon { color: var(--ok); font-size: 13px; }
.tool-chip b { color: var(--text); font-family: var(--mono); font-size: 12px; }
.tool-chip details { flex: 1; min-width: 0; }
.tool-chip summary { cursor: pointer; color: var(--text-faint); outline: none; user-select: none; }
.tool-chip pre {
  margin-top: 8px; background: #0b0d13; border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  font-family: var(--mono); font-size: 11.5px; overflow-x: auto; max-height: 220px; overflow-y: auto; color: #b7c0d8;
  white-space: pre-wrap; word-break: break-all;
}
.tool-chip.running { border-color: rgba(62,207,142,.4); }
.tool-chip.running .tool-icon::after { content: ''; display: inline-block; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* typing cursor */
.cursor { display: inline-block; width: 8px; height: 16px; background: var(--accent); border-radius: 2px; margin-left: 3px; vertical-align: -2px; animation: pulse .9s infinite; }

/* ---------- composer ---------- */
#composer-zone { padding: 0 24px 18px; max-width: 828px; margin: 0 auto; width: 100%; position: relative; }
#composer-zone::before {
  content: ''; position: absolute; left: 0; right: 0; top: -26px; height: 26px;
  background: linear-gradient(to bottom, rgba(10,14,23,0), var(--bg)); pointer-events: none;
}
#attach-list { margin-bottom: 6px; }
/* Ligne unique compacte : compte + dossier (ou nom du fichier unique), liste complète au survol. */
.attach-line {
  display: inline-flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-dim);
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: 999px; padding: 5px 6px 5px 13px; margin-bottom: 8px;
}
.attach-line .txt {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.attach-line .txt:hover { color: var(--text); }
.attach-line b { color: var(--text); }
.attach-clear {
  margin-left: auto; flex-shrink: 0; border: 1px solid var(--border); background: var(--bg-panel);
  color: var(--text-dim); font-size: 11.5px; border-radius: 999px; padding: 3px 10px;
}
.attach-clear:hover { color: var(--err); border-color: var(--err); }
#composer {
  display: flex; align-items: flex-end; gap: 6px; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
  transition: border-color .15s, box-shadow .15s;
}
#composer:focus-within { border-color: rgba(91,140,255,.55); box-shadow: 0 0 0 3px rgba(91,140,255,.1); }
#input {
  flex: 1; background: none; border: none; outline: none; resize: none; color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.55; max-height: 200px; padding: 6px 4px;
}
#input::placeholder { color: var(--text-dim); opacity: .75; }
.c-btn {
  background: none; border: none; color: var(--text-dim); font-size: 19px; width: 36px; height: 36px;
  border-radius: 10px; flex-shrink: 0;
}
.c-btn:hover { background: var(--bg-panel2); color: var(--text); }
.c-send {
  background: var(--accent); border: none; color: #fff; width: 38px; height: 38px;
  border-radius: 10px; font-size: 15px; flex-shrink: 0; transition: background .15s;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.c-send:hover { background: var(--accent-hover); }
.c-send:disabled { background: #2a3044; color: var(--text-faint); cursor: not-allowed; }
.composer-note { text-align: center; font-size: 11px; color: var(--text-faint); margin-top: 9px; }

/* error banner */
.msg-content .err-banner { background: rgba(239,107,107,.1); border: 1px solid rgba(239,107,107,.35); color: #f3a6a6; border-radius: 10px; padding: 10px 14px; font-size: 13px; }

/* responsive */
@media (max-width: 860px) {
  /* tiroir fermé par défaut dès le premier rendu CSS (pas de flash avant le JS) */
  #sidebar { position: fixed; z-index: 30; height: 100vh; height: 100dvh; box-shadow: 10px 0 40px rgba(0,0,0,.5); margin-left: -272px; }
  #sidebar.open { margin-left: 0; }
  #sb-open { display: block; }
  .welcome h1 { font-size: 26px; }
  #messages { padding: 16px 14px 30px; }
  #composer-zone { padding: 0 12px calc(12px + env(safe-area-inset-bottom)); }
  #topbar { padding-top: env(safe-area-inset-top); }
  /* iOS : focus sur un input < 16px = zoom automatique de la page */
  /* (#app #input pour passer devant le #input de la feuille principale, déclaré plus bas) */
  #app #input { font-size: 16px; }
  /* tableaux des réponses : défilement horizontal au lieu d'écraser les colonnes */
  .msg-content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* fermeture du tiroir : tap sur le fond assombri */
  #sb-backdrop {
    display: none; position: fixed; inset: 0; z-index: 25;
    background: rgba(4,8,16,.55); backdrop-filter: blur(2px);
  }
  #sidebar.open ~ #sb-backdrop { display: block; }
}
/* tactile : pas de survol possible — les actions révélées au hover restent visibles */
@media (hover: none) {
  .msg-actions { opacity: 1; }
  .code-block .copy-btn { opacity: 1; }
  .conv-del { opacity: 1; }
  .doc-row .doc-del { opacity: 1; }
}
/* petits écrans : suggestions empilées pleine largeur (confort de tap), login hors zones système */
@media (max-width: 640px) {
  #suggestions { flex-direction: column; align-items: stretch; }
  #suggestions .sug { text-align: left; }
  .login-screen {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
}

/* ---------- login ---------- */
.login-screen { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: var(--bg-main, #131316); }
.login-card { width: min(360px, 90vw); background: var(--bg-panel, #1b1b20); border: 1px solid var(--border, #2a2a30); border-radius: 16px; padding: 34px 30px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.45); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; }
.login-logo { width: 30px; height: 30px; }
.login-title { font-size: 21px; font-weight: 300; color: var(--text, #ececf1); }
.login-title b { font-weight: 700; }
.login-sub { text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-faint, #8a8a94); margin-bottom: 8px; }
.login-input { background: var(--bg-panel2, #232329); border: 1px solid var(--border, #2a2a30); color: var(--text, #ececf1); border-radius: 10px; padding: 11px 13px; font-size: 14px; outline: none; }
.login-input:focus { border-color: var(--accent, #5B8CFF); }
.login-btn { margin-top: 6px; background: var(--accent, #5B8CFF); color: #fff; border: none; border-radius: 10px; padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer; }
.login-btn:hover { filter: brightness(1.08); }
.login-err { color: var(--err, #ef6b6b); font-size: 12.5px; text-align: center; }
.user-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--border, #2a2a30); border-radius: 10px; background: var(--bg-panel2, #232329); }
.user-name { font-size: 12.5px; color: var(--text-dim, #c7c7d0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn { background: none; border: none; color: var(--text-faint, #8a8a94); font-size: 14px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.logout-btn:hover { color: var(--err, #ef6b6b); background: rgba(239,107,107,.1); }

/* ---------- bouton retour au bas (apparaît quand on a remonté pendant l'écriture) ---------- */
#jump-btn {
  display: none; position: absolute; right: 22px; bottom: 120px;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg-panel2); color: var(--text-dim);
  border: 1px solid var(--border); cursor: pointer; z-index: 6;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
  align-items: center; justify-content: center;
}
#jump-btn.show { display: flex; }
#jump-btn:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 720px) { #jump-btn { right: 12px; bottom: 104px; } }

/* ---------- puces de vérification (contrôle qualité) ---------- */
.tool-chip.verify { opacity: .92; }
.tool-chip.verify .tool-icon { filter: saturate(.7); }
.tool-chip.verify-main { border-color: rgba(62, 207, 142, .45); }
.tool-chip.verify-main.done { border-color: var(--ok); }
.tool-chip.verify-main.done .tool-icon, .tool-chip.verify-main.done b { color: var(--ok); }
.tool-chip.verify-main.fixed { border-color: var(--warn); }
.tool-chip.verify-main.fixed .tool-icon, .tool-chip.verify-main.fixed b { color: var(--warn); }

/* ---------- bloc réflexion (reasoning streamé du modèle) ---------- */
.think-box {
  margin: 2px 0 10px; border-left: 3px solid var(--accent);
  background: var(--bg-panel2); border-radius: 10px; padding: 6px 10px;
}
.think-box summary {
  cursor: pointer; color: var(--text-faint); font-size: 12.5px; font-weight: 600;
  user-select: none; list-style: none; display: inline-block;
}
.think-box summary::-webkit-details-marker { display: none; }
.think-box summary::before { content: '\25B8  '; }
.think-box[open] summary::before { content: '\25BE  '; }
.think-box .think-body {
  white-space: pre-wrap; color: var(--text-dim); font-style: italic;
  font-size: 12.5px; line-height: 1.5; max-height: 200px; overflow-y: auto; margin-top: 6px;
}

/* ---------- ligne de statut agent (indicateur d'activité unique) ---------- */
.agent-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-dim);
  margin: 2px 0 10px; min-height: 16px;
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  padding: 4px 12px; border-radius: 999px; width: fit-content;
  position: relative; overflow: hidden;
}
.agent-status::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 32%, rgba(91,140,255,.09) 50%, transparent 68%);
  transform: translateX(-100%); animation: shimmer 1.8s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.agent-status .spin {
  flex: none; width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--accent); border-top-color: transparent;
  animation: agent-spin .8s linear infinite;
}
@keyframes agent-spin { to { transform: rotate(360deg); } }

/* ---------- interactions type marché : stop, actions message, suggestions ---------- */
.c-send.stop { background: #e5484d; box-shadow: 0 3px 12px rgba(229,72,77,.35); }
.msg-actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions button {
  border: none; background: transparent; color: var(--text-faint); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 5px 7px; border-radius: 7px; transition: all .12s;
}
.msg-actions button:hover { background: var(--bg-panel2); color: var(--text); }
.corrected-note { font-size: 11.5px; color: var(--warn); margin-top: 8px; font-style: italic; }
#suggestions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 28px; }
#suggestions .sug {
  border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-dim);
  border-radius: 12px; padding: 13px 18px; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
}
#suggestions .sug:hover {
  transform: translateY(-2px); border-color: rgba(91,140,255,.55); color: var(--text);
  background: var(--accent-soft); box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.msg { animation: msg-in .18s ease; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.status-elapsed { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.msg-images a { display: block; max-width: 100%; }
.msg-images img { max-width: 100%; max-height: 340px; border-radius: 10px; border: 1px solid var(--border); background: #fff; display: block; }

/* ---- Documents bureautiques générés (rapports PDF/PPTX/XLSX/DOCX) : cartes de téléchargement ---- */
.msg-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.msg-files .file-card {
  display: flex; align-items: center; gap: 10px; min-width: 200px; max-width: 100%;
  padding: 10px 14px 10px 10px; border-radius: 10px; text-decoration: none;
  background: var(--bg-surface); border: 1px solid var(--border);
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
}
.msg-files .file-card:hover { border-color: var(--accent); transform: translateY(-1px); background: var(--bg-panel2); }
.msg-files .file-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; border-radius: 8px; font-size: 10px; font-weight: 700;
  letter-spacing: .04em; color: var(--text); background: var(--accent-soft); border: 1px solid rgba(91, 140, 255, .35);
  font-family: var(--mono);
}
.msg-files .fi-pdf { background: rgba(240, 90, 79, .16); border-color: rgba(240, 90, 79, .4); }
.msg-files .fi-pptx { background: rgba(243, 183, 78, .16); border-color: rgba(243, 183, 78, .4); }
.msg-files .fi-xlsx { background: rgba(54, 198, 146, .16); border-color: rgba(54, 198, 146, .4); }
.msg-files .file-meta { display: flex; flex-direction: column; min-width: 0; }
.msg-files .file-name {
  font-family: var(--mono);
  font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px;
}
.msg-files .file-kind { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

/* ============================================================
   PREMIUM POLISH v2 — ajouté 2026-10-11 (additif : affine la base)
   Réversible : supprimer ce bloc redonne exactement la v1.
   ============================================================ */
:root{
  /* Police : stack système cohérente Mac/Windows. Inter n'était jamais chargée
     (fallback silencieux). 100% local → souverain, rendu identique partout. */
  --font: -apple-system, "SF Pro Text", BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --accent-grad: linear-gradient(135deg, #6E9BFF 0%, #5B8CFF 55%, #6D7CF0 100%);
  --elev-top: inset 0 1px 0 rgba(255,255,255,.05); /* filet de lumière haut */
}

/* Profondeur : surfaces élevées « posées » */
#composer, .msg.user .msg-content, .tool-chip, .agent-status,
.attach-line, .login-card, .code-block pre, .doc-row.file.sel { box-shadow: var(--elev-top); }
#composer:focus-within { box-shadow: var(--elev-top), 0 0 0 3px rgba(91,140,255,.10); }

/* Action primaire : léger dégradé + halo (le reste reste uni) */
.c-send:not(.stop) { background: var(--accent-grad); box-shadow: var(--elev-top), 0 4px 14px rgba(91,140,255,.30); }
.c-send:not(.stop):hover { filter: brightness(1.08); }

/* Logo : halo accent plus présent */
.brand-logo, .login-logo { box-shadow: 0 4px 16px rgba(110,155,255,.42); }

/* Rail conversation active : dégradé accent */
.conv-item.active::before { background: var(--accent-grad); }

/* Welcome : plus aéré, titre net (pas de texte en dégradé = cliché IA) */
.welcome { margin-top: 12vh; }
.welcome h1 { font-size: 42px; letter-spacing: -.6px; color: var(--text); }
.welcome p { font-size: 15.5px; }

/* Tables : arrondies, filets internes fins, en-tête dégradé subtil */
.msg-content table { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.msg-content th, .msg-content td { border: none; border-bottom: 1px solid var(--border-subtle); }
.msg-content th { background: linear-gradient(180deg, #1C2435, #161D2C); letter-spacing: .2px; }
.msg-content tr:last-child td { border-bottom: none; }

/* Code : fond plus profond */
.code-block pre { background: #090B11; }

/* Réponse assistant : un cheveu plus d'air + emphase plus lumineuse */
.msg.assistant .msg-content { padding-left: 16px; border-left-color: rgba(110,155,255,.40); }
.msg-content strong { color: #F2F5FF; }

/* Scrollbars : accent au survol */
#chat-scroll::-webkit-scrollbar-thumb:hover,
#conv-list::-webkit-scrollbar-thumb:hover,
.dp-list::-webkit-scrollbar-thumb:hover { background: #39415A; }

/* Topbar : titre plus présent */
#topbar-title { color: var(--text); font-weight: 600; letter-spacing: .2px; }

/* ============================================================
   TYPO LECTURE v3 — 2026-10-11 : réponses assistant en serif
   style Claude (Tiempos) : lecture longue confortable.
   Stack 100% locale : Charter (macOS) / Georgia (Windows).
   Interface, questions user, code : inchangés (sans/mono).
   Réversible : supprimer ce bloc.
   ============================================================ */
:root { --serif: "Tiempos Text", Charter, "Bitstream Charter", "Iowan Old Style", Georgia, Cambria, "Times New Roman", serif; }
.msg.assistant .msg-content { font-family: var(--serif); font-size: 16px; line-height: 1.66; }
/* Les titres du markdown assistant suivent le serif (comme Claude) */
.msg.assistant .msg-content h1,
.msg.assistant .msg-content h2,
.msg.assistant .msg-content h3 { font-family: var(--serif); letter-spacing: -.1px; }
/* Citations et tableaux assistant : même famille, taille tenue */
.msg.assistant .msg-content blockquote { font-style: italic; color: var(--text-dim); border-left: 2px solid var(--border); padding-left: 12px; margin: 10px 0; }
.msg.assistant .msg-content th,
.msg.assistant .msg-content td { font-family: var(--serif); font-size: 14px; }

/* ============================================================
   COMPOSER v4 — 2026-10-11 : refonte moderne type ChatGPT/Claude.
   Pill 2 niveaux (texte / contrôles), trombone SVG, envoi circulaire
   avec halo + micro-lift. HTML associé restructuré (.c-row).
   Réversible : supprimer ce bloc + revenir au HTML v1.
   ============================================================ */
#composer {
  flex-direction: column; align-items: stretch; gap: 0;
  border-radius: 24px; padding: 13px 13px 10px;
  background: linear-gradient(180deg, var(--bg-panel2), var(--bg-surface));
  transition: border-color .18s, box-shadow .18s;
}
#composer:focus-within {
  border-color: rgba(91,140,255,.6);
  box-shadow: var(--elev-top), 0 0 0 4px rgba(91,140,255,.12), 0 12px 34px rgba(0,0,0,.35);
}
#input { padding: 3px 7px 8px; font-size: 15.5px; }
.c-row { display: flex; align-items: center; gap: 8px; }
.c-row .c-btn { margin-right: auto; }
.c-btn {
  width: 34px; height: 34px; border-radius: 50%; font-size: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); transition: background .15s, color .15s;
}
.c-btn:hover { background: var(--bg-panel2); color: var(--accent); }
.c-send {
  width: 34px; height: 34px; border-radius: 50%;
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.c-send:not(.stop):not(:disabled):hover { transform: translateY(-1px); }
.c-send:disabled { background: var(--bg-panel2); color: var(--text-faint); box-shadow: none; }
.c-send.stop { border-radius: 50%; }
@media (max-width: 860px) { #composer { border-radius: 20px; } }

/* ============================================================
   LOGIN v5 — 2026-10-11 : refonte professionnelle.
   (v7 ci-dessous remplace le décor ambiant par l'avion vu de face)
   ============================================================ */
.login-screen { background: var(--bg); overflow: hidden; }

.login-card {
  position: relative; z-index: 1; width: min(400px, 92vw);
  background: linear-gradient(180deg, var(--bg-panel2), var(--bg-panel));
  border: 1px solid var(--border-subtle); border-radius: 20px;
  padding: 38px 34px 24px; gap: 0;
  box-shadow: var(--elev-top), 0 30px 80px rgba(0,0,0,.55);
  animation: loginIn .4s ease;
}
@keyframes loginIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.login-brand { gap: 12px; margin-bottom: 5px; }
.login-logo { width: 36px; height: 36px; }
.login-title { font-size: 24px; letter-spacing: .3px; }
.login-sub { font-size: 12px; letter-spacing: 1.4px; margin-bottom: 16px; }
.login-label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-faint); margin: 10px 2px 5px;
}
.login-input {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 11px;
  padding: 12px 14px; font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s;
}
.login-input:focus { border-color: rgba(91,140,255,.65); box-shadow: 0 0 0 4px rgba(91,140,255,.12); }
.login-btn {
  margin-top: 16px; padding: 12.5px; border-radius: 11px; font-size: 14.5px; font-weight: 650;
  background: var(--accent-grad);
  box-shadow: var(--elev-top), 0 6px 18px rgba(91,140,255,.30);
  transition: transform .15s, filter .15s;
}
.login-btn:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }
.login-btn:disabled { filter: saturate(.55) brightness(.85); cursor: wait; }
.login-err {
  background: rgba(240,90,79,.10); border: 1px solid rgba(240,90,79,.35);
  border-radius: 10px; padding: 9px 12px; font-size: 12.5px; text-align: center; margin-top: 10px;
}
.login-foot {
  margin-top: 18px; text-align: center; font-size: 10.5px; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text-faint); opacity: .75;
}

/* ============================================================
   LOGO v6 — 2026-10-11 : wordmark officiel DoIT (source OneDrive
   logoDoIT/ForWeb/medium.png, rogné 900×276) sur pastille claire —
   le wordmark est sombre (luma 92), illisible posé sur le fond
   sombre. Sidebar = pastille + suffixe « AI » accent ; login =
   pastille seule. Favicon = variante carrée small.png.
   ============================================================ */
.brand { gap: 9px; }
.brand-logo {
  width: auto; height: 30px; padding: 7px 9px;
  background: #F4F7FD; border-radius: 7px;
  box-shadow: 0 2px 8px rgba(0,0,0,.30);
}
.brand-name { font-size: 16px; }
.login-logo {
  width: auto; height: 46px; padding: 10px 14px;
  background: #F4F7FD; border-radius: 11px;
  box-shadow: 0 3px 12px rgba(0,0,0,.35);
}
.login-brand { margin-bottom: 8px; }

/* ============================================================
   LOGIN v7 — 2026-10-11 : fond « avion vu de face » (line-art).
   La carte = le nez (z-index 1 déjà en v5) ; dérive au-dessus,
   ailes en flèche derrière, nacelles = halos encadrants
   (cx ajustés 430/1010 pour coller à la carte 400 px sur les
   écrans courants), ventre sous la carte. Anneaux radar
   conservés (groupe .lb-radar) avec pulse lent.
   Réversible : supprimer le SVG du HTML + ce bloc.
   ============================================================ */
.login-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; display: block;
}
.lb-radar { animation: radarPulse 7s ease-in-out infinite; }
@keyframes radarPulse { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lb-radar { animation: none; } }
@media (max-width: 640px) { .login-bg { opacity: .55; } }

/* ============================================================
   TRANSCRIPT AGENT — 2026-10-11 : présentation type CLI.
   Blocs d'outils repliables au-dessus de la réponse (chaque
   appel = légende + arguments + résultat résumé, corps
   dépliable), ligne de statut globale avec chrono + tokens,
   section de vérification repliable sous la réponse avec
   verdict (ok / corrigée / indisponible), badges persistants.
   ============================================================ */
.msg-tools { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 10px; }
.tool-block {
  border: 1px solid var(--border-subtle); border-left: 2px solid var(--accent);
  border-radius: 8px; background: var(--bg-surface); overflow: hidden;
}
.tool-block .tb-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  cursor: pointer; user-select: none; min-width: 0;
}
.tool-block .tb-head:hover { background: var(--bg-panel2); }
.tb-ic {
  flex: 0 0 auto; width: 12px; height: 12px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 11px; line-height: 1;
  color: var(--ok);
}
.tool-block.running .tb-ic,
.verify-sec:not(.done) .tb-ic {
  width: 11px; height: 11px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: agent-spin .8s linear infinite;
}
.tb-cap { flex: 0 0 auto; font-size: 12.5px; font-weight: 600; color: var(--text); }
.tb-args {
  flex: 0 1 auto; font-family: var(--mono); font-size: 11px; color: var(--text-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.tb-res {
  flex: 1 1 auto; font-size: 11.5px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right;
}
.tb-chev { flex: 0 0 auto; color: var(--text-faint); font-size: 10px; transition: transform .15s; }
.tool-block.open .tb-chev, .verify-sec.open .tb-chev { transform: rotate(180deg); }
.tb-body { display: none; border-top: 1px solid var(--border-subtle); background: var(--bg); }
.tool-block.open .tb-body { display: block; }
.tb-sec { padding: 8px 10px; }
.tb-sec + .tb-sec { border-top: 1px dashed var(--border-subtle); }
.tb-sec pre {
  margin: 0; font-family: var(--mono); font-size: 11px; line-height: 1.55;
  color: var(--text-dim); white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow: auto;
}

/* ---- section de vérification (post-réponse) ---- */
.verify-sec {
  margin-top: 10px; border: 1px solid var(--border-subtle); border-radius: 10px;
  background: var(--bg-surface); overflow: hidden;
}
.vs-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  cursor: pointer; user-select: none; min-width: 0;
}
.vs-head:hover { background: var(--bg-panel2); }
.vs-label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.vs-meta {
  margin-left: auto; font-size: 11px; color: var(--text-faint);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.vs-tools {
  display: none; padding: 8px; flex-direction: column; gap: 6px;
  border-top: 1px solid var(--border-subtle);
}
.verify-sec.open .vs-tools { display: flex; }
.verify-sec.done .tb-ic { width: auto; height: auto; border: none; animation: none; }
.verify-sec.done.ok { border-color: rgba(54, 198, 146, .35); }
.verify-sec.done.ok .vs-label { color: var(--ok); }
.verify-sec.done.ok .tb-ic::before { content: '✓'; }
.verify-sec.done.fixed { border-color: rgba(243, 183, 78, .4); }
.verify-sec.done.fixed .vs-label { color: var(--warn); }
.verify-sec.done.fixed .tb-ic::before { content: '↻'; }
.verify-sec.done.ko .vs-label { color: var(--text-faint); }
.verify-sec.done.ko .tb-ic::before { content: '—'; color: var(--text-faint); }

/* ---- badges de message (vérifiée / corrigée après contrôle) ---- */
.v-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px;
  font-weight: 600; letter-spacing: .02em; border-radius: 999px;
  padding: 3px 10px; margin-bottom: 10px;
}
.v-badge::before { font-size: 11px; }
.v-badge.ok { color: var(--ok); background: rgba(54, 198, 146, .12); border: 1px solid rgba(54, 198, 146, .3); }
.v-badge.ok::before { content: '✓'; }
.v-badge.fixed { color: var(--warn); background: rgba(243, 183, 78, .12); border: 1px solid rgba(243, 183, 78, .3); }
.v-badge.fixed::before { content: '↻'; }

/* ============================================================
   VERRIERE COCKPIT v8 — 2026-10-11 : UI v2 « instrument panel ».
   Additif réversible (fonts/ + ce bloc). Référence :
   comm_vibecd_claude/deliverables/maquette_ui_vnairline_v2.html
   ============================================================ */

/* ---- Polices self-hostées (IBM Plex Sans variable + Plex Mono) ---- */
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 100 700; font-display: swap; src: url('fonts/PlexSans-400.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 100 700; font-display: swap; src: url('fonts/PlexSans-400-ext.woff2') format('woff2'); unicode-range: U+0100-02AF, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 100 700; font-display: swap; src: url('fonts/PlexSans-400-vn.woff2') format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/PlexMono-400.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/PlexMono-400-ext.woff2') format('woff2'); unicode-range: U+0100-02AF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/PlexMono-400-vn.woff2') format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/PlexMono-500.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/PlexMono-500-ext.woff2') format('woff2'); unicode-range: U+0100-02AF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/PlexMono-500-vn.woff2') format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/PlexMono-600.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/PlexMono-600-ext.woff2') format('woff2'); unicode-range: U+0100-02AF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/PlexMono-600-vn.woff2') format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
:root {
  --font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'IBM Plex Mono', 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  /* sévérités CAS (4 warning → 1 advisory) + cyan données */
  --sev4: #FF5247; --sev3: #F5A623; --sev2: #E8C84A; --sev1: #9AA7BC;
  --cyan: #55D2E6;
}

/* ---- Bandeau d'état cockpit (topbar) ---- */
#topbar { height: 50px; padding: 0 4px 0 18px; font-family: var(--mono); }
#topbar-brand { flex: 1; min-width: 0; }
#topbar-title { font-family: var(--font); font-size: 13.5px; }
#topbar-right { display: flex; align-items: stretch; height: 100%; }
.st-cell {
  display: flex; align-items: center; gap: 7px; padding: 0 16px; height: 100%;
  border-left: 1px solid var(--border-subtle); color: var(--text-dim);
  font-family: var(--mono); font-size: 11.5px; white-space: nowrap;
}
.st-k { color: var(--text-faint); letter-spacing: .08em; }
.st-v { color: var(--text); }
.st-shield { color: var(--ok); font-size: 13px; line-height: 1; }
.st-dot {
  align-self: center; margin: 0 14px 0 6px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 8px var(--ok); flex: none;
}
@media (max-width: 1060px) { .st-cell.c-model, .st-cell.c-user { display: none; } }
@media (max-width: 860px) { #topbar .st-cell { display: none; } .st-dot { margin-right: 12px; } }

/* ---- Layout large : grilles 1200, prose plafonnée ---- */
#messages { max-width: 1200px; }
.msg.user .msg-content { max-width: 760px; }
#composer-zone { max-width: 1200px; }
.msg.assistant .msg-content > p,
.msg.assistant .msg-content > ul,
.msg.assistant .msg-content > ol,
.msg.assistant .msg-content > blockquote,
.msg.assistant .msg-content > h1,
.msg.assistant .msg-content > h2,
.msg.assistant .msg-content > h3 { max-width: 760px; }
.msg.assistant .msg-content .code-block,
.msg.assistant .msg-content .msg-images,
.msg.assistant .msg-content .msg-files { max-width: none; }

/* ---- Grilles premium (passe DOM post-sanitize) ---- */
.msg.assistant .msg-content .grid {
  margin: 16px 0; border: 1px solid var(--border); border-radius: 13px; overflow: hidden;
  background: var(--bg-surface); box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
}
.msg.assistant .msg-content .grid .grid-h {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 11px 16px; background: var(--bg-panel2); border-bottom: 1px solid var(--border-subtle);
  font-size: 12px; color: var(--text-dim);
}
.msg.assistant .msg-content .grid .grid-h .cnt { font-family: var(--mono); color: var(--text-dim); }
.msg.assistant .msg-content .grid .grid-h .cnt b { color: var(--text); font-weight: 600; }
.msg.assistant .msg-content .grid .grid-h .exp { display: flex; gap: 8px; margin-left: auto; }
.exp-btn {
  border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-dim);
  border-radius: 7px; padding: 4px 10px; font-size: 11px; font-family: var(--mono);
  cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.exp-btn:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.msg.assistant .msg-content .grid .gscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.msg.assistant .msg-content .grid table {
  margin: 0; width: 100%; border: none; border-radius: 0; font-size: 12.5px;
}
.msg.assistant .msg-content .grid th,
.msg.assistant .msg-content .grid td {
  font-family: var(--mono) !important; font-size: 12.5px; padding: 8px 12px;
  border: none; border-bottom: 1px solid var(--border-subtle); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.msg.assistant .msg-content .grid th { background: linear-gradient(180deg, #1C2435, #161D2C); color: var(--text); letter-spacing: .02em; }
.msg.assistant .msg-content .grid tr:last-child td { border-bottom: none; }
.msg.assistant .msg-content .grid tr:nth-child(even) td { background: rgba(255, 255, 255, .02); }
.msg.assistant .msg-content .grid th.r, .msg.assistant .msg-content .grid td.r { text-align: right; }
.msg.assistant .msg-content .grid td.dt { white-space: nowrap; color: var(--text-dim); }
/* annonciateurs sévérité CAS */
.ann {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 22px; border-radius: 6px; font-weight: 600;
  font-size: 12px; font-family: var(--mono);
}
.ann.s4 { background: rgba(255, 82, 71, .15); color: var(--sev4); border: 1px solid rgba(255, 82, 71, .5); box-shadow: 0 0 10px rgba(255, 82, 71, .2); }
.ann.s3 { background: rgba(245, 166, 35, .15); color: var(--sev3); border: 1px solid rgba(245, 166, 35, .5); }
.ann.s2 { background: rgba(232, 200, 74, .13); color: var(--sev2); border: 1px solid rgba(232, 200, 74, .4); }
.ann.s1 { background: rgba(154, 167, 188, .12); color: var(--sev1); border: 1px solid rgba(154, 167, 188, .35); }
/* liseré de ligne selon sévérité max */
.msg.assistant .msg-content .grid tr.s4 td:first-child { box-shadow: inset 3px 0 0 var(--sev4); }
.msg.assistant .msg-content .grid tr.s3 td:first-child { box-shadow: inset 3px 0 0 var(--sev3); }
/* micro-barre proximité limite (X / Y) */
.lim { display: flex; align-items: center; gap: 9px; justify-content: flex-end; }
.lim .val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.bar { width: 54px; height: 5px; border-radius: 3px; background: #222c3e; overflow: hidden; position: relative; flex: none; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: linear-gradient(90deg, var(--sev3), var(--sev4)); }
.bar.over i { background: linear-gradient(90deg, var(--sev4), #FF9C94); }
/* n° de vol / immat cliquables */
.msg.assistant .msg-content .grid .flt,
.msg.assistant .msg-content .flt { font-family: var(--mono); color: var(--cyan); cursor: pointer; }
.msg.assistant .msg-content .flt:hover { text-decoration: underline; }
/* légende de grille */
.msg.assistant .msg-content .grid .legend {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  font-size: 11.5px; color: var(--text-faint); padding: 10px 16px;
  background: var(--bg-panel2); border-top: 1px solid var(--border-subtle);
}
.msg.assistant .msg-content .grid .legend .ann { min-width: 22px; height: 18px; font-size: 11px; }

/* ---- Annonciateur de tête (lead WARNING/CAUTION) ---- */
.lead {
  display: flex; gap: 14px; align-items: flex-start;
  background: linear-gradient(180deg, rgba(255, 82, 71, .08), transparent);
  border: 1px solid rgba(255, 82, 71, .3); border-radius: 12px;
  padding: 14px 16px; margin: 0 0 16px; max-width: 860px;
}
.lead.c-caution { background: linear-gradient(180deg, rgba(245, 166, 35, .08), transparent); border-color: rgba(245, 166, 35, .3); }
.lead .cas {
  flex: none; font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--sev4);
  border: 1px solid rgba(255, 82, 71, .5); border-radius: 6px; padding: 4px 8px;
  letter-spacing: .06em; box-shadow: 0 0 12px rgba(255, 82, 71, .25);
}
.lead.c-caution .cas { color: var(--sev3); border-color: rgba(245, 166, 35, .5); box-shadow: 0 0 12px rgba(245, 166, 35, .2); }
.lead p { font-size: 15px; line-height: 1.6; margin: 0; max-width: none !important; }
.lead strong { color: #fff; }

/* ---- Lecture SMS (recommandation sûreté) ---- */
.reco {
  display: flex; gap: 11px; align-items: flex-start; margin-top: 16px;
  max-width: 760px; font-size: 13.5px; color: var(--text-dim); line-height: 1.6;
}
.reco .tag {
  flex: none; font-size: 10px; font-family: var(--mono); letter-spacing: .1em;
  color: var(--cyan); border: 1px solid var(--border); border-radius: 5px;
  padding: 3px 7px; margin-top: 2px;
}
.reco strong { color: var(--text); }

/* ---- Sceau « vérifié sur la base » ---- */
.seal {
  display: inline-flex; align-items: center; gap: 8px; width: fit-content;
  background: linear-gradient(180deg, rgba(54, 198, 146, .16), rgba(54, 198, 146, .08));
  border: 1px solid rgba(54, 198, 146, .42); color: var(--ok);
  border-radius: 999px; padding: 6px 13px; font-size: 12px; font-weight: 600;
  margin: 0 0 12px;
}
.seal svg { width: 14px; height: 14px; flex: none; }
.seal.fixed {
  background: linear-gradient(180deg, rgba(243, 183, 78, .16), rgba(243, 183, 78, .08));
  border-color: rgba(243, 183, 78, .45); color: var(--warn);
}

/* ---- Ligne outil épurée (pas de JSON brut replié) ---- */
.tool-block .tb-args { display: none; }
.tb-ic { color: var(--cyan); }

/* ---- Mobile : grilles et bandeau ---- */
@media (max-width: 860px) {
  /* rétablit l'inset notch (le shorthand padding du bandeau ci-dessus l'écrase) */
  #topbar { padding-top: env(safe-area-inset-top); }
  .msg.assistant .msg-content .grid { margin: 12px 0; border-radius: 10px; }
  .msg.assistant .msg-content .grid th, .msg.assistant .msg-content .grid td { padding: 7px 9px; font-size: 12px; }
  .lead { padding: 11px 12px; gap: 10px; }
  .reco { font-size: 13px; }
}
