@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap");

/* ══════════════════════════════════════════════════════════════
   DESIGN TOKENS — Single source of truth
   ══════════════════════════════════════════════════════════════ */
:root {
  /* ── Palette ── */
  --bg-base: #060809;
  --bg-elevated: rgba(12, 14, 16, 0.82);
  --bg-surface: rgba(16, 19, 22, 0.72);
  --bg-surface-solid: #0e1012;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(255, 255, 255, 0.07);

  /* Glass */
  --glass-bg: rgb(28, 30, 32);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-hover: rgba(255, 255, 255, 0.14);
  --glass-blur: blur(24px) saturate(130%);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04);

  /* Accent */
  --accent: #84ffaa;
  --accent-soft: rgba(132, 255, 170, 0.12);
  --accent-softer: rgba(132, 255, 170, 0.06);
  --accent-glow: 0 0 20px rgba(132, 255, 170, 0.15);
  --accent-border: rgba(132, 255, 170, 0.25);

  /* Text */
  --text-primary: rgba(240, 246, 243, 0.96);
  --text-secondary: rgba(190, 204, 198, 0.72);
  --text-tertiary: rgba(160, 174, 168, 0.50);
  --text-bright: #f4faf7;

  /* Lines / borders */
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.04);

  /* ── Scale: Spacing ── */
  --sp-4: 4px;
  --sp-6: 6px;
  --sp-8: 8px;
  --sp-10: 10px;
  --sp-12: 12px;
  --sp-16: 16px;
  --sp-20: 20px;
  --sp-24: 24px;
  --sp-32: 32px;

  /* ── Scale: Radii ── */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;
  --r-2xl: 28px;
  --r-pill: 999px;

  /* ── Typography ── */
  --font-ui: "Outfit", "Segoe UI", -apple-system, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace;

  /* ── Misc ── */
  --green: #84ffaa;
  --green-soft: rgba(132, 255, 170, 0.26);
  --transition-fast: 140ms ease;
  --transition-med: 220ms ease;
  --grid-size: 25px;
  --grid-offset-x: 0px;
  --grid-offset-y: 0px;
  --workflow-rail-width: 60px;
}

/* ══════════════════════════════════════════════════════════════
   RESET
   ══════════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
  font-family: var(--font-ui);
}

html,
body,
#app {
  margin: 0;
  width: 100%;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--text-primary);
  background: var(--bg-base);
  overflow: hidden;
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbars : fond transparent partout (plus de piste blanche native).
   Les règles spécifiques (.next-panel, etc.) restent prioritaires. */
* {
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
  background: transparent;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
}
*::-webkit-scrollbar-corner {
  background: transparent;
}

/* ══════════════════════════════════════════════════════════════
   STAGE / CANVAS
   ══════════════════════════════════════════════════════════════ */
.graph-stage-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  touch-action: none;
  --grid-size: 25px;
  --grid-dot: 4px;
  --grid-offset-x: 0px;
  --grid-offset-y: 0px;
  --workflow-rail-width: 60px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 120% 100% at 20% 0%, rgba(20, 40, 50, 0.18), transparent 60%),
    radial-gradient(ellipse 100% 100% at 80% 100%, rgba(15, 35, 25, 0.12), transparent 60%),
    linear-gradient(180deg, #060809 0%, #080a0c 50%, #060809 100%);
}

.graph-stage-wrap.is-panning {
  cursor: grabbing;
}

/* ══════════════════════════════════════════════════════════════
   VIEWPORT
   ══════════════════════════════════════════════════════════════ */
.graph-viewport {
  position: absolute;
  inset: 0;
  transform-origin: top left;
}

/* ══════════════════════════════════════════════════════════════
   EDGES (luminous cables)
   ══════════════════════════════════════════════════════════════ */
.edges-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: auto;
  overflow: visible;
}

.edge-group {
  pointer-events: stroke;
  cursor: pointer;
}

.edge-bloom {
  fill: none;
  stroke: var(--edge-color, var(--accent));
  stroke-width: 12px;
  vector-effect: non-scaling-stroke;
  stroke-linecap: butt;
  opacity: 0.10;
  filter: url(#edge-glow);
  pointer-events: none;
}

.edge-strand {
  fill: none;
  stroke: var(--edge-color, var(--accent));
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  pointer-events: none;
}

.edge-s1 {
  stroke-width: 1.2px;
  opacity: 0.22;
  stroke: color-mix(in srgb, var(--edge-color, var(--accent)) 25%, #888);
}

.edge-s2 {
  stroke-width: 1.0px;
  opacity: 0.18;
  stroke: color-mix(in srgb, var(--edge-color, var(--accent)) 20%, #999);
}

.edge-core {
  fill: none;
  stroke: color-mix(in srgb, var(--edge-color, var(--accent)) 90%, white);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  opacity: 0.85;
  filter: drop-shadow(0 0 1.5px color-mix(in srgb, var(--edge-color, var(--accent)) 15%, transparent));
  pointer-events: none;
}

.edge-group:hover .edge-bloom { opacity: 0.20; }
.edge-group:hover .edge-core { opacity: 1; stroke-width: 2.2px; }
.edge-group:hover .edge-s1,
.edge-group:hover .edge-s2 { opacity: 0.38; }

/* Invisible fat hit target for reliable hover on a thin curve */
.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 22px;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  pointer-events: stroke;
  cursor: pointer;
}

/* Delete button that appears at the edge midpoint on hover */
.edge-delete {
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  transform-box: fill-box;
  cursor: pointer;
}
.edge-group:hover .edge-delete {
  opacity: 1;
  pointer-events: auto;
}
.edge-delete-halo {
  fill: transparent;
  stroke: rgba(110, 110, 120, 0.95);
  stroke-width: 1.25;
  pointer-events: none;
}
.edge-delete-bg {
  fill: rgba(110, 110, 120, 0.95);
  stroke: none;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}
.edge-delete-x {
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
  pointer-events: none;
}
.edge-delete:hover .edge-delete-bg {
  fill: rgba(200, 70, 70, 0.98);
}
.edge-delete:hover .edge-delete-halo {
  stroke: rgba(200, 70, 70, 0.98);
}

/* ── Edge anchors (rendered in overlay layer z-index 3) ── */
.edge-anchor-spread {
  fill: var(--edge-color, var(--accent));
  opacity: 0.35;
  filter: url(#ol-anchor-spread-glow);
  pointer-events: none;
}

.edge-anchor-glow {
  fill: var(--edge-color, var(--accent));
  opacity: 0.75;
  filter: url(#ol-anchor-glow);
  pointer-events: none;
}

.edge-anchor-fill {
  fill: var(--edge-color, var(--accent));
  opacity: 1;
  pointer-events: none;
}

.edge-anchor-wing-spread {
  fill: none;
  stroke: var(--edge-color, var(--accent));
  stroke-width: 6;
  opacity: 0.3;
  filter: url(#ol-anchor-spread-glow);
  pointer-events: none;
}

.edge-anchor-wing-glow {
  fill: none;
  stroke: var(--edge-color, var(--accent));
  stroke-width: 4;
  opacity: 0.6;
  filter: url(#ol-wing-glow);
  pointer-events: none;
}

.edge-anchor-wing-fill {
  fill: var(--edge-color, var(--accent));
  opacity: 1;
  pointer-events: none;
}

.edge-group:hover .edge-anchor-spread { opacity: 0.5; }
.edge-group:hover .edge-anchor-glow { opacity: 0.7; }
.edge-group:hover .edge-anchor-wing-glow { opacity: 0.85; }
.edge-group:hover .edge-anchor-fill { opacity: 1; }

.edge-anchor-hit {
  fill: transparent;
  stroke: none;
  pointer-events: auto;
  cursor: grab;
}
.edge-anchor-hit:active {
  cursor: grabbing;
}

/* ── Edge labels ── */
.edge-label {
  pointer-events: none;
}

.edge-label-text {
  fill: #ffffff;
  font-size: 16px;
  font-family: inherit;
  font-weight: 300;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: 0.3px;
}

.edge-label-bg {
  fill: rgb(20, 20, 22);
  stroke: none;
}

/* ── Edge preview ── */
.edge-preview-group {
  pointer-events: none;
  opacity: 0;
  transition: opacity 100ms ease;
}

.edge-preview-group.visible { opacity: 1; }

.edge-preview-glow {
  fill: none;
  stroke: rgba(255, 255, 255, 1);
  stroke-width: 12px;
  opacity: 0.10;
  vector-effect: non-scaling-stroke;
  stroke-linecap: butt;
  filter: url(#edge-glow-preview);
}

.edge-preview-core {
  fill: none;
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  opacity: 0.85;
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.35));
}

.edge-preview-anchor {
  fill: rgba(255, 255, 255, 0.98);
  stroke: none;
  filter:
    drop-shadow(0 0 3px rgba(255, 255, 255, 0.55))
    drop-shadow(0 0 8px rgba(255, 255, 255, 0.35));
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════
   NODES
   ══════════════════════════════════════════════════════════════ */
.nodes-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.nodes-layer > .graph-node {
  pointer-events: auto;
}

.anchors-overlay-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  overflow: visible;
}

.graph-node {
  --kind-color: #86f8a6;
  --node-glow: rgba(134, 248, 166, 0.20);
  position: absolute;
  width: 300px;
  isolation: isolate;
  transform: rotate(var(--node-tilt, 0deg));
  transform-origin: center;
  transition: transform var(--transition-fast);
  animation: node-in 300ms ease both;
}

.graph-node:hover {
  transform: rotate(var(--node-tilt, 0deg));
}

.graph-stage-wrap.is-2d .graph-node:hover {
  transform: rotate(0deg);
}

/* ── 3D mode ──
   When the user toggles "3D" in the top bar, the 2D edges/nodes layers are
   hidden in favor of the WebGL canvas mounted by graph3d.ts. UI siblings
   (toolbars, panels) stay visible and interactive above the canvas. */
.graph-stage-wrap.is-3d .graph-viewport,
.graph-stage-wrap.is-3d .peer-handle {
  display: none;
}

.graph-3d-canvas {
  display: block;
  cursor: grab;
}

.graph-3d-canvas:active {
  cursor: grabbing;
}

/* HTML label overlay positioned each frame by graph3d.ts. */
.graph-3d-labels-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
}

/* Minimal "• Name" label, no pill, soft drop shadow for readability over
   the bright halos. The dot inherits the node tint. */
.graph-3d-label {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 500 11px/1 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0.015em;
  color: rgba(238, 244, 250, 0.85);
  white-space: nowrap;
  pointer-events: none;
  will-change: transform, opacity;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.7);
  transition: color 120ms ease, font-weight 120ms ease;
}

.graph-3d-label::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--label-tint, #ffffff);
  box-shadow: 0 0 6px var(--label-tint, #ffffff), 0 0 2px var(--label-tint, #ffffff);
  vertical-align: middle;
  flex-shrink: 0;
}

.graph-3d-label.is-selected {
  color: var(--label-tint, #ffffff);
  font-weight: 700;
}

.graph-3d-label.is-pinned::after {
  content: "·";
  margin-left: 4px;
  color: rgba(255, 255, 255, 0.45);
}

/* Centered labels (agents, projects) sit in the middle of the node body. The
   leading dot is hidden (the label IS the node visually), the type is a touch
   bolder, and the text shadow is reinforced so it reads against the bright
   particle cloud underneath. */
.graph-3d-label.is-centered {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.96);
  text-shadow:
    0 0 4px rgba(0, 0, 0, 0.95),
    0 0 14px rgba(0, 0, 0, 0.8),
    0 0 24px rgba(0, 0, 0, 0.55);
}

.graph-3d-label.is-centered::before {
  display: none;
}

.graph-3d-label.is-centered.is-selected {
  color: var(--label-tint, #ffffff);
}

/* Floating bottom toolbar: Noyau / Lien / Pause / Recentrer. */
.graph-3d-toolbar {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  background: rgba(14, 18, 22, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  z-index: 10;
  pointer-events: auto;
}

.graph-3d-toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: transparent;
  border: none;
  color: rgba(220, 228, 235, 0.7);
  font: 600 11.5px/1 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.graph-3d-toolbar button svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.graph-3d-toolbar button:hover {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.05);
}

.graph-3d-toolbar button.is-active {
  color: #0d1014;
  background: rgba(255, 255, 255, 0.92);
}

/* Multi-line hint anchored bottom-right. */
.graph-3d-hint {
  position: absolute;
  bottom: 18px;
  right: 26px;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font: 500 10.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: rgba(220, 230, 240, 0.40);
  text-align: right;
  pointer-events: none;
  letter-spacing: 0.015em;
}

.graph-3d-hint em {
  font-style: normal;
  color: rgba(220, 230, 240, 0.22);
  margin: 0 3px;
}

/* ── Node backplate (outer glass halo) ── */
.node-backplate {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: var(--r-2xl);
  pointer-events: none;
  z-index: -1;
  background: transparent;
  backdrop-filter: none;
}

.node-backplate-1 {
  inset: -15px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.02),
    0 20px 40px rgba(0, 0, 0, 0.22);
  transform: none;
}

.node-backplate-2 {
  display: none;
}

.graph-stage-wrap.is-2d .node-backplate-1 {
  transform: none;
}

/* ── Node surface (main glass card) ── */
.node-surface {
  position: relative;
  z-index: 1;
  border-radius: 26px;
  min-height: 178px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: var(--glass-bg);
  backdrop-filter: none;
  box-shadow: var(--glass-shadow);
  padding: var(--sp-20);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.graph-node:hover .node-surface {
  border-color: var(--glass-border-hover);
}

/* ── Agent en cours d'exécution : bordure verte + lueur pulsée + ondes radar ──
   Piloté par la classe .is-running (voir applyRunningNodeHighlights). */
.graph-node.is-running .node-surface {
  border-color: var(--accent);
  animation: node-running-glow 1.7s ease-in-out infinite;
}

@keyframes node-running-glow {
  0%, 100% {
    box-shadow:
      var(--glass-shadow),
      0 0 0 1px rgba(132, 255, 170, 0.45),
      0 0 18px rgba(132, 255, 170, 0.35),
      0 0 44px rgba(132, 255, 170, 0.20);
  }
  50% {
    box-shadow:
      var(--glass-shadow),
      0 0 0 1px rgba(132, 255, 170, 0.9),
      0 0 34px rgba(132, 255, 170, 0.7),
      0 0 82px rgba(132, 255, 170, 0.42);
  }
}

/* Ondes concentriques émanant du node (deux anneaux déphasés). Rendues
   derrière la surface (z-index:1) grâce à l'isolation du .graph-node. */
.graph-node.is-running::before,
.graph-node.is-running::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 26px;
  border: 2px solid rgba(132, 255, 170, 0.5);
  pointer-events: none;
  animation: node-running-wave 2.4s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
.graph-node.is-running::after { animation-delay: 1.2s; }

@keyframes node-running-wave {
  0% { transform: scale(1); opacity: 0.6; }
  70% { opacity: 0.12; }
  100% { transform: scale(1.22); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .graph-node.is-running .node-surface,
  .graph-node.is-running::before,
  .graph-node.is-running::after { animation: none; }
  .graph-node.is-running .node-surface {
    box-shadow: var(--glass-shadow), 0 0 24px rgba(132, 255, 170, 0.5);
  }
}


.graph-stage-wrap.is-editor-mode .node-surface {
  cursor: grab;
}

.graph-stage-wrap.is-editor-mode .node-surface:active {
  cursor: grabbing;
}

/* ── Node header ── */
.node-header {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  user-select: none;
  text-align: left;
  z-index: 1;
  pointer-events: none;
}

.node-header * {
  pointer-events: auto;
}

.graph-node.is-agents-view .node-header {
  cursor: default;
}

/* ── Node actions (edit/delete) ── */
.node-action {
  position: absolute;
  top: var(--sp-16);
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  cursor: pointer;
  z-index: 2;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.node-action:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.node-action svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: none;
}

.node-action-edit {
  left: var(--sp-16);
}

.node-action-delete {
  right: var(--sp-16);
  color: rgba(255, 160, 170, 0.75);
}

.node-action-delete:hover {
  color: rgba(255, 200, 206, 0.95);
  background: rgba(255, 100, 110, 0.08);
}

/* ── Node meta ── */
.node-meta {
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.node-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-16);
}

.node-title-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
}

.node-title-icon {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  color: var(--text-primary);
  opacity: 0.88;
}

.node-title-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: none;
}

.node-kind {
  margin: 0;
  font-size: 15px;
  font-weight: 200;
  line-height: 1.1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.node-title {
  margin: 0;
  font-size: 22px;
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-bright);
  text-wrap: balance;
  max-width: 100%;
}

.node-check {
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--kind-color);
  font-size: 20px;
}

/* ── Node live chips ── */
.node-live {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-6);
  margin-top: var(--sp-10);
}

.node-live p {
  margin: 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

.chip {
  border-radius: var(--r-pill);
  padding: 4px var(--sp-10);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.chip-model    { border-color: rgba(132, 255, 170, 0.25); color: rgba(170, 255, 200, 0.88); }
.chip-skill    { border-color: rgba(120, 210, 255, 0.25); color: rgba(160, 225, 255, 0.88); }
.chip-tool     { border-color: rgba(200, 220, 255, 0.25); color: rgba(210, 230, 255, 0.88); }
.chip-capability { border-color: rgba(255, 212, 123, 0.24); color: rgba(255, 226, 166, 0.92); }
.chip-capability-native { border-color: rgba(255, 212, 123, 0.34); color: rgba(255, 228, 175, 0.98); }
.chip-capability-local { border-color: rgba(255, 239, 168, 0.24); color: rgba(255, 240, 188, 0.92); }
.chip-capability-hybrid { border-color: rgba(255, 196, 120, 0.34); color: rgba(255, 223, 168, 0.98); }
.chip-capability-unavailable { border-color: rgba(255, 120, 120, 0.22); color: rgba(255, 170, 170, 0.88); }

/* ══════════════════════════════════════════════════════════════
   PORTS
   ══════════════════════════════════════════════════════════════ */
.node-ports {
  position: absolute;
  top: -15px;
  bottom: -15px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  pointer-events: none;
  width: 0;
}

.node-ports-in  { left: -15px; }
.node-ports-out { right: -15px; }

.port {
  border: none;
  border-radius: 0;
  background: transparent;
  color: transparent;
  font-size: 0;
  display: block;
  padding: 0;
  width: 12px;
  height: 12px;
  cursor: crosshair;
  pointer-events: auto;
  position: relative;
}

.node-ports-in .port  { transform: translateX(-6px); }
.node-ports-out .port { transform: translateX(-6px); }

.port:hover    { border-color: transparent; }
.port-dot      { display: none; }
.port-out      { flex-direction: row-reverse; }
.port-label    { display: none; }

/* Floating handle that appears when hovering on a node's contour (workflow view)
   Clicking it starts a peer link, which can be dropped anywhere on another agent. */
/* ── Popover d'infos d'un node (survol / clic) ── */
.node-popover {
  position: absolute;
  z-index: 8;
  transform: translate(-50%, calc(-100% - 14px));
  min-width: 200px;
  max-width: 300px;
  padding: var(--sp-12) var(--sp-12) var(--sp-10);
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  pointer-events: none;
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.4;
  animation: nodePopoverIn 0.12s ease-out;
}

.node-popover[hidden] { display: none; }

/* Menu flottant de choix du type de lien agent↔agent (pair / délégation). */
.link-type-menu {
  position: fixed;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  min-width: 240px;
  padding: var(--sp-6, 6px);
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  color: var(--text-primary);
  animation: linkTypeMenuIn 0.12s ease-out;
}

@keyframes linkTypeMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.link-type-menu-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--r-md, 10px);
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
}

.link-type-menu-item:hover,
.link-type-menu-item:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

@keyframes nodePopoverIn {
  from { opacity: 0; transform: translate(-50%, calc(-100% - 8px)); }
  to { opacity: 1; transform: translate(-50%, calc(-100% - 14px)); }
}

.node-popover-kind {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--kind-color, var(--text-secondary));
}

.node-popover-title {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
}

.node-popover-desc {
  margin: 6px 0 0;
  color: var(--text-secondary);
}

.node-popover-resources {
  margin-top: var(--sp-8);
  padding-top: var(--sp-8);
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.node-popover-res {
  display: flex;
  gap: var(--sp-8);
}

.node-popover-res-kind {
  flex: 0 0 auto;
  min-width: 70px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.node-popover-res-names {
  color: var(--text-secondary);
}

.peer-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  border-radius: 50%;
  border: none;
  background: rgba(110, 110, 120, 0.95);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  opacity: 0;
  transform: scale(calc(0.6 * var(--cam-zoom, 1)));
  transform-origin: center center;
  transition: opacity 90ms ease, transform 120ms ease, background 120ms ease;
  pointer-events: none;
  cursor: default;
  z-index: 6;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
.peer-handle::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.25px solid rgba(110, 110, 120, 0.95);
  pointer-events: none;
}
.peer-handle.visible {
  opacity: 1;
  transform: scale(var(--cam-zoom, 1));
  pointer-events: auto;
}
.peer-handle.visible:hover {
  background: rgba(140, 140, 150, 0.98);
  transform: scale(calc(1.1 * var(--cam-zoom, 1)));
}
.peer-handle svg {
  width: 11px;
  height: 11px;
}

/* Target node highlight while dragging a peer link */
.graph-node.is-peer-target .node-backplate-1 {
  border-color: rgba(199, 123, 255, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.02),
    0 0 22px rgba(199, 123, 255, 0.55),
    0 20px 40px rgba(0, 0, 0, 0.22);
}

.node-id {
  display: none;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════
   MODE TABS (top center)
   ══════════════════════════════════════════════════════════════ */
.mode-tabs {
  position: absolute;
  top: var(--sp-20);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: none;
  border-radius: var(--r-lg);
  padding: 3px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  gap: var(--sp-4);
}

.mode-tabs button {
  border: 0;
  min-width: 80px;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-secondary);
  padding: 12px var(--sp-16);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.mode-tabs button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mode-tabs button.is-active {
  color: var(--text-bright);
  background: var(--bg-active);
  border: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════════════
   DETAIL AGENT HEADER (top-left info)
   ══════════════════════════════════════════════════════════════ */
.detail-agent-header {
  --detail-header-tint: #81f8a1;
  position: absolute;
  top: calc(var(--sp-24) + var(--sp-8));
  left: calc(var(--sp-24) + 52px + var(--sp-24));
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-16);
  max-width: min(560px, calc(100vw - 460px));
  pointer-events: none;
}

.detail-agent-header[hidden] { display: none; }

.detail-agent-topline {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-12);
}

.detail-agent-copy { min-width: 0; }

.detail-agent-title-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-10);
  min-width: 0;
  flex-wrap: wrap;
}

.detail-agent-title,
.detail-agent-handle { margin: 0; }

.detail-agent-title {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text-bright);
  text-wrap: balance;
  pointer-events: auto;
  cursor: pointer;
}

.detail-agent-title-edit {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  backdrop-filter: blur(14px);
  box-shadow: var(--glass-shadow);
  pointer-events: auto;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.detail-agent-title-edit:hover {
  color: var(--text-bright);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.detail-agent-title-edit svg {
  width: 18px;
  height: 18px;
}

.detail-agent-rename {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  flex-wrap: wrap;
  margin-top: var(--sp-2);
  pointer-events: auto;
}

.detail-agent-rename[hidden] { display: none; }

.detail-agent-rename-input {
  min-width: min(320px, calc(100vw - 220px));
  flex: 1 1 280px;
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: rgba(5, 6, 10, 0.56);
  color: var(--text-bright);
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.detail-agent-rename-input:focus {
  border-color: color-mix(in srgb, var(--detail-header-tint) 52%, white);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--detail-header-tint) 18%, transparent);
}

.detail-agent-rename-save,
.detail-agent-rename-cancel {
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  padding: 10px 14px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.detail-agent-rename-save:hover,
.detail-agent-rename-cancel:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.18);
}

.detail-agent-handle {
  font-size: 20px;
  font-weight: 400;
  line-height: 1.1;
  color: var(--text-secondary);
}

.detail-agent-role {
  display: none;
}

/* ══════════════════════════════════════════════════════════════
   MODEL EDITOR MODAL
   ══════════════════════════════════════════════════════════════ */
.model-editor-modal {
  position: absolute;
  inset: 0;
  /* Au-dessus du panneau « Éditer le bloc » (z-index 12) : le sélecteur de
     modèles s'ouvre par-dessus quand on clique « Ajouter » dans l'onglet Modèle. */
  z-index: 85;
}

.model-editor-modal[hidden] { display: none; }

.model-editor-modal .model-editor-dialog {
  width: min(780px, calc(100vw - 48px));
  padding: var(--sp-32);
}

.model-editor-modal .model-editor-list {
  max-height: min(520px, calc(100vh - 280px));
  padding: 8px 5px 8px 10px;
}

.model-editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  backdrop-filter: blur(12px);
}

.model-editor-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px));
  border-radius: var(--r-2xl);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.55), var(--glass-shadow);
  padding: var(--sp-24);
}

.model-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-16);
}

.model-editor-copy { min-width: 0; }

.model-editor-eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.model-editor-title {
  margin: var(--sp-6) 0 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text-bright);
}

.model-editor-close {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-hover);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.model-editor-close:hover {
  color: var(--text-primary);
  background: var(--bg-active);
  border-color: var(--glass-border-hover);
}

.model-editor-field {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

/* Le `display: flex` ci-dessus a la même spécificité que `[hidden]` du UA et le
   gagne → sans cette règle, les blocs de config par-tool (browser/spotify/hue/
   email/dreame) resteraient visibles pour TOUS les nodes malgré l'attribut
   hidden posé par le JS. `.model-editor-field[hidden]` (0,2,0) reprend la main. */
.model-editor-field[hidden] {
  display: none;
}

.model-editor-field span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Interrupteur activer/désactiver un trigger (éditeur de trigger). Visuel piloté
   entièrement en CSS via l'état :checked de la case masquée. */
.trigger-editor-modal {
  position: absolute;
  inset: 0;
  z-index: 85;
}

.trigger-editor-modal[hidden] {
  display: none;
}

.trigger-editor-modal .model-editor-dialog {
  display: flex;
  max-height: calc(100vh - 48px);
  flex-direction: column;
}

.trigger-editor-body {
  min-height: 0;
  margin-top: 10px;
  padding-right: 4px;
  overflow-y: auto;
}

.trigger-enabled-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  user-select: none;
}
.trigger-enabled-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.trigger-enabled-track {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  transition: background 0.18s ease;
}
.trigger-enabled-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease;
}
.trigger-enabled-toggle input:checked ~ .trigger-enabled-track {
  background: #34c759;
}
.trigger-enabled-toggle input:checked ~ .trigger-enabled-track .trigger-enabled-thumb {
  transform: translateX(18px);
}
.trigger-enabled-toggle input:focus-visible ~ .trigger-enabled-track {
  outline: 2px solid var(--accent, #4f8cff);
  outline-offset: 2px;
}
.trigger-enabled-label {
  font-size: 14px;
  font-weight: 600;
}
.trigger-enabled-label .on {
  display: none;
  color: #34c759;
}
.trigger-enabled-label .off {
  display: inline;
  opacity: 0.7;
}
.trigger-enabled-toggle input:checked ~ .trigger-enabled-label .on {
  display: inline;
}
.trigger-enabled-toggle input:checked ~ .trigger-enabled-label .off {
  display: none;
}

.trigger-routing-section {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.trigger-routing-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trigger-routing-heading strong {
  color: var(--text-bright);
  font-size: 14px;
}

.trigger-routing-heading span {
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.45;
}

.trigger-activity-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  cursor: pointer;
}

.trigger-activity-toggle > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.trigger-activity-toggle > i {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  transition: background var(--transition-fast);
}

.trigger-activity-toggle > i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: transform var(--transition-fast);
}

.trigger-activity-toggle > input:checked + i {
  background: var(--accent);
}

.trigger-activity-toggle > input:checked + i::after {
  transform: translateX(16px);
}

.trigger-activity-toggle > input:focus-visible + i {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.trigger-activity-toggle > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.trigger-activity-toggle strong {
  color: var(--text-primary);
  font-size: 13px;
}

.trigger-activity-toggle small,
.trigger-routing-section .model-editor-field small {
  color: var(--text-tertiary);
  font-size: 11.5px;
  line-height: 1.4;
}

.trigger-existing-conversation-field {
  margin-top: -3px;
  padding-left: 14px;
  border-left: 2px solid var(--accent-border);
}

.node-rename-browser-field {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

.node-rename-browser-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-8) var(--sp-12);
}

.node-rename-browser-grid .model-editor-field {
  margin-top: 0;
}

.node-rename-browser-input {
  width: 100%;
  height: 44px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 0 var(--sp-12);
  font: inherit;
  font-size: 14px;
  transition: border-color var(--transition-fast);
}

.node-rename-browser-input:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.model-editor-select {
  width: 100%;
  height: 48px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  color: var(--text-primary);
  padding: 0 var(--sp-12);
  font: inherit;
  font-size: 14px;
  transition: border-color var(--transition-fast);
}

.model-editor-select:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.model-editor-field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.model-editor-field-help {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-tertiary);
}

.model-editor-list-outer {
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  padding: 8px 6px;
  margin-top: 4px;
  overflow: hidden;
}

.model-editor-list {
  max-height: 320px;
  overflow-y: auto;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
  color-scheme: dark;
  scrollbar-color: #888 transparent;
}

.model-editor-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.model-editor-group-label {
  padding: var(--sp-4) var(--sp-8);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.model-editor-option {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  align-items: center;
  gap: var(--sp-8);
  padding: var(--sp-8) var(--sp-10);
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.model-editor-option:hover {
  background: var(--bg-hover);
}

.model-editor-option.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.model-editor-option.is-primary {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.model-editor-option-check {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--accent);
}

.model-editor-option.is-selected .model-editor-option-check {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.model-editor-option-check.is-empty {
  display: inline-block;
}

.model-editor-option-name {
  font-weight: 500;
}

.model-editor-option-api {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
}

.model-editor-option-metrics {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-left: auto;
}

.model-editor-option-metric {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.model-editor-option-metric-wer {
  color: #5eead4;
  border-color: color-mix(in srgb, #5eead4 35%, var(--border));
  background: color-mix(in srgb, #5eead4 10%, transparent);
}

.model-editor-option-metric-price {
  color: #ffe258;
  border-color: color-mix(in srgb, #ffe258 35%, var(--border));
  background: color-mix(in srgb, #ffe258 10%, transparent);
}

.model-editor-option-metric-intel {
  color: #a5b4fc;
  border-color: color-mix(in srgb, #a5b4fc 35%, var(--border));
  background: color-mix(in srgb, #a5b4fc 10%, transparent);
}

.model-editor-option-metric-modality {
  color: #7dd3fc;
  border-color: color-mix(in srgb, #7dd3fc 35%, var(--border));
  background: color-mix(in srgb, #7dd3fc 10%, transparent);
}

.model-editor-option-metric-tbd {
  text-decoration: line-through;
  opacity: 0.65;
}

.model-editor-option.is-unavailable {
  text-decoration: line-through;
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.4);
}

.model-editor-option.is-unavailable:hover {
  background: inherit;
  border-color: inherit;
}

.model-editor-option-primary {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.model-editor-option-local {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  color: #86efac;
  border: 1px solid color-mix(in srgb, #86efac 35%, var(--border));
  background: color-mix(in srgb, #86efac 12%, transparent);
}

.model-editor-option-setprimary {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: transparent;
  color: var(--text-tertiary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.model-editor-option-setprimary:hover {
  color: var(--accent);
  border-color: var(--accent-border);
}

.model-editor-meta-empty {
  display: block;
  color: var(--text-tertiary);
  font-size: 12px;
}

.model-editor-meta-count {
  margin-top: var(--sp-8);
  font-size: 11px;
  color: var(--text-tertiary);
}

.model-editor-meta {
  margin-top: var(--sp-12);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  padding: var(--sp-12);
}

.model-editor-meta p,
.model-editor-meta span,
.model-editor-meta small {
  margin: 0;
  display: block;
}

.model-editor-meta p {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
}

.model-editor-meta span {
  margin-top: var(--sp-6);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

.model-editor-meta small {
  margin-top: var(--sp-8);
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.45;
}

.model-editor-meta code {
  font-family: var(--font-mono);
  font-size: 12px;
}

.model-editor-actions {
  margin-top: var(--sp-20);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-10);
}

.model-editor-btn {
  height: 44px;
  border-radius: var(--r-md);
  padding: 0 var(--sp-20);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.model-editor-btn.is-ghost {
  border: 1px solid var(--border);
  background: var(--bg-hover);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
}

.model-editor-btn.is-ghost:hover {
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
  background: var(--bg-active);
}

.model-editor-btn.is-primary {
  border: 1px solid var(--accent-border);
  background: linear-gradient(180deg, rgba(50, 120, 70, 0.85), rgba(30, 75, 45, 0.90));
  color: var(--text-bright);
  box-shadow: 0 4px 16px rgba(132, 255, 170, 0.10);
}

.model-editor-btn.is-primary:hover {
  box-shadow: 0 4px 20px rgba(132, 255, 170, 0.18);
  border-color: rgba(132, 255, 170, 0.35);
}

/* ── AI Agent Editor Modal (reuses model-editor-dialog styles) ── */
.aiagent-editor-modal {
  position: absolute;
  inset: 0;
  z-index: 12;
}

.aiagent-editor-modal[hidden] { display: none; }

.aiagent-editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  backdrop-filter: blur(12px);
}

.aiagent-editor-options {
  display: grid;
  gap: 12px;
}

.aiagent-editor-option {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  color: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
}

.aiagent-editor-option:hover {
  border-color: rgba(132,255,170,0.35);
  background: rgba(132,255,170,0.08);
  transform: translateY(-1px);
}

.aiagent-editor-option.is-active {
  border-color: rgba(132,255,170,0.55);
  background: rgba(132,255,170,0.12);
  box-shadow: 0 0 0 1px rgba(132,255,170,0.10) inset;
}

.aiagent-editor-option strong,
.aiagent-editor-option span {
  display: block;
}

.aiagent-editor-option strong {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-bright);
}

.aiagent-editor-option span {
  margin-top: 6px;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* ── Node Rename Modal (reuses model-editor-dialog styles) ── */
.node-rename-modal {
  position: absolute;
  inset: 0;
  z-index: 12;
}
.node-rename-modal[hidden] { display: none; }
/* Éditeur d'agent (nom + prompt) : format large qui tient dans la hauteur de
   l'écran, avec scroll interne — header et boutons toujours accessibles, même
   sur un écran large/court (avant ça débordait en haut/bas et rognait tout). */
.node-rename-modal .model-editor-dialog {
  width: min(1040px, calc(100vw - 40px));
  /* Hauteur FIXE + colonne flex : header, onglets et footer (Annuler /
     Enregistrer) restent épinglés ; seul le corps .node-rename-body scrolle.
     La taille du panneau ne change donc pas d'un onglet à l'autre. */
  height: min(820px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.node-rename-modal .model-editor-head,
.node-rename-modal .node-rename-tabs,
.node-rename-modal .model-editor-actions {
  flex: 0 0 auto;
}
.node-rename-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
/* Footer persistant en bas du panneau. */
.node-rename-modal .model-editor-actions {
  margin-top: var(--sp-16);
  padding-top: var(--sp-16);
  border-top: 1px solid var(--border-subtle);
}
.node-rename-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  backdrop-filter: blur(12px);
}
.node-rename-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.node-rename-input:focus {
  border-color: rgba(132,255,170,0.5);
  box-shadow: 0 0 0 3px rgba(132,255,170,0.08);
}
.node-rename-system-prompt-field[hidden] { display: none; }
.node-rename-system-prompt-input {
  width: 100%;
  min-height: 140px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.node-rename-system-prompt-input:focus {
  border-color: rgba(132,255,170,0.5);
  box-shadow: 0 0 0 3px rgba(132,255,170,0.08);
}
.node-rename-description-input {
  width: 100%;
  min-height: 70px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.node-rename-description-input:focus {
  border-color: rgba(132,255,170,0.5);
  box-shadow: 0 0 0 3px rgba(132,255,170,0.08);
}
.node-rename-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.node-rename-tabs[hidden] { display: none; }
.node-rename-tabs button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.node-rename-tabs button:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.node-rename-tabs button.is-active {
  background: rgba(132,255,170,0.12);
  color: #fff;
  border-color: rgba(132,255,170,0.35);
}
.node-rename-resource-panel { margin-top: 6px; }
.node-rename-resource-panel[hidden] { display: none; }
.nr-res-list,
.nr-res-catalog {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nr-res-catalog {
  margin: 8px 0 0;
}
/* En-tête de catégorie dans la liste d'ajout (regroupement par catégorie). */
.nr-res-cat-label {
  margin: 14px 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.nr-res-cat-label:first-child {
  margin-top: 6px;
}
.nr-res-item,
.nr-res-add {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.nr-res-item:hover,
.nr-res-add:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(132,255,170,0.3);
}
.nr-res-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.nr-res-name {
  font-size: 13px;
  color: #fff;
  font-weight: 500;
}
.nr-res-desc {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nr-res-badge {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-soft);
  vertical-align: middle;
}
.nr-res-modelbtn {
  flex: none;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.nr-res-modelbtn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-base, #0b0f14);
}
.nr-res-remove {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.4);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 7px;
  border-radius: 6px;
  flex: none;
}
.nr-res-remove:hover {
  color: #ff9a9a;
  background: rgba(255, 90, 90, 0.14);
}
.nr-res-add b {
  color: rgba(132,255,170,0.85);
  font-size: 16px;
  flex: none;
}
.nr-res-add-btn { margin: 2px 0 0; }
.node-rename-system-prompt-help,
.node-rename-description-help {
  margin: 6px 0 0;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  line-height: 1.4;
}
/* Statut de connexion OAuth (Daikin, etc.) dans le panneau du tool. */
.node-rename-oauth-status {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
}
.node-rename-oauth-status.is-ok { color: var(--accent); }
.node-rename-oauth-status.is-warn { color: #ffcf8a; }
.node-rename-oauth-status[hidden] { display: none; }
/* Label « Prompt système » + bouton « Importer le prompt par défaut » sur la
   même ligne, bouton à droite (au lieu de prendre toute la largeur). */
.node-rename-system-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-12);
}
.node-rename-preview[hidden] { display: none; }
.node-rename-preview {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}
/* Pas de contour ni de fond : seul le <pre> (noir) reste visible. */
.node-rename-preview-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.node-rename-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 12px;
}
/* Titre aligné sur les autres labels de champ. */
.node-rename-preview-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}
.node-rename-preview-status {
  color: rgba(132,255,170,0.8);
  font-size: 11px;
}
.node-rename-preview-body {
  margin: 0;
  padding: 10px 12px;
  max-height: 260px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.55;
  color: rgba(255,255,255,0.82);
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ── Visualiseurs Mémoire / Historique d'un agent (reuse model-editor-dialog) ── */
.agent-viewer-status {
  margin: 6px 0 0;
  min-height: 16px;
  font-size: 12px;
  color: rgba(132,255,170,0.8);
}
.agent-memory-viewer-modal,
.agent-history-viewer-modal {
  position: absolute;
  inset: 0;
  z-index: 12;
}
.agent-memory-viewer-modal[hidden],
.agent-history-viewer-modal[hidden] { display: none; }
.agent-memory-viewer-modal .model-editor-dialog,
.agent-history-viewer-modal .model-editor-dialog {
  width: min(900px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.agent-memory-viewer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
  max-height: min(520px, calc(100vh - 240px));
  overflow-y: auto;
}
.agent-history-viewer-body {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  gap: 14px;
  margin: 14px 0;
  min-height: 0;
}
.agent-history-viewer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(520px, calc(100vh - 240px));
  overflow-y: auto;
}
.agent-history-viewer-list .projects-modal-row {
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.agent-history-viewer-list .projects-modal-row.is-active {
  border-color: rgba(132,255,170,0.45);
  background: rgba(132,255,170,0.10);
}
.agent-history-viewer-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(520px, calc(100vh - 240px));
  overflow-y: auto;
  padding-right: 4px;
}
.agent-history-message {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  padding: 10px 12px;
}
.agent-history-message-role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(132,255,170,0.8);
  margin-bottom: 6px;
}
.agent-history-message-content {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255,255,255,0.85);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ══════════════════════════════════════════════════════════════
   SETTINGS MODAL (centré plein écran)
   ══════════════════════════════════════════════════════════════ */
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-24);
}
.settings-modal[hidden] {
  display: none;
}
.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.settings-dialog {
  /* Neutralise le positionnement de .model-editor-dialog (top/left/transform 50%)
     pour laisser le flex centering de .settings-modal faire son boulot. */
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  width: min(720px, 100%);
  /* Hauteur FIXE : pas de redimensionnement en changeant d'onglet. */
  height: min(660px, calc(100vh - 48px));
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 24px;
  border-radius: 16px;
  background: rgba(18, 22, 28, 0.96);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.9);
}
.settings-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-dialog h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-field label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
}
.settings-default-agent-prompt {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.35);
  color: rgba(255,255,255,0.92);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.settings-default-agent-prompt:focus {
  border-color: rgba(132,255,170,0.55);
  box-shadow: 0 0 0 3px rgba(132,255,170,0.15);
}
.settings-field-help {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255,255,255,0.6);
}
.settings-field-help code {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.85);
}
.settings-status {
  min-height: 16px;
  font-size: 12px;
  color: rgba(132,255,170,0.85);
}
.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ════════════════════════════════════════════════════════════════
   RÉGLAGES — onglets, champs custom, clés API, usage
   ════════════════════════════════════════════════════════════════ */

/* Champs texte custom (token, nom de workflow) — fini le blanc natif. */
.settings-token-input,
.settings-workflow-name {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.01em;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.settings-token-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.settings-token-input::placeholder,
.settings-workflow-name::placeholder { color: var(--text-tertiary); }
.settings-token-input:focus,
.settings-workflow-name:focus {
  border-color: var(--accent-border);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Onglets ───────────────────────────────────────────────────── */
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
}
.settings-tab {
  flex: 1 1 auto;
  min-width: 84px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.settings-tab:hover {
  color: var(--text-primary);
  background: var(--accent-softer);
}
.settings-tab.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
  box-shadow: var(--accent-glow);
}

/* ── Panneaux ──────────────────────────────────────────────────── */
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: settings-fade 200ms ease;
}
.settings-panel[hidden] {
  display: none;
}
@keyframes settings-fade {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.settings-section-copy h4 {
  margin: 0;
  color: var(--text-bright);
  font-size: 15px;
  font-weight: 650;
}

.settings-section-copy p {
  margin: 5px 0 0;
  color: var(--text-tertiary);
  font-size: 12.5px;
  line-height: 1.5;
}

.settings-section-copy-spaced {
  margin-top: 4px;
}

.settings-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.settings-choice-card {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.settings-choice-card > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.settings-choice-card-body {
  display: flex;
  min-height: 102px;
  height: 100%;
  flex-direction: column;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.settings-choice-card:hover .settings-choice-card-body {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.settings-choice-card.is-selected .settings-choice-card-body {
  border-color: var(--accent-border);
  background: var(--accent-softer);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
}

.settings-choice-card > input:focus-visible + .settings-choice-card-body {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-choice-card-body strong {
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.25;
}

.settings-choice-card.is-selected .settings-choice-card-body strong {
  color: var(--accent);
}

.settings-choice-card-body small {
  color: var(--text-tertiary);
  font-size: 11.5px;
  line-height: 1.45;
}

.settings-voice-tools {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-surface);
}

.settings-toggle-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  cursor: pointer;
}

.settings-toggle-row + .settings-toggle-row {
  border-top: 1px solid var(--border-subtle);
}

.settings-toggle-row > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.settings-toggle-row strong {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.settings-toggle-row small {
  color: var(--text-tertiary);
  font-size: 11.5px;
  line-height: 1.35;
}

.settings-toggle-row > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.settings-toggle-row > i {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  transition: background var(--transition-fast);
}

.settings-toggle-row > i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: transform var(--transition-fast);
}

.settings-toggle-row > input:checked + i {
  background: var(--accent);
}

.settings-toggle-row > input:checked + i::after {
  transform: translateX(16px);
}

.settings-toggle-row > input:focus-visible + i {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-inline-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.settings-inline-result {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-inline-result.is-ok { color: var(--accent); }
.settings-inline-result.is-error { color: #ff9a9a; }
.settings-inline-result.is-ok::before { content: "✓"; font-weight: 700; }
.settings-inline-result.is-error::before { content: "⚠"; }
.settings-btn-danger { color: #ff9a9a; }
.settings-btn-danger:hover {
  background: rgba(255, 90, 90, 0.14);
  border-color: rgba(255, 120, 120, 0.32);
}

/* ── Clés API ──────────────────────────────────────────────────── */
.settings-keys-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.settings-keys-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-key-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-surface), var(--bg-surface-solid));
  transition: border-color var(--transition-fast);
}
.settings-key-row:hover { border-color: var(--border-strong); }
.settings-key-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.settings-key-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.settings-key-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.settings-key-badge.is-user {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}
.settings-key-badge.is-env {
  background: rgba(120, 180, 255, 0.12);
  border-color: rgba(120, 180, 255, 0.25);
  color: #aacdff;
}
.settings-key-badge.is-none {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
  color: var(--text-tertiary);
}
.settings-key-hint {
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.settings-key-controls {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.settings-key-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.settings-key-input::placeholder { color: var(--text-tertiary); }
.settings-key-input:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.settings-key-btn {
  height: 42px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.settings-key-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}
.settings-key-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.settings-key-btn.is-clear { color: #ff9a9a; }
.settings-key-btn.is-clear:hover {
  background: rgba(255, 90, 90, 0.14);
  border-color: rgba(255, 120, 120, 0.32);
  color: #ffb3b3;
}

/* ── Usage ─────────────────────────────────────────────────────── */
.settings-usage {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.settings-usage-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.settings-usage-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: radial-gradient(140% 140% at 0% 0%, var(--accent-softer), transparent 55%), var(--bg-surface);
}
.settings-usage-card-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-tertiary);
}
.settings-usage-cost {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.settings-usage-tokens {
  font-size: 12.5px;
  color: var(--text-secondary);
}
.settings-usage-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin: 0 0 8px;
}
.settings-usage-table {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
}
.settings-usage-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  font-size: 13px;
}
.settings-usage-line:nth-child(odd) { background: var(--accent-softer); }
.settings-usage-line-name {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.25;
}
.settings-usage-line-sub {
  color: var(--text-tertiary);
  font-size: 11px;
}
.settings-usage-line-tokens {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.settings-usage-line-cost {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 56px;
  text-align: right;
}
.settings-usage-empty {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 10px 2px;
}

/* ══════════════════════════════════════════════════════════════
   VIEW CONTROLS (top-right)
   ══════════════════════════════════════════════════════════════ */
.view-controls {
  position: absolute;
  top: var(--sp-24);
  right: var(--sp-24);
  z-index: 6;
  display: flex;
  align-items: stretch;
  gap: var(--sp-8);
}

/* ── View mode toggle (2D/3D) + bouton affichage — désormais dans le footer ──
   Scopés sous `.bottom-actions` pour battre la spécificité de `.bottom-actions button`. */
.bottom-actions .view-mode-toggle {
  min-width: 44px;
  padding: 11px var(--sp-12);
  border: 0;
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-align: center;
  color: var(--text-bright);
  background: var(--bg-active);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.bottom-actions .view-mode-toggle:hover {
  color: var(--text-bright);
  background: var(--bg-hover);
}

.bottom-actions .view-visibility-btn {
  width: 34px;
  height: 34px;
  padding: var(--sp-6);
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.bottom-actions .view-visibility-btn svg {
  width: 18px;
  height: 18px;
}

.bottom-actions .view-visibility-btn:hover,
.bottom-actions .view-visibility-btn[aria-expanded="true"] {
  color: var(--text-bright);
  background: var(--bg-active);
}

.visibility-panel {
  position: absolute;
  /* Au-dessus du footer — bottom: sp-20 (offset du footer) + ~46px (hauteur du footer) + sp-12 gap */
  bottom: calc(var(--sp-20) + 46px + var(--sp-12));
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  min-width: 220px;
  padding: var(--sp-8);
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: visibilityPanelIn 0.18s ease-out;
}

/* Le `display: flex` ci-dessus a la même spécificité que `[hidden]` du UA
   stylesheet et gagnait par ordre d'apparition. On force le hide explicitement. */
.visibility-panel[hidden] {
  display: none;
}

/* Opacité seule : un translate clobberait le translateX(-50%) de centrage. */
@keyframes visibilityPanelIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.visibility-panel-title {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: var(--sp-4) var(--sp-8) var(--sp-8);
  margin: 0;
}

.visibility-row {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  padding: var(--sp-8) var(--sp-8);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
}

.visibility-row:hover {
  background: var(--bg-active);
  color: var(--text-bright);
}

.visibility-row input[type="checkbox"] {
  /* Hide the native checkbox — the `.visibility-eye` icon is the visual */
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.visibility-eye {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: var(--bg-active);
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.visibility-eye svg {
  grid-area: 1 / 1;
  width: 18px;
  height: 18px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

/* Default (unchecked) = eye-off shown, eye-open hidden */
.visibility-eye .visibility-eye-open {
  opacity: 0;
  transform: scale(0.85);
}
.visibility-eye .visibility-eye-off {
  opacity: 1;
  transform: scale(1);
}

/* Checked = eye-open shown, eye-off hidden */
.visibility-row input:checked ~ .visibility-eye .visibility-eye-open {
  opacity: 1;
  transform: scale(1);
}
.visibility-row input:checked ~ .visibility-eye .visibility-eye-off {
  opacity: 0;
  transform: scale(0.85);
}

/* When checked, color the eye in the accent (green) so it pops as "visible" */
.visibility-row input:checked ~ .visibility-eye {
  background: color-mix(in srgb, var(--accent, #7ce8a0) 18%, transparent);
  color: var(--accent, #7ce8a0);
}

.visibility-row input:checked ~ .visibility-label {
  color: var(--text-bright);
}

.visibility-label {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}

.visibility-row input:focus-visible ~ .visibility-eye {
  outline: 2px solid var(--accent, #7ce8a0);
  outline-offset: 2px;
}

/* ── Settings button (bottom-left, sous le bouton conversation et le bouton lunettes) ── */
/* Bouton paramètres — désormais dans le footer du milieu (scopé sous .bottom-actions
   pour battre la spécificité de .bottom-actions button). */
.bottom-actions .view-settings-btn {
  width: 34px;
  height: 34px;
  padding: var(--sp-6);
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.bottom-actions .view-settings-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-actions .view-settings-btn:hover {
  color: var(--text-bright);
  background: var(--bg-active);
}


.chat-panel-toggle {
  position: absolute;
  top: var(--sp-24);
  left: var(--sp-24);
  z-index: 7;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.chat-panel-toggle[hidden] { display: none; }

.chat-panel-toggle svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-panel-toggle:hover {
  color: var(--text-bright);
  border-color: var(--glass-border-hover);
}

.chat-panel-toggle.is-active {
  color: var(--text-bright);
  background: var(--bg-active);
  border-color: var(--glass-border-hover);
}

/* ══════════════════════════════════════════════════════════════
   SYNC INDICATOR
   ══════════════════════════════════════════════════════════════ */
.sync-indicator {
  display: none;
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════════════════════════
   NEXT PANEL (right sidebar)
   ══════════════════════════════════════════════════════════════ */
.next-panel {
  position: absolute;
  top: calc(var(--sp-24) + 52px + var(--sp-16));
  left: var(--sp-24);
  z-index: 6;
  width: min(420px, calc(100vw - 48px));
  /* Réserve l'espace du progress-card en bas-droite (24px d'offset + ~110px de hauteur + 12px de marge)
     pour que le panel s'arrête juste avant et ne le recouvre jamais à sa taille max. */
  max-height: calc(100vh - var(--sp-24) - 52px - var(--sp-16) - var(--sp-24) - 110px - var(--sp-12));
  overflow-y: auto;
  border-radius: var(--r-xl);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  /* Padding latéral 18px (≈ moyenne 16/20) pour s'aligner sur .projects-modal. */
  padding: var(--sp-20) 18px var(--sp-12);
}

.next-panel[hidden] { display: none; }

.next-panel::-webkit-scrollbar {
  width: 4px;
}

.next-panel::-webkit-scrollbar-track {
  background: transparent;
}

.next-panel::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
}

.next-panel h2 {
  margin-top: 1px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ── Search ── */
.next-search {
  margin-top: 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  color: var(--text-tertiary);
  font-size: 14px;
  padding: var(--sp-10) var(--sp-12);
  display: flex;
  align-items: center;
  gap: var(--sp-10);
  transition: border-color var(--transition-fast);
}

.next-search:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 2px var(--accent-softer);
}

.next-search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
}

.next-search-input::placeholder {
  color: var(--text-tertiary);
}

.next-search-icon,
.next-item-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  color: var(--text-secondary);
}

/* Tint par catégorie : visible à la fois sur le bouton root et sur les items du catalogue.
   Garde la même couleur que kindConfig.tint pour cohérence avec le label `--kind-color` des node cards. */
.next-item-icon--agent { color: #34d399; }
.next-item-icon--feature { color: #ffffff; }
.next-item-icon--capability { color: #7ce8a0; }
.next-item-icon--ai-capability { color: #ffd47b; }
.next-item-icon--tool { color: #7ec5ff; }
.next-item-icon--skill { color: #ff8b8b; }
.next-item-icon--project { color: #ff4fbf; }
.next-item-icon--trigger { color: #ffa657; }
.next-item-icon--vector { color: #c77bff; }
.next-item-icon--app { color: #4d9bff; }

.next-search-icon svg,
.next-item-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── List items ── */
.next-panel ul {
  list-style: none;
  margin: var(--sp-12) 0 3px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.next-panel ul[hidden] { display: none; }

.next-panel li {
  display: flex;
  align-items: center;
  gap: var(--sp-16);
  padding: var(--sp-8) var(--sp-6);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.next-panel li[hidden] { display: none; }

.next-panel li:hover {
  background: var(--bg-hover);
}

.next-panel-action {
  cursor: pointer;
}

.next-panel-action.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.next-panel-action--primary {
  appearance: none;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-lg);
  color: var(--text-bright);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 8px 0;
  width: 100%;
  text-align: left;
  font: inherit;
}

.next-panel-action--primary:hover {
  background: var(--accent);
  color: var(--bg-base, #0b0f14);
  border-color: var(--accent);
}

.next-item-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.next-panel li p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.next-item-copy span {
  display: block;
  margin-top: 2px;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.3;
  /* Tronque sur une seule ligne avec « … » ; le texte complet est dispo via le title (tooltip natif). */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Le nom du node aussi tronqué pour ne pas casser le layout si trop long. */
.next-panel li p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Nom du connecteur + pastilles d'exécution (Cloud / Local desktop / Local mobile). */
.next-item-name {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  min-width: 0;
  overflow: visible;
}

.exec-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 0 0 auto;
}

.exec-badge {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-pill);
  padding: 1px 7px;
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

/* Cloud → teinte bleue. */
.exec-badge--cloud {
  border-color: rgba(120, 197, 255, 0.34);
  background: color-mix(in srgb, #78c5ff 12%, transparent);
  color: rgba(170, 215, 255, 0.96);
}

/* Local desktop → teinte verte. */
.exec-badge--local-desktop {
  border-color: rgba(134, 239, 172, 0.34);
  background: color-mix(in srgb, #86efac 12%, transparent);
  color: rgba(170, 240, 195, 0.96);
}

/* Local mobile → teinte violette. */
.exec-badge--local-mobile {
  border-color: rgba(199, 123, 255, 0.34);
  background: color-mix(in srgb, #c77bff 12%, transparent);
  color: rgba(214, 178, 255, 0.96);
}

.next-panel li b {
  margin-left: auto;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.next-panel li b:hover {
  border-color: var(--glass-border-hover);
  background: var(--bg-active);
}

.next-panel li b svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
}

/* ── Item stack ── */
.next-item-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
}

.next-item-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-10);
}

/* ── Tool catalog ── */
.next-tool-catalog {
  display: flex;
  flex-direction: column;
  gap: var(--sp-10);
  padding-left: 34px;
}

.next-tool-entry {
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  padding: var(--sp-12);
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.next-tool-topline {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-10);
}

.next-tool-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.next-tool-meta p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.next-tool-meta span {
  margin-top: 2px;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.35;
}

.next-tool-status {
  margin-left: auto;
  flex: 0 0 auto;
  border-radius: var(--r-pill);
  padding: 4px var(--sp-10);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.next-tool-status.is-configured {
  color: rgba(170, 255, 200, 0.92);
  background: rgba(50, 120, 70, 0.20);
  border-color: rgba(132, 255, 170, 0.20);
}

.next-tool-status.is-pending {
  color: rgba(255, 225, 160, 0.92);
  background: rgba(120, 95, 30, 0.18);
  border-color: rgba(255, 210, 100, 0.18);
}

.next-tool-command-grid {
  margin-top: var(--sp-10);
  display: grid;
  gap: var(--sp-6);
}

.next-tool-command-grid code,
.next-tool-binary code {
  font-family: var(--font-mono);
  font-size: 11px;
}

.next-tool-command-grid code {
  display: block;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.30);
  color: var(--text-primary);
  padding: var(--sp-6) var(--sp-8);
  overflow-x: auto;
}

.next-tool-foot {
  margin-top: var(--sp-10);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  color: var(--text-tertiary);
  font-size: 11px;
}

.next-tool-links {
  margin-top: var(--sp-10);
  display: flex;
  gap: var(--sp-8);
}

.next-tool-links a,
.next-tool-links span {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  padding: var(--sp-6) var(--sp-10);
  background: var(--bg-surface);
  backdrop-filter: blur(8px);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.next-tool-links a:hover {
  border-color: var(--glass-border-hover);
  background: var(--bg-active);
}

.next-catalog-view[hidden] { display: none; }

.next-panel-back {
  margin-top: var(--sp-12);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  transition: color var(--transition-fast);
}

.next-panel-back:hover {
  color: var(--accent);
}

.next-catalog-list {
  margin-top: 0;
}

.next-catalog-section + .next-catalog-section {
  margin-top: var(--sp-16);
}

.next-catalog-section-title {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  margin: 0 0 var(--sp-8);
  padding: 0 var(--sp-4);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.next-catalog-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--glass-bg, rgba(255, 255, 255, 0.08));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-tertiary, var(--text-secondary));
}

.next-tool-entry-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
  appearance: none;
  color: inherit;
}

.next-tool-entry-button:hover {
  border-color: var(--glass-border-hover);
  transform: translateY(-1px);
}

.next-empty-state {
  margin-top: var(--sp-12);
  border-radius: var(--r-md);
  border: 1px dashed var(--border-strong);
  padding: var(--sp-16);
  background: var(--bg-hover);
}

.next-empty-state p,
.next-empty-state span { margin: 0; }

.next-empty-state span {
  display: block;
  margin-top: var(--sp-4);
  color: var(--text-tertiary);
  font-size: 12px;
}

/* ══════════════════════════════════════════════════════════════
   PROGRESS CARD (bottom-right)
   ══════════════════════════════════════════════════════════════ */
.progress-card {
  position: absolute;
  right: var(--sp-24);
  bottom: var(--sp-24);
  z-index: 5;
  width: 350px;
  border-radius: var(--r-xl);
  border: 1px solid var(--accent-border);
  background:
    radial-gradient(110% 160% at 0% 100%, rgba(100, 210, 120, 0.35), transparent 65%),
    var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow), var(--accent-glow);
  overflow: hidden;
  /* La carte est ancrée en bas-droite : en grandissant elle s'étend vers le haut. */
  transition:
    width 340ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 240ms ease,
    border-color 240ms ease;
}

.progress-card:not(.is-expanded):hover { border-color: var(--accent); }

.progress-card.is-expanded {
  width: 444px;
  border-color: var(--accent);
  box-shadow:
    var(--glass-shadow),
    0 0 0 1px var(--accent-border),
    0 24px 60px rgba(0, 0, 0, 0.5),
    var(--accent-glow);
}

/* Partie résumé toujours visible — c'est le bouton qui ouvre/ferme. */
.progress-card-summary {
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: transparent;
  border: 0;
  color: inherit;
  padding: var(--sp-16) var(--sp-16) var(--sp-12);
  transition: background 160ms ease;
}
.progress-card-summary:hover { background: rgba(255, 255, 255, 0.03); }
.progress-card-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.progress-card-chevron {
  display: inline-flex;
  width: 15px;
  height: 15px;
  margin-left: 4px;
  color: var(--text-tertiary);
  transition: transform 300ms ease;
}
.progress-card-chevron svg { width: 100%; height: 100%; }
.progress-card.is-expanded .progress-card-chevron { transform: rotate(180deg); }

/* Corps déroulant : clippé à 0 en collapsed, grandit + défile en expanded. */
.progress-card-body {
  max-height: 0;
  overflow-y: auto;
  opacity: 0;
  border-top: 1px solid transparent;
  transition:
    max-height 340ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 220ms ease,
    border-color 220ms ease;
}
.progress-card.is-expanded .progress-card-body {
  max-height: min(72vh, 600px);
  opacity: 1;
  border-top-color: var(--border-subtle);
}
.progress-card-body .activity-scroll { overflow: visible; }
/* Filtres épinglés en haut du corps pendant le défilement. */
.progress-card-body .activity-filters {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(16, 22, 18, 0.94);
  backdrop-filter: var(--glass-blur);
}

.progress-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-12);
}

.progress-head p { margin: 0; min-width: 0; }

.progress-head p span {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.progress-head p strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-metric {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
}

.progress-metric-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.progress-metric-icon svg { width: 100%; height: 100%; }

/* Live: pulse the metric to signal "running now". */
.progress-card[data-state="live"] .progress-metric-label { color: var(--accent); }
.progress-card[data-state="live"] .progress-metric-icon { animation: progress-pulse 1.4s ease-in-out infinite; }

@keyframes progress-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.progress-track {
  position: relative;
  margin-top: var(--sp-12);
  height: 8px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, 0.35);
  overflow: visible;
  border: 1px solid var(--border-subtle);
}

.progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), rgba(89, 226, 124, 0.90));
  box-shadow: 0 0 12px var(--accent-soft);
  transition: width 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-knob {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #eafff0;
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px var(--accent-soft), 0 1px 4px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
  transition: left 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-scale {
  margin-top: var(--sp-10);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
}

/* Journal des agents : la barre de progression (jauge + échelle 0-100 %) ne sert
   à rien pour lire ce que les agents ont fait — on la retire du pill. */
.progress-card .progress-track,
.progress-card .progress-scale { display: none; }

/* Compteur « non lus » mis en avant sur le pill quand des runs t'attendent. */
.progress-card.has-unread .progress-metric-label {
  color: #06231a;
  background: var(--accent);
  padding: 1px 8px;
  border-radius: var(--r-pill);
  font-weight: 700;
}
.progress-card.has-unread .progress-metric-icon { color: var(--accent); animation: progress-pulse 1.4s ease-in-out infinite; }

/* ══════════════════════════════════════════════════════════════
   ACTIVITY — contenu du corps de la carte (filtres, à venir, runs)
   ══════════════════════════════════════════════════════════════ */
.activity-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: var(--sp-12) var(--sp-20);
  border-bottom: 1px solid var(--border-subtle);
}
.activity-chip {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 140ms ease;
}
.activity-chip:hover { color: var(--text-bright); border-color: var(--accent-border); }
.activity-chip.active {
  background: var(--accent-soft, rgba(89, 226, 124, 0.18));
  border-color: var(--accent);
  color: var(--accent);
}

.activity-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-16) var(--sp-20) var(--sp-24);
}
.activity-section { margin-bottom: var(--sp-20); }
.activity-section-title {
  margin: 0 0 var(--sp-10);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.activity-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--accent-soft, rgba(89, 226, 124, 0.18));
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.activity-upcoming { display: flex; flex-direction: column; gap: 6px; }
.activity-upcoming-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-md, 10px);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
}
.activity-upcoming-spec { color: var(--text-bright); font-family: var(--font-mono); }
.activity-upcoming-agents { margin-left: auto; color: var(--text-tertiary); }

.activity-runs { display: flex; flex-direction: column; gap: 6px; }
.activity-run {
  border-radius: var(--r-md, 10px);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
  transition: border-color 160ms ease;
}
.activity-run.expanded { border-color: var(--accent-border); }
.activity-run-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
}
.activity-run-row:hover { background: rgba(255, 255, 255, 0.03); }

.activity-status-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-tertiary);
}
.activity-status-dot.success { background: var(--accent); box-shadow: 0 0 8px var(--accent-soft); }
.activity-status-dot.error { background: #ff6b6b; box-shadow: 0 0 8px rgba(255, 107, 107, 0.5); }
.activity-status-dot.stopped { background: #f0b440; }
.activity-status-dot.running {
  background: var(--accent);
  animation: progress-pulse 1.2s ease-in-out infinite;
}

.activity-run-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.activity-run-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.activity-run-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Badge « nouveau » sur un run fait en ton absence. */
.activity-run-new {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #06231a;
  background: var(--accent);
  padding: 1px 6px;
  border-radius: var(--r-pill);
}
.activity-run-msg {
  font-size: 11.5px;
  color: var(--text-secondary);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}
/* Run non lu : liseré d'accent + fond très légèrement teinté. */
.activity-run.is-unread {
  border-color: var(--accent-border);
  box-shadow: inset 3px 0 0 var(--accent);
}
.activity-run.is-unread .activity-run-msg { color: var(--text-bright); }
.activity-run-meta {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.activity-run-time { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; }

.activity-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.activity-badge.trigger-cron { color: #7fd0ff; border-color: rgba(127, 208, 255, 0.3); }
.activity-badge.trigger-webhook { color: #c79bff; border-color: rgba(199, 155, 255, 0.3); }
.activity-badge.trigger-geoloc { color: #ff9b9b; border-color: rgba(255, 155, 155, 0.3); }
.activity-badge.trigger-autonomous_loop { color: var(--accent); border-color: var(--accent-border); }
.activity-badge.trigger-agent_chain { color: #ffd27f; border-color: rgba(255, 210, 127, 0.3); }
.activity-badge.trigger-manual { color: var(--text-secondary); }

.activity-run-detail {
  padding: 4px 12px 12px;
  border-top: 1px solid var(--border-subtle);
}
.activity-run-error {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: var(--r-md, 10px);
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ff9b9b;
  font-size: 12px;
}
.activity-run-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 8px 0;
  font-size: 11px;
  color: var(--text-secondary);
}
.activity-run-facts b { color: var(--text-tertiary); font-weight: 600; margin-right: 4px; }

/* Détail d'un run : déclencheur + réponse finale (le cœur de ce qu'on veut lire). */
.activity-run-block { margin: 10px 0; }
.activity-run-block-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.activity-run-trigger {
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--r-md, 10px);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.activity-run-response {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r-md, 10px);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--accent-border);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-bright);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow-y: auto;
}
.activity-run-response-empty { margin: 10px 0; font-size: 12px; color: var(--text-tertiary); }

/* Détails techniques : repliés par défaut (étapes / outils / timeline). */
.activity-run-tech { margin-top: 10px; }
.activity-run-tech > summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  list-style: none;
  user-select: none;
  padding: 4px 0;
}
.activity-run-tech > summary::-webkit-details-marker { display: none; }
.activity-run-tech > summary::before { content: "▸ "; }
.activity-run-tech[open] > summary::before { content: "▾ "; }
.activity-run-tech > summary:hover { color: var(--text-secondary); }

.activity-timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.activity-timeline li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  font-size: 11px;
  border-left: 2px solid var(--border-subtle);
  padding-left: 10px;
}
.activity-timeline .ev-time { color: var(--text-tertiary); font-family: var(--font-mono); flex-shrink: 0; }
.activity-timeline .ev-name { color: var(--text-bright); font-weight: 600; flex-shrink: 0; }
.activity-timeline .ev-detail {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-empty { color: var(--text-tertiary); font-size: 13px; text-align: center; padding: var(--sp-20); }

/* ══════════════════════════════════════════════════════════════
   BOTTOM ACTIONS BAR
   ══════════════════════════════════════════════════════════════ */
.bottom-actions {
  position: absolute;
  bottom: var(--sp-20);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-6);
  border-radius: var(--r-lg);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  padding: 3px;
  padding-right: var(--sp-8);
}

.bottom-actions button,
.bottom-actions span {
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 11px var(--sp-16);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-ui);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.bottom-actions button.is-active {
  background: var(--bg-active);
  border: 1px solid var(--border);
  color: var(--text-bright);
}

.bottom-actions button {
  cursor: pointer;
}

.bottom-actions button:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.bottom-actions .zoom-btn {
  padding: var(--sp-6);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
}

.bottom-actions .zoom-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ══════════════════════════════════════════════════════════════
   EXECUTION CHAT PANEL
   ══════════════════════════════════════════════════════════════ */
.execution-chat-panel {
  position: absolute;
  /* Décalé de la gauche pour laisser la colonne d'onglets (dock) bas-gauche respirer. */
  left: calc(var(--sp-24) + 52px + var(--sp-16));
  /* Un peu plus haut (démarre plus haut → plus grand) et ancré en bas. */
  top: calc(var(--sp-24) + 52px + var(--sp-12));
  bottom: var(--sp-24);
  z-index: 6;
  width: min(600px, calc(100vw - 48px));
  border-radius: var(--r-xl);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom left;
  transition:
    width 0.22s ease,
    transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.22s ease,
    visibility 0s linear 0s;
}


.execution-chat-panel[hidden] {
  display: flex;
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  pointer-events: none;
  visibility: hidden;
  transition:
    width 0.22s ease,
    transform 0.2s cubic-bezier(0.4, 0, 1, 1),
    opacity 0.18s ease,
    visibility 0s linear 0.2s;
}

.execution-chat-restore {
  position: absolute;
  left: var(--sp-24);
  /* Pile bottom-left : settings (24px) puis ce bouton juste au-dessus (84px) — ancien emplacement des lunettes, retirées. */
  bottom: calc(var(--sp-24) + 52px + var(--sp-8));
  z-index: 6;
  width: 52px;
  height: 52px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  color: var(--text-secondary);
  cursor: pointer;
  transform-origin: bottom left;
  transition:
    color var(--transition-fast),
    border-color var(--transition-fast),
    background var(--transition-fast),
    transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.18s ease,
    visibility 0s linear 0s;
}

.execution-chat-restore[hidden] {
  display: grid;
  opacity: 0;
  transform: translateY(10px) scale(0.85);
  pointer-events: none;
  visibility: hidden;
  transition:
    transform 0.18s cubic-bezier(0.4, 0, 1, 1),
    opacity 0.15s ease,
    visibility 0s linear 0.18s;
}

.execution-chat-restore:hover {
  color: var(--text-bright);
  border-color: var(--glass-border-hover);
}

.execution-chat-restore svg {
  width: 22px;
  height: 22px;
}

/* ── Dock d'onglets (bas-gauche) : panneaux réduits ── */
.panel-dock {
  position: absolute;
  left: var(--sp-24);
  bottom: var(--sp-24);
  /* Au-dessus des fenêtres de chat (z ~40+ au focus) pour rester cliquable + popover visible. */
  z-index: 100;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-8);
}

.panel-dock[hidden] { display: none; }

/* Onglets du dock : boutons CARRÉS (arrondis), comme les autres boutons. */
.panel-dock-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.panel-dock-tab:hover {
  color: var(--text-bright);
  border-color: var(--glass-border-hover);
}

.panel-dock-tab-icon {
  display: inline-flex;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  color: var(--kind-color, var(--text-secondary));
}

.panel-dock-tab-icon svg { width: 22px; height: 22px; }

/* Nom du node : popover latéral à droite, visible uniquement au survol de l'onglet. */
.panel-dock-tab-label {
  position: absolute;
  left: calc(100% + var(--sp-8));
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  color: var(--text-bright);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  z-index: 2;
}

.panel-dock-tab:hover .panel-dock-tab-label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.execution-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-12);
  padding: 8px 8px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  cursor: move;
}

.execution-chat-head-left {
  display: flex;
  align-items: center;
  gap: 1;
  min-width: 0;
  flex: 1 1 auto;
}

.execution-chat-head-right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-shrink: 0;
}

.execution-chat-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  padding: 0;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.execution-chat-icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Croix de fermeture : teinte rouge au survol (toutes les fenêtres, primary comprise). */
.execution-chat-close:hover {
  color: #ff6b6b;
}

.execution-chat-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-bright);
  border-color: var(--border-subtle);
}

.execution-chat-icon-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}

.execution-chat-ephemeral:disabled {
  opacity: 0.45;
  cursor: default;
}

.execution-chat-agent-picker-wrap {
  position: relative;
  min-width: 0;
  flex: 1 1 auto;
}

.execution-chat-agent-picker {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-6);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--text-bright);
  padding: 8px 10px 8px 14px;
  cursor: pointer;
  max-width: 100%;
  min-width: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.execution-chat-agent-picker:hover {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

.execution-chat-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.execution-chat-picker-chevron {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: transform 0.18s ease;
}

.execution-chat-panel.is-picker-open .execution-chat-picker-chevron {
  transform: rotate(180deg);
}

.execution-chat-agent-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 4;
  min-width: 240px;
  max-width: 360px;
  max-height: 320px;
  overflow-y: auto;
  border-radius: var(--r-md);
  border: none;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  padding: var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-color: var(--border-strong) transparent;
}

.execution-chat-agent-menu::-webkit-scrollbar-track {
  background: transparent;
}

.execution-chat-agent-menu::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
}

.execution-chat-agent-menu::-webkit-scrollbar-thumb:hover {
  background: var(--glass-border-hover, var(--border-strong));
}

.execution-chat-agent-menu[hidden] { display: none; }

.execution-chat-agent-menu-empty {
  margin: 0;
  padding: var(--sp-12);
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
}

.execution-chat-agent-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: var(--sp-8) var(--sp-10);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.execution-chat-agent-option:hover {
  background: var(--bg-hover);
}

.execution-chat-agent-option.is-active {
  background: transparent;
  border-color: transparent;
}

.execution-chat-agent-option.is-active .execution-chat-agent-option-name {
  color: var(--accent);
}

.execution-chat-agent-option-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
}

.execution-chat-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.execution-chat-rail {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 50%;
  z-index: 10;
  padding: var(--sp-12) var(--sp-10);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  scrollbar-color: var(--border-strong) transparent;
  animation: execution-chat-rail-slide 0.18s ease-out both;
}

.execution-chat-rail::-webkit-scrollbar-track {
  background: transparent;
}

.execution-chat-rail::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
}

.execution-chat-rail::-webkit-scrollbar-thumb:hover {
  background: var(--glass-border-hover, var(--border-strong));
}

.execution-chat-rail[hidden] { display: none; }

@keyframes execution-chat-rail-slide {
  from {
    transform: translateX(-12px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.execution-chat-rail-head {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  padding: 0 var(--sp-2);
  margin-bottom: var(--sp-6);
}

.execution-chat-rail-head .execution-chat-rail-title {
  flex: 1 1 auto;
}

.execution-chat-rail-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.execution-chat-rail-close:hover {
  background: var(--bg-hover);
  color: var(--text-bright);
  border-color: var(--border-strong);
}

.execution-chat-rail-close svg {
  width: 14px;
  height: 14px;
}

.execution-chat-rail-title {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.execution-chat-rail-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.execution-chat-rail-new:hover {
  background: var(--bg-hover);
  color: var(--text-bright);
  border-color: var(--border-strong);
}

.execution-chat-rail-new svg {
  width: 14px;
  height: 14px;
}

.execution-chat-rail-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.execution-chat-rail-empty {
  margin: 0;
  padding: var(--sp-8);
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

.execution-chat-rail-option {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  width: 100%;
  padding: var(--sp-6) var(--sp-8);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
}

.execution-chat-rail-option:hover {
  background: var(--bg-hover);
}

.execution-chat-rail-option.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.execution-chat-rail-option-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  text-align: left;
}

.execution-chat-rail-option-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.execution-chat-rail-option-kind {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.execution-chat-rail-option-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

.execution-chat-rail-option:hover .execution-chat-rail-option-actions,
.execution-chat-rail-option:focus-within .execution-chat-rail-option-actions {
  opacity: 1;
}

.execution-chat-rail-option-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: var(--r-xs);
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.execution-chat-rail-option-action:hover {
  background: var(--bg-hover);
  color: var(--text-bright);
}

.execution-chat-rail-option-action.is-danger:hover {
  background: rgba(220, 80, 80, 0.18);
  color: rgb(240, 130, 130);
}

.execution-chat-rail-option-action svg {
  width: 13px;
  height: 13px;
}

.execution-chat-rail-option.is-renaming {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

.execution-chat-rail-option-rename {
  flex: 1 1 auto;
  display: flex;
}

.execution-chat-rail-option-rename-input {
  flex: 1 1 auto;
  width: 100%;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-xs);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-bright);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  outline: none;
}

.execution-chat-rail-option-rename-input:focus {
  border-color: var(--accent-border);
}

.execution-chat-rail-toggle[hidden] { display: none; }

.execution-chat-phone[hidden] { display: none; }

.execution-chat-phone[aria-pressed="true"] {
  background: rgba(120, 200, 240, 0.18);
  color: rgb(160, 220, 250);
  border-color: rgba(120, 200, 240, 0.55);
}

.execution-chat-phone:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.execution-chat-ghost[aria-pressed="true"] {
  background: rgba(180, 160, 230, 0.18);
  color: rgb(200, 180, 240);
  border-color: rgba(180, 160, 230, 0.55);
}

.execution-chat-panel.is-ephemeral-locked .execution-chat-ghost,
.execution-chat-ghost:disabled {
  background: rgba(180, 160, 230, 0.22);
  color: rgb(210, 190, 245);
  border-color: rgba(180, 160, 230, 0.7);
  cursor: not-allowed;
  opacity: 1;
}

.execution-chat-panel.is-ephemeral-locked .execution-chat-ghost:hover,
.execution-chat-ghost:disabled:hover {
  background: rgba(180, 160, 230, 0.22);
  color: rgb(210, 190, 245);
  border-color: rgba(180, 160, 230, 0.7);
}

.execution-chat-panel.is-ephemeral {
  border-color: rgba(180, 160, 230, 0.45);
  box-shadow: var(--glass-shadow), 0 0 0 1px rgba(180, 160, 230, 0.25) inset;
}

.execution-chat-panel.is-ephemeral .execution-chat-form {
  border-color: rgba(180, 160, 230, 0.45);
}

.execution-chat-panel.is-ephemeral .execution-chat-input::placeholder {
  color: rgba(200, 180, 240, 0.7);
}

.execution-chat-panel.is-ephemeral .execution-chat-send {
  background: rgba(180, 160, 230, 0.18);
  border-color: rgba(180, 160, 230, 0.55);
  color: rgb(200, 180, 240);
}

.execution-chat-panel.is-ephemeral .execution-chat-send:hover {
  background: rgba(180, 160, 230, 0.28);
  box-shadow: 0 0 18px rgba(180, 160, 230, 0.35);
}

.execution-chat-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-16) var(--sp-20);
  display: flex;
  flex-direction: column;
  gap: var(--sp-10);
  scrollbar-color: var(--border-strong) transparent;
}

.execution-chat-thread::-webkit-scrollbar-track {
  background: transparent;
}

.execution-chat-thread::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
}

.execution-chat-thread::-webkit-scrollbar-thumb:hover {
  background: var(--glass-border-hover, var(--border-strong));
}

.execution-chat-empty {
  margin: auto 0;
  padding: var(--sp-24) var(--sp-16);
  text-align: center;
}

.execution-chat-empty p,
.execution-chat-empty span {
  margin: 0;
  color: var(--text-tertiary);
  font-size: 13px;
}

.execution-chat-empty span {
  display: block;
  margin-top: var(--sp-4);
  font-size: 12px;
  line-height: 1.4;
}

.execution-chat-empty-recents {
  width: min(100%, 390px);
  margin: 28px auto 0;
}

.execution-chat-empty .execution-chat-empty-recents-label {
  margin: 0 0 9px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.execution-chat-empty-recents-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.execution-chat-empty-recent {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.execution-chat-empty-recent:hover {
  color: var(--text-bright);
  border-color: var(--accent-border);
  background: var(--accent-softer);
  transform: translateY(-1px);
}

.execution-chat-empty-recent > span {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: inherit;
  font-size: 12.5px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.execution-chat-empty-recent > small {
  flex: 0 0 auto;
  color: var(--text-tertiary);
  font-size: 10.5px;
  white-space: nowrap;
}

/* ── Chat messages ── */
.execution-chat-message {
  max-width: 85%;
  border-radius: var(--r-lg);
  padding: var(--sp-10) var(--sp-12);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  border: 1px solid var(--border-subtle);
  background: var(--bg-hover);
  backdrop-filter: blur(8px);
}

.execution-chat-message-user {
  align-self: flex-end;
  background: var(--accent-softer);
  border-color: rgba(132, 255, 170, 0.10);
  border-radius: var(--r-lg) var(--r-lg) var(--sp-4) var(--r-lg);
}

/* Messages de l'agent : pas de bulle (ni bordure ni fond), pleine largeur,
   texte posé directement sur le fond de la discussion — comme l'app iOS.
   Les messages user gardent leur bulle. */
.execution-chat-message-assistant {
  align-self: stretch;
  max-width: 100%;
  border: none;
  background: transparent;
  backdrop-filter: none;
  border-radius: 0;
  padding: var(--sp-4) 0;
}

.execution-chat-message-tool {
  align-self: flex-start;
  max-width: 100%;
  background: rgba(100, 200, 230, 0.05);
  border-color: rgba(100, 200, 230, 0.08);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) var(--sp-4);
}

/* ── Tool trace : repliable, sans bulle, texte brut ── */
.execution-chat-tool-trace {
  align-self: stretch;
  max-width: 100%;
  background: transparent;
  border: none;
  padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-6);
  margin: 0;
}

.execution-chat-tool-trace-summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: var(--sp-6);
  user-select: none;
  outline: none;
  padding: 2px 0;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.execution-chat-tool-trace-summary::-webkit-details-marker {
  display: none;
}

.execution-chat-tool-trace-summary::before {
  content: "▸";
  font-size: 9px;
  color: var(--text-quaternary, var(--text-tertiary));
  flex-shrink: 0;
  transition: transform var(--transition-fast);
  display: inline-block;
}

.execution-chat-tool-trace[open] > .execution-chat-tool-trace-summary {
  white-space: normal;
}

.execution-chat-tool-trace[open] > .execution-chat-tool-trace-summary::before {
  transform: rotate(90deg);
}

.execution-chat-tool-trace-summary:hover {
  color: var(--text-secondary);
}

.execution-chat-tool-trace-body {
  margin-top: var(--sp-6);
  padding-left: var(--sp-12);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.execution-chat-tool-step {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.85;
}

/* ── Statut pending (placeholder permanent en bas du thread) ── */
.execution-chat-pending {
  align-self: stretch;
  max-width: 100%;
  background: transparent;
  border: none;
  padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-6);
  margin: 0;
}

.execution-chat-pending-summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  user-select: none;
  outline: none;
  padding: 2px 0;
  line-height: 1.4;
}

.execution-chat-pending-summary::-webkit-details-marker {
  display: none;
}

.execution-chat-pending-summary::after {
  content: "▸";
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
  line-height: 1;
}

.execution-chat-pending[open] > .execution-chat-pending-summary::after {
  transform: rotate(90deg);
}

.execution-chat-pending-summary:hover {
  color: var(--text-primary);
}

.execution-chat-pending-spinner {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: execution-chat-pending-spin 0.9s linear infinite;
  opacity: 0.6;
}

.execution-chat-pending[data-pending-kind="tool"] .execution-chat-pending-spinner {
  border-color: var(--accent-primary, currentColor);
  border-top-color: transparent;
  opacity: 0.8;
}

.execution-chat-pending-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.execution-chat-pending[open] .execution-chat-pending-label {
  white-space: normal;
}

.execution-chat-pending-body {
  margin-top: var(--sp-6);
  padding-left: var(--sp-12);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.85;
}

@keyframes execution-chat-pending-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Entrée archivée (étape terminée — réflexion ou tool) ── */
.execution-chat-status {
  align-self: stretch;
  max-width: 100%;
  background: transparent;
  border: none;
  padding: var(--sp-2) var(--sp-4) var(--sp-2) var(--sp-6);
  margin: 0;
}

.execution-chat-status-summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--text-tertiary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  user-select: none;
  outline: none;
  padding: 2px 0;
  line-height: 1.4;
}

.execution-chat-status-summary::-webkit-details-marker {
  display: none;
}

.execution-chat-status-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.execution-chat-status[open] > .execution-chat-status-summary .execution-chat-status-chevron {
  transform: rotate(90deg);
}

.execution-chat-status-summary:hover {
  color: var(--text-secondary);
}


.execution-chat-status-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.execution-chat-status[open] .execution-chat-status-label {
  white-space: normal;
}

.execution-chat-status-body {
  margin-top: var(--sp-4);
  padding-left: var(--sp-12);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.85;
}

/* ── Artefacts (image / vidéo / audio / autre) rendus sous le message ── */
.execution-chat-medias {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  margin-top: var(--sp-6);
}

.execution-chat-media {
  display: block;
  border-radius: var(--r-md);
  overflow: hidden;
  max-width: 320px;
}

.execution-chat-media-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r-md);
}

.execution-chat-media-video,
.execution-chat-media-audio {
  width: 100%;
  max-width: 320px;
  border-radius: var(--r-md);
  background: var(--bg-surface);
}

.execution-chat-media-audio {
  height: 40px;
}

.execution-chat-media-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-8) var(--sp-10);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.execution-chat-media-link:hover {
  background: var(--bg-hover);
  border-color: var(--glass-border-hover);
}

.execution-chat-media-link-name {
  font-size: 13px;
  font-weight: 500;
}

.execution-chat-media-link-meta {
  font-size: 11px;
  color: var(--text-tertiary);
}

.execution-chat-role {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.execution-chat-message p {
  margin: 0;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Markdown par blocs (réponses de l'agent) ── */
.execution-chat-md-h {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
  margin: var(--sp-8) 0 var(--sp-2);
}
.execution-chat-md-h1 { font-size: 20px; }
.execution-chat-md-h2 { font-size: 17px; }
.execution-chat-md-h3 { font-size: 15px; }
.execution-chat-md-h4,
.execution-chat-md-h5,
.execution-chat-md-h6 { font-size: 14px; }

.execution-chat-md-hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--sp-10) 0;
}

.execution-chat-md-list {
  margin: var(--sp-4) 0;
  padding-left: 20px;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}
.execution-chat-md-list li {
  margin: 2px 0;
  word-break: break-word;
}

.execution-chat-md-code {
  margin: var(--sp-6) 0;
  padding: var(--sp-10) var(--sp-12);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow-x: auto;
}
.execution-chat-md-code code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: var(--text-primary);
  white-space: pre;
}

.execution-chat-md-table {
  border-collapse: collapse;
  width: 100%;
  margin: var(--sp-6) 0;
  font-size: 13px;
}
.execution-chat-md-table th,
.execution-chat-md-table td {
  text-align: left;
  padding: var(--sp-6) var(--sp-8);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: top;
}
.execution-chat-md-table th {
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

/* ── Chat form ── */
.execution-chat-form {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-4);
  margin: 0 var(--sp-12) var(--sp-10);
  padding: 5px 5px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  backdrop-filter: blur(8px);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.execution-chat-form:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 2px var(--accent-softer);
}

.execution-chat-form .execution-chat-input {
  flex: 1 1 auto;
  min-width: 0;
}

.execution-chat-attach,
.execution-chat-mic,
.execution-chat-voice-mode {
  width: 32px;
  height: 32px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.execution-chat-attach[hidden],
.execution-chat-mic[hidden],
.execution-chat-voice-mode[hidden] { display: none; }

.execution-chat-attach svg,
.execution-chat-mic svg,
.execution-chat-voice-mode svg {
  width: 16px;
  height: 16px;
}

.execution-chat-attach:hover,
.execution-chat-mic:hover,
.execution-chat-voice-mode:hover {
  color: var(--text-bright);
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

.execution-chat-mic.is-recording {
  background: rgba(255, 90, 90, 0.18);
  border-color: rgba(255, 90, 90, 0.6);
  color: rgb(255, 130, 130);
  animation: chat-mic-pulse 1.4s ease-in-out infinite;
}

.execution-chat-voice-mode.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  animation: chat-voice-mode-pulse 1.6s ease-in-out infinite;
}

@keyframes chat-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 90, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(255, 90, 90, 0); }
}

@keyframes chat-voice-mode-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

.execution-chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-6);
  padding: 0 var(--sp-16);
  margin-top: var(--sp-8);
}

.execution-chat-attachments[hidden] { display: none; }

.execution-chat-attachment {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-6);
  padding: var(--sp-4) var(--sp-8);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-hover);
  font-size: 12px;
  color: var(--text-primary);
  max-width: 220px;
}

.execution-chat-attachment-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.execution-chat-attachment-remove {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.execution-chat-attachment-remove:hover {
  background: var(--bg-surface);
  color: var(--text-bright);
}

.execution-chat-input {
  min-height: 32px;
  max-height: 168px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--text-primary);
  padding: 6px var(--sp-8);
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  resize: none;
  overflow-y: auto;
  transition: none;
}

.execution-chat-input::placeholder {
  color: var(--text-tertiary);
  font-size: 14px;
}

.execution-chat-input:focus {
  outline: none;
  box-shadow: none;
}

.execution-chat-send {
  width: 32px;
  height: 32px;
  border-radius: 14px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.execution-chat-send svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.execution-chat-send:hover {
  background: rgba(132, 255, 170, 0.18);
  box-shadow: var(--accent-glow);
  transform: scale(1.05);
}

.execution-chat-send:active {
  transform: scale(0.95);
}

/* ── Chat inline selectors (Tools / Skills / Projet) ──
   Affichés juste au-dessus de l'input prompt → dropdowns s'ouvrent vers le bas. */
.execution-chat-selectors {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-12);
  margin: 0 var(--sp-12) var(--sp-6);
  padding: 0 var(--sp-6);
}

.execution-chat-selector-wrap {
  position: relative;
}

.execution-chat-selector {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text-tertiary);
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.execution-chat-selector:hover {
  color: var(--text-bright);
}

.execution-chat-selector.has-selection {
  color: var(--text-primary);
}

.execution-chat-selector.is-empty .execution-chat-selector-label {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  opacity: 0.55;
}

.execution-chat-selector-chevron {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.execution-chat-selector[aria-expanded="true"] .execution-chat-selector-chevron {
  transform: rotate(180deg);
}

.execution-chat-selector-menu {
  position: absolute;
  /* Tous les sélecteurs déroulent VERS LE HAUT (au-dessus du bouton). */
  bottom: calc(100% + 6px);
  top: auto;
  left: 0;
  min-width: 200px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: none;
  border-radius: var(--r-md);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.28);
  padding: var(--sp-8) var(--sp-4);
  z-index: 20;
}

.execution-chat-selector-menu[hidden] {
  display: none;
}

.execution-chat-selector-option {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  width: 100%;
  padding: var(--sp-4) var(--sp-8);
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.execution-chat-selector-option:hover {
  background: var(--bg-hover);
}

.execution-chat-selector-option.is-selected {
  color: var(--accent);
}

.execution-chat-selector-option-check {
  display: inline-flex;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--accent);
}

.execution-chat-selector-option-check[data-empty="true"] {
  visibility: hidden;
}

.execution-chat-selector-empty {
  padding: var(--sp-4) var(--sp-8);
  color: var(--text-tertiary);
  font-size: 12px;
}

/* Étiquette de section dans un menu combiné (ex. « Modèle » / « Raisonnement » du sélecteur modèle). */
.execution-chat-selector-section {
  padding: var(--sp-6) var(--sp-8) var(--sp-2);
  margin: 0;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.execution-chat-selector-divider {
  height: 1px;
  margin: var(--sp-6) var(--sp-6);
  background: var(--border-subtle);
}

/* ── Popover du bouton « Joindre » (projets rattachés + fichiers de l'ordinateur) ── */
.execution-chat-attach-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.execution-chat-attach-wrap[hidden] {
  display: none;
}

.execution-chat-attach-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  top: auto;
  left: 0;
  min-width: 220px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: none;
  border-radius: var(--r-md);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.28);
  padding: var(--sp-8) var(--sp-4);
  z-index: 20;
}

.execution-chat-attach-menu[hidden] {
  display: none;
}

.execution-chat-attach-option {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  width: 100%;
  padding: var(--sp-6) var(--sp-8);
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.execution-chat-attach-option:hover {
  background: var(--bg-hover);
}

.execution-chat-attach-option.is-selected {
  color: var(--accent);
}

.execution-chat-attach-option svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.execution-chat-attach-empty {
  padding: var(--sp-4) var(--sp-8);
  color: var(--text-tertiary);
  font-size: 12px;
}

/* ══════════════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════════════ */
@keyframes edge-pulse {
  0%, 100% { opacity: 0.10; }
  50%      { opacity: 0.18; }
}

@keyframes node-in {
  from { opacity: 0; transform: scale(0.96) rotate(var(--node-tilt, 0deg)); }
  to   { opacity: 1; transform: scale(1) rotate(var(--node-tilt, 0deg)); }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 1440px) {
  .node-title { font-size: 18px; }
  .next-panel { width: 320px; }
  .next-panel h2 { font-size: 32px; }
}

@media (max-width: 1200px) {
  .graph-node { width: 272px; }
}

@media (max-width: 940px) {
  .sync-indicator {
    top: 14px;
    right: 170px;
  }

  .mode-tabs {
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
  }

  .view-controls {
    top: var(--sp-16);
    right: var(--sp-16);
  }

  .detail-agent-header {
    top: var(--sp-16);
    left: calc(var(--sp-16) + 52px + var(--sp-12));
    gap: var(--sp-12);
    max-width: min(380px, calc(100vw - 100px));
  }

  .detail-agent-topline { gap: var(--sp-10); }
  .detail-agent-title { font-size: 26px; }

  .detail-agent-handle { font-size: 17px; }

  .detail-agent-role {
    padding: var(--sp-6) var(--sp-10);
    font-size: 11px;
  }

  .graph-node { width: 238px; }
  .node-title { font-size: 16px; }

  .progress-card { width: 292px; }
  .progress-head p strong { font-size: 16px; }

  .execution-chat-panel {
    left: var(--sp-16);
    top: calc(var(--sp-16) + 52px + var(--sp-12));
    bottom: var(--sp-16);
    width: min(400px, calc(100vw - 34px));
  }

  .projects-modal {
    right: var(--sp-16);
    top: calc(var(--sp-16) + 52px + var(--sp-12));
    /* Plafond seulement : se dimensionne au contenu, scroll interne au-delà. */
    max-height: calc(100vh - var(--sp-16) - 52px - var(--sp-12) - var(--sp-24) - 110px - var(--sp-12));
    width: min(400px, calc(100vw - 34px));
  }
}

@media (max-width: 760px) {
  .mode-tabs { display: none; }

  .settings-choice-grid {
    grid-template-columns: 1fr;
  }

  .settings-choice-card-body {
    min-height: 0;
  }

  .view-controls {
    top: var(--sp-16);
    right: var(--sp-16);
  }

  .detail-agent-header {
    top: calc(var(--sp-12) + 60px + var(--sp-12));
    left: var(--sp-12);
    right: var(--sp-12);
    gap: var(--sp-12);
    max-width: none;
  }

  .detail-agent-title { font-size: 27px; }

  .execution-chat-panel {
    left: var(--sp-12);
    right: var(--sp-12);
    top: 70px;
    bottom: 82px;
    width: auto;
  }

  .projects-modal {
    left: var(--sp-12);
    right: var(--sp-12);
    top: 70px;
    /* Plafond seulement (max-height), pas de bottom : se rétrécit au contenu. */
    max-height: calc(100vh - 70px - 82px);
    width: auto;
  }

  .execution-chat-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .detail-agent-handle { font-size: 17px; }
  .detail-agent-role { margin-top: 2px; }

  .bottom-actions {
    left: var(--sp-12);
    right: var(--sp-12);
    transform: none;
    width: auto;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .progress-card {
    left: var(--sp-12);
    right: var(--sp-12);
    width: auto;
    bottom: 136px;
  }

  .sync-indicator {
    top: 58px;
    right: var(--sp-12);
    font-size: 10px;
    padding: var(--sp-6) var(--sp-10);
  }
}

/* ══════════════════════════════════════════════════════════════
   PROJECTS — toggle button + modal
   ══════════════════════════════════════════════════════════════ */
.projects-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  height: 52px;
  padding: 0 var(--sp-16);
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.projects-toggle:hover {
  color: var(--text-bright);
  border-color: var(--glass-border-hover);
}

.projects-toggle-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  background: var(--bg-active);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.projects-toggle-count.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.projects-modal {
  position: absolute;
  right: var(--sp-24);
  top: calc(var(--sp-24) + 52px + var(--sp-16));
  /* Plafond aligné sur .next-panel : laisse la place au progress-card (~110px + offset 24px + 12px).
     Pas de `bottom` → le panel se dimensionne au contenu et n'occupe la hauteur max que si
     la liste de projets dépasse. */
  max-height: calc(100vh - var(--sp-24) - 52px - var(--sp-16) - var(--sp-24) - 110px - var(--sp-12));
  z-index: 6;
  width: min(420px, calc(100vw - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-xl);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
}

.projects-modal[hidden] {
  display: none;
}

.side-panel-head {
  /* Padding latéral 18px : aligné avec .next-panel pour que titre et search se positionnent au même endroit. */
  padding: 16px 16px 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-12);
}

.side-panel-head-copy {
  min-width: 0;
}

.side-panel-head .model-editor-eyebrow {
  margin: 0 0 var(--sp-4);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.side-panel-title {
  margin: 0;
  /* Aligné sur .next-panel h2 ("What should we add?") pour cohérence visuelle. */
  font-size: 20px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.01em;
}

/* Spacing de l'input de recherche dans le panneau Projets (en dehors du body scrollable
   pour rester pinné en haut, comme le titre). Marge latérale 18px alignée sur .next-panel. */
.projects-modal-search {
  margin: 0 18px 0;
}

.side-panel-head-action {
  appearance: none;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--text-bright);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.side-panel-head-action-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.side-panel-head-action:hover {
  background: var(--accent);
  color: var(--bg-base, #0b0f14);
  border-color: var(--accent);
}

.side-panel-body {
  /* `flex: 0 1 auto` plutôt que `1 1 auto` : ne grandit pas au-delà du contenu.
     Sinon le body remplissait toute la hauteur autorisée par max-height même avec peu de projets. */
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  /* Padding latéral 18px aligné sur .next-panel (titre + search + items au même endroit horizontalement). */
  padding: var(--sp-16) 18px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
}

.projects-modal-list {
  display: grid;
  /* Une seule colonne qui remplit toute la largeur du panneau ; le `minmax(0, 1fr)` autorise
     les enfants à shrink-down (sinon le contenu textuel impose sa taille et l'ellipsis ne s'applique pas). */
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.projects-modal-empty {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
  border: 1px dashed var(--border);
  border-radius: 14px;
}

/* Lignes de projet stylées comme .next-panel li (sans bordure noire, hover discret). */
.projects-modal-row {
  display: flex;
  align-items: center;
  gap: var(--sp-16);
  padding: var(--sp-8) var(--sp-6);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.projects-modal-row:hover {
  background: var(--bg-hover);
}

.projects-modal-row:focus-visible {
  outline: none;
  border-color: var(--accent-border);
}

/* min-width: 0 + flex: 1 nécessaire pour que text-overflow: ellipsis fonctionne dans un flex
   sinon le contenu textuel pousse la colonne plus large que prévu et déborde verticalement. */
.projects-modal-row > .next-item-copy {
  flex: 1 1 0;
  min-width: 0;
}

.projects-modal-row .next-item-copy p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.projects-modal-row .next-item-copy span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Bouton d'édition à droite : même boîte 42×42 que le chevron des items du panneau de nodes. */
.projects-modal-row > b {
  margin-left: auto;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.projects-modal-row > b:hover,
.projects-modal-row:hover > b {
  border-color: var(--glass-border-hover);
  background: var(--bg-active);
  color: var(--text-bright);
}

.projects-modal-row > b svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Actions inline (pinceau édit + poubelle au hover) sur les lignes Projets / Apps. */
.projects-modal-row-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
}
.projects-modal-row-action {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
}
.projects-modal-row-action:hover {
  border-color: var(--glass-border-hover);
  background: var(--bg-active);
  color: var(--text-bright);
}
.projects-modal-row-action svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Le pinceau (édit) reste toujours visible. */
.projects-modal-row-action--edit {
  opacity: 1;
}
/* La poubelle n'apparaît qu'au hover de la ligne (ou focus clavier sur le bouton). */
.projects-modal-row-action--delete {
  opacity: 0;
  pointer-events: none;
}
.projects-modal-row:hover .projects-modal-row-action--delete,
.projects-modal-row:focus-within .projects-modal-row-action--delete,
.projects-modal-row-action--delete:focus-visible {
  opacity: 1;
  pointer-events: auto;
}
.projects-modal-row-action--delete:hover {
  border-color: #b3404a;
  background: rgba(179, 64, 74, 0.16);
  color: #f6b3b8;
}

.projects-modal-status {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  /* Pas de min-height : la ligne ne prend de place que quand un message est affiché. */
}

.projects-modal-status:empty {
  display: none;
}

.project-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  /* Popup non-modale : on laisse passer les clics autour de la fenêtre pour
     pouvoir continuer à interagir avec le reste de l'app. */
  pointer-events: none;
}

.project-editor-modal[hidden] {
  display: none;
}

/* Mode visualisation (lecture seule) : on neutralise les champs/boutons du corps.
   Les onglets et les boutons de pied de page restent cliquables, et le corps
   reste défilable (pointer-events seulement sur les contrôles, pas sur le body). */
.project-editor-modal.is-readonly .project-editor-body input,
.project-editor-modal.is-readonly .project-editor-body textarea,
.project-editor-modal.is-readonly .project-editor-body select,
.project-editor-modal.is-readonly .project-editor-body button {
  pointer-events: none;
}

.project-editor-dialog {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  top: auto;
  left: auto;
  transform: none;
  width: min(880px, calc(100vw - 64px));
  /* Hauteur FIXE : header + onglets épinglés, seul le corps scrolle, taille
     constante d'un onglet à l'autre. */
  height: min(700px, calc(100vh - 64px));
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-radius: var(--r-2xl);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.6), var(--glass-shadow);
}

.project-editor-dialog .model-editor-head {
  padding: 28px 32px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.project-editor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.12);
}

.project-editor-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  margin-bottom: -1px;
}

.project-editor-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.project-editor-tab.is-active {
  color: var(--text-bright);
  border-bottom-color: var(--accent);
  background: var(--bg-hover);
}

.project-editor-tab[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.project-editor-tab .project-editor-tab-count {
  margin-left: 6px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-active);
  color: var(--text-tertiary);
  font-weight: 700;
}

.project-editor-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 32px;
}

.project-editor-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 16px 32px 20px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.12);
}

.project-editor-status {
  margin: 0;
  padding: 0 32px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  min-height: 14px;
}

.project-editor-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.project-editor-loading {
  padding: 60px 32px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.project-editor-locked {
  padding: 32px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.12);
}

.project-editor-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-editor-field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.project-editor-input,
.project-editor-textarea,
.project-editor-select {
  font: inherit;
  font-size: 14px;
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 12px 14px;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.project-editor-input::placeholder,
.project-editor-textarea::placeholder {
  color: var(--text-tertiary);
}

.project-editor-input:focus,
.project-editor-textarea:focus,
.project-editor-select:focus {
  outline: none;
  border-color: var(--accent-border);
  background: var(--bg-active);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.project-editor-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.project-editor-section {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-surface);
}

.project-editor-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.project-editor-section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0;
}

.project-editor-section-help {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0;
  line-height: 1.5;
}

.project-editor-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-editor-empty {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.project-editor-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.project-editor-item-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.project-editor-item-text strong {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
}

.project-editor-item-text span {
  font-size: 12px;
  color: var(--text-secondary);
}

.project-editor-item-text em {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: normal;
  line-height: 1.5;
  white-space: pre-wrap;
}

.project-editor-item-remove {
  appearance: none;
  border: 1px solid rgba(255, 100, 100, 0.25);
  background: rgba(255, 100, 100, 0.08);
  color: #ffb3b3;
  border-radius: 10px;
  width: 30px;
  height: 30px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.project-editor-item-remove:hover {
  background: rgba(255, 100, 100, 0.18);
  border-color: rgba(255, 100, 100, 0.45);
}

.project-editor-add {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
/* Import de fichier dans l'onglet Documents (extraction serveur docx/pdf/texte). */
.project-editor-doc-import {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.project-editor-doc-import > span {
  font-size: 12px;
  color: var(--text-secondary);
}
.project-editor-doc-import input[type="file"] {
  font-size: 12px;
  color: var(--text-secondary);
}

.project-editor-add-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.project-editor-add-grid-3 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 10px;
}

.project-editor-add input,
.project-editor-add select,
.project-editor-add textarea {
  font: inherit;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 10px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.project-editor-add input::placeholder,
.project-editor-add textarea::placeholder {
  color: var(--text-tertiary);
}

.project-editor-add input:focus,
.project-editor-add select:focus,
.project-editor-add textarea:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.project-editor-add-button {
  align-self: flex-end;
  appearance: none;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--text-bright);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.project-editor-add-button:hover {
  background: var(--accent);
  color: var(--bg-base, #0b0f14);
  border-color: var(--accent);
}


/* ── Facturation ─────────────────────────────────────────────────────────── */
/* Reprend les cartes de l'onglet Usage : les deux parlent d'argent, ils
   doivent se ressembler. */

.settings-billing-head {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

/* Jauge du budget mensuel. Volontairement discrète tant qu'on est loin du
   plafond : une barre rouge en permanence finit par ne plus rien dire. */
.settings-billing-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-active);
  overflow: hidden;
  margin-bottom: 14px;
}
.settings-billing-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.settings-billing-warning {
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--accent-border);
  background: var(--accent-softer);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.settings-billing-note {
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  margin-bottom: 18px;
}

.settings-billing-title {
  margin: 22px 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  font-weight: 600;
}

.settings-billing-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.settings-billing-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  cursor: pointer;
}

/* Le repli « Avancé » garde les cinq réglages fins hors du chemin principal :
   un seul nombre est demandé à l'utilisateur, le reste en est dérivé. */
.settings-billing-advanced {
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-top: 8px;
  background: var(--bg-surface);
}
.settings-billing-advanced > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  user-select: none;
}
.settings-billing-advanced[open] > summary {
  margin-bottom: 12px;
}

/* Coût estimé d'une automatisation, affiché au moment où on la configure.
   C'est là que l'information sert : « toutes les 15 minutes » et « une fois par
   jour » se ressemblent dans un formulaire, et il y a un facteur 96 entre les
   deux. */
.trigger-cost {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 4px 0 14px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 13px;
  color: var(--text-secondary);
}
.trigger-cost strong {
  color: var(--text-bright);
  font-size: 15px;
}
.trigger-cost span {
  font-size: 12px;
  color: var(--text-tertiary);
}
/* Au-delà de ~20 $/mois : le niveau où une récurrence mal réglée se remarque
   sur la facture. On attire l'œil sans crier. */
.trigger-cost.is-high {
  border-color: var(--accent-border);
  background: var(--accent-softer);
}
.trigger-cost-note {
  font-style: italic;
}
