/* Charte CXO Booster V6 : les jetons viennent de cxo-theme.css (chargé avant ce fichier). */
:root {
  color-scheme: light;
  --bg: var(--cxo-paper);
  --surface: var(--cxo-card);
  --surface-2: var(--cxo-paper-2);
  --line: var(--cxo-sand);
  --ink: var(--cxo-ink);
  --muted: var(--cxo-muted);
  --accent: var(--cxo-indigo);
  --accent-ink: #fff;
  --warm: var(--cxo-ochre);
  --danger: var(--cxo-danger);
  --zone-internal: #5b7fa6;
  --zone-dmz: #d9944a;
  --zone-saas: #8b7ad8;
  --ground: var(--cxo-night-2);
  --ground-line: var(--cxo-night-3);
  --topbar-h: 56px;
  --panel-w: 380px;
  font-family: var(--cxo-font-sans);
}

/* Scène du paysage : fond nuit, comme les illustrations sombres de la V6. */
.map-wrap {
  color-scheme: dark;
  --bg: var(--cxo-night);
  --surface: var(--cxo-night-2);
  --surface-2: var(--cxo-night-3);
  --line: var(--cxo-night-line);
  --ink: var(--cxo-night-ink);
  --muted: var(--cxo-night-muted);
  --accent: var(--cxo-indigo-soft);
  --accent-ink: var(--cxo-night);
  --warm: var(--cxo-gold);
  --danger: #ff8a80;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  padding-top: var(--cxo-band-h);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Barre du haut ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: relative;
  z-index: 30;
}
.brand { font-weight: 800; letter-spacing: -0.04em; font-size: 1.1rem; text-decoration: none; }
.brand span { color: var(--accent); }
.title-block { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.title-block h1 { margin: 0; font-size: 1rem; font-weight: 700; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .18rem .55rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: .78rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw;
}
.chip.live { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.top-links { margin-left: auto; display: flex; gap: 1rem; }
.top-links a { color: var(--muted); text-decoration: none; font-size: .9rem; }
.top-links a:hover { color: var(--ink); }

/* ---------- Scène ---------- */
.stage { position: relative; height: calc(100% - var(--topbar-h)); display: flex; }
.map-wrap { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.map {
  width: 100%; height: 100%; display: block;
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab;
  background:
    radial-gradient(ellipse at 50% 30%, #23213a 0%, var(--bg) 70%);
}
.map.panning { cursor: grabbing; }

.banner {
  position: absolute; z-index: 20; top: 12px; left: 50%; transform: translateX(-50%);
  max-width: min(640px, calc(100% - 32px));
  padding: .55rem .85rem; border-radius: 8px;
  background: color-mix(in srgb, var(--warm) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warm) 45%, var(--line));
  font-size: .85rem;
}

/* ---------- Sol et zones ---------- */
.ground-plate { fill: var(--ground); stroke: var(--line); stroke-width: 1; }
.ground-grid { stroke: var(--ground-line); stroke-width: 1; fill: none; }
.zone { stroke-width: 1.5; stroke-dasharray: 5 4; }
.zone.internal { fill: color-mix(in srgb, var(--zone-internal) 16%, transparent); stroke: var(--zone-internal); }
.zone.dmz { fill: color-mix(in srgb, var(--zone-dmz) 16%, transparent); stroke: var(--zone-dmz); }
.zone.saas { fill: color-mix(in srgb, var(--zone-saas) 16%, transparent); stroke: var(--zone-saas); }

.host-link { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 2 5; stroke-linecap: round; fill: none; opacity: .7; }
.team-link { stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 8 6; fill: none; opacity: .75; stroke-linecap: round; }
.team-label { fill: var(--accent); font-size: 12px; font-weight: 700; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.drop-tile { fill: color-mix(in srgb, var(--accent) 30%, transparent); stroke: var(--accent); stroke-width: 2; }
.drop-tile.target { fill: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ---------- Éléments (apps, robots) ---------- */
.item { cursor: pointer; outline: none; }
.item.dragging { cursor: grabbing; opacity: .92; }
.item .focus-ring { fill: none; stroke: var(--accent); stroke-width: 2.5; opacity: 0; }
.item:focus-visible .focus-ring, .item.selected .focus-ring { opacity: 1; }
.app-label { font-size: 13px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.app-vendor { font-size: 11px; fill: var(--muted); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.app-glyph { font-size: 18px; font-weight: 800; fill: rgba(255,255,255,.85); pointer-events: none; }
.robot-label { font-size: 11px; font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.robot.killed .robot-body { filter: grayscale(1) brightness(.6); }

.wheel { transform-box: fill-box; transform-origin: center; animation: spin 2.4s linear infinite; }
.wheel path, .wheel circle { fill: none; stroke: var(--accent); stroke-width: 2; }
.wheel .hub { fill: var(--accent); stroke: none; }
.wait-bubble circle { fill: var(--warm); }
.wait-bubble text { fill: var(--cxo-night); font-weight: 900; font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { 50% { transform: translateY(-2px); } }
.robot.working .robot-body { animation: bob 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .wheel { animation-duration: 12s; }
  .robot.working .robot-body { animation: none; }
}

/* ---------- Outils ---------- */
.toolbar {
  position: absolute; z-index: 15;
  left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 4px;
  padding: 4px; border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.tool {
  min-width: 44px; height: 44px; padding: 0 .6rem;
  border: 0; border-radius: 7px; background: transparent;
  font-size: 1.15rem; cursor: pointer;
}
.tool.wide { font-size: .88rem; font-weight: 600; }
.tool:hover { background: var(--surface-2); }
.tool-sep { width: 1px; height: 24px; background: var(--line); margin: 0 2px; }

.legend {
  position: absolute; z-index: 15; right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 260px; font-size: .82rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line); border-radius: 10px;
  backdrop-filter: blur(10px);
}
.legend summary { padding: .6rem .8rem; cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.legend ul { list-style: none; margin: 0; padding: 0 .8rem .3rem; display: grid; gap: .35rem; }
.legend li { display: flex; align-items: center; gap: .5rem; color: var(--muted); }
.legend-hint { margin: .3rem .8rem .7rem; color: var(--muted); }
.sw { width: 14px; height: 14px; border-radius: 3px; border: 1.5px dashed; }
.sw.zone-internal { border-color: var(--zone-internal); background: color-mix(in srgb, var(--zone-internal) 25%, transparent); }
.sw.zone-dmz { border-color: var(--zone-dmz); background: color-mix(in srgb, var(--zone-dmz) 25%, transparent); }
.sw.zone-saas { border-color: var(--zone-saas); background: color-mix(in srgb, var(--zone-saas) 25%, transparent); }
.lg-wheel { color: var(--accent); width: 14px; text-align: center; }
.lg-wait { width: 14px; height: 14px; border-radius: 50%; background: var(--warm); color: var(--cxo-night); font-weight: 900; font-size: 10px; display: inline-grid; place-items: center; }
.lg-team { width: 14px; border-top: 2.5px dashed var(--accent); }

.toast {
  position: absolute; z-index: 25; left: 50%; transform: translateX(-50%);
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 64px);
  max-width: min(520px, calc(100% - 32px));
  padding: .6rem .9rem; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  font-size: .88rem;
}
.toast.error { border-color: color-mix(in srgb, var(--danger) 60%, var(--line)); }

/* ---------- États ---------- */
.state {
  position: absolute; inset: 0; z-index: 12;
  display: grid; place-content: center; justify-items: center; gap: .6rem;
  text-align: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}
.state[hidden] { display: none; }
.state h2 { margin: 0; font-size: 1.15rem; }
.state p { margin: 0; color: var(--muted); max-width: 420px; }
.state-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: .4rem; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }

.btn {
  min-height: 44px; padding: .55rem .95rem; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Panneau de détail ---------- */
.panel {
  width: var(--panel-w); flex: none;
  border-left: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto; overscroll-behavior: contain;
  position: relative;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
}
.panel[hidden] { display: none; }
.panel-grip { display: none; }
.panel-close {
  position: absolute; top: 10px; right: 10px;
  width: 44px; height: 44px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; font-size: 1rem; color: var(--muted);
}
.panel-close:hover { background: var(--surface-2); color: var(--ink); }
.panel h2 { margin: 0 44px .25rem 0; font-size: 1.15rem; line-height: 1.25; }
.panel h3 { margin: 1.25rem 0 .45rem; font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.panel p { margin: 0; }
.panel .sub { color: var(--muted); font-size: .88rem; }
.panel-head { display: flex; gap: .75rem; align-items: center; margin-bottom: .5rem; }
.avatar { width: 44px; height: 44px; flex: none; }
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  border: 1px solid var(--line);
}
.pill.working { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.pill.waiting { color: var(--warm); border-color: color-mix(in srgb, var(--warm) 45%, var(--line)); }
.pill.idle { color: var(--muted); }
.pill.killed { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.pill.internal { color: #2f5d8f; }
.pill.dmz { color: var(--cxo-ochre-ink); }
.pill.saas { color: #5b47b8; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chips code, .chips .chip-item {
  font: 500 .78rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: .25rem .5rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line);
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.harness { width: 100%; border-collapse: collapse; font-size: .85rem; }
.harness th, .harness td { text-align: left; padding: .4rem .3rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.harness th { color: var(--muted); font-weight: 600; font-size: .76rem; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; }
.timeline li { display: grid; grid-template-columns: 4.2rem 1fr; gap: .6rem; font-size: .88rem; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .8rem; padding-top: .1rem; }
.proposal {
  margin-top: .6rem; padding: .8rem; border-radius: 8px;
  background: color-mix(in srgb, var(--warm) 9%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--warm) 40%, var(--line));
}
.proposal strong { display: block; margin-bottom: .25rem; }
.proposal .actions { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.panel-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.25rem; }
.empty-note { color: var(--muted); font-size: .88rem; }

/* ---------- Dialogue ---------- */
.dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 0;
  background: var(--surface); color: var(--ink);
  width: min(420px, calc(100% - 32px));
}
.dialog::backdrop { background: rgba(15,14,20,.45); backdrop-filter: blur(4px); }
.dialog form { padding: 20px; display: grid; gap: .8rem; }
.dialog h2 { margin: 0 0 .2rem; font-size: 1.1rem; }
.dialog label { display: grid; gap: .3rem; font-size: .88rem; color: var(--muted); }
.dialog input, .dialog select {
  min-height: 44px; padding: .5rem .65rem; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .3rem; }
.form-error { margin: 0; min-height: 1.2em; color: var(--danger); font-size: .85rem; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .top-links { display: none; }
  .title-block h1 { font-size: .95rem; }
  .panel {
    position: absolute; z-index: 40; left: 0; right: 0; bottom: 0;
    width: auto; max-height: 62%;
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 40px rgba(0,0,0,.5);
    padding-top: 26px;
  }
  .panel-grip { display: block; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line); }
  .legend { top: 12px; bottom: auto; right: 12px; }
  .legend:not([open]) summary { padding: .5rem .7rem; }
  .toolbar { left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .tool.wide { font-size: .82rem; }
}

/* ---------- Bibliothèque éditeurs : IA intégrée, capacités (D7.5) ---------- */
:root { --native-ai: #5eead4; }
.app-caps { font-size: 9.5px; font-weight: 700; letter-spacing: .06em; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.app-caps .cap-api { fill: #9aa3a6; }
.app-caps .cap-mcp { fill: #7dd3fc; }
.app-caps .cap-native_ai { fill: var(--native-ai); }
.native-orb .orb-halo { fill: color-mix(in srgb, var(--native-ai) 18%, transparent); stroke: var(--native-ai); stroke-width: 1; opacity: .9; transform-box: fill-box; transform-origin: center; animation: orb-pulse 2.8s ease-in-out infinite; }
.native-orb .orb-core { fill: #0e2a27; stroke: var(--native-ai); stroke-width: 1.6; }
.native-orb .orb-spark { fill: var(--native-ai); }
.native-orb .orb-stem { stroke: var(--native-ai); stroke-width: 1.4; stroke-dasharray: 2 3; opacity: .7; }
@keyframes orb-pulse { 0%, 100% { transform: scale(.85); opacity: .55; } 50% { transform: scale(1.15); opacity: 1; } }
.delegate-link { fill: none; stroke-width: 1.6; stroke-dasharray: 3 5; opacity: .85; stroke-linecap: round; animation: dash-flow 1.6s linear infinite; }
@keyframes dash-flow { to { stroke-dashoffset: -16; } }
@media (prefers-reduced-motion: reduce) {
  .native-orb .orb-halo, .delegate-link { animation: none; }
}
.lg-orb { color: var(--native-ai); width: 14px; text-align: center; }
.lg-delegate { width: 14px; border-top: 2px dotted var(--native-ai); }
.panel h4 { margin: .9rem 0 .4rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cap-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.cap-list li { display: grid; grid-template-columns: auto 1fr; gap: .6rem; align-items: start; font-size: .9rem; }
.cap-list .sub { display: block; }
.cap-list .orch { color: var(--ink); opacity: .8; }
.cap-type { font-size: .68rem; font-weight: 700; letter-spacing: .05em; padding: .15rem .4rem; border-radius: 6px; border: 1px solid var(--line); min-width: 2.6rem; text-align: center; }
.cap-type.api { color: var(--muted); }
.cap-type.mcp { color: #2f5d8f; border-color: color-mix(in srgb, #2f5d8f 40%, var(--line)); }
.cap-type.native_ai { color: var(--native-ai); border-color: color-mix(in srgb, var(--native-ai) 45%, var(--line)); }
.cap-status { font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 .45rem; white-space: nowrap; }
.cap-status.ga { color: var(--accent); }
.cap-status.preview, .cap-status.limited { color: var(--warm); }

/* ---------- Gouvernance, mémoire, score (RF9 proposition) ---------- */
.assistant-link { display: inline-flex; margin-top: .7rem; text-decoration: none; }
.score { font-size: .7rem; border-radius: 999px; padding: 0 .45rem; border: 1px solid var(--line); margin-left: .3rem; white-space: nowrap; }
.score.ok { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.score.fix { color: var(--warm); border-color: color-mix(in srgb, var(--warm) 40%, var(--line)); }
.score.rejected { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.score.pending { color: var(--muted); }
.score-summary { display: grid; grid-template-columns: auto 1fr; gap: .1rem .6rem; align-items: baseline; margin-bottom: .7rem; }
.score-summary strong { font-size: 1.4rem; }
.score-summary .meter { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.score-summary .meter span { display: block; height: 100%; background: var(--accent); }
.levels, .memory { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .5rem; font-size: .9rem; }
.levels li, .memory li { display: grid; grid-template-columns: auto 1fr; gap: .6rem; align-items: start; }
.levels .sub, .memory .sub, .timeline .sub { display: block; }
.lvl { width: 1.6rem; height: 1.6rem; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: .8rem; border: 1px solid var(--line); }
.lvl.l0 { color: var(--danger); }
.lvl.l1 { color: var(--warm); }
.lvl.l2 { color: #2f5d8f; }
.lvl.l3 { color: var(--accent); }
.mem-scope { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: .12rem .4rem; min-width: 5.4rem; text-align: center; }
.kv.small { font-size: .82rem; margin-top: .6rem; }
.kv .sub { display: block; }

/* ---------- Menu commun (vision globale, robots, créer, bibliothèque, assistant) ---------- */
.app-nav { display: flex; gap: .25rem; margin-left: auto; }
.app-nav a {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 38px; padding: 0 .7rem;
  border-radius: 9px; color: var(--muted); text-decoration: none; font-size: .88rem; font-weight: 600;
}
@media (hover: hover) { .app-nav a:hover { color: var(--ink); background: var(--surface-2); } }
.app-nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.app-nav a.accent { color: var(--accent-ink); background: var(--accent); }
.app-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.has-app-nav .top-links { display: none; }
@media (max-width: 760px) {
  :root { --bottomnav-h: calc(60px + env(safe-area-inset-bottom)); }
  .app-nav {
    position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; margin: 0;
    height: var(--bottomnav-h); padding: 4px 6px env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line); gap: 0;
  }
  .app-nav a { flex: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 0; font-size: .66rem; min-height: 52px; }
  .app-nav a[aria-current="page"] { background: transparent; box-shadow: none; color: var(--accent); }
  .app-nav a.accent { background: transparent; color: var(--accent); }
  .app-nav a.accent svg { background: var(--accent); color: var(--accent-ink); border-radius: 50%; padding: 3px; width: 26px; height: 26px; }
  .has-app-nav .stage { height: calc(100% - var(--topbar-h) - var(--bottomnav-h)); }
  .has-app-nav .panel { bottom: 0; }
}

/* ---------- Palette « Nouveau robot » (glisser-déposer) ---------- */
.palette {
  position: absolute; z-index: 16; left: max(16px, env(safe-area-inset-left)); top: 16px;
  display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem .45rem .45rem;
  border-radius: 12px; border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; color: var(--ink);
  font: inherit; text-align: left;
}
.palette:active { cursor: grabbing; }
.palette svg { width: 34px; height: 44px; flex: none; }
.palette strong { display: block; font-size: .88rem; }
.palette span { font-size: .75rem; color: var(--muted); }
.drag-ghost { position: fixed; z-index: 90; pointer-events: none; width: 44px; height: 58px; transform: translate(-50%, -80%); filter: drop-shadow(0 8px 10px rgba(0,0,0,.5)); }
.map-wrap.drop-target::after { content: ""; position: absolute; inset: 0; border: 2px dashed var(--accent); border-radius: 4px; pointer-events: none; }

/* ---------- Fiche de création d'un robot ---------- */
.dialog.wide { width: min(640px, calc(100% - 32px)); max-height: calc(100dvh - 32px); }
.dialog.wide form { gap: 1rem; }
.dialog textarea {
  min-height: 72px; padding: .55rem .65rem; border-radius: 7px; resize: vertical;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit;
}
.dialog fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem .8rem; margin: 0; display: grid; gap: .55rem; }
.dialog legend { padding: 0 .35rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dialog .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.dialog .row { display: grid; grid-template-columns: auto 1fr minmax(0, 12rem); gap: .6rem; align-items: center; color: var(--ink); font-size: .9rem; }
.dialog .row input[type="checkbox"], .dialog .check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.dialog .check { display: flex; gap: .55rem; align-items: center; color: var(--ink); font-size: .9rem; }
.dialog .hint { margin: 0; font-size: .8rem; color: var(--muted); }
.swatches { display: flex; gap: .45rem; flex-wrap: wrap; }
.swatches label { display: block; }
.swatches input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatches span { display: block; width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatches input:checked + span { border-color: var(--ink); }
.swatches input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.dialog .steps { display: flex; gap: .4rem; font-size: .78rem; color: var(--muted); flex-wrap: wrap; }
@media (max-width: 760px) {
  .dialog.wide { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .dialog .grid2 { grid-template-columns: 1fr; }
  .dialog .row { grid-template-columns: auto 1fr; }
  .dialog .row select { grid-column: 1 / -1; }
  .dialog.wide .dialog-actions { position: sticky; bottom: 0; background: var(--surface); padding: .6rem 0 calc(.6rem + env(safe-area-inset-bottom)); margin: 0; }
  .palette { top: auto; bottom: max(76px, calc(env(safe-area-inset-bottom) + 70px)); left: 12px; }
  .palette span { display: none; }
}

/* ---------- Plateforme, base de connaissances et mémoires d'outils ---------- */
:root { --kb: #e8c468; --tool-mem: #5eead4; }
.zone.platform { fill: color-mix(in srgb, var(--kb) 7%, transparent); stroke: var(--kb); stroke-dasharray: 2 5; stroke-width: 1.6; }
.platform-label { fill: var(--kb); font-size: 12px; font-weight: 700; letter-spacing: .04em; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.item.kb { cursor: pointer; transition: opacity .2s; }
.item.kb.lit polygon:not(.focus-ring) { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--kb) 70%, transparent)); }
.item.kb.dim, .mem-tool.dim { opacity: .35; }
.mem-tool .disc { fill: color-mix(in srgb, var(--tool-mem) 30%, #15191a); stroke: var(--tool-mem); stroke-width: 1.2; }
.mem-tool.lit .disc { fill: var(--tool-mem); stroke: #e9fffb; }
.mem-tool.lit { filter: drop-shadow(0 0 5px var(--tool-mem)); }
.mem-tool-label { fill: var(--tool-mem); font-size: 10px; font-weight: 700; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.mem-link { fill: none; stroke-width: 2.2; stroke-dasharray: 4 5; animation: mem-flow 1.2s linear infinite; pointer-events: none; }
.mem-link.enterprise { stroke: var(--kb); }
.mem-link.tool { stroke: var(--tool-mem); }
@keyframes mem-flow { to { stroke-dashoffset: -18; } }
@media (prefers-reduced-motion: reduce) { .mem-link { animation: none; } }
.mem-scope.enterprise { color: var(--kb); border-color: color-mix(in srgb, var(--kb) 45%, var(--line)); }
.mem-scope.team { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.mem-scope.tool { color: var(--tool-mem); border-color: color-mix(in srgb, var(--tool-mem) 45%, var(--line)); }
.mem-group { margin: .7rem 0 .2rem; font-size: .78rem; color: var(--muted); font-weight: 700; }
.memory a { color: var(--ink); }
h3 .sub.inline { display: inline; text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: .3rem; }
.lg-kb { width: 14px; height: 10px; border-radius: 2px; background: var(--kb); }
.lg-tool { width: 10px; height: 12px; border-radius: 50% / 30%; background: var(--tool-mem); }
.lg-platform { width: 14px; height: 10px; border: 1.5px dashed var(--kb); border-radius: 2px; }

/* ---------- Charte CXO Booster V6 : habillage des briques de base ---------- */
/* Pas de backdrop-filter ici : il ferait de la barre le repère du menu fixe en bas sur téléphone. */
.topbar { background: var(--cxo-paper); }
.brand { font: 500 1.35rem/1 var(--cxo-font-serif); letter-spacing: -.02em; color: var(--ink); }
.brand span { color: var(--cxo-ochre); }
.title-block h1 { font: 500 1.05rem/1.2 var(--cxo-font-serif); letter-spacing: -.01em; }
.chip { background: rgba(255,255,255,.6); font-family: var(--cxo-font-mono); font-size: .72rem; letter-spacing: .04em; }
.chip.live { color: var(--cxo-sage-ink); }
.app-nav a { border-radius: var(--cxo-radius-pill); font-weight: 500; }
.app-nav a[aria-current="page"] { color: var(--cxo-paper); background: var(--cxo-ink); box-shadow: none; }
.app-nav a.accent { color: #fff; background: var(--cxo-indigo); }
.btn { border-radius: var(--cxo-radius-pill); font-weight: 500; padding-inline: 1.1rem; transition: transform .3s var(--cxo-ease); }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--cxo-ink); color: var(--cxo-paper); border-color: var(--cxo-ink); }
.map-wrap .btn.primary { background: var(--cxo-paper); color: var(--cxo-ink); border-color: var(--cxo-paper); }
.panel h2, .dialog h2, .state h2 { font-family: var(--cxo-font-serif); font-weight: 500; letter-spacing: -.01em; font-size: 1.35rem; }
.panel h3, .panel h4, .dialog legend { font-family: var(--cxo-font-mono); font-weight: 500; }
.dialog { border-radius: var(--cxo-radius-card); box-shadow: var(--cxo-shadow-card); }
.dialog input, .dialog select, .dialog textarea { border-radius: var(--cxo-radius-field); background: #fff; }
.dialog input:focus-visible, .dialog select:focus-visible, .dialog textarea:focus-visible { outline: none; border-color: var(--cxo-indigo); box-shadow: 0 0 0 4px rgba(65,70,200,.15); }
.toolbar, .legend, .palette { border-radius: 16px; }
@media (max-width: 760px) {
  .app-nav a[aria-current="page"] { color: var(--cxo-indigo); background: transparent; }
  .app-nav a.accent { background: transparent; color: var(--cxo-indigo); }
  .app-nav a.accent svg { background: var(--cxo-indigo); color: #fff; }
}
