/* OpenCoder — feuille de style unique (aucun style en ligne : CSP stricte).
   Couleurs réservées à un rôle : bleu = action principale ; vert, orange, rouge = états. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e6e9ee;
  --border: #d5d9e0;
  --text: #1c2026;
  --muted: #5b6472;
  --accent: #2563d9;
  --accent-text: #ffffff;
  --accent-soft: #e3ecfd;
  --ok: #1a7f43;
  --ok-soft: #e0f3e7;
  --warn: #a45a00;
  --warn-soft: #fbedd7;
  --danger: #c0392b;
  --danger-soft: #fbe4e1;
  --diff-add: #e0f3e7;
  --diff-del: #fbe4e1;
  --code-bg: #f0f2f5;
  --focus: #2563d9;
  --shadow: 0 1px 2px rgba(20, 28, 40, 0.08);
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --fs: 15px;
  --gap: 12px;
  --pad: 12px;
  --row: 34px;
  color-scheme: light;
}

/* Thème sombre : presque noir, étagé (bandeaux, zone centrale, cartes à liseré fin). */
:root[data-theme="dark"] {
  --bg: #0d0d0f;
  --surface: #151517;
  --surface-2: #1d1d20;
  --surface-3: #2a2a2e;
  --border: #2b2b30;
  --text: #ededf0;
  --muted: #9c9ca6;
  --accent: #5b93f5;
  --accent-text: #0e1420;
  --accent-soft: #263652;
  --ok: #5fc27e;
  --ok-soft: #21392a;
  --warn: #e0a04a;
  --warn-soft: #40321c;
  --danger: #f0786c;
  --danger-soft: #472826;
  --diff-add: #21392a;
  --diff-del: #472826;
  --code-bg: #0b0b0d;
  --focus: #7aa9ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0d0d0f;
    --surface: #151517;
    --surface-2: #1d1d20;
    --surface-3: #2a2a2e;
    --border: #2b2b30;
    --text: #ededf0;
    --muted: #9c9ca6;
    --accent: #5b93f5;
    --accent-text: #0e1420;
    --accent-soft: #263652;
    --ok: #5fc27e;
    --ok-soft: #21392a;
    --warn: #e0a04a;
    --warn-soft: #40321c;
    --danger: #f0786c;
    --danger-soft: #472826;
    --diff-add: #21392a;
    --diff-del: #472826;
    --code-bg: #0b0b0d;
    --focus: #7aa9ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-density="compact"] { --gap: 8px; --pad: 8px; --row: 28px; }
:root[data-text="s"] { --fs: 13px; }
:root[data-text="l"] { --fs: 17px; }

* { box-sizing: border-box; }
/* Barres de défilement fines, aux couleurs du thème (sans flèches ni piste claire). */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track, *::-webkit-scrollbar-corner { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }
*::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
html { font-size: var(--fs); }
body {
  /* Symboles (⚠ ✔ ✖) toujours en glyphes de texte, jamais en émojis colorés. */
  font-variant-emoji: text;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 var(--gap); }
h2 { font-size: 1.1rem; margin: var(--gap) 0 calc(var(--gap) / 2); }
h3 { font-size: 1rem; margin: var(--gap) 0 calc(var(--gap) / 2); }
p { margin: 0 0 var(--gap); }
code, pre, kbd { font-family: var(--mono); font-size: 0.92em; }
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
  overflow-x: auto;
  margin: 0 0 var(--gap);
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.inline { display: inline; }
.hidden, [hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Barre du haut */
.topbar {
  display: flex; align-items: center; gap: var(--gap);
  padding: 0 var(--pad); min-height: 44px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
/* Logo à fond transparent, en deux variantes : contour foncé en thème clair, clair en thème sombre. */
.brand-logo { width: 24px; height: 24px; flex: 0 0 auto; }
.logo-sombre { display: none; }
:root[data-theme="dark"] .logo-clair { display: none; }
:root[data-theme="dark"] .logo-sombre { display: block; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .logo-clair { display: none; }
  :root[data-theme="auto"] .logo-sombre { display: block; }
}
.topbar nav { display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap; }
.topbar-end { margin-left: auto; }
.content { max-width: 1100px; margin: 0 auto; padding: calc(var(--pad) * 1.5) var(--pad); }

/* Cartes et mise en page */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: calc(var(--pad) * 1.5);
  box-shadow: var(--shadow); margin-bottom: var(--gap);
}
.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--gap); flex-wrap: wrap; }

/* Formulaires */
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 10px; min-height: var(--row); max-width: 100%;
}
input[type="checkbox"], input[type="radio"] { min-height: 0; padding: 0; }
textarea { min-height: 5rem; resize: vertical; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad); margin: 0; }
legend { font-weight: 600; padding: 0 6px; }
.help { font-weight: 400; color: var(--muted); font-size: 0.9em; }

/* Boutons : 3 tailles (s, défaut, l), 3 rôles (principal, normal, danger) + discret */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  min-height: var(--row); padding: 0 14px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-s { min-height: calc(var(--row) - 8px); padding: 0 8px; font-size: 0.88em; }
.btn-l { min-height: calc(var(--row) + 10px); padding: 0 20px; font-size: 1.05em; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
/* Bouton réduit à une icône monochrome : toujours avec title et aria-label. */
.btn-icon { padding: 0; min-width: calc(var(--row) - 8px); }
.btn-icon + .btn-icon { margin-left: 6px; }
.icon { display: block; }

/* États (toujours avec une icône textuelle en plus de la couleur) */
.notice {
  border: 1px solid var(--border); border-left-width: 4px;
  border-radius: var(--radius); padding: 8px 12px; background: var(--surface-2);
}
.notice::before { font-weight: 700; margin-right: 6px; }
.notice-info { border-left-color: var(--accent); }
.notice-info::before { content: "ℹ"; color: var(--accent); }
.notice-ok { border-left-color: var(--ok); background: var(--ok-soft); }
.notice-ok::before { content: "✔"; color: var(--ok); }
.notice-warn { border-left-color: var(--warn); background: var(--warn-soft); }
.notice-warn::before { content: "⚠"; color: var(--warn); }
.notice-error { border-left-color: var(--danger); background: var(--danger-soft); }
.notice-error::before { content: "✖"; color: var(--danger); }
.badge {
  display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 0.82em;
  background: var(--surface-3); color: var(--text); white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* Tableaux et listes */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.9em; }
.table-wrap { overflow-x: auto; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--gap); flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; color: var(--muted); }
.tabs a[aria-current="page"] { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 600; }

/* Point animé (repris d'OpenClaude) : quatre points qui pulsent en carré. */
.dots { position: relative; width: 14px; height: 14px; flex-shrink: 0; display: inline-block; }
.dots i {
  position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
  animation: dots 1.6s ease-in-out infinite; --dx: 2.5px; --dy: 2.5px;
}
.dots i:nth-child(1) { left: 1px; top: 1px; }
.dots i:nth-child(2) { right: 1px; top: 1px; animation-delay: 0.2s; --dx: -2.5px; }
.dots i:nth-child(3) { right: 1px; bottom: 1px; animation-delay: 0.4s; --dx: -2.5px; --dy: -2.5px; }
.dots i:nth-child(4) { left: 1px; bottom: 1px; animation-delay: 0.6s; --dy: -2.5px; }
@keyframes dots {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 1; }
  25% { transform: translate(var(--dx), var(--dy)) scale(0.6); opacity: 0.45; }
  50% { transform: translate(0, 0) scale(1.15); opacity: 1; }
  75% { transform: translate(-1px, 1px) scale(0.8); opacity: 0.7; }
}
/* Animations réduites demandées par le système : plus de déplacement, un simple fondu, pour que
   « l'agent travaille » reste visible. */
@keyframes dots-fondu { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation-name: dots-fondu; } }

/* Visionneuse et édition de code */
.viewer { max-height: 70vh; overflow: auto; white-space: pre; tab-size: 4; }
.code-edit { font-family: var(--mono); font-size: 0.92em; width: 100%; white-space: pre; tab-size: 4; }

/* Conversation (fil épuré) */
.thread { display: flex; flex-direction: column; gap: var(--gap); margin-bottom: var(--gap); }
.msg { max-width: 900px; }
.msg-author { font-size: 0.85em; color: var(--muted); margin: 0 0 2px; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-note { color: var(--muted); font-size: 0.92em; border-left: 3px solid var(--border); padding-left: 10px; }
.msg-compacted { opacity: 0.7; }
.steps { color: var(--muted); font-size: 0.92em; margin-bottom: 4px; }
.steps > summary, .step > summary { cursor: pointer; }
.step { margin: 4px 0 4px 12px; }
.step pre { max-height: 320px; overflow: auto; white-space: pre-wrap; }
.step-error > summary { color: var(--danger); }
/* « L'agent travaille » : une ligne vivante (activité en cours, chronomètre), puis le texte en direct. */
.working { color: var(--muted); }
.working-line { display: flex; align-items: center; gap: 8px; margin: 0; }
.working-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.timer { font-variant-numeric: tabular-nums; font-size: 0.86em; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.working-live { margin: 4px 0 0 22px; }
.working-live:empty { display: none; }

/* Formulaire en ligne : boutons alignés sur le bas des champs (le libellé est au-dessus du champ). */
form.row { align-items: flex-end; margin-bottom: var(--gap); }

/* Conversation vide : demandes prêtes à envoyer. */
.empty-state { margin: 8vh auto 0; text-align: center; }
.empty-state h2 { font-size: 1.3rem; margin-bottom: 4px; }
.suggestions { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.suggestion {
  font: inherit; cursor: pointer; padding: 8px 14px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px;
}
.suggestion:hover { border-color: var(--accent); }

/* Pièces jointes choisies, avant l'envoi : petites pastilles dans la zone de saisie. */
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; padding: 0; }
.chip { display: flex; align-items: center; gap: 8px; max-width: 220px; padding: 4px 4px 4px 6px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; }
.chip-thumb { width: 36px; height: 36px; border-radius: 6px; flex: 0 0 auto; background: var(--surface-2); }
.chip-kind { flex: 0 0 auto; min-width: 36px; padding: 9px 4px; text-align: center; font-size: 0.68em; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 6px; }
.chip-kind:empty { display: none; }
.chip-text { min-width: 0; display: flex; flex-direction: column; font-size: 0.85em; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.chip-size { color: var(--muted); font-size: 0.9em; }
.chips-alert { margin: 0 0 8px; font-size: 0.88em; color: var(--warn); }
/* Avec le script, « Pièces jointes » ouvre directement le choix des fichiers. */
.js #pieces > label, .js #pieces > #files-names { display: none; }

/* Images de la conversation en grand (carrousel). */
.lightbox { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(0, 0, 0, 0.88); color: #f2f2f4; }
.lightbox[open] { display: flex; flex-direction: column; }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.6); }
.lightbox-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.lightbox-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lightbox .act { color: #f2f2f4; }
.lightbox .act:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.lightbox-stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px 16px; }
/* Damier clair sous l'image : une image transparente aux traits foncés reste lisible. */
.lightbox-stage img {
  max-width: 100%; max-height: 100%; min-width: 0; object-fit: contain; flex: 0 1 auto; margin: 0 auto; border-radius: 6px;
  background: repeating-conic-gradient(#e6e6ea 0% 25%, #fafafc 0% 50%) 0 0 / 16px 16px;
}
.lightbox-nav { flex: 0 0 auto; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: #f2f2f4; background: rgba(255, 255, 255, 0.1); border: 0; border-radius: 50%; }
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-nav[hidden] { display: inline-flex !important; visibility: hidden; }

/* Confirmations discrètes, dans le coin bas droit ; elles s'effacent seules. */
.toasts { position: fixed; right: 16px; bottom: 44px; z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { margin: 0; padding: 8px 14px; color: var(--text); background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); font-size: 0.92em; transition: opacity 0.3s; }
.toast-out { opacity: 0; }

/* Retour en bas du fil, quand on est remonté pendant que l'agent écrit. */
/* Ancré juste au-dessus de la zone de saisie, quelle que soit sa hauteur. */
.to-bottom-holder { position: relative; height: 0; flex: 0 0 0; }
.to-bottom {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 6;
  width: 34px; height: 34px; padding: 0; display: none; align-items: center; justify-content: center; cursor: pointer;
  color: var(--text); background: var(--surface-3); border: 1px solid var(--border); border-radius: 50%; box-shadow: var(--shadow);
}
.js .to-bottom.js-only:not([hidden]) { display: inline-flex; }
.composer { display: flex; flex-direction: column; gap: 8px; max-width: 900px; }
.composer textarea { width: 100%; }
.queue { max-width: 900px; margin-bottom: var(--gap); }
.queued { border: 1px dashed var(--border); border-radius: var(--radius); padding: 8px; margin-bottom: 8px; }
.queued textarea { width: 100%; }
.todo-completed { color: var(--muted); text-decoration: line-through; }

/* Demande d'autorisation dans le fil */
.perm { border-left: 4px solid var(--warn); max-width: 900px; }
.perm-preview { max-height: 360px; overflow: auto; white-space: pre-wrap; }
.perm-actions { align-items: center; }

/* Assistant de création */
.choice { display: block; color: var(--text); }
.choice:hover { border-color: var(--accent); text-decoration: none; }
.narrow-form { max-width: 640px; }
progress { width: 100%; height: 10px; }

/* Revue des changements */
.diff { white-space: pre; overflow-x: auto; padding: 0; }
.diff span { display: block; padding: 0 10px; min-height: 1.4em; }
.diff-add { background: var(--diff-add); }
.diff-del { background: var(--diff-del); }
.diff-hunk { color: var(--muted); background: var(--surface-2); }
.change { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; margin-bottom: 8px; }
.change > summary { cursor: pointer; }
.commands code { min-width: 12rem; }
.js-only { display: none; }
.js .js-only { display: inline-flex; }

/* --- Interface IDE : trois zones, deux poignées verticales, une poignée horizontale --- */
/* Tailles par pas (aucun style en ligne : la CSP l'interdit) ; écrites par le serveur. */
.ew-180 { --explorer: 180px; } .ew-200 { --explorer: 200px; } .ew-220 { --explorer: 220px; } .ew-240 { --explorer: 240px; } .ew-260 { --explorer: 260px; } .ew-280 { --explorer: 280px; } .ew-300 { --explorer: 300px; } .ew-320 { --explorer: 320px; } .ew-340 { --explorer: 340px; } .ew-360 { --explorer: 360px; } .ew-380 { --explorer: 380px; } .ew-400 { --explorer: 400px; } .ew-420 { --explorer: 420px; } .ew-440 { --explorer: 440px; } .ew-460 { --explorer: 460px; } .ew-480 { --explorer: 480px; }
.pw-260 { --panel: 260px; } .pw-280 { --panel: 280px; } .pw-300 { --panel: 300px; } .pw-320 { --panel: 320px; } .pw-340 { --panel: 340px; } .pw-360 { --panel: 360px; } .pw-380 { --panel: 380px; } .pw-400 { --panel: 400px; } .pw-420 { --panel: 420px; } .pw-440 { --panel: 440px; } .pw-460 { --panel: 460px; } .pw-480 { --panel: 480px; } .pw-500 { --panel: 500px; } .pw-520 { --panel: 520px; } .pw-540 { --panel: 540px; } .pw-560 { --panel: 560px; } .pw-580 { --panel: 580px; } .pw-600 { --panel: 600px; } .pw-620 { --panel: 620px; } .pw-640 { --panel: 640px; }
.sh-20 { --split: 20%; } .sh-30 { --split: 30%; } .sh-40 { --split: 40%; } .sh-50 { --split: 50%; } .sh-60 { --split: 60%; } .sh-70 { --split: 70%; } .sh-80 { --split: 80%; }

/* Couleurs du code (Pygments), thème clair puis thème sombre. */
.code .t-c { color: #3D7B7B; font-style: italic } /* Comment */
.code .t-err { border: 1px solid #F00 } /* Error */
.code .t-k { color: #008000; font-weight: bold } /* Keyword */
.code .t-o { color: #666 } /* Operator */
.code .t-ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
.code .t-cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
.code .t-cp { color: #9C6500 } /* Comment.Preproc */
.code .t-cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */
.code .t-c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */
.code .t-cs { color: #3D7B7B; font-style: italic } /* Comment.Special */
.code .t-gd { color: #A00000 } /* Generic.Deleted */
.code .t-ge { font-style: italic } /* Generic.Emph */
.code .t-ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.code .t-gr { color: #E40000 } /* Generic.Error */
.code .t-gh { color: #000080; font-weight: bold } /* Generic.Heading */
.code .t-gi { color: #008400 } /* Generic.Inserted */
.code .t-go { color: #717171 } /* Generic.Output */
.code .t-gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.code .t-gs { font-weight: bold } /* Generic.Strong */
.code .t-gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.code .t-gt { color: #04D } /* Generic.Traceback */
.code .t-kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.code .t-kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.code .t-kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.code .t-kp { color: #008000 } /* Keyword.Pseudo */
.code .t-kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.code .t-kt { color: #B00040 } /* Keyword.Type */
.code .t-m { color: #666 } /* Literal.Number */
.code .t-s { color: #BA2121 } /* Literal.String */
.code .t-na { color: #687822 } /* Name.Attribute */
.code .t-nb { color: #008000 } /* Name.Builtin */
.code .t-nc { color: #00F; font-weight: bold } /* Name.Class */
.code .t-no { color: #800 } /* Name.Constant */
.code .t-nd { color: #A2F } /* Name.Decorator */
.code .t-ni { color: #717171; font-weight: bold } /* Name.Entity */
.code .t-ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
.code .t-nf { color: #00F } /* Name.Function */
.code .t-nl { color: #767600 } /* Name.Label */
.code .t-nn { color: #00F; font-weight: bold } /* Name.Namespace */
.code .t-nt { color: #008000; font-weight: bold } /* Name.Tag */
.code .t-nv { color: #19177C } /* Name.Variable */
.code .t-ow { color: #A2F; font-weight: bold } /* Operator.Word */
.code .t-w { color: #BBB } /* Text.Whitespace */
.code .t-mb { color: #666 } /* Literal.Number.Bin */
.code .t-mf { color: #666 } /* Literal.Number.Float */
.code .t-mh { color: #666 } /* Literal.Number.Hex */
.code .t-mi { color: #666 } /* Literal.Number.Integer */
.code .t-mo { color: #666 } /* Literal.Number.Oct */
.code .t-sa { color: #BA2121 } /* Literal.String.Affix */
.code .t-sb { color: #BA2121 } /* Literal.String.Backtick */
.code .t-sc { color: #BA2121 } /* Literal.String.Char */
.code .t-dl { color: #BA2121 } /* Literal.String.Delimiter */
.code .t-sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.code .t-s2 { color: #BA2121 } /* Literal.String.Double */
.code .t-se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */
.code .t-sh { color: #BA2121 } /* Literal.String.Heredoc */
.code .t-si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */
.code .t-sx { color: #008000 } /* Literal.String.Other */
.code .t-sr { color: #A45A77 } /* Literal.String.Regex */
.code .t-s1 { color: #BA2121 } /* Literal.String.Single */
.code .t-ss { color: #19177C } /* Literal.String.Symbol */
.code .t-bp { color: #008000 } /* Name.Builtin.Pseudo */
.code .t-fm { color: #00F } /* Name.Function.Magic */
.code .t-vc { color: #19177C } /* Name.Variable.Class */
.code .t-vg { color: #19177C } /* Name.Variable.Global */
.code .t-vi { color: #19177C } /* Name.Variable.Instance */
.code .t-vm { color: #19177C } /* Name.Variable.Magic */
.code .t-il { color: #666 } /* Literal.Number.Integer.Long */
:root[data-theme="dark"] .code .t-c { color: #959077 } /* Comment */
:root[data-theme="dark"] .code .t-err { color: #ED007E; background-color: #1E0010 } /* Error */
:root[data-theme="dark"] .code .t-esc { color: #F8F8F2 } /* Escape */
:root[data-theme="dark"] .code .t-g { color: #F8F8F2 } /* Generic */
:root[data-theme="dark"] .code .t-k { color: #66D9EF } /* Keyword */
:root[data-theme="dark"] .code .t-l { color: #AE81FF } /* Literal */
:root[data-theme="dark"] .code .t-n { color: #F8F8F2 } /* Name */
:root[data-theme="dark"] .code .t-o { color: #FF4689 } /* Operator */
:root[data-theme="dark"] .code .t-x { color: #F8F8F2 } /* Other */
:root[data-theme="dark"] .code .t-p { color: #F8F8F2 } /* Punctuation */
:root[data-theme="dark"] .code .t-ch { color: #959077 } /* Comment.Hashbang */
:root[data-theme="dark"] .code .t-cm { color: #959077 } /* Comment.Multiline */
:root[data-theme="dark"] .code .t-cp { color: #959077 } /* Comment.Preproc */
:root[data-theme="dark"] .code .t-cpf { color: #959077 } /* Comment.PreprocFile */
:root[data-theme="dark"] .code .t-c1 { color: #959077 } /* Comment.Single */
:root[data-theme="dark"] .code .t-cs { color: #959077 } /* Comment.Special */
:root[data-theme="dark"] .code .t-gd { color: #FF4689 } /* Generic.Deleted */
:root[data-theme="dark"] .code .t-ge { color: #F8F8F2; font-style: italic } /* Generic.Emph */
:root[data-theme="dark"] .code .t-ges { color: #F8F8F2; font-weight: bold; font-style: italic } /* Generic.EmphStrong */
:root[data-theme="dark"] .code .t-gr { color: #FF4689 } /* Generic.Error */
:root[data-theme="dark"] .code .t-gh { color: #F8F8F2 } /* Generic.Heading */
:root[data-theme="dark"] .code .t-gi { color: #A6E22E } /* Generic.Inserted */
:root[data-theme="dark"] .code .t-go { color: #66D9EF } /* Generic.Output */
:root[data-theme="dark"] .code .t-gp { color: #FF4689; font-weight: bold } /* Generic.Prompt */
:root[data-theme="dark"] .code .t-gs { color: #F8F8F2; font-weight: bold } /* Generic.Strong */
:root[data-theme="dark"] .code .t-gu { color: #959077 } /* Generic.Subheading */
:root[data-theme="dark"] .code .t-gt { color: #66D9EF } /* Generic.Traceback */
:root[data-theme="dark"] .code .t-kc { color: #66D9EF } /* Keyword.Constant */
:root[data-theme="dark"] .code .t-kd { color: #66D9EF } /* Keyword.Declaration */
:root[data-theme="dark"] .code .t-kn { color: #FF4689 } /* Keyword.Namespace */
:root[data-theme="dark"] .code .t-kp { color: #66D9EF } /* Keyword.Pseudo */
:root[data-theme="dark"] .code .t-kr { color: #66D9EF } /* Keyword.Reserved */
:root[data-theme="dark"] .code .t-kt { color: #66D9EF } /* Keyword.Type */
:root[data-theme="dark"] .code .t-ld { color: #E6DB74 } /* Literal.Date */
:root[data-theme="dark"] .code .t-m { color: #AE81FF } /* Literal.Number */
:root[data-theme="dark"] .code .t-s { color: #E6DB74 } /* Literal.String */
:root[data-theme="dark"] .code .t-na { color: #A6E22E } /* Name.Attribute */
:root[data-theme="dark"] .code .t-nb { color: #A6E22E } /* Name.Builtin */
:root[data-theme="dark"] .code .t-nc { color: #A6E22E } /* Name.Class */
:root[data-theme="dark"] .code .t-no { color: #66D9EF } /* Name.Constant */
:root[data-theme="dark"] .code .t-nd { color: #A6E22E } /* Name.Decorator */
:root[data-theme="dark"] .code .t-ni { color: #F8F8F2 } /* Name.Entity */
:root[data-theme="dark"] .code .t-ne { color: #A6E22E } /* Name.Exception */
:root[data-theme="dark"] .code .t-nf { color: #A6E22E } /* Name.Function */
:root[data-theme="dark"] .code .t-nl { color: #F8F8F2 } /* Name.Label */
:root[data-theme="dark"] .code .t-nn { color: #F8F8F2 } /* Name.Namespace */
:root[data-theme="dark"] .code .t-nx { color: #A6E22E } /* Name.Other */
:root[data-theme="dark"] .code .t-py { color: #F8F8F2 } /* Name.Property */
:root[data-theme="dark"] .code .t-nt { color: #FF4689 } /* Name.Tag */
:root[data-theme="dark"] .code .t-nv { color: #F8F8F2 } /* Name.Variable */
:root[data-theme="dark"] .code .t-ow { color: #FF4689 } /* Operator.Word */
:root[data-theme="dark"] .code .t-pm { color: #F8F8F2 } /* Punctuation.Marker */
:root[data-theme="dark"] .code .t-w { color: #F8F8F2 } /* Text.Whitespace */
:root[data-theme="dark"] .code .t-mb { color: #AE81FF } /* Literal.Number.Bin */
:root[data-theme="dark"] .code .t-mf { color: #AE81FF } /* Literal.Number.Float */
:root[data-theme="dark"] .code .t-mh { color: #AE81FF } /* Literal.Number.Hex */
:root[data-theme="dark"] .code .t-mi { color: #AE81FF } /* Literal.Number.Integer */
:root[data-theme="dark"] .code .t-mo { color: #AE81FF } /* Literal.Number.Oct */
:root[data-theme="dark"] .code .t-sa { color: #E6DB74 } /* Literal.String.Affix */
:root[data-theme="dark"] .code .t-sb { color: #E6DB74 } /* Literal.String.Backtick */
:root[data-theme="dark"] .code .t-sc { color: #E6DB74 } /* Literal.String.Char */
:root[data-theme="dark"] .code .t-dl { color: #E6DB74 } /* Literal.String.Delimiter */
:root[data-theme="dark"] .code .t-sd { color: #E6DB74 } /* Literal.String.Doc */
:root[data-theme="dark"] .code .t-s2 { color: #E6DB74 } /* Literal.String.Double */
:root[data-theme="dark"] .code .t-se { color: #AE81FF } /* Literal.String.Escape */
:root[data-theme="dark"] .code .t-sh { color: #E6DB74 } /* Literal.String.Heredoc */
:root[data-theme="dark"] .code .t-si { color: #E6DB74 } /* Literal.String.Interpol */
:root[data-theme="dark"] .code .t-sx { color: #E6DB74 } /* Literal.String.Other */
:root[data-theme="dark"] .code .t-sr { color: #E6DB74 } /* Literal.String.Regex */
:root[data-theme="dark"] .code .t-s1 { color: #E6DB74 } /* Literal.String.Single */
:root[data-theme="dark"] .code .t-ss { color: #E6DB74 } /* Literal.String.Symbol */
:root[data-theme="dark"] .code .t-bp { color: #A6E22E } /* Name.Builtin.Pseudo */
:root[data-theme="dark"] .code .t-fm { color: #A6E22E } /* Name.Function.Magic */
:root[data-theme="dark"] .code .t-vc { color: #F8F8F2 } /* Name.Variable.Class */
:root[data-theme="dark"] .code .t-vg { color: #F8F8F2 } /* Name.Variable.Global */
:root[data-theme="dark"] .code .t-vi { color: #F8F8F2 } /* Name.Variable.Instance */
:root[data-theme="dark"] .code .t-vm { color: #F8F8F2 } /* Name.Variable.Magic */
:root[data-theme="dark"] .code .t-il { color: #AE81FF } /* Literal.Number.Integer.Long */
@media (prefers-color-scheme: dark) {
:root[data-theme="auto"] .code .t-c { color: #959077 } /* Comment */
:root[data-theme="auto"] .code .t-err { color: #ED007E; background-color: #1E0010 } /* Error */
:root[data-theme="auto"] .code .t-esc { color: #F8F8F2 } /* Escape */
:root[data-theme="auto"] .code .t-g { color: #F8F8F2 } /* Generic */
:root[data-theme="auto"] .code .t-k { color: #66D9EF } /* Keyword */
:root[data-theme="auto"] .code .t-l { color: #AE81FF } /* Literal */
:root[data-theme="auto"] .code .t-n { color: #F8F8F2 } /* Name */
:root[data-theme="auto"] .code .t-o { color: #FF4689 } /* Operator */
:root[data-theme="auto"] .code .t-x { color: #F8F8F2 } /* Other */
:root[data-theme="auto"] .code .t-p { color: #F8F8F2 } /* Punctuation */
:root[data-theme="auto"] .code .t-ch { color: #959077 } /* Comment.Hashbang */
:root[data-theme="auto"] .code .t-cm { color: #959077 } /* Comment.Multiline */
:root[data-theme="auto"] .code .t-cp { color: #959077 } /* Comment.Preproc */
:root[data-theme="auto"] .code .t-cpf { color: #959077 } /* Comment.PreprocFile */
:root[data-theme="auto"] .code .t-c1 { color: #959077 } /* Comment.Single */
:root[data-theme="auto"] .code .t-cs { color: #959077 } /* Comment.Special */
:root[data-theme="auto"] .code .t-gd { color: #FF4689 } /* Generic.Deleted */
:root[data-theme="auto"] .code .t-ge { color: #F8F8F2; font-style: italic } /* Generic.Emph */
:root[data-theme="auto"] .code .t-ges { color: #F8F8F2; font-weight: bold; font-style: italic } /* Generic.EmphStrong */
:root[data-theme="auto"] .code .t-gr { color: #FF4689 } /* Generic.Error */
:root[data-theme="auto"] .code .t-gh { color: #F8F8F2 } /* Generic.Heading */
:root[data-theme="auto"] .code .t-gi { color: #A6E22E } /* Generic.Inserted */
:root[data-theme="auto"] .code .t-go { color: #66D9EF } /* Generic.Output */
:root[data-theme="auto"] .code .t-gp { color: #FF4689; font-weight: bold } /* Generic.Prompt */
:root[data-theme="auto"] .code .t-gs { color: #F8F8F2; font-weight: bold } /* Generic.Strong */
:root[data-theme="auto"] .code .t-gu { color: #959077 } /* Generic.Subheading */
:root[data-theme="auto"] .code .t-gt { color: #66D9EF } /* Generic.Traceback */
:root[data-theme="auto"] .code .t-kc { color: #66D9EF } /* Keyword.Constant */
:root[data-theme="auto"] .code .t-kd { color: #66D9EF } /* Keyword.Declaration */
:root[data-theme="auto"] .code .t-kn { color: #FF4689 } /* Keyword.Namespace */
:root[data-theme="auto"] .code .t-kp { color: #66D9EF } /* Keyword.Pseudo */
:root[data-theme="auto"] .code .t-kr { color: #66D9EF } /* Keyword.Reserved */
:root[data-theme="auto"] .code .t-kt { color: #66D9EF } /* Keyword.Type */
:root[data-theme="auto"] .code .t-ld { color: #E6DB74 } /* Literal.Date */
:root[data-theme="auto"] .code .t-m { color: #AE81FF } /* Literal.Number */
:root[data-theme="auto"] .code .t-s { color: #E6DB74 } /* Literal.String */
:root[data-theme="auto"] .code .t-na { color: #A6E22E } /* Name.Attribute */
:root[data-theme="auto"] .code .t-nb { color: #A6E22E } /* Name.Builtin */
:root[data-theme="auto"] .code .t-nc { color: #A6E22E } /* Name.Class */
:root[data-theme="auto"] .code .t-no { color: #66D9EF } /* Name.Constant */
:root[data-theme="auto"] .code .t-nd { color: #A6E22E } /* Name.Decorator */
:root[data-theme="auto"] .code .t-ni { color: #F8F8F2 } /* Name.Entity */
:root[data-theme="auto"] .code .t-ne { color: #A6E22E } /* Name.Exception */
:root[data-theme="auto"] .code .t-nf { color: #A6E22E } /* Name.Function */
:root[data-theme="auto"] .code .t-nl { color: #F8F8F2 } /* Name.Label */
:root[data-theme="auto"] .code .t-nn { color: #F8F8F2 } /* Name.Namespace */
:root[data-theme="auto"] .code .t-nx { color: #A6E22E } /* Name.Other */
:root[data-theme="auto"] .code .t-py { color: #F8F8F2 } /* Name.Property */
:root[data-theme="auto"] .code .t-nt { color: #FF4689 } /* Name.Tag */
:root[data-theme="auto"] .code .t-nv { color: #F8F8F2 } /* Name.Variable */
:root[data-theme="auto"] .code .t-ow { color: #FF4689 } /* Operator.Word */
:root[data-theme="auto"] .code .t-pm { color: #F8F8F2 } /* Punctuation.Marker */
:root[data-theme="auto"] .code .t-w { color: #F8F8F2 } /* Text.Whitespace */
:root[data-theme="auto"] .code .t-mb { color: #AE81FF } /* Literal.Number.Bin */
:root[data-theme="auto"] .code .t-mf { color: #AE81FF } /* Literal.Number.Float */
:root[data-theme="auto"] .code .t-mh { color: #AE81FF } /* Literal.Number.Hex */
:root[data-theme="auto"] .code .t-mi { color: #AE81FF } /* Literal.Number.Integer */
:root[data-theme="auto"] .code .t-mo { color: #AE81FF } /* Literal.Number.Oct */
:root[data-theme="auto"] .code .t-sa { color: #E6DB74 } /* Literal.String.Affix */
:root[data-theme="auto"] .code .t-sb { color: #E6DB74 } /* Literal.String.Backtick */
:root[data-theme="auto"] .code .t-sc { color: #E6DB74 } /* Literal.String.Char */
:root[data-theme="auto"] .code .t-dl { color: #E6DB74 } /* Literal.String.Delimiter */
:root[data-theme="auto"] .code .t-sd { color: #E6DB74 } /* Literal.String.Doc */
:root[data-theme="auto"] .code .t-s2 { color: #E6DB74 } /* Literal.String.Double */
:root[data-theme="auto"] .code .t-se { color: #AE81FF } /* Literal.String.Escape */
:root[data-theme="auto"] .code .t-sh { color: #E6DB74 } /* Literal.String.Heredoc */
:root[data-theme="auto"] .code .t-si { color: #E6DB74 } /* Literal.String.Interpol */
:root[data-theme="auto"] .code .t-sx { color: #E6DB74 } /* Literal.String.Other */
:root[data-theme="auto"] .code .t-sr { color: #E6DB74 } /* Literal.String.Regex */
:root[data-theme="auto"] .code .t-s1 { color: #E6DB74 } /* Literal.String.Single */
:root[data-theme="auto"] .code .t-ss { color: #E6DB74 } /* Literal.String.Symbol */
:root[data-theme="auto"] .code .t-bp { color: #A6E22E } /* Name.Builtin.Pseudo */
:root[data-theme="auto"] .code .t-fm { color: #A6E22E } /* Name.Function.Magic */
:root[data-theme="auto"] .code .t-vc { color: #F8F8F2 } /* Name.Variable.Class */
:root[data-theme="auto"] .code .t-vg { color: #F8F8F2 } /* Name.Variable.Global */
:root[data-theme="auto"] .code .t-vi { color: #F8F8F2 } /* Name.Variable.Instance */
:root[data-theme="auto"] .code .t-vm { color: #F8F8F2 } /* Name.Variable.Magic */
:root[data-theme="auto"] .code .t-il { color: #AE81FF } /* Literal.Number.Integer.Long */
}

/* 100dvh : hauteur réellement visible sur téléphone (la barre du navigateur réduit la fenêtre) ;
   100vh reste pour les navigateurs qui ne connaissent pas l'unité. */
.ide-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.ide-page .topbar { flex: 0 0 auto; }
.ide {
  flex: 1 1 auto; min-height: 0; display: grid;
  grid-template-columns: var(--explorer, 260px) 6px minmax(420px, 1fr) 6px var(--panel, 320px);
  grid-template-areas: "explorer he center hp panel";
}
.ide.e-off { grid-template-columns: 0 0 minmax(420px, 1fr) 6px var(--panel, 320px); }
.ide.p-off { grid-template-columns: var(--explorer, 260px) 6px minmax(420px, 1fr) 0 0; }
.ide.e-off.p-off { grid-template-columns: 0 0 minmax(420px, 1fr) 0 0; }
.ide.e-off #explorer, .ide.e-off .handle-e, .ide.p-off #panel, .ide.p-off .handle-p { display: none; }
#explorer { grid-area: explorer; overflow: auto; background: var(--surface); border-right: 1px solid var(--border); padding: var(--pad); min-width: 0; }
#panel { grid-area: panel; overflow: auto; background: var(--surface); border-left: 1px solid var(--border); padding: var(--pad); min-width: 0; }
#center { grid-area: center; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.handle { background: var(--surface-3); touch-action: none; }
.handle:hover, .handle:focus-visible, .dragging .handle:active { background: var(--accent); }
.handle-e { grid-area: he; cursor: col-resize; }
.handle-p { grid-area: hp; cursor: col-resize; }
.handle-h { flex: 0 0 6px; cursor: row-resize; }
.dragging { user-select: none; }
.ide-tabs { flex: 0 0 auto; margin: 0; padding: 4px var(--pad) 0; background: var(--surface-2); flex-wrap: nowrap; overflow-x: auto; }
.ide-tabs a { white-space: nowrap; }
#viewer { flex: 0 0 var(--split, 50%); min-height: 0; overflow: auto; background: var(--surface); border-bottom: 1px solid var(--border); }
/* Aperçu d'une image : damier discret pour voir la transparence, taille limitée à la zone. */
.viewer-image { margin: 0; padding: 16px; text-align: center; background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 0 0 / 16px 16px; }
.viewer-image img { max-width: 100%; max-height: 60vh; height: auto; }
.viewer-head { position: sticky; top: 0; background: var(--surface-2); padding: 4px var(--pad); border-bottom: 1px solid var(--border); z-index: 1; }
#chat { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
#thread-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--pad); }
/* Contenu lisible jusqu'à 900 px, centré dans la zone. */
#thread-scroll > *, #composer-slot > * { max-width: 900px; margin-left: auto; margin-right: auto; }
#composer-slot { flex: 0 0 auto; padding: 0 var(--pad) var(--pad); border-top: 1px solid var(--border); background: var(--bg); }
.zone-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 6px; }
.zone-head h2 { margin: 0; font-size: 0.95rem; }
.tree { list-style: none; margin: 0; padding: 0; font-size: 0.93em; }
.tree li { padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree a { color: var(--text); }
.tree a[aria-current="true"] { font-weight: 700; color: var(--accent); }
.panel-part { border-bottom: 1px solid var(--border); padding: 6px 0; }
.panel-part > summary { font-weight: 600; cursor: pointer; }

/* Visionneuse : numéros de ligne, ancre « ouvrir à la ligne N » */
.code-table { border-collapse: collapse; font-family: var(--mono); font-size: 0.9em; width: 100%; }
.code-table td { border: 0; padding: 0 8px; vertical-align: top; white-space: pre; }
.code-table .ln { text-align: right; user-select: none; width: 1%; background: var(--surface-2); }
.code-table .ln a { color: var(--muted); }
.code-table tr:target td { background: var(--accent-soft); }
.code-block { position: relative; margin: 0 0 var(--gap); }
.code-block pre { margin: 0; }
.code-block [data-copy-code] { position: absolute; top: 4px; right: 4px; }
.code-lang { position: absolute; top: 4px; left: 10px; font-size: 0.75em; color: var(--muted); }
.code-block .code-lang + [data-copy-code] + pre, .code-block .code-lang ~ pre { padding-top: 24px; }

/* Texte des réponses (Markdown rendu par le serveur) */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote { margin: 0 0 8px; }
.md ul, .md ol { padding-left: 1.4em; }
.md blockquote { border-left: 3px solid var(--border); padding-left: 10px; color: var(--muted); }
.md code { background: var(--code-bg); border-radius: 3px; padding: 0 3px; }
.md pre code { background: none; padding: 0; }
.msg-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* Barre d'état permanente */
.statusbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 2px var(--pad); min-height: 26px; font-size: 0.85em;
  background: var(--surface-2); border-top: 1px solid var(--border); color: var(--muted);
}
.statusbar a { color: inherit; }
/* Pages simples : la barre d'état reste en bas de la fenêtre, même quand le contenu est court. */
body.page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.page .content { flex: 1 0 auto; width: 100%; box-sizing: border-box; }
.page .statusbar { position: sticky; bottom: 0; }
.statusbar-end { margin-left: auto; display: flex; gap: 14px; align-items: center; min-width: 0; }
/* Dernier message : tronqué plutôt que de faire passer la barre sur deux lignes. */
.status-last { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Liste des commandes « / » et palette */
.slash { position: relative; }
#slash-list {
  position: absolute; bottom: 100%; left: 0; right: 0; max-height: 260px; overflow: auto; z-index: 5;
  list-style: none; margin: 0 0 4px; padding: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
#slash-list li { padding: 3px 8px; border-radius: 4px; cursor: pointer; }
#slash-list li[aria-selected="true"] { background: var(--accent-soft); }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: var(--pad); max-width: min(640px, 92vw); width: 100%; }
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
#palette-results a { display: block; padding: 4px 8px; border-radius: 4px; color: var(--text); }
#palette-results a:focus, #palette-results a:hover { background: var(--accent-soft); text-decoration: none; outline: none; }
.composer.dropping { outline: 2px dashed var(--accent); }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-items { position: absolute; right: 0; top: 100%; z-index: 10; min-width: 220px; display: flex; flex-direction: column; gap: 4px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.only-mobile { display: none; }
.perm-more-menu { display: none; }
/* --- Page de conversation : colonnes latérales calmes, fil aéré, saisie en une carte --- */
.ide-page .topbar { min-height: 40px; border-bottom-color: var(--border); background: var(--bg); }
#explorer, #panel { background: var(--bg); padding: 10px 12px; border: 0; }
#center, #composer-slot { background: var(--surface); }
#composer-slot { border-top: 0; padding-top: 4px; }
.handle { background: transparent; border-left: 1px solid var(--border); }
.handle-h { border-left: 0; border-top: 1px solid var(--border); }
.handle:hover, .handle:focus-visible, .dragging .handle:active { background: var(--accent); border-color: var(--accent); }
#thread-scroll { padding: 20px var(--pad) 8px; }
#thread-scroll > *, #composer-slot > * { max-width: 780px; }
.msg, .composer, .queue { max-width: 780px; }

/* Colonne de gauche : conversations puis fichiers */
.side-new { margin: 0 0 6px; }
.side-action { width: 100%; justify-content: flex-start; gap: 8px; font-weight: 500; border-color: transparent; background: transparent; }
.side-action:hover { background: var(--surface-2); }
.side-title { font-size: 0.8rem; font-weight: 600; color: var(--muted); margin: 14px 0 4px; padding: 0 8px; }
.side-list, .tree { list-style: none; margin: 0; padding: 0; }
.side-list li, .tree li { padding: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-list a, .tree a, .tree li > span.muted { display: block; padding: 5px 8px; border-radius: var(--radius); color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.tree li { display: flex; align-items: center; gap: 4px; }
.tree li > a { flex: 1 1 auto; min-width: 0; }
.tree a, .tree li > span.muted, .files-name { display: flex; align-items: center; gap: 6px; }
.tree .icon, .files-name .icon { flex: 0 0 auto; color: var(--muted); }
.side-list a:hover, .tree a:hover { background: var(--surface-2); text-decoration: none; }
.side-list a[aria-current="page"] { background: var(--surface-2); font-weight: 600; }
.side-list a.muted { color: var(--muted); font-size: 0.9em; }
#explorer form[role="search"] { margin: 0 0 6px; }
#explorer input[type="search"] { width: 100%; }
.zone-head.only-mobile-flex { display: none; }

/* Fil : messages de la personne en bulles à droite, réponses en texte libre */
.thread { display: flex; flex-direction: column; gap: 6px; }
.thread .msg { width: 100%; }
.thread .msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.msg-user .bubble {
  max-width: 85%; background: var(--surface-2); border-radius: 16px; padding: 9px 14px;
}
.msg-user .msg-text { margin: 0; }
/* Fichiers d'un message : vignettes d'images et cartes de téléchargement. */
.cards { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 0; padding: 0; }
.msg-user .cards { justify-content: flex-end; }
.card-image { display: block; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: repeating-conic-gradient(#e6e6ea 0% 25%, #fafafc 0% 50%) 0 0 / 12px 12px; }
.card-image img { display: block; width: 140px; height: 104px; object-fit: cover; }
.card-file {
  display: flex; align-items: center; gap: 10px; min-width: 200px; max-width: 320px; padding: 8px 12px;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.card-file:hover { text-decoration: none; border-color: var(--accent); }
.card-kind { flex: 0 0 auto; min-width: 40px; padding: 4px 6px; text-align: center; font-size: 0.72em; font-weight: 700; color: var(--muted); background: var(--surface-3); border-radius: 6px; }
.card-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-size { font-size: 0.8em; color: var(--muted); }
.card-file .icon { flex: 0 0 auto; color: var(--muted); }

/* Pied d'un message : heure et actions. Visible pour le dernier message, au survol ou au focus
   clavier pour les autres ; toujours visible sur un écran tactile (pas de survol). */
.msg-foot { display: flex; align-items: center; gap: 2px; margin-top: 2px; min-height: 26px; opacity: 0; transition: opacity 0.12s; }
.msg:hover > .msg-foot, .msg:focus-within > .msg-foot, .msg-last > .msg-foot, .msg-pinned > .msg-foot { opacity: 1; }
@media (hover: none) { .msg-foot { opacity: 1; } }
/* Réponses : icônes puis heure. Messages de la personne (à droite) : heure puis icônes. */
.msg-time { font-size: 0.78em; color: var(--muted); order: 2; margin-left: 6px; }
.msg-user .msg-time { order: 0; margin: 0 6px 0 0; }
.act {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0;
  color: var(--muted); background: transparent; border: 0; border-radius: 6px; cursor: pointer;
}
.js .act.js-only { display: inline-flex; }
.act:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.act-on, .act[aria-pressed="true"], .act-done { color: var(--text); background: var(--surface-3); }
.msg:target { scroll-margin-top: 12px; }
.msg:target > .md, .msg:target > .bubble { outline: 2px solid var(--accent-soft); outline-offset: 6px; border-radius: 8px; }
.ppins a { white-space: normal; }
.steps { font-size: 0.9em; }
.steps > summary { display: inline-block; padding: 2px 8px; border-radius: var(--radius); }
.steps > summary:hover { background: var(--surface-2); }
.msg-note { border-left: 0; padding: 6px 10px; background: var(--surface-2); border-radius: var(--radius); }
.msg-actions { margin-top: 0; }

/* Saisie : une carte, le texte en haut, les outils dans la barre du bas */
.composer {
  gap: 0; padding: 10px 12px 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.composer:focus-within { border-color: var(--focus); }
.composer textarea {
  background: transparent; border: 0; padding: 4px 2px; min-height: 3.2rem; resize: none; box-shadow: none;
}
.composer textarea:focus-visible { outline: none; }
.composer-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.composer-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
#pieces > summary { list-style: none; gap: 6px; font-weight: 500; color: var(--muted); }
#pieces > summary::-webkit-details-marker { display: none; }
#pieces[open] { flex: 1 1 100%; }
#pieces label { display: block; margin-top: 6px; font-size: 0.9em; }
select.quiet { background: transparent; border-color: transparent; color: var(--muted); max-width: 240px; min-height: calc(var(--row) - 6px); }
select.quiet:hover, select.quiet:focus-visible { border-color: var(--border); color: var(--text); }
.btn-send { min-width: var(--row); padding: 0; border-radius: 50%; }
#composer-wrap > form.inline { display: block; margin-top: 6px; text-align: center; }

/* Colonne de droite : cartes (progression, sorties, conteneur, contexte, réglages) */
#panel-body { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.pcard > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; }
.pcard > summary::-webkit-details-marker { display: none; }
.pcard > summary::before { content: "›"; color: var(--muted); margin-right: 6px; display: inline-block; }
.pcard[open] > summary::before { transform: rotate(90deg); }
.pcard[open] > summary { margin-bottom: 8px; }
.pcard-title { font-weight: 600; flex: 1 1 auto; }
.pcard-meta { font-size: 0.82em; color: var(--muted); white-space: nowrap; }
.pcard p { margin-bottom: 6px; font-size: 0.92em; }
.pcard-foot { font-size: 0.82em; margin-top: 6px; }
.pcard-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 8px 0 0; }
.psteps, .pfiles, .pctx-parts { list-style: none; margin: 0; padding: 0; font-size: 0.9em; }
.pstep { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; }
.pstep-icon { flex: 0 0 16px; display: flex; justify-content: center; padding-top: 2px; }
/* Icônes monochromes : l'état se lit à la forme (coche, triangle, carré), pas à la couleur. */
.pstep-ok .pstep-icon, .pstep-error .pstep-icon { color: var(--text); }
.pstep-stopped .pstep-icon { color: var(--muted); }
.pstep-text { min-width: 0; display: flex; flex-direction: column; }
.pstep-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pstep-detail { font-size: 0.86em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psteps-before > summary { cursor: pointer; color: var(--muted); font-size: 0.86em; margin-bottom: 2px; }
.pfiles li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.pfiles a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pstate-marche { color: var(--ok); }
.pstate-injoignable { color: var(--danger); }
.pctx-head { display: flex; justify-content: space-between; align-items: baseline; }
.pctx-ok { color: var(--ok); }
.pctx-warn { color: var(--warn); }
.pctx-danger { color: var(--danger); }
.pctx-meter { width: 100%; height: 8px; margin: 2px 0 8px; }
.pctx-parts li { display: grid; grid-template-columns: 14px 1fr auto 52px; gap: 6px; align-items: center; padding: 2px 0; }
.pctx-parts li > :last-child, .pctx-parts li > :nth-child(3) { text-align: right; }
.pdot { width: 9px; height: 9px; border-radius: 2px; background: var(--muted); }
.pdot-resume { background: #7b6fd6; }
.pdot-messages { background: #4f86e8; }
.pdot-resultats { background: #e0803c; }
.pdot-appels { background: #2fa97c; }
.pdot-systeme { background: #8a8f98; }
.pdot-projet { background: #b9a179; }
.pdot-consignes { background: #5f6672; }
.pdot-libre { background: var(--surface-3); }
.env-list { list-style: none; margin: 0 0 8px; padding: 0; font-size: 0.93em; }
.env-list li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.env-list li > :last-child { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Code de connexion : six cases (avec JavaScript), champ unique sinon */
.otp { display: flex; gap: 10px; justify-content: space-between; }
.otp-set { border: 0; margin: 0; padding: 0; min-width: 0; }
.otp-set legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.js .otp-set.js-only { display: block; }
.js .nojs-only { display: none; }
.otp input { width: 48px; height: 54px; padding: 0; text-align: center; font-size: 1.4rem; font-weight: 600; border-radius: 10px; }
.btn-block { width: 100%; }
.after-form { margin-top: 14px; }


/* Téléphone : conversation plein écran, explorateur et panneau en tiroirs, en-tête réduit */
@media (max-width: 760px) {
  .ide, .ide.e-off, .ide.p-off, .ide.e-off.p-off { display: block; position: relative; overflow: hidden; }
  #center { height: 100%; }
  .handle { display: none; }
  #explorer, #panel, .ide.e-off #explorer, .ide.p-off #panel {
    display: none; position: absolute; top: 0; bottom: 0; width: min(86vw, 340px); z-index: 20; box-shadow: var(--shadow);
  }
  #explorer { left: 0; }
  #panel { right: 0; }
  .ide.drawer-explorer #explorer, .ide.drawer-panel #panel { display: block; }
  #viewer { flex-basis: 45%; }
  .only-mobile { display: inline-flex; }
  .zone-head.only-mobile-flex { display: flex; }
  .msg-user .bubble { max-width: 92%; }
  .composer-tools > a.btn { display: none; }
  select.quiet { max-width: 170px; }
  .statusbar { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
  .only-desktop { display: none !important; }
  .topbar { gap: 6px; }
  .topbar .crumbs { display: none; }
  .content { padding: var(--pad); }
  /* Demande d'autorisation simplifiée : « Autoriser » en grand, « Toujours » dans un menu. */
  .perm-actions { flex-direction: column; align-items: stretch; }
  .perm-actions .btn { width: 100%; min-height: 44px; }
  .perm-more { display: none; }
  .perm-more-menu { display: block; }
  .perm-more-menu .btn { width: 100%; margin-top: 4px; }
  .row { gap: 8px; }
  input, select, textarea { max-width: 100%; }
  table { display: block; overflow-x: auto; }
}
