/* ============================================================
   aminAi Build — espace de développement (connecteurs + agent)
   Chargé après grok.css.
   ============================================================ */

#build-view {
  height: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  color: var(--text);
}

.app[data-view="build"] .stage { padding-bottom: 0; }
.app[data-view="build"] .task-strip,
.app[data-view="build"] #upgrade-card { display: none !important; }

.bd-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--bg);
}

/* ---------- barre supérieure ---------- */
.bd-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  flex: none;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}

.bd-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.bd-brand .bd-logo {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--inverse);
  color: var(--inverse-text);
  font-size: 13px;
  font-weight: 800;
}

.bd-bar-sep { width: 1px; height: 22px; background: var(--line); flex: none; }

.bd-target-wrap { position: relative; min-width: 0; }

.bd-target {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 340px;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 12.5px;
  border: 1px solid transparent;
}
.bd-target:hover { border-color: var(--line); }
.bd-target strong { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bd-target small { color: var(--muted); font-size: 11px; }
.bd-target .bd-caret { color: var(--muted); font-size: 10px; }

.bd-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.bd-dot.on { background: #4ade80; box-shadow: 0 0 8px rgba(74, 222, 128, 0.55); }
.bd-dot.err { background: var(--danger); }

.bd-bar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.bd-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid transparent;
  white-space: nowrap;
}
.bd-btn:hover { background: var(--bg-hover); color: var(--text); }
.bd-btn.on { background: var(--bg-active); color: var(--text); }
.bd-btn.primary { background: var(--inverse); color: var(--inverse-text); font-weight: 600; }
.bd-btn.primary:hover { background: color-mix(in srgb, var(--inverse) 86%, transparent); color: var(--inverse-text); }
.bd-btn.danger { color: var(--danger); }
.bd-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bd-icon { padding: 7px; }

/* Menus flottants */
.bd-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  max-width: min(440px, 90vw);
  max-height: 70vh;
  overflow: auto;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}
.bd-menu.right { left: auto; right: 0; }
.bd-menu-label { padding: 7px 9px 4px; color: var(--faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; }
.bd-menu button, .bd-menu a {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  border-radius: 8px;
  text-align: left;
  color: var(--text);
  font-size: 12.5px;
  text-decoration: none;
}
.bd-menu button:hover, .bd-menu a:hover { background: var(--bg-hover); }
.bd-menu button .bd-menu-mark {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  background: var(--bg-elev-2); color: var(--muted); font-size: 10px; font-weight: 700; flex: none;
}
.bd-menu button .bd-menu-main { min-width: 0; }
.bd-menu button .bd-menu-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.bd-menu button .bd-menu-main small { display: block; color: var(--muted); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

/* ---------- corps ---------- */
.bd-body {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 382px;
  flex: 1;
  min-height: 0;
}

.bd-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.bd-files { border-right: 1px solid var(--line); }
.bd-chat { border-left: 1px solid var(--line); position: relative; }

.bd-panel-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 8px 0 12px;
  flex: none;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.bd-panel-head .bd-panel-actions { margin-left: auto; display: flex; gap: 2px; }
.bd-panel-head button { padding: 5px 7px; border-radius: 6px; color: var(--muted); font-size: 12px; }
.bd-panel-head button:hover { background: var(--bg-hover); color: var(--text); }

/* Arborescence */
.bd-tree {
  flex: 1;
  overflow: auto;
  padding: 6px 4px 40px;
  font-size: 12.5px;
  user-select: none;
}
.bd-tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 8px 4px 6px;
  border-radius: 6px;
  text-align: left;
  color: var(--text);
  white-space: nowrap;
}
.bd-tree-row:hover { background: var(--bg-hover); }
.bd-tree-row.on { background: var(--bg-active); }
.bd-tree-row .bd-tw { width: 10px; flex: none; color: var(--faint); font-size: 9px; }
.bd-tree-row .bd-ico { width: 14px; flex: none; color: var(--muted); font-size: 11px; text-align: center; }
.bd-tree-row .bd-name { overflow: hidden; text-overflow: ellipsis; }
.bd-tree-row.dir .bd-name { font-weight: 550; }
.bd-tree-row .bd-dirty { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--inverse); flex: none; }

/* ligne d'arborescence avec menu d'actions (style VS Code) */
.bd-tree-line {
  display: flex;
  align-items: center;
  border-radius: 6px;
}
.bd-tree-line:hover { background: var(--bg-hover); }
.bd-tree-line .bd-tree-row { flex: 1; width: auto; min-width: 0; background: transparent; }
.bd-tree-line .bd-tree-row:hover { background: transparent; }
.bd-tree-line .bd-tree-row.on { background: var(--bg-active); }
.bd-tree-more {
  flex: none;
  width: 22px;
  height: 22px;
  margin-right: 3px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s;
}
.bd-tree-line:hover .bd-tree-more,
.bd-tree-more:focus { opacity: 1; }
.bd-tree-more:hover { background: var(--bg-hover); color: var(--text); }
@media (max-width: 920px) {
  .bd-tree-more { opacity: 1; }
}
#bd-tree-menu { min-width: 190px; }
#bd-tree-menu button.danger { color: var(--danger); }

/* dialogues de l'explorateur */
.bd-sheet.small { width: min(460px, 96vw); }
.bd-dialog-form { display: flex; flex-direction: column; }
.bd-dialog-message { margin: 8px 0 6px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.bd-dialog-error { min-height: 0; margin: 5px 0 0; color: var(--danger); font-size: 11px; }
.bd-dialog-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 14px; }
.bd-dialog-actions button { padding: 8px 13px; border-radius: 8px; font-size: 12px; }
.bd-dialog-actions button:hover { background: var(--bg-hover); }
.bd-dialog-actions button.primary { background: var(--inverse); color: var(--inverse-text); font-weight: 600; }
.bd-dialog-actions button.primary:hover { filter: brightness(0.94); }
.bd-dialog-actions button.danger-solid { background: var(--danger); color: #fff; font-weight: 600; }
.bd-dialog-actions button.danger-solid:hover { filter: brightness(1.05); }
.bd-tree-empty { padding: 16px 12px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.bd-tree-empty button { color: var(--text); text-decoration: underline; margin-top: 6px; }

/* Étiquette de panneau (mobile) */
.bd-mobile-panes { display: none; }

/* ---------- éditeur ---------- */
.bd-work { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.bd-tabs {
  display: flex;
  align-items: stretch;
  height: 38px;
  flex: none;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
  background: var(--bg);
}
.bd-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px 0 12px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  max-width: 220px;
}
.bd-tab.on { color: var(--text); background: var(--bg-elev); }
.bd-tab .bd-tab-close { padding: 2px 4px; border-radius: 4px; color: var(--faint); font-size: 12px; }
.bd-tab .bd-tab-close:hover { background: var(--bg-hover); color: var(--text); }
.bd-tab .bd-tab-dirty { width: 6px; height: 6px; border-radius: 50%; background: var(--inverse); }
.bd-tab-empty { display: flex; align-items: center; padding: 0 12px; color: var(--faint); font-size: 12px; }
.bd-tab-special { font-weight: 600; color: var(--muted); }
.bd-tab-special.on { color: var(--text); background: var(--bg-elev); }

.bd-browser {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.bd-browser-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
  flex: none;
}
.bd-browser-bar input {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
}
.bd-browser-bar input:focus { outline: none; border-color: color-mix(in srgb, var(--text) 30%, transparent); }
.bd-browser-bar button,
.bd-browser-bar a {
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 11px;
  text-decoration: none;
  white-space: nowrap;
}
.bd-browser-bar button:hover,
.bd-browser-bar a:hover { background: var(--bg-hover); }
.bd-browser-bar a.disabled { opacity: 0.4; pointer-events: none; }
#bd-browser-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}
.bd-browser-note {
  margin: 0;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 10.5px;
  flex: none;
}

.bd-preview {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: var(--bg);
}
.bd-preview-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
  flex: none;
}
.bd-preview-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font: 11.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bd-preview-head button {
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--inverse);
  color: var(--inverse-text);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.bd-preview-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bd-preview-frame { flex: 1; width: 100%; min-height: 70vh; border: 0; background: #fff; }
.bd-preview-md { max-width: 900px; margin: 0 auto; padding: 20px 24px; color: var(--text); font-size: 13.5px; line-height: 1.65; }
.bd-preview-code {
  margin: 0;
  padding: 14px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bd-preview-image { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.bd-preview-note {
  margin: 0;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 10.5px;
}
.bd-preview-empty { padding: 32px 20px; text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.6; }

/* ---------- aperçu mobile + sélection d'élément ---------- */
.bd-preview-head { flex-wrap: wrap; row-gap: 6px; }
.bd-preview-tools,
.bd-viewport {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 6px;
  background: var(--bg);
}
.bd-preview-tools button,
.bd-viewport button {
  padding: 4px 7px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}
.bd-viewport button { padding: 4px 6px; font-size: 12px; }
.bd-preview-tools button.on,
.bd-viewport button.on { background: var(--bg-elev-2); color: var(--text); }
.bd-pick-toggle {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}
.bd-pick-toggle.on { background: #ffffff; border-color: transparent; color: #000000; font-weight: 700; }

.bd-preview-device {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  overflow: auto;
  background: var(--bg);
}
.bd-preview-device .bd-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  border: 0;
  background: #fff;
}
.bd-preview-device > .bd-preview-md,
.bd-preview-device > .bd-preview-code { width: 100%; }
.bd-preview-device.tablet > .bd-preview-md,
.bd-preview-device.tablet > .bd-preview-code { width: min(768px, 100%); }
.bd-preview-device.mobile > .bd-preview-md,
.bd-preview-device.mobile > .bd-preview-code { width: min(390px, 100%); }
.bd-preview-device > .bd-preview-image { max-width: 100%; height: auto; }
.bd-preview-device.tablet > .bd-preview-image { max-width: 768px; }
.bd-preview-device.mobile > .bd-preview-image { max-width: 390px; }
.bd-preview-device.tablet .bd-preview-frame {
  width: min(768px, 100%);
  flex: none;
}
.bd-preview-device.mobile .bd-preview-frame {
  width: min(390px, 100%);
  height: calc(100% - 24px);
  flex: none;
  margin: 12px 0;
  border: 8px solid #141414;
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
#bd-browser-frame.view-tablet {
  width: min(768px, 100%);
  max-width: 100%;
  margin: 0 auto;
}
#bd-browser-frame.view-mobile {
  width: min(390px, 100%);
  max-width: 100%;
  height: calc(100% - 24px);
  flex: none;
  margin: 12px auto;
  border: 8px solid #141414;
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.bd-pick {
  flex: none;
  max-height: 42%;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 10px 12px;
}
.bd-pick-head { display: flex; align-items: center; gap: 8px; }
.bd-pick-head strong { flex: 1; font-size: 12px; }
.bd-pick-head button { padding: 2px 7px; border-radius: 5px; color: var(--muted); font-size: 16px; }
.bd-pick-head button:hover { background: var(--bg-hover); color: var(--text); }
.bd-pick-ico {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: #ffffff;
  color: #000000;
  font-size: 11px;
  font-weight: 800;
}
.bd-pick-sel {
  margin-top: 6px;
  color: #ffffff;
  font: 11.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}
.bd-pick-meta { margin-top: 2px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.bd-pick-html { margin-top: 6px; color: var(--muted); font-size: 10.5px; }
.bd-pick-html summary { cursor: pointer; }
.bd-pick-html pre {
  margin: 4px 0 0;
  max-height: 120px;
  overflow: auto;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 10.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bd-pick-input {
  width: 100%;
  min-height: 38px;
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  resize: vertical;
}
.bd-pick-input:focus { outline: none; border-color: #ffffff; }
.bd-pick-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 7px; }
.bd-pick-actions button { padding: 6px 10px; border-radius: 7px; color: var(--muted); font-size: 11px; }
.bd-pick-actions button:hover { background: var(--bg-hover); color: var(--text); }
.bd-pick-actions button.primary { background: var(--inverse); color: var(--inverse-text); font-weight: 600; }
.bd-pick-actions button.primary:hover { filter: brightness(0.94); }

.bd-tool-line {
  padding: 4px 10px 6px 30px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font: 10.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bd-tool-line.ok { color: var(--muted); }
.bd-tool-line.err { color: var(--danger); }

.bd-editor-wrap {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  background: var(--bg-elev);
  overflow: hidden;
}
.bd-gutter {
  flex: none;
  width: 46px;
  margin: 0;
  padding: 10px 8px 40px 0;
  overflow: hidden;
  text-align: right;
  color: var(--faint);
  font: 12px/20px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg);
  border-right: 1px solid var(--line);
  user-select: none;
}
.bd-editor {
  flex: 1;
  min-width: 0;
  padding: 10px 16px 40px 12px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  caret-color: var(--text);
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  font: 12.5px/20px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bd-editor-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}
.bd-editor-empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.bd-editor-badge {
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-elev-2);
  color: var(--muted);
  font-size: 10.5px;
  pointer-events: none;
}
.bd-editor-badge.dirty { color: var(--text); background: var(--inverse); color: var(--inverse-text); }

/* Terminal */
.bd-term {
  flex: none;
  height: 190px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: var(--bg);
  min-height: 34px;
}
.bd-term.collapsed { height: 34px; }
.bd-term.collapsed .bd-term-out, .bd-term.collapsed .bd-term-form { display: none; }
.bd-term-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  flex: none;
  padding: 0 8px 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.bd-term-head .bd-term-state { text-transform: none; letter-spacing: 0; color: var(--faint); font-size: 11px; }
.bd-term-head button { margin-left: auto; padding: 4px 7px; color: var(--muted); border-radius: 5px; }
.bd-term-head button:hover { background: var(--bg-hover); color: var(--text); }
.bd-term-out {
  flex: 1;
  margin: 0;
  padding: 8px 12px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font: 11.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bd-term-out .ok { color: var(--ok); }
.bd-term-out .err { color: var(--danger); }
.bd-term-out .cmd { color: var(--text); }
.bd-term-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 0 12px 8px;
}
.bd-term-form span { color: var(--ok); font: 12px ui-monospace, monospace; }
.bd-term-form input {
  flex: 1;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  color: var(--text);
  font: 11.5px ui-monospace, monospace;
  background: transparent;
}
.bd-term-form input::placeholder { color: var(--faint); }

/* ---------- chat agent ---------- */
.bd-chat-head { justify-content: space-between; }
.bd-model-pick {
  max-width: 150px;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--bg-elev-2);
  color: var(--muted);
  font-size: 10.5px;
  text-transform: none;
  letter-spacing: 0;
}
.bd-chat-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.bd-msg { max-width: 100%; font-size: 13px; line-height: 1.55; }
.bd-msg.user { align-self: flex-end; max-width: 92%; padding: 9px 12px; border-radius: 14px 14px 4px 14px; background: var(--bubble); color: var(--text); white-space: pre-wrap; }
.bd-msg.assistant { color: var(--text); }
.bd-msg.assistant .md { font-size: 13px; line-height: 1.6; }
.bd-msg.assistant .md pre { overflow: auto; padding: 10px; border-radius: 8px; background: var(--bg-elev-2); font-size: 11.5px; }
.bd-msg.assistant .md code { font-size: 11.5px; }
.bd-msg-status { color: var(--faint); font-size: 11px; }
.bd-msg-error { padding: 9px 11px; border-radius: 9px; border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); font-size: 12px; }

.bd-tool {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-elev);
  overflow: hidden;
  font-size: 12px;
}
.bd-tool summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
}
.bd-tool summary::-webkit-details-marker { display: none; }
.bd-tool summary .bd-tool-ico { width: 16px; height: 16px; display: grid; place-items: center; border-radius: 5px; background: var(--bg-elev-2); color: var(--muted); font-size: 10px; }
.bd-tool summary .bd-tool-name { font-family: ui-monospace, monospace; font-size: 11.5px; }
.bd-tool summary .bd-tool-arg { color: var(--muted); font-family: ui-monospace, monospace; font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-tool summary .bd-tool-state { margin-left: auto; color: var(--faint); font-size: 10px; }
.bd-tool summary .bd-tool-state.ok { color: var(--ok); }
.bd-tool summary .bd-tool-state.err { color: var(--danger); }
.bd-tool pre { margin: 0; padding: 9px 11px; max-height: 260px; overflow: auto; border-top: 1px solid var(--line); color: var(--muted); white-space: pre-wrap; word-break: break-word; font: 11px/1.5 ui-monospace, monospace; }

.bd-chat-empty { margin: auto; padding: 20px 14px; text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.bd-chat-empty strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 14px; }
.bd-chat-empty .bd-sugg { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.bd-chat-empty .bd-sugg button { padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; }
.bd-chat-empty .bd-sugg button:hover { color: var(--text); border-color: var(--muted); }

.bd-chat-form { flex: none; padding: 10px 10px 12px; border-top: 1px solid var(--line); }
.bd-chat-input-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  padding: 8px 9px 6px;
}
.bd-chat-input-wrap:focus-within { border-color: color-mix(in srgb, var(--text) 30%, transparent); }
.bd-chat-form textarea {
  width: 100%;
  min-height: 40px;
  max-height: 180px;
  padding: 2px 2px 6px;
  resize: none;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  background: transparent;
}
.bd-chat-form textarea::placeholder { color: var(--faint); }
.bd-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 1px 6px;
}
.bd-attachments.hidden { display: none; }
.bd-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev-2);
  color: var(--muted);
  font-size: 10.5px;
}
.bd-attachment.upload {
  border-color: color-mix(in srgb, #7cc4ff 45%, transparent);
  color: #b9dcff;
}
.bd-attachment.ready {
  border-color: color-mix(in srgb, #8dffb2 35%, transparent);
  color: #c8ffdb;
}
.bd-attachment.error {
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
  color: #ff9b93;
}
.bd-att-icon {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--bg-hover);
  color: var(--text);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.bd-att-name {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.bd-att-size { color: var(--faint); font-size: 9.5px; }
.bd-att-remove {
  width: 20px;
  height: 20px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.bd-att-remove:hover { background: var(--bg-hover); color: var(--text); }
.bd-chat-actions { display: flex; align-items: center; gap: 5px; }
.bd-chat-actions .bd-spacer { flex: 1; }
.bd-chat-actions button {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 4%, transparent);
  color: var(--muted);
  font-size: 0;
  line-height: 1;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.16s ease, box-shadow 0.18s ease;
}
.bd-chat-actions button:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: color-mix(in srgb, var(--text) 20%, transparent);
  transform: translateY(-1px);
}
.bd-chat-actions button:active { transform: translateY(0) scale(0.95); }
.bd-chat-actions button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--text) 55%, transparent);
  outline-offset: 2px;
}
.bd-chat-actions button:disabled { opacity: 0.35; cursor: default; transform: none; }
.bd-chat-actions button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.bd-chat-actions button.on {
  background: color-mix(in srgb, var(--text) 10%, transparent);
  border-color: color-mix(in srgb, var(--text) 22%, transparent);
  color: var(--text);
}
.bd-chat-actions button.send {
  background: var(--inverse);
  color: var(--inverse-text);
  border-color: transparent;
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--inverse) 60%, transparent);
}
.bd-chat-actions button.send svg { stroke-width: 2.1; }
.bd-chat-actions button.send:hover {
  background: color-mix(in srgb, var(--inverse) 88%, transparent);
  transform: translateY(-1px);
}
.bd-chat-actions button.send:disabled { opacity: 0.35; cursor: default; transform: none; box-shadow: none; }
.bd-chat-actions button.rec {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
  animation: bdPulse 1.1s infinite;
}
.bd-chat-actions button.stop {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}
.bd-chat-actions button.stop:hover { background: color-mix(in srgb, var(--danger) 28%, transparent); }
#bd-mute .bd-icon-muted { display: none; }
#bd-mute.on .bd-icon-sound { display: none; }
#bd-mute.on .bd-icon-muted { display: block; }
#bd-stop svg rect { fill: currentColor; stroke: none; }
@keyframes bdPulse { 50% { opacity: 0.45; } }
.bd-voice-hint { padding: 0 3px 3px; color: var(--faint); font-size: 10.5px; }

/* ---------- journal des tâches ---------- */
.bd-chat-tabs {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 7px;
  background: var(--bg);
  text-transform: none;
  letter-spacing: 0;
}
.bd-chat-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 10.5px;
}
.bd-chat-tabs button:hover { color: var(--text); }
.bd-chat-tabs button.on { background: var(--bg-elev-2); color: var(--text); }
.bd-jcount {
  min-width: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  color: var(--muted);
  font-size: 9px;
  line-height: 15px;
  text-align: center;
}
.bd-chat-tabs button.on .bd-jcount { background: var(--inverse); color: var(--inverse-text); }

.bd-journal {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bd-journal-empty {
  margin: auto;
  padding: 20px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.bd-journal-empty strong { display: block; margin-bottom: 5px; color: var(--text); font-size: 13.5px; }

.bd-jentry {
  flex: none;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  font-size: 11px;
}
.bd-jentry[data-open="1"] .bd-jout { display: block; }
.bd-jentry.kind-step { border-style: dashed; background: transparent; }
.bd-jhead { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bd-jtime { flex: none; color: var(--faint); font: 9.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.bd-jico { flex: none; width: 14px; text-align: center; color: var(--muted); }
.bd-jtitle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 550; }
.bd-jstate { flex: none; color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; }
.bd-jentry.status-running .bd-jstate { color: #fbbf24; }
.bd-jentry.status-ok .bd-jstate { color: var(--ok); }
.bd-jentry.status-error .bd-jstate { color: var(--danger); }
.bd-jentry.kind-done .bd-jtitle { color: var(--ok); }
.bd-jentry.kind-error .bd-jtitle { color: var(--danger); }
.bd-jentry.kind-request .bd-jtitle { color: var(--text); }
.bd-jdetail {
  margin: 3px 0 0 20px;
  color: var(--muted);
  font: 10.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}
.bd-jout {
  display: none;
  margin: 6px 0 0 20px;
  padding: 6px 8px;
  max-height: 220px;
  overflow: auto;
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 10.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bd-jentry .bd-jhead { cursor: pointer; }

/* ---------- question de l'agent ---------- */
.bd-question {
  flex: none;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, #ffffff 45%, var(--line));
  border-radius: 11px;
  background: color-mix(in srgb, #ffffff 8%, var(--bg-elev));
}
.bd-q-head {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}
.bd-q-ico {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: #ffffff;
  color: #000000;
  font-size: 10px;
  font-weight: 800;
}
.bd-q-text { margin: 7px 0 9px; color: var(--text); font-size: 12.5px; line-height: 1.5; }
.bd-q-options { display: flex; flex-wrap: wrap; gap: 6px; }
.bd-q-option {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 11.5px;
  text-align: left;
}
.bd-q-option:hover { color: var(--text); border-color: var(--muted); }
.bd-q-option.on { background: var(--inverse); color: var(--inverse-text); border-color: transparent; font-weight: 600; }
.bd-q-free {
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  resize: vertical;
}
.bd-q-free:focus { outline: none; border-color: color-mix(in srgb, #ffffff 60%, var(--line)); }
.bd-q-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.bd-q-actions button { padding: 6px 11px; border-radius: 7px; font-size: 11.5px; }
.bd-q-skip { color: var(--muted); }
.bd-q-skip:hover { background: var(--bg-hover); color: var(--text); }
.bd-q-send { background: var(--inverse); color: var(--inverse-text); font-weight: 600; }
.bd-q-send:hover { filter: brightness(0.94); }
.bd-q-note { margin-top: 7px; color: var(--faint); font-size: 10.5px; }
.bd-question[data-state="answered"] { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.bd-question[data-state="answered"] .bd-q-note { color: var(--ok); }
.bd-question[data-state="cancelled"] { opacity: 0.72; }
.bd-question[data-state="cancelled"] .bd-q-note { color: var(--danger); }
.bd-live[data-mode="question"] .bd-live-dot { background: #ffffff; }

.bd-live {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  font-size: 11px;
}
.bd-live-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fbbf24;
  animation: bdPulse 1s infinite;
}
.bd-live[data-mode="error"] .bd-live-dot { background: var(--danger); animation: none; }
.bd-live button {
  margin-left: auto;
  padding: 3px 7px;
  border-radius: 5px;
  color: var(--text);
  font-size: 10.5px;
}
.bd-live button:hover { background: var(--bg-hover); }
.bd-live .bd-live-stop {
  margin-left: auto;
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 42%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  font-weight: 600;
}
.bd-live .bd-live-stop:hover { background: color-mix(in srgb, var(--danger) 24%, transparent); }
.bd-live #bd-live-open { margin-left: 0; }

#toast { z-index: 400; }
.bd-conn-test {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 10px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.bd-conn-test.ok { color: var(--ok); }
.bd-conn-test.err { color: var(--danger); }

/* ---------- bouton d'arrêt global (agent + voix) ---------- */
.global-stop {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 250;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #e07a72;
  color: #fff;
  font-weight: 650;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  animation: bdStopIn 0.18s ease-out;
}
.global-stop:hover { filter: brightness(1.06); }
.global-stop.voice { background: #ffffff; color: #000000; }
.global-stop .gs-square { width: 10px; height: 10px; border-radius: 2px; background: currentColor; }
@keyframes bdStopIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
}
.bd-chat-actions button.stop {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
  color: var(--danger);
}
.bd-chat-actions button.stop:hover { background: color-mix(in srgb, var(--danger) 32%, transparent); }
@media (max-width: 960px) {
  .global-stop { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- état vide / overlay ---------- */
.bd-empty {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 30px;
}
.bd-empty-card {
  max-width: 520px;
  padding: 26px 26px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-elev);
  text-align: center;
}
.bd-empty-card .bd-empty-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 13px;
  background: var(--inverse);
  color: var(--inverse-text);
  font-size: 20px;
  font-weight: 800;
}
.bd-empty-card h2 { margin: 0 0 6px; font-size: 18px; letter-spacing: -0.02em; }
.bd-empty-card p { margin: 0 auto 16px; max-width: 400px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.bd-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.bd-empty-note { margin-top: 14px; color: var(--faint); font-size: 11px; }

.bd-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
}
.bd-sheet {
  width: min(620px, 96vw);
  max-height: 88dvh;
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}
.bd-sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.bd-sheet-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }
.bd-sheet-head button { margin-left: auto; padding: 5px 8px; border-radius: 6px; color: var(--muted); font-size: 16px; }
.bd-sheet-head button:hover { background: var(--bg-hover); color: var(--text); }
.bd-sheet > p.bd-lead { margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.55; }

.bd-tabsrow { display: flex; gap: 4px; margin: 0 0 16px; padding: 3px; border-radius: 9px; background: var(--bg); }
.bd-tabsrow button { flex: 1; padding: 7px 8px; border-radius: 7px; color: var(--muted); font-size: 12px; }
.bd-tabsrow button.on { background: var(--bg-elev-2); color: var(--text); }

.bd-field { display: grid; gap: 5px; margin-bottom: 10px; }
.bd-field label { color: var(--muted); font-size: 11px; }
.bd-field input, .bd-field select, .bd-field textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 12.5px;
}
.bd-field textarea { min-height: 80px; resize: vertical; font-family: ui-monospace, monospace; font-size: 11px; }
.bd-field input:focus, .bd-field select:focus, .bd-field textarea:focus { outline: none; border-color: color-mix(in srgb, var(--text) 32%, transparent); }
.bd-row2 { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }
.bd-form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.bd-card-list { display: grid; gap: 8px; margin-bottom: 14px; }
.bd-conn-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.bd-conn-card .bd-conn-main { min-width: 0; flex: 1; }
.bd-conn-card strong { display: block; font-size: 12.5px; font-weight: 600; }
.bd-conn-card small { display: block; color: var(--muted); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-conn-card .bd-conn-state { flex: none; color: var(--ok); font-size: 10.5px; }
.bd-conn-card .bd-conn-state.err { color: var(--danger); }
.bd-conn-card button { padding: 5px 8px; border-radius: 6px; color: var(--muted); font-size: 11px; }
.bd-conn-card button:hover { background: var(--bg-hover); color: var(--text); }

.bd-note { padding: 9px 11px; border-radius: 8px; background: var(--bg-elev-2); color: var(--muted); font-size: 11px; line-height: 1.55; }
.bd-note a { color: var(--text); }
.bd-note.warn { border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; color: var(--danger); }

.bd-check { display: flex; align-items: center; gap: 7px; margin: 8px 0; color: var(--muted); font-size: 11.5px; }
.bd-check input { width: auto; }

/* ---------- mode vocal ---------- */
.bd-voice-bar {
  position: static;
  align-self: center;
  max-width: calc(100% - 20px);
  margin: 8px 10px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  font-size: 13px;
  color: var(--muted);
}
.bd-voice-bar .bd-orb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--faint);
}
.bd-voice-bar.listen .bd-orb { background: #4ade80; animation: none; }
.bd-voice-bar.think .bd-orb { background: #fbbf24; animation: bdVoiceWave 1.1s ease-in-out infinite; }
.bd-voice-bar.speak .bd-orb { background: #ffffff; animation: bdVoiceWave 0.8s ease-in-out infinite; }
@keyframes bdVoiceWave {
  0%, 100% { transform: scale(0.75); opacity: .55; }
  50% { transform: scale(1.25); opacity: 1; }
}
.bd-voice-bar button { padding: 4px 8px; border-radius: 999px; color: var(--text); font-size: 12.5px; }
.bd-voice-bar button:hover { background: var(--bg-hover); }

/* ---------- mobile ---------- */
@media (max-width: 1180px) {
  .bd-body { grid-template-columns: 208px minmax(0, 1fr) 340px; }
  .bd-target { max-width: 240px; }
}

@media (max-width: 920px) {
  .bd-brand span.bd-brand-text { display: none; }
  .bd-body { display: block; position: relative; }
  .bd-panel { position: absolute; inset: 0; display: none; }
  .bd-body[data-pane="files"] .bd-files,
  .bd-body[data-pane="work"] .bd-work,
  .bd-body[data-pane="chat"] .bd-chat { display: flex; }
  .bd-chat { border-left: 0; }
  .bd-files { border-right: 0; }
  .bd-mobile-panes {
    display: flex;
    flex: none;
    gap: 3px;
    padding: 6px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-elev);
  }
  .bd-mobile-panes button {
    flex: 1;
    padding: 7px 8px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 11.5px;
  }
  .bd-mobile-panes button.on { background: var(--bg-elev-2); color: var(--text); }
  .bd-term { height: 160px; }
  .bd-term.mobile-hidden { display: none; }
  .bd-target small { display: none; }
  .bd-bar { padding: 0 8px; height: 46px; }
  .bd-target { max-width: 180px; padding: 6px 8px; }
  .bd-bar-actions .bd-btn .bd-label { display: none; }
  .bd-tabs { height: 36px; }
  .bd-editor-wrap { padding-bottom: 0; }
}

@media (max-width: 480px) {
  .bd-target strong { max-width: 130px; }
  .bd-empty-card { padding: 20px 16px; }
}

/* ---------- modèle réservé à l'admin ---------- */
#bd-model,
.bd-model-pick { display: none !important; }

/* ---------- bouton vocal : vert pour appeler, rouge pour raccrocher ---------- */
#bd-voice {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  border-radius: 50% !important;
  background: radial-gradient(circle at 32% 26%, #8dffb2 0%, #28d96c 42%, #087a36 100%) !important;
  color: #03170a !important;
  border: 1px solid rgba(72, 255, 140, 0.78) !important;
  box-shadow: 0 0 14px rgba(40, 217, 108, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.42);
}
#bd-voice svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#bd-voice:hover { filter: brightness(1.08); transform: translateY(-1px); }
#bd-voice.on {
  background: radial-gradient(circle at 32% 26%, #ff9a9a 0%, #e53935 45%, #8f0f0f 100%) !important;
  color: #fff !important;
  border-color: rgba(255, 120, 120, 0.88) !important;
  box-shadow: 0 0 16px rgba(229, 57, 53, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}
#bd-mute.on {
  background: rgba(229, 57, 53, 0.16) !important;
  border-color: rgba(229, 57, 53, 0.38) !important;
  color: #ff9b93 !important;
}

/* ---------- terminal Matrix ---------- */
#bd-term {
  background: #020803;
  border-top-color: rgba(51, 255, 102, 0.28);
}
#bd-term-head {
  color: #4dff88;
  border-bottom-color: rgba(51, 255, 102, 0.2);
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
  text-shadow: 0 0 7px rgba(51, 255, 102, 0.35);
}
#bd-term-head .bd-term-state { color: #7dffa8; }
#bd-term-toggle {
  color: #4dff88 !important;
  background: rgba(51, 255, 102, 0.09) !important;
  border: 1px solid rgba(51, 255, 102, 0.4);
  border-radius: 6px;
  padding: 3px 8px !important;
  opacity: 1 !important;
  text-shadow: 0 0 8px rgba(51, 255, 102, 0.5);
}
#bd-term-toggle:hover {
  background: rgba(51, 255, 102, 0.2) !important;
  color: #c8ffdb !important;
}
#bd-term-out {
  color: #5dff92;
  background: #020803;
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
  text-shadow: 0 0 6px rgba(51, 255, 102, 0.22);
}
#bd-term-out .ok { color: #8dffb2; }
#bd-term-out .err { color: #ff6b6b; }
#bd-term-out .cmd { color: #c8ffdb; }
#bd-term-form span { color: #4dff88; text-shadow: 0 0 6px rgba(51, 255, 102, 0.4); }
#bd-term-form input {
  color: #8dffb2;
  border-top-color: rgba(51, 255, 102, 0.18);
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
}
#bd-term-form input::placeholder { color: rgba(141, 255, 178, 0.32); }

/* ---------- dossier local ---------- */
.bd-conn-card .bd-btn,
.bd-sheet .bd-btn { display: inline-flex; width: auto; margin-top: 8px; }
.bd-lead + .bd-btn { align-self: flex-start; }

/* ============================================================
   Scène Build Web : orbe solaire, étoiles, journal de l'agent
   ============================================================ */
.bd-scene {
  --scene-size: clamp(220px, 38vh, 340px);
  --scene-accent: rgba(165, 205, 255, 0.55);
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(62% 56% at 50% 38%, rgba(55, 95, 180, 0.13), transparent 72%),
    #050510;
}
.bd-scene.hidden { display: none; }
.bd-scene-stars {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.bd-scene-stars span {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: bd-scene-star var(--d, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.bd-scene-orb {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
}
.bd-scene-core {
  position: relative;
  width: var(--scene-size);
  height: var(--scene-size);
  border-radius: 50%;
}
.bd-scene-sun {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: calc(var(--scene-size) * 0.26);
  height: calc(var(--scene-size) * 0.26);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, rgba(255, 251, 224, 0.96) 0%, rgba(255, 228, 138, 0.92) 18%, rgba(255, 194, 71, 0.86) 38%, rgba(255, 154, 31, 0.74) 62%, rgba(227, 90, 5, 0.58) 84%, rgba(90, 25, 0, 0.38) 100%);
  box-shadow:
    0 0 14px rgba(255, 214, 120, 0.42),
    0 0 34px var(--scene-accent),
    0 0 64px rgba(255, 170, 90, 0.18),
    inset 0 0 14px rgba(255, 255, 255, 0.34),
    inset -6px -8px 20px rgba(105, 25, 0, 0.30);
  animation: bd-scene-sun-float 2.4s ease-in-out infinite;
}
.bd-scene-sun::after {
  content: "";
  position: absolute;
  inset: -5%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 10%, rgba(255, 255, 255, 0.30) 18%, transparent 30% 46%, rgba(255, 140, 0, 0.30) 56%, transparent 68% 82%, rgba(255, 255, 255, 0.16) 90%, transparent 100%);
  mix-blend-mode: screen;
  opacity: 0.42;
  animation: bd-scene-sun-spin 20s linear infinite;
  pointer-events: none;
}
.bd-scene-sun-core {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.70) 0%, rgba(255, 238, 170, 0.24) 40%, transparent 72%);
  mix-blend-mode: screen;
  animation: bd-scene-sun-pulse 2s ease-in-out infinite;
  pointer-events: none;
}
.bd-scene-corona {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.bd-scene-corona span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(1.5px, calc(var(--scene-size) * 0.006));
  height: calc(var(--scene-size) * 0.07);
  margin-left: calc(var(--scene-size) * -0.003);
  border-radius: 999px;
  background: linear-gradient(to top, transparent 0%, var(--scene-accent) 100%);
  filter: drop-shadow(0 0 5px var(--scene-accent));
  transform-origin: 50% 100%;
  transform: rotate(var(--a, 0deg)) translateY(calc(var(--scene-size) * -0.17)) scaleY(var(--v, 0.35));
  animation: bd-scene-pulse var(--d, 2.5s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.bd-scene-orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: calc(var(--orbit) * 2);
  height: calc(var(--orbit) * 2);
  border: 1px solid rgba(200, 220, 255, 0.055);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: bd-scene-orbit var(--t) linear infinite;
  will-change: transform;
  pointer-events: none;
}
.bd-scene-orbit.earth { --orbit: calc(var(--scene-size) * 0.32); --t: 6s; }
.bd-scene-orbit.red { --orbit: calc(var(--scene-size) * 0.22); --t: 5.2s; }
.bd-scene-orbit.blue { --orbit: calc(var(--scene-size) * 0.39); --t: 8.4s; }
.bd-scene-orbit.violet { --orbit: calc(var(--scene-size) * 0.47); --t: 11.5s; }
.bd-scene-planet {
  position: absolute;
  left: 50%;
  top: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: bd-scene-orbit-rev var(--t) linear infinite;
  will-change: transform;
  pointer-events: none;
}
.bd-scene-planet.earth {
  width: calc(var(--scene-size) * 0.062);
  height: calc(var(--scene-size) * 0.062);
  background: radial-gradient(circle at 35% 30%, #eef7ff 0%, #9fc3e0 34%, #50799c 64%, #1d354e 100%);
  box-shadow: inset -3px -4px 7px rgba(0, 0, 0, 0.55), 0 0 10px rgba(130, 190, 255, 0.35);
}
.bd-scene-planet.red {
  width: calc(var(--scene-size) * 0.036);
  height: calc(var(--scene-size) * 0.036);
  background: radial-gradient(circle at 35% 30%, #ffd2b8 0%, #e57354 38%, #a53225 72%, #4a0f0a 100%);
  box-shadow: inset -2px -3px 5px rgba(0, 0, 0, 0.55), 0 0 8px rgba(255, 120, 90, 0.30);
}
.bd-scene-planet.blue {
  width: calc(var(--scene-size) * 0.048);
  height: calc(var(--scene-size) * 0.048);
  background: radial-gradient(circle at 35% 30%, #e0f4ff 0%, #8cc9f2 34%, #3779ad 66%, #0b2a46 100%);
  box-shadow: inset -2px -3px 6px rgba(0, 0, 0, 0.50), 0 0 9px rgba(100, 180, 255, 0.32);
}
.bd-scene-planet.violet {
  width: calc(var(--scene-size) * 0.030);
  height: calc(var(--scene-size) * 0.030);
  background: radial-gradient(circle at 35% 30%, #f0ddff 0%, #c79df0 34%, #7b45b5 70%, #341154 100%);
  box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.50), 0 0 7px rgba(180, 120, 255, 0.32);
}
.bd-scene-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}
.bd-scene-ring::before,
.bd-scene-ring::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 168%;
  height: 44%;
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
  pointer-events: none;
}
.bd-scene-ring::before {
  border: 2px solid rgba(205, 220, 255, 0.55);
  box-shadow: 0 0 6px rgba(170, 205, 255, 0.35);
}
.bd-scene-ring::after {
  border: 3px solid rgba(0, 0, 0, 0.35);
  filter: blur(2px);
  transform: translate(-50%, -42%) rotate(-18deg);
  z-index: -1;
}
.bd-scene-status {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 0 8px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}
.bd-scene-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--scene-accent);
  box-shadow: 0 0 8px var(--scene-accent);
}
.bd-scene-step { color: rgba(255, 255, 255, 0.30); margin-left: 4px; }
.bd-scene[data-state="working"] { --scene-accent: #7cc4ff; }
.bd-scene[data-state="tool"] { --scene-accent: #ffd479; }
.bd-scene[data-state="speaking"] { --scene-accent: #8dffb2; }
.bd-scene[data-state="question"] { --scene-accent: #ffffff; }
.bd-scene[data-state="done"] { --scene-accent: #8dffb2; }
.bd-scene[data-state="error"] { --scene-accent: #ff8f87; }
.bd-scene[data-state="working"] .bd-scene-sun,
.bd-scene[data-state="tool"] .bd-scene-sun,
.bd-scene[data-state="speaking"] .bd-scene-sun,
.bd-scene[data-state="question"] .bd-scene-sun { animation-duration: 1.35s; }
.bd-scene[data-state="working"] .bd-scene-sun::after,
.bd-scene[data-state="tool"] .bd-scene-sun::after { animation-duration: 10s; }
.bd-scene[data-state="speaking"] .bd-scene-sun::after { animation-duration: 5s; }
.bd-scene[data-state="working"] .bd-scene-orbit,
.bd-scene[data-state="working"] .bd-scene-planet { animation-duration: calc(var(--t) * 0.75); }
.bd-scene[data-state="tool"] .bd-scene-orbit,
.bd-scene[data-state="tool"] .bd-scene-planet { animation-duration: calc(var(--t) * 0.62); }
.bd-scene[data-state="speaking"] .bd-scene-orbit,
.bd-scene[data-state="speaking"] .bd-scene-planet { animation-duration: calc(var(--t) * 0.82); }
.bd-scene[data-state="working"] .bd-scene-dot,
.bd-scene[data-state="tool"] .bd-scene-dot,
.bd-scene[data-state="speaking"] .bd-scene-dot,
.bd-scene[data-state="question"] .bd-scene-dot { animation: bd-scene-blink 1.1s ease-in-out infinite; }
.bd-scene-feed-wrap {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  width: min(680px, calc(100% - 28px));
  height: min(28%, 210px);
  margin: 0 auto 12px;
  padding: 8px 12px 4px;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  background: linear-gradient(to top, rgba(5, 5, 16, 0.90), rgba(5, 5, 16, 0.35));
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.bd-scene-feed-head {
  display: flex;
  justify-content: space-between;
  flex: none;
  padding: 0 2px 6px;
  color: rgba(255, 255, 255, 0.30);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.bd-scene-feed {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to top, #000 0 82%, transparent 100%);
  mask-image: linear-gradient(to top, #000 0 82%, transparent 100%);
}
.bd-scene-feed::-webkit-scrollbar { display: none; }
.bd-scene-line {
  display: grid;
  grid-template-columns: 38px 60px minmax(0, 1fr);
  gap: 8px;
  padding: 3px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  font: 10.5px/1.45 "SFMono-Regular", Consolas, "Courier New", monospace;
  animation: bd-scene-rise 0.3s ease both;
}
.bd-scene-time { color: rgba(255, 255, 255, 0.22); }
.bd-scene-kind {
  color: var(--scene-accent);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-top: 1px;
}
.bd-scene-text { color: rgba(255, 255, 255, 0.68); white-space: pre-wrap; overflow-wrap: anywhere; }
.bd-scene-line.request .bd-scene-kind { color: #8cc8ff; }
.bd-scene-line.tool .bd-scene-kind { color: #ffd479; }
.bd-scene-line.ok .bd-scene-kind,
.bd-scene-line.done .bd-scene-kind,
.bd-scene-line.agent .bd-scene-kind { color: #8dffb2; }
.bd-scene-line.error .bd-scene-kind { color: #ff8f87; }
.bd-scene-line.question .bd-scene-kind { color: #fff; }
.bd-scene-line.stream .bd-scene-text::after {
  content: "▍";
  color: #8dffb2;
  animation: bd-scene-caret 1s steps(1) infinite;
}
@keyframes bd-scene-sun-float {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, calc(-50% - 2px)) scale(1.015); }
}
@keyframes bd-scene-sun-spin { to { transform: rotate(360deg); } }
@keyframes bd-scene-sun-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.96); }
  50% { opacity: 0.68; transform: scale(1.04); }
}
@keyframes bd-scene-pulse {
  0%, 100% { opacity: 0.35; transform: rotate(var(--a, 0deg)) translateY(calc(var(--scene-size) * -0.17)) scaleY(calc(var(--v, 0.35) * 0.65)); }
  50% { opacity: 1; transform: rotate(var(--a, 0deg)) translateY(calc(var(--scene-size) * -0.17)) scaleY(var(--v, 0.35)); }
}
@keyframes bd-scene-orbit {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}
@keyframes bd-scene-orbit-rev {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(-360deg); }
}
@keyframes bd-scene-star {
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50% { opacity: 0.9; transform: scale(1.2); }
}
@keyframes bd-scene-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes bd-scene-blink { 50% { opacity: 0.35; } }
@keyframes bd-scene-caret { 50% { opacity: 0; } }
@media (max-width: 960px) {
  .bd-scene { --scene-size: clamp(180px, 34vh, 260px); }
  .bd-scene-feed-wrap { width: calc(100% - 18px); height: min(32%, 190px); }
  .bd-scene-line { grid-template-columns: 34px 52px minmax(0, 1fr); font-size: 10px; }
}
@media (max-width: 480px) {
  .bd-scene { --scene-size: clamp(160px, 30vh, 230px); }
}
@media (prefers-reduced-motion: reduce) {
  .bd-scene-sun,
  .bd-scene-sun::after,
  .bd-scene-sun-core,
  .bd-scene-orbit,
  .bd-scene-planet,
  .bd-scene-corona span,
  .bd-scene-stars span,
  .bd-scene-line { animation: none !important; }
}

/* Onglet Scène : point live quand l'agent travaille */
.bd-tab.bd-tab-special.live::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 6px;
  border-radius: 50%;
  background: #8dffb2;
  box-shadow: 0 0 6px #8dffb2;
  vertical-align: middle;
  animation: bd-scene-blink 1s ease-in-out infinite;
}

.bd-scene-feed::before {
  content: "";
  flex: none;
  margin-top: auto;
}

/* Le stop global est redondant avec #bd-stop dans la zone chat. */
#global-stop {
  display: none !important;
}
