/* ============================================================================
   MIDDLIA — Design system professionnel (thème clair par défaut + sombre).
   Esprit : outil B2B (Linear / Vercel / Datadog) — sobre, dense, lisible.
   ============================================================================ */

:root,
:root[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f2f4f7;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --muted: #667085;
  --faint: #98a2b3;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-border: #c7d2fe;
  --ok: #079455;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --sidebar: #ffffff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
  --code-bg: #0f1729;
  --code-text: #d6e2ff;
}

:root[data-theme="dark"] {
  --bg: #0b0e14;
  --surface: #12161f;
  --surface-2: #161b26;
  --surface-3: #1c2230;
  --border: #232a38;
  --border-strong: #333c4d;
  --text: #e6e9ef;
  --text-2: #b3bccb;
  --muted: #8b95a7;
  --faint: #6b7688;
  --primary: #6366f1;
  --primary-hover: #7c7ff2;
  --primary-soft: #1b1f38;
  --primary-border: #34396a;
  --ok: #32d583;
  --ok-soft: #0f2a1e;
  --warn: #fdb022;
  --warn-soft: #2a2210;
  --danger: #f97066;
  --danger-soft: #2a1514;
  --sidebar: #0e121a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --code-bg: #05070d;
  --code-text: #cdd8f5;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--primary-soft); }

/* ------------------------------- Layout ------------------------------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.app.nav-collapsed { grid-template-columns: 62px minmax(0, 1fr); }
.app.nav-collapsed .brand { justify-content: center; padding: 6px 0 18px; }
.app.nav-collapsed .brand .name { display: none; }
.app.nav-collapsed .nav-section h6 { display: none; }
.app.nav-collapsed .nav-item .lbl { display: none; }
.app.nav-collapsed .nav-item { justify-content: center; padding: 9px 0; }
.app.nav-collapsed .side-foot .card { display: none; }
.app.nav-collapsed .sidebar { padding-left: 6px; padding-right: 6px; }
.icon-btn.nav-collapse { display: inline-grid; }
.icon-btn.nav-collapse svg { transform: rotate(90deg); transition: transform .2s ease; }
.app.nav-collapsed .icon-btn.nav-collapse svg { transform: rotate(-90deg); }
@media (max-width: 960px) { .icon-btn.nav-collapse { display: none; } }
.icon-btn.nav-toggle { display: none; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(16, 24, 40, 0.5); z-index: 60; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap .table { min-width: 560px; }
.play-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand .mark { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.brand .name { font-weight: 700; letter-spacing: -0.01em; font-size: 14.5px; }
.brand .name small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0; }
.logo-mark { display: block; border-radius: 9px; box-shadow: 0 3px 10px color-mix(in srgb, var(--primary) 30%, transparent); }
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; }
.brand-lockup-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-lockup-text .brand-name { font-weight: 700; letter-spacing: -0.01em; }
.brand-lockup-text .brand-tagline { font-size: 11px; color: var(--muted); }

.nav-section { margin-bottom: 14px; }
.nav-section h6 { margin: 0 8px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; cursor: pointer; transition: background .12s, color .12s; background: transparent; border: none; font-family: inherit; font-size: 14px; text-align: left; width: 100%; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item .ico { color: currentColor; display: grid; place-items: center; width: 18px; }
.nav-item .badge-count { margin-left: auto; font-size: 11px; color: var(--muted); background: var(--surface-3); border-radius: 6px; padding: 1px 6px; }
.sidebar .spacer { flex: 1; }
.sidebar .side-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }

.workspace { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 12px 28px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
}
.topbar .tb-title { min-width: 0; }
.topbar .tb-title h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.topbar .tb-title p { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }
.topbar .tb-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.content { padding: 28px; width: 100%; max-width: 1240px; margin: 0 auto; }

/* Moins d'espace en mode atelier (plein écran) */
.content.wide { max-width: none; padding: 8px; }

/* ------------------------------- Typography ------------------------------- */
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.lead { color: var(--text-2); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 12px; }
.section-title h2 { font-size: 15px; font-weight: 600; }
.section-title .link { font-size: 13px; color: var(--primary); cursor: pointer; }

/* ------------------------------- Buttons ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-3); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--border-strong); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.ghost.primary { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.btn.ghost.primary:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn.block { width: 100%; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: 14.5px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }

/* ------------------------------- Cards / stats ------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); }
.card.pad { padding: 20px; }
.card.pad-lg { padding: 26px; }
.card.hover { transition: border-color .12s, box-shadow .12s, transform .12s; cursor: pointer; }
.card.hover:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 18px; }
.stat .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.stat .hint { font-size: 12px; color: var(--faint); }

/* ------------------------------- Forms ------------------------------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--faint); }
input, select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-family: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* ------------------------------- Chips / badges ------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.chip .k { color: var(--muted); font-weight: 500; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--border); background: var(--surface-3); color: var(--text-2); }
.badge.primary { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary); }
.badge.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.badge.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.badge.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.tag { display: inline-block; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--border); font-size: 11px; color: var(--muted); }

/* ------------------------------- Progress ------------------------------- */
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .5s ease; }
.progress.thin { height: 4px; }
.progress.ok > i { background: var(--ok); }

/* ------------------------------- Tabs ------------------------------- */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 9px; }
.tabs button { border: none; background: transparent; color: var(--text-2); font-weight: 550; font-size: 13px; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ------------------------------- Table / rows ------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.table tr:last-child td { border-bottom: none; }
.table tr.me { background: var(--primary-soft); }
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.row-item + .row-item { margin-top: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--border); font-size: 15px; }

/* ------------------------------- Dropdown ------------------------------- */
.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; display: none; }
.menu.open { display: block; }
.menu a, .menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 7px; border: none; background: transparent; color: var(--text-2); font-size: 13.5px; font-weight: 500; cursor: pointer; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--surface-3); color: var(--text); }
.menu .sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ------------------------------- Modal / toast ------------------------------- */
.modal-root { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; background: rgba(16, 24, 40, 0.5); padding: 20px; }
.modal-root.show { display: grid; }
.modal { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 24px; }
.modal h2 { margin-bottom: 6px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: grid; gap: 8px; }
.toast { min-width: 240px; max-width: 380px; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13.5px; color: var(--text); border-left: 3px solid var(--primary); animation: toastIn .2s ease; }
.toast.ok { border-left-color: var(--ok); }
.toast.no { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------------------------------- Empty / loading ------------------------------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ico { color: var(--faint); margin-bottom: 10px; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-3), color-mix(in srgb, var(--surface-3) 60%, var(--border)), var(--surface-3)); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ------------------------------- Auth ------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 0.9fr; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth .auth-side { display: none; } }
.auth .auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth .auth-card { width: 100%; max-width: 400px; }
.auth .auth-side { background: var(--surface); border-left: 1px solid var(--border); padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; }
.auth .auth-side .row { flex-wrap: nowrap; }

/* ============================================================================
   STUDIO — moteur plein écran, panneaux flottants (widgets)
   ============================================================================ */
.workbench { position: relative; height: calc(100vh - 74px); min-height: 460px; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
  background-image: radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0); background-size: 22px 22px; }

/* ---------- Habillage « IDE » par éditeur (skins) ---------- */
.workbench[data-ide] #st-run { background: var(--wb-accent); border-color: var(--wb-accent); color: #fff; }
.workbench[data-ide] .node.selected { border-color: var(--wb-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--wb-accent) 32%, transparent); }
.workbench[data-ide] .node.active { border-color: var(--wb-accent); }
.workbench[data-ide] .pal-group-title { color: color-mix(in srgb, var(--wb-accent) 55%, var(--text-2)); }
.workbench[data-ide] .wb-head { border-left: 3px solid var(--wb-accent); }
.wb-ide-badge { font-size: 11px; font-weight: 600; color: var(--text-2); border: 1px dashed var(--border-strong); border-radius: 999px; padding: 3px 9px; background: color-mix(in srgb, var(--surface) 90%, transparent); white-space: nowrap; }
.wb-ide-explorer { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px 2px; }
.wb-ide-folder { font-size: 11px; color: var(--muted); background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }
.wb-ide-folder::before { content: '▸ '; color: var(--faint); }
/* Panneau « signature » de l'IDE (explorateur / outline du produit). */
.ide-body { padding: 6px 8px 10px; display: flex; flex-direction: column; gap: 1px; }
.ide-group { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin: 9px 2px 3px; }
.workbench[data-ide] .ide-group { color: color-mix(in srgb, var(--wb-accent) 55%, var(--text-2)); }
.ide-row { display: flex; align-items: center; gap: 7px; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 7px; padding: 5px 7px; font-size: 12px; color: var(--text-2); font-family: inherit; cursor: pointer; }
.ide-row:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.ide-ico { width: 18px; height: 18px; display: grid; place-items: center; flex: 0 0 auto; }
.ide-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ide-row .badge { margin-left: auto; }
.ide-idx { width: 15px; flex: 0 0 auto; font-size: 10.5px; color: var(--faint); text-align: right; }
/* Étiquette de langage de l'éditeur (DataWeave, ESQL…) dans l'inspecteur. */
.insp-lang { font-size: 10px; font-weight: 700; color: #fff; background: var(--wb-accent, var(--primary)); border-radius: 5px; padding: 1px 6px; vertical-align: middle; }
/* Éditeurs dédiés (DataWeave, ESQL, JSONata, mapping…) avec aperçu en direct. */
.wb-editor { position: absolute; inset: 5% 5%; z-index: 40; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.we-head { display: flex; align-items: center; gap: 9px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.we-title { font-weight: 650; font-size: 13px; }
.we-lang { font-size: 10.5px; font-weight: 700; color: #fff; background: var(--wb-accent, var(--primary)); border-radius: 5px; padding: 1px 7px; }
.we-file { font-size: 11.5px; color: var(--faint); font-family: ui-monospace, Consolas, monospace; }
.we-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
.we-left { border-right: 1px solid var(--border); padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.we-right { padding: 12px; overflow: auto; display: flex; flex-direction: column; }
.we-hint { font-size: 11.5px; color: var(--muted); }
.we-code { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px; resize: vertical; min-height: 160px; flex: 1; }
.we-prev-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.we-out { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; max-height: 300px; overflow: auto; white-space: pre-wrap; margin: 0; }
.we-out.err { border-color: var(--danger); color: var(--danger); }
.we-map-row { display: grid; grid-template-columns: 1fr auto 1.5fr auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.we-map-row input { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.we-arrow { color: var(--faint); }
@media (max-width: 780px) { .we-body { grid-template-columns: 1fr; } .we-left { border-right: none; border-bottom: 1px solid var(--border); } }
/* Formes de nœuds propres à chaque IDE (repères visuels du produit). */
.workbench[data-ide="Software AG · webMethods"] .node { border-radius: 4px; border-left: 3px solid var(--wb-accent); }
.workbench[data-ide="Software AG · webMethods"] .node .n-head { background: color-mix(in srgb, var(--wb-accent) 7%, var(--surface)); }
.workbench[data-ide="Salesforce · MuleSoft"] .node { border-radius: 14px; }
.workbench[data-ide="Salesforce · MuleSoft"] .node .n-head { border-radius: 14px 14px 0 0; background: color-mix(in srgb, var(--wb-accent) 8%, var(--surface)); }
.workbench[data-ide="Apache Kafka"] .node { border-radius: 6px; border-top: 3px solid var(--wb-accent); }
.workbench[data-ide="Dell Boomi"] .node { border-radius: 10px; border-left: 3px solid var(--wb-accent); }
.workbench[data-ide="Kong"] .node { border-radius: 8px; }
.workbench[data-ide="WSO2"] .node { border-radius: 6px; border-bottom: 3px solid var(--wb-accent); }
.workbench[data-ide="IBM · ACE"] .node { border-radius: 16px; }
.workbench[data-ide="IBM · ACE"] .node .n-head { border-radius: 16px 16px 0 0; background: color-mix(in srgb, var(--wb-accent) 7%, var(--surface)); }

/* Disposition verticale « Flow steps » (façon webMethods Designer). */
.workbench[data-flow="v"] .node { border-left: 2px solid var(--wb-accent, var(--border-strong)); }
.workbench[data-flow="v"] .node .n-head { border-bottom: none; }
.workbench[data-flow="v"] .n-step { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--wb-accent, var(--primary)); color: #fff; font-size: 10.5px; font-weight: 700; flex: 0 0 auto; }
.workbench[data-flow="v"] .node .port.in { left: 50%; right: auto; top: -7px; transform: translateX(-50%); }
.workbench[data-flow="v"] .node .port.out[data-port="out"] { left: 50%; right: auto; top: auto !important; bottom: -7px; transform: translateX(-50%); }
.workbench .canvas-wrap { position: absolute; inset: 0; }
.wb-bar { position: absolute; top: 40px; left: 12px; z-index: 14; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; max-width: calc(100% - 24px);
  background: color-mix(in srgb, var(--surface) 90%, transparent); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); backdrop-filter: blur(10px); }
.wb-bar > * { flex: 0 0 auto; }
/* Chrome façon IDE : bandeau d'onglets (haut) + barre de statut (bas). */
.wb-tabs { position: absolute; top: 0; left: 0; right: 0; height: 30px; z-index: 13; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(6px); }
.wb-tab { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); padding: 4px 10px; border-radius: 7px 7px 0 0; border: 1px solid transparent; border-bottom: 2px solid var(--wb-accent, var(--primary)); background: var(--surface); }
.wb-tab .wb-tab-ico { display: inline-flex; align-items: center; }
.wb-tab .wb-tab-x { color: var(--faint); display: inline-flex; margin-left: 2px; }
.wb-tabs-ide { margin-left: auto; font-size: 11px; color: var(--faint); font-weight: 600; letter-spacing: .02em; }
.wb-status { position: absolute; bottom: 0; left: 0; right: 0; height: 24px; z-index: 13; display: flex; align-items: center; gap: 14px; padding: 0 12px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(6px); font-size: 11px; color: var(--muted); }
.wb-st-item.err { color: var(--danger); font-weight: 600; }
.wb-bar select { flex: 0 0 auto; }
.wb-more-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: 6px; max-width: min(480px, calc(100vw - 40px)); padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); }
.wb-more-menu[hidden] { display: none; }

/* Dock de sortie (console) : s'ouvre en bas, pleine largeur. */
.wb-dock { position: absolute; left: 0; right: 0; bottom: 24px; z-index: 16; height: 236px; display: flex; flex-direction: column; background: color-mix(in srgb, var(--surface) 97%, transparent); backdrop-filter: blur(10px); border-top: 2px solid var(--wb-accent, var(--border-strong)); box-shadow: 0 -12px 30px rgba(0, 0, 0, .20); }
.wb-dock[hidden] { display: none; }
.wb-dock-body { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px 12px; }
.wb-dock .panel { border: none; border-radius: 0; background: transparent; }
.wb-dock .panel-title { border-bottom: 1px solid var(--border); background: transparent; }
.wb-dock .io { max-height: 220px; }

/* Contrôles de zoom (barre de statut, façon IDE). */
.wb-status .zoom-ctl { display: inline-flex; align-items: center; gap: 4px; }
.wb-zoomb { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px; padding: 0 5px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text-2); font-size: 11px; font-weight: 600; line-height: 1; cursor: pointer; }
.wb-zoomb:hover { border-color: var(--border-strong); color: var(--text); }
.wb-zoomb.wide { padding: 0 8px; }

/* Écran d'accueil de l'atelier */
.studio-home { max-width: 1120px; }
.studio-home h1 { font-size: 26px; }
.studio-home .card.hover { transition: border-color .15s, transform .15s; }
.studio-home .card.hover:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.wb-panel { position: absolute; top: 94px; bottom: 34px; width: 322px; z-index: 10; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; overflow-x: hidden; padding: 2px 4px 2px 2px; }
.wb-panel.floating { bottom: auto; }
.wb-left { left: 12px; }
.wb-right { right: 12px; width: 344px; }
.wb-resize { position: absolute; top: 0; bottom: 0; width: 9px; z-index: 3; cursor: col-resize; }
.wb-left .wb-resize { right: 0; }
.wb-right .wb-resize { left: 0; }
.wb-resize::after { content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; border-radius: 2px; transition: background .15s; }
.wb-resize:hover::after, .wb-resize.active::after { background: var(--primary); }
@media (max-width: 1080px) { .wb-resize { display: none; } }
.wb-left.collapsed, .wb-right.collapsed { display: none; }
.wb-panel .panel { background: color-mix(in srgb, var(--surface) 95%, transparent); backdrop-filter: blur(10px); box-shadow: var(--shadow-lg); }
.wb-head { display: flex; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 9px; cursor: grab; font-size: 11.5px; color: var(--muted); background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--border); box-shadow: var(--shadow-sm); backdrop-filter: blur(10px); user-select: none; }
.wb-head .grip { letter-spacing: 1px; color: var(--faint); }
.wb-head .wb-title { font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-panel.dragging { opacity: .96; }
@media (max-width: 1080px) { .wb-head { display: none; } }
@media (max-width: 1080px) {
  .workbench { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .workbench .canvas-wrap {
    position: relative; inset: auto; flex: none;
    height: min(58vh, 520px); min-height: 340px;
    margin: 0 8px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  }
  .wb-bar { position: relative; z-index: 4; transform: none; margin: 8px; max-width: none; }
  .wb-panel { position: relative; z-index: 3; width: auto; overflow: visible; padding: 0 8px 8px; }
  .wb-left, .wb-right { max-height: 48vh; overflow-y: auto; }
  .wb-tabs { display: none; }
  .wb-status { position: relative; z-index: 3; height: auto; min-height: 32px; flex-wrap: wrap; padding: 6px 10px; gap: 6px 14px; }
}
/* Aides visuelles sur le canevas */
.canvas-hint { position: absolute; left: 12px; bottom: 12px; z-index: 3; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; font-size: 12px; color: var(--muted); box-shadow: var(--shadow-sm); max-width: min(72%, 430px); }
.canvas-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; pointer-events: none; padding: 20px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.panel-pad { padding: 12px; }
.panel-title { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.col-scroll { overflow-y: auto; min-height: 0; }

.studio-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

.pal-search { width: 100%; }
.pal-group-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin: 12px 4px 6px; }
.pal-item { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 8px; border: 1px solid transparent; cursor: grab; font-size: 13px; color: var(--text-2); width: 100%; background: transparent; text-align: left; font-family: inherit; }
.pal-item:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.pal-item .pi { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-3); font-size: 13px; }

/* Logo officiel de l'éditeur : pastille claire pour rester lisible en thème clair et sombre. */
.brand-logo { display: inline-flex; align-items: center; justify-content: center; background: #fff; border: 1px solid var(--border); border-radius: 5px; padding: 2px 3px; box-sizing: border-box; line-height: 0; }
.brand-logo svg { display: block; height: 14px; width: auto; max-width: 46px; }
.pal-item .pi:has(.brand-logo), .node .n-head .nh:has(.brand-logo) { width: auto; min-width: 24px; padding: 0 3px; }

.canvas-wrap { position: relative; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); cursor: grab; }
.canvas-wrap.panning { cursor: grabbing; }
.workbench .canvas-wrap { background: transparent; border: none; border-radius: 0; }
.node { cursor: default; }
.canvas { position: relative; }
.scene { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.edges { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.edges .edge .wire { fill: none; stroke: var(--border-strong); stroke-width: 2; stroke-linecap: round; }
.edges .edge.named .wire { stroke: #7c9cff; }
.edges .edge.err .wire { stroke: var(--danger); stroke-dasharray: 6 4; }
.edges .edge .hit { fill: none; stroke: transparent; stroke-width: 18; pointer-events: stroke; cursor: pointer; }
.edges .edge:hover .wire { stroke: var(--primary); stroke-width: 3; }
.edges .edge .edge-label { font-size: 10px; font-weight: 600; fill: var(--muted); pointer-events: none; paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; stroke-linejoin: round; }
.edges .edge.named .edge-label { fill: #5b7cf0; }
.edges .edge.err .edge-label { fill: var(--danger); }
.edges .edge .edge-del { fill: var(--surface); stroke: var(--border-strong); opacity: 0; transition: opacity .15s; cursor: pointer; pointer-events: all; }
.edges .edge:hover .edge-del { opacity: 1; }
.edges .edge .edge-x { font-size: 11px; font-weight: 700; fill: var(--danger); opacity: 0; pointer-events: none; }
.edges .edge:hover .edge-x { opacity: 1; }

.node { position: absolute; width: 196px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-sm); user-select: none; }
.node.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.node.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.canvas-wrap.space .node { cursor: grab; }
.guides { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.guide { position: absolute; background: #ff4d8d; }
.guide-v { width: 1px; top: 0; }
.guide-h { height: 1px; left: 0; }
.node.err { border-color: var(--danger); }
.node .n-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 12.5px; font-weight: 600; border-bottom: 1px solid var(--border); cursor: grab; }
.node .n-head .nh { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 5px; background: var(--surface-3); font-size: 12px; }
.node .n-head .n-del { margin-left: auto; color: var(--faint); cursor: pointer; font-size: 13px; }
.node .n-head .n-del:hover { color: var(--danger); }
.node .n-body { padding: 7px 10px; font-size: 11.5px; color: var(--muted); word-break: break-word; }
.port { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); cursor: crosshair; z-index: 2; }
.port.in { left: -7px; top: 50%; transform: translateY(-50%); }
.port.out { right: -7px; }
.port.err { border-color: var(--danger); }
.port:hover, .port.connecting { background: var(--primary); }
.port.err:hover { background: var(--danger); }
.port-label { position: absolute; right: 12px; font-size: 9.5px; color: var(--faint); transform: translateY(-50%); }

.insp-field { display: grid; gap: 4px; margin-bottom: 12px; }
.insp-field label { font-size: 12px; font-weight: 550; color: var(--text-2); }
.insp-help { font-size: 11.5px; color: var(--faint); }
.map-row { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 5px; margin-bottom: 6px; }
.rule-row { display: grid; grid-template-columns: 1.3fr 1fr auto; gap: 5px; margin-bottom: 6px; }
.map-row input, .rule-row input { padding: 6px 8px; font-size: 12px; font-family: ui-monospace, monospace; }

.io { background: var(--code-bg); color: var(--code-text); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; }
.trace-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; margin-bottom: 6px; }
.trace-row.error { border-color: var(--danger); background: var(--danger-soft); }
.trace-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.trace-row.error .dot { background: var(--danger); }
.trace-row .t-name { font-weight: 600; }
.trace-row .t-ms { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
.check-row.neutral { background: var(--surface-2); }
.check-row.pass { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.check-row.fail { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); background: var(--danger-soft); }
.check-row .c-ico { flex: none; margin-top: 1px; }
.score { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

/* ------------------------------- Utilities ------------------------------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.between { justify-content: space-between; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; } .mt-4 { margin-top: 28px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 20px; }
.gap-1 { gap: 6px; } .gap-2 { gap: 12px; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ============================== Responsive ============================== */
@media (max-width: 1080px) {
  .studio, .studio.lab-mode { grid-template-columns: 1fr; height: auto; min-height: 0; }
  #pal-list { max-height: 320px; overflow-y: auto; }
  .studio-bar { gap: 8px; }
  .wb-dock { position: relative; z-index: 3; height: auto; max-height: 380px; margin: 8px; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-sm); }
  .wb-dock-body { padding: 8px; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .app.nav-collapsed { grid-template-columns: 1fr; }
  .icon-btn.nav-toggle { display: inline-grid; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 282px; max-width: 86vw;
    transform: translateX(-100%); transition: transform .22s ease; z-index: 70; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; }
  .content { padding: 20px 16px 64px; }
  .content.wide { padding: 14px 12px 56px; }
  .play-grid { grid-template-columns: 1fr; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 10px 14px; }
}
@media (max-width: 720px) {
  .hide-md { display: none !important; }
  .topbar { padding: 9px 12px; gap: 10px; }
  .topbar .tb-title h1 { font-size: 14.5px; }
  .topbar .tb-title p { display: none; }
  h1 { font-size: 20px; }
  .content { padding: 16px 14px 56px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
  .section-title { margin: 20px 0 10px; }
  .studio-bar .faint { display: none; }
}
@media (max-width: 560px) {
  h1 { font-size: 19px; }
  .card.pad-lg { padding: 18px; }
  .grid { gap: 12px; }
  .tabs { display: flex; width: 100%; }
  .tabs button { flex: 1; }
  .modal { padding: 18px; }
  .canvas-wrap { min-height: 340px; }
  .chip { height: 28px; padding: 0 8px; }
}

/* Schémas pédagogiques (diagrammes attachés aux questions) */
.diagram { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 14px 0 4px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.diagram figcaption { flex-basis: 100%; margin-top: 6px; font-size: 11.5px; color: var(--faint); }
.dg-node { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; font-weight: 550; color: var(--text-2); white-space: nowrap; }
.dg-node.dg-source { border-color: var(--primary); color: var(--primary); }
.dg-node.dg-service { border-color: #00a1e0; }
.dg-node.dg-db { border-color: #00b894; }
.dg-node.dg-warn { border-color: var(--danger); color: var(--danger); }
.dg-arrow { color: var(--faint); font-weight: 700; }
.diagram.steps { flex-direction: column; align-items: stretch; }
.dg-step { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--text-2); }
.dg-step .dg-n { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 10.5px; font-weight: 700; flex: 0 0 auto; }
.diagram-pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow: auto; margin: 14px 0 4px; white-space: pre; }

/* ---- Publicités (version gratuite) ---- */
.ad-slot { position: relative; margin: 18px 0; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface-2); padding: 15px 14px 12px; }
.ad-label { position: absolute; top: -9px; left: 12px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); background: var(--surface-2); padding: 0 6px; }
.ad-house { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.ad-house strong { font-size: 13.5px; }
@media (max-width: 560px) { .ad-house { flex-direction: column; align-items: flex-start; } }

/* ---- Offres (Gratuit / Pro / Équipe / Entreprise) ---- */
.plan-price { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; }
.plan-price small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.plan-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.plan-list li { position: relative; padding-left: 22px; font-size: 13px; color: var(--text-2); }
.plan-list li::before { content: '✓'; position: absolute; left: 0; color: var(--ok); font-weight: 700; }
.plan-current { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent); }

/* ---- Icône de parcours (logo éditeur ou icône SVG) ---- */
.ci-tile { width: 40px; height: 40px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2); }
.ci-tile.lg { width: 52px; height: 52px; border-radius: 12px; }
.ci-tile svg { max-width: 34px; height: auto; }
.ci-tile.lg svg { max-width: 46px; }

/* ---- Pastille de plan dans la barre ---- */
.chip.plan { font-weight: 600; }
.chip.plan.pro, .chip.plan.team, .chip.plan.enterprise { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
