/* TIA ÉLEC LAB — feuille de style principale */
:root {
  --navy-900: #0f172a; --navy-800: #1e293b; --navy-700: #334155; --navy-600: #475569; --navy-500: #64748b;
  --blue: #f59e0b; --blue-600: #d97706; --blue-100: #fff7ed;
  --green: #16a34a; --green-100: #dcfce7; --orange: #f97316; --orange-100: #ffedd5; --red: #dc2626; --red-100: #fee2e2;
  --ink: #0f172a; --ink-2: #475569; --ink-3: #94a3b8; --line: #dbe2ea; --surface: #ffffff; --surface-2: #f4f7fa;
  --radius: 10px; --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .06);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--navy-900); font-size: 14px; overflow: hidden; }
button, select, input { font: inherit; }
[hidden] { display: none !important; }

.file-banner { background: var(--orange-100); color: #7c2d12; padding: 10px 16px; font-size: 13px; border-bottom: 2px solid var(--orange); }
.file-banner code { background: #fff; padding: 1px 6px; border-radius: 4px; }

/* ---------- Grille générale ---------- */
.app {
  --lib-size: 252px;
  --insp-size: 328px;
  --console-size: 190px;
  height: 100vh; display: grid; background: var(--surface-2);
  grid-template-columns: var(--lib-size) minmax(0, 1fr) var(--insp-size);
  grid-template-rows: minmax(58px, auto) minmax(0, 1fr) var(--console-size);
  grid-template-areas: "top top top" "lib stage insp" "lib console insp";
}
.app.lib-collapsed { --lib-size: 38px; }
.app.insp-collapsed { --insp-size: 38px; }
.app.no-info, .app.focus-mode { --console-size: 0; }
.app.no-info .console { display: none; }
.app.no-info .hud { display: none; }
.topbar { grid-area: top; }
.library { grid-area: lib; }
.stage { grid-area: stage; }
.inspector { grid-area: insp; }
.console { grid-area: console; }

/* Rails des panneaux repliés : une seule poignée pour rouvrir, jamais de commande fictive. */
.side-rail { display: none; }
.app.lib-collapsed .library,
.app.insp-collapsed .inspector { overflow: hidden; padding: 0; }
.app.lib-collapsed .library > :not(.side-rail),
.app.insp-collapsed .inspector > :not(.side-rail) { display: none; }
.app.lib-collapsed .side-rail,
.app.insp-collapsed .side-rail {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; padding: 10px 0;
  border: 0; background: var(--navy-700); color: var(--orange-100);
  font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  writing-mode: vertical-rl; cursor: pointer;
}
.app.insp-collapsed .side-rail { transform: rotate(180deg); }
.app.lib-collapsed .side-rail:hover,
.app.insp-collapsed .side-rail:hover { background: var(--navy-600); color: #fff; }
.app.focus-mode .stage { background: linear-gradient(180deg, #fffdf8, #f8fafc); }

/* ---------- Barre supérieure ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 6px 12px; background: linear-gradient(180deg, var(--navy-800), var(--navy-900)); color: #fff; border-bottom: 1px solid #000; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 34px; height: 34px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; letter-spacing: .08em; font-size: 16px; }
.brand-name b { color: #fbbf24; }
.brand-slogan { font-size: 10.5px; color: #94a3b8; letter-spacing: .02em; }
.sim-picker { display: flex; align-items: center; gap: 8px; padding-left: 18px; border-left: 1px solid var(--navy-600); }
.sim-picker label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; }
.sim-picker select { background: var(--navy-700); color: #fff; border: 1px solid var(--navy-500); border-radius: 8px; padding: 7px 28px 7px 10px; font-weight: 600; min-width: 190px; }
.project-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; max-width: 190px; padding-left: 12px; border-left: 1px solid var(--navy-600); }
.project-caption { font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: #94a3b8; }
.project-name { font-size: 13px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: flex; align-items: center; gap: 8px; margin-left: auto; padding: 6px 12px; border-radius: 999px; background: var(--navy-700); border: 1px solid var(--navy-500); font-size: 13px; font-weight: 600; white-space: nowrap; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: #64748b; }
.status[data-state="running"] .dot { background: #22c55e; box-shadow: 0 0 0 4px rgba(249, 115, 22, .25); animation: pulse 1.4s infinite; }
.status[data-state="fault"] .dot { background: #ef4444; box-shadow: 0 0 0 4px rgba(239, 68, 68, .25); }
.status .clock { font-family: var(--mono); font-weight: 500; color: #cbd5e1; font-size: 12px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(249, 115, 22, 0); } }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.top-actions .tb-group { display: flex; align-items: center; gap: 4px; }
.top-actions .tb-group + .tb-group { padding-left: 8px; border-left: 1px solid var(--navy-600); }
.top-actions .btn { padding: 7px 9px; font-size: 12px; }
.btn.unavailable { opacity: .4; border-style: dashed; cursor: not-allowed; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover:not(:disabled) { border-color: var(--blue); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--blue-600); }
.btn.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn.danger:hover:not(:disabled) { background: #991b1b; border-color: #991b1b; }
.btn.ghost { background: transparent; border-color: var(--navy-500); color: #e2e8f0; }
.btn.ghost:hover:not(:disabled) { background: var(--navy-700); border-color: #fbbf24; }
.btn.ghost.toggle[aria-pressed="true"] { background: var(--navy-600); border-color: #fbbf24; color: #fff; }
.btn.ghost-dark { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn.accent { background: var(--blue-100); border-color: #fed7aa; color: var(--blue-600); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
.btn.xs { padding: 3px 8px; font-size: 11.5px; }
.btn.icon { min-width: 32px; justify-content: center; }

/* ---------- Verrouillage structurel (simulation en cours / défaut) ---------- */
.lock-notice { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 4px 10px; border-radius: 999px; background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; font-size: 12px; font-weight: 600; }
.lock-notice[hidden] { display: none; }
.lock-notice svg { width: 14px; height: 14px; flex: none; }
.lock-notice[data-state="fault"] { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
/* Commandes structurelles désactivées : disabled natif + repère visuel cohérent. */
.sel-sm:disabled, .tab-body select:disabled, .tab-body input:disabled, .chk input:disabled { opacity: .55; cursor: not-allowed; background: #eef2f7; }
.sim-picker select:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Bibliothèque ---------- */
.library { background: var(--navy-800); color: #e2e8f0; overflow-y: auto; padding: 14px 10px 20px; border-right: 1px solid #000; }
.side-title { font-weight: 800; text-transform: uppercase; letter-spacing: .1em; font-size: 12px; color: #94a3b8; padding: 0 6px; }
.side-hint { margin: 4px 6px 12px; font-size: 12px; color: #94a3b8; }
.lib-search { display: flex; align-items: center; gap: 6px; margin: 8px 4px 10px; padding: 6px 8px; border-radius: 8px; background: var(--navy-900); border: 1px solid var(--navy-600); color: #94a3b8; }
.lib-search:focus-within { border-color: #fbbf24; }
.lib-search svg { width: 15px; height: 15px; flex: none; }
.lib-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: #fff; font-size: 12px; }
.lib-search input::placeholder { color: #94a3b8; }
.lib-search input::-webkit-search-cancel-button { filter: grayscale(1) invert(1); }
.cat { margin-bottom: 8px; }
.cat > button { width: 100%; display: flex; justify-content: space-between; align-items: center; background: var(--navy-700); color: #fff; border: 0; border-radius: 8px; padding: 8px 10px; font-weight: 700; font-size: 12.5px; cursor: pointer; }
.cat > button::after { content: "▾"; color: #94a3b8; transition: transform .15s; }
.cat.closed > button::after { transform: rotate(-90deg); }
.cat.closed .items { display: none; }
.items { display: grid; gap: 6px; padding: 6px 0 2px; }
.lib-item { display: grid; grid-template-columns: 56px 1fr; gap: 8px; align-items: center; padding: 6px; background: var(--navy-900); border: 1px solid var(--navy-600); border-radius: 8px; cursor: grab; text-align: left; color: inherit; width: 100%; }
.lib-item:hover { border-color: #fbbf24; background: #334155; }
.lib-item:active { cursor: grabbing; }
.lib-item .pv { background: #fff; border-radius: 6px; height: 56px; display: grid; place-items: center; overflow: hidden; }
.prev { width: 100%; height: 100%; }
.prev text, .prev .hidden { display: none; }
.lib-item .nm { font-weight: 700; font-size: 12.5px; color: #fff; line-height: 1.2; }
.lib-item .rf { display: inline-block; font-family: var(--mono); font-size: 10.5px; color: #fdba74; margin-left: 4px; }
.lib-item .ds { font-size: 11px; color: #94a3b8; margin-top: 2px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-item:disabled { opacity: .45; cursor: not-allowed; }
.lib-item:disabled:hover { border-color: var(--navy-600); background: var(--navy-900); }
.lib-item:disabled:active { cursor: not-allowed; }

/* ---------- Atelier ---------- */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tb-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tb-group + .tb-group { padding-left: 14px; border-left: 1px solid var(--line); }
.tb-label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.sel-sm { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 12.5px; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.canvas-wrap { position: relative; flex: 1; min-height: 0; }
#workshop { position: absolute; inset: 0; width: 100%; height: 100%; cursor: default; touch-action: none; user-select: none; display: block; }
#workshop.panning { cursor: grabbing; }
#workshop.zoom-out .gridm { opacity: .3; }

/* Composants SVG */
.comp { cursor: grab; }
.comp.interactive { cursor: pointer; }
.chit { fill: transparent; pointer-events: all; }
.box { fill: #fff; stroke: #1e293b; stroke-width: 2; }
.inbox { font: 700 12px var(--font); fill: #0f172a; pointer-events: none; }
.inbox.sub { font-weight: 500; font-size: 10.5px; fill: #475569; }
.ref { font: 800 12.5px var(--font); fill: var(--blue-600); paint-order: stroke; stroke: #f4f7fa; stroke-width: 4px; pointer-events: none; }
.btnlabel { font: 700 11px var(--font); fill: #0f172a; paint-order: stroke; stroke: #f4f7fa; stroke-width: 3px; pointer-events: none; }
.warnTxt { font: 700 10.5px var(--font); fill: var(--red); pointer-events: none; }
.mstate { font: 700 10.5px var(--font); fill: #475569; pointer-events: none; paint-order: stroke; stroke: #f4f7fa; stroke-width: 3px; }
.mstate.marche { fill: var(--green); } .mstate.defaut { fill: var(--red); } .mstate.transition { fill: var(--orange); }
.motor-rotor { transform-box: view-box; will-change: transform; }
.mstate-dir { font: 700 10px var(--font); fill: #475569; pointer-events: none; paint-order: stroke; stroke: #f4f7fa; stroke-width: 3px; }
.mspd-txt { font: 600 9.5px var(--font); fill: #64748b; pointer-events: none; }
.sub { font: 500 10px var(--font); fill: #64748b; }
.lamp.lit { filter: drop-shadow(0 0 7px var(--glow)); }
.comp text { pointer-events: none; }
.comp:hover .box { stroke: var(--blue); }

.terms { pointer-events: none; }
.term { pointer-events: all; cursor: crosshair; }
.term .thit { fill: transparent; }
.term .dot { fill: #fff; stroke: #0f172a; stroke-width: 1.8; transition: r .1s; }
.term.wired .dot { fill: #0f172a; }
.term.opt:not(.wired) .dot { stroke: #94a3b8; }
.term:hover .dot { r: 6.5; fill: #38bdf8; stroke: var(--blue-600); }
.tlabel { font: 600 9.5px var(--font); fill: #334155; pointer-events: none; paint-order: stroke; stroke: #f4f7fa; stroke-width: 3px; }
#workshop.hide-terms .tlabel { display: none; }
#workshop.hide-terms .term:hover .tlabel { display: block; }
#workshop.hide-refs .ref, #workshop.hide-refs .btnlabel { display: none; }

/* Fils */
.wire { cursor: pointer; }
.whit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; }
.wbase { fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.wlive { fill: none; stroke: #22c55e; stroke-width: 6; opacity: .38; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.wsel { fill: none; stroke: var(--blue); stroke-width: 8; opacity: .35; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.wire:hover .wbase { stroke-width: 3.6; }
.pending { fill: none; stroke: var(--blue); stroke-width: 2.4; stroke-dasharray: 6 4; pointer-events: none; }
.hl-sel { fill: rgba(245, 158, 11, .06); stroke: var(--blue); stroke-width: 1.5; stroke-dasharray: 5 4; pointer-events: none; }
.hl-bad { fill: rgba(220, 38, 38, .08); stroke: var(--red); stroke-width: 2; stroke-dasharray: 6 4; pointer-events: none; }

/* HUD, toast, état vide */
.hud { position: absolute; right: 12px; bottom: 12px; max-width: 320px; background: rgba(30, 41, 59, .92); color: #e6efff; border-radius: var(--radius); padding: 10px 12px; font-size: 12px; box-shadow: var(--shadow); pointer-events: none; }
.hud:empty { display: none; }
.hud h4 { margin: 0 0 6px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #94a3b8; }
.hud .row { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; }
.hud .row i { width: 9px; height: 9px; border-radius: 50%; background: #64748b; flex: none; }
.hud .row.on i { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.hud .row.bad i { background: #ef4444; }
.hud .row.warn i { background: #f59e0b; }
.toast { position: absolute; top: 12px; left: 50%; transform: translate(-50%, -20px); background: var(--navy-800); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; box-shadow: var(--shadow); max-width: 80%; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.empty-card { pointer-events: auto; background: rgba(255, 255, 255, .96); border: 1px solid var(--line); border-radius: 14px; padding: 22px 26px; max-width: 460px; box-shadow: var(--shadow); text-align: center; }
.empty-card h2 { margin: 0 0 6px; font-size: 18px; }
.empty-card p { margin: 0 0 10px; color: var(--ink-2); line-height: 1.45; }
.empty-card .small { font-size: 12px; color: var(--ink-3); }
.empty-actions { display: flex; gap: 8px; justify-content: center; margin-top: 6px; }

/* ---------- Inspecteur ---------- */
.inspector { background: var(--surface-2); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab { flex: 1; padding: 11px 6px; border: 0; background: transparent; font-weight: 700; font-size: 12.5px; color: var(--ink-2); cursor: pointer; border-bottom: 3px solid transparent; }
.tab.active { color: var(--blue-600); border-bottom-color: var(--blue); }
.badge { display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; }
.badge.ok { background: var(--green); }
.tab-body { overflow-y: auto; padding: 12px; flex: 1; min-height: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.card h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); }
.card .title { font-size: 16px; font-weight: 800; }
.card .sub { color: var(--ink-2); font-size: 12px; margin-top: 2px; }
.kv { display: grid; grid-template-columns: 112px 1fr; gap: 6px 8px; align-items: center; font-size: 13px; }
.kv label { color: var(--ink-2); font-size: 12px; }
.kv input, .kv select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #e2e8f0; color: #334155; }
.pill.on { background: var(--green-100); color: #166534; } .pill.bad { background: var(--red-100); color: #991b1b; } .pill.warn { background: var(--orange-100); color: #9a3412; }
.term-list { margin: 0; padding: 0; list-style: none; font-size: 12.5px; }
.term-list li { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.term-list li:last-child { border-bottom: 0; }
.term-list b { min-width: 54px; font-family: var(--mono); color: var(--blue-600); }
.term-list span { color: var(--ink-2); }
.term-list .none { color: var(--ink-3); font-style: italic; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.note { font-size: 12px; color: var(--ink-2); line-height: 1.45; }
.fault { border-left: 4px solid var(--red); background: var(--red-100); padding: 7px 10px; border-radius: 6px; font-size: 12.5px; margin-top: 6px; }
.fault.warning { border-color: var(--orange); background: var(--orange-100); }

.diag-item { display: grid; grid-template-columns: 24px 1fr; gap: 8px; padding: 9px 10px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 7px; font-size: 12.8px; line-height: 1.45; cursor: default; }
.diag-item[data-comps] { cursor: pointer; }
.diag-item[data-comps]:hover { border-color: var(--blue); }
.diag-item .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #fff; }
.diag-item.error .ic { background: var(--red); } .diag-item.warning .ic { background: var(--orange); } .diag-item.ok .ic { background: var(--green); } .diag-item.info .ic { background: var(--blue); }
.diag-item.error { border-left: 4px solid var(--red); } .diag-item.warning { border-left: 4px solid var(--orange); } .diag-item.ok { border-left: 4px solid var(--green); }
details.scope { font-size: 12px; color: var(--ink-2); margin-top: 8px; }
details.scope summary { cursor: pointer; font-weight: 700; }
details.scope ul { margin: 6px 0 0; padding-left: 18px; }
.exo h2 { margin: 0 0 6px; font-size: 17px; }
.exo p { margin: 0 0 10px; color: var(--ink-2); line-height: 1.5; font-size: 13px; }
.exo ol { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.5; }
.exo li { margin-bottom: 6px; }

/* ---------- Console ---------- */
.console { background: var(--navy-900); color: #f8fafc; display: flex; flex-direction: column; min-height: 0; border-top: 1px solid #000; grid-column: 2; }
.console-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: #94a3b8; background: var(--navy-800); }
.console-log { flex: 1; overflow-y: auto; padding: 6px 12px; font-family: var(--mono); font-size: 12px; line-height: 1.55; }
.ev { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 1px 0; }
.ev .t { color: #64748b; }
.ev.ok .m { color: #4ade80; } .ev.warn .m { color: #fbbf24; } .ev.error .m { color: #f87171; font-weight: 600; } .ev.info .m { color: #f8fafc; }
.ev.empty-log .m { color: #64748b; font-style: italic; }

/* ---------- Bannière et diagnostic du projet enregistré ---------- */
.doc-notice { display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px; font-size: 12.5px; line-height: 1.4; border-bottom: 1px solid var(--line); border-left: 4px solid var(--ink-3); background: var(--surface-2); }
.doc-notice.warning { background: var(--orange-100); border-left-color: var(--orange); color: #7c2d12; }
.doc-notice.error { background: var(--red-100); border-left-color: var(--red); color: #7f1d1d; }
.doc-notice.info { background: var(--blue-100); border-left-color: var(--blue); color: #9a3412; }
.doc-notice-icon { flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 11px; color: #fff; background: var(--ink-3); }
.doc-notice.warning .doc-notice-icon { background: var(--orange); }
.doc-notice.error .doc-notice-icon { background: var(--red); }
.doc-notice.info .doc-notice-icon { background: var(--blue); }
.doc-notice-body { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.doc-notice-body strong { font-size: 12.5px; }
.doc-notice-body span { color: inherit; opacity: .9; }
.doc-notice .btn { flex: none; }
.doc-notice-close { flex: none; border: 0; background: transparent; color: inherit; opacity: .7; font-size: 18px; line-height: 1; padding: 0 4px; border-radius: 6px; cursor: pointer; }
.doc-notice-close:hover { opacity: 1; background: rgba(15, 23, 42, .08); }

.doc-card { border-left: 4px solid var(--line); }
.doc-status { margin-bottom: 6px; }
.doc-card .doc-meta { margin: 4px 0 0; font-size: 12px; color: var(--ink-2); }
.doc-card .doc-ok { margin: 8px 0 0; color: #166534; }
.doc-group { margin-top: 10px; }
.doc-group h4 { margin: 0 0 5px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.doc-issue { display: grid; grid-template-columns: 20px 1fr; gap: 7px; align-items: start; padding: 6px 8px; border-radius: 7px; background: var(--surface-2); border-left: 3px solid var(--line); font-size: 12.3px; line-height: 1.4; margin-bottom: 5px; }
.doc-issue .ic { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 10.5px; color: #fff; background: var(--ink-3); }
.doc-issue.error { border-left-color: var(--red); } .doc-issue.error .ic { background: var(--red); }
.doc-issue.warning { border-left-color: var(--orange); } .doc-issue.warning .ic { background: var(--orange); }
.doc-issue.info { border-left-color: var(--blue); } .doc-issue.info .ic { background: var(--blue); }
.pill.info { background: var(--blue-100); color: #9a3412; }

/* ---------- Onglet Résultats ---------- */
.res-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.res-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.res-row:last-child { border-bottom: 0; }
.res-row span:first-child { color: var(--ink-2); }
.res-row b { font-family: var(--mono); font-size: 12px; color: var(--ink); text-align: right; }
.res-motor { border-left: 3px solid var(--blue); padding-left: 8px; margin: 8px 0; }
.res-motor.defaut { border-left-color: var(--red); }
.res-motor.transition { border-left-color: var(--orange); }
.res-note { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }

/* ---------- Barre de statut ---------- */
.statusbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 5px 12px; border-top: 1px solid var(--navy-600); background: var(--navy-800); color: #cbd5e1; font-size: 11.5px; white-space: nowrap; }
.sb-item { display: inline-flex; align-items: center; gap: 5px; }
.sb-item::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #64748b; flex: none; }
.sb-item.on::before { background: #22c55e; } .sb-item.warn::before { background: #f59e0b; } .sb-item.bad::before { background: #ef4444; }
.sb-msg { margin-left: auto; color: #f8fafc; overflow: hidden; text-overflow: ellipsis; max-width: 42ch; }
.app.no-info .statusbar { display: none; }

/* ---------- Design system moderne ---------- */
:root {
  --accent: #fb923c;
  --accent-2: #f59e0b;
  --glass: rgba(10, 30, 58, .78);
  --home-line: rgba(148, 163, 184, .18);
  --home-ink: #f8fafc;
}

body {
  background:
    radial-gradient(1100px 620px at 8% -8%, rgba(245, 158, 11, .20), transparent 62%),
    radial-gradient(900px 520px at 100% 0%, rgba(249, 115, 22, .10), transparent 55%),
    var(--navy-900);
}

.topbar {
  position: relative;
  background: linear-gradient(135deg, rgba(15, 41, 75, .97), rgba(15, 23, 42, .98));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(148, 163, 184, .22);
  box-shadow: 0 10px 32px rgba(2, 8, 23, .32);
}
.topbar::after {
  content: "";
  position: absolute;
  left: 16px; right: 16px; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(251, 146, 60, .75), transparent);
}
.brand-name { letter-spacing: .03em; text-shadow: 0 1px 12px rgba(251, 146, 60, .28); }
.brand-name b { color: #fdba74; }
.brand-slogan { color: #94a3b8; }
.project-id { border-left-color: rgba(148, 163, 184, .22); }
.project-caption { color: #94a3b8; }
.sim-picker { border-left-color: rgba(148, 163, 184, .22); }
.sim-picker select {
  background: rgba(30, 41, 59, .92);
  border-color: rgba(148, 163, 184, .35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}
.status {
  background: rgba(30, 41, 59, .86);
  border-color: rgba(148, 163, 184, .35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.top-actions .tb-group + .tb-group { border-left-color: rgba(148, 163, 184, .22); }
.top-actions .btn {
  border-radius: 10px;
  border-color: rgba(148, 163, 184, .28);
  background: rgba(255, 255, 255, .055);
  color: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: transform .15s, background .15s, border-color .15s, box-shadow .15s;
}
.top-actions .btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(251, 146, 60, .18);
  border-color: rgba(253, 186, 116, .7);
  box-shadow: 0 6px 18px rgba(245, 158, 11, .24);
}
.top-actions .btn.primary {
  background: linear-gradient(135deg, #fb923c, #ea580c);
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(245, 158, 11, .35);
}
.top-actions .btn.danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(220, 38, 38, .22);
}
.top-actions .btn.unavailable { background: rgba(255, 255, 255, .02); }

.library {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border-right-color: rgba(148, 163, 184, .18);
}
.side-title { color: #cbd5e1; }
.side-hint { color: #94a3b8; }
.lib-search {
  border-color: rgba(148, 163, 184, .28);
  background: rgba(15, 23, 42, .82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
.cat > button {
  background: rgba(30, 41, 59, .82);
  border: 1px solid rgba(148, 163, 184, .18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
.lib-item {
  border-color: rgba(148, 163, 184, .18);
  background: rgba(15, 23, 42, .78);
  transition: transform .14s, border-color .14s, background .14s, box-shadow .14s;
}
.lib-item:hover:not(:disabled) {
  transform: translateX(3px);
  border-color: rgba(253, 186, 116, .75);
  background: rgba(51, 65, 85, .92);
  box-shadow: 0 8px 22px rgba(2, 8, 23, .28);
}
.lib-item .pv { border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .08); }
.prev-term { font: 700 8px var(--mono); fill: #b45309; pointer-events: none; paint-order: stroke; stroke: #fff; stroke-width: 2.5px; }
.lib-item .rf { color: #fdba74; }

.stage { background: linear-gradient(180deg, #f8fbff, #eef4fb); }
.canvas-wrap { background: #f8fbff; }
.toolbar {
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  border-bottom-color: rgba(148, 163, 184, .28);
}
.inspector {
  background: linear-gradient(180deg, #f6f9fd, #eef3f9);
  border-left-color: rgba(148, 163, 184, .35);
}
.tabs {
  background: rgba(255, 255, 255, .78);
  border-bottom-color: rgba(148, 163, 184, .28);
  padding: 6px 6px 0;
  gap: 3px;
}
.tab {
  border-radius: 9px 9px 0 0;
  border-bottom: 0;
  padding: 10px 4px;
  transition: background .15s, color .15s, box-shadow .15s;
}
.tab:hover { background: rgba(245, 158, 11, .07); }
.tab.active {
  background: #fff;
  color: var(--blue-600);
  box-shadow: 0 -2px 10px rgba(15, 23, 42, .06);
}
.card {
  border-color: rgba(148, 163, 184, .26);
  border-radius: 13px;
  box-shadow: 0 2px 4px rgba(15, 23, 42, .04), 0 10px 26px rgba(15, 23, 42, .05);
}
.tab-body .card:first-child { border-top: 3px solid rgba(245, 158, 11, .55); }
.diag-item, .doc-issue {
  border-color: rgba(148, 163, 184, .26);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}
.console {
  background: linear-gradient(180deg, #020617, #1e293b);
  border-top-color: rgba(148, 163, 184, .2);
}
.console-head { background: rgba(30, 41, 59, .92); }
.statusbar {
  background: rgba(15, 23, 42, .96);
  border-top-color: rgba(148, 163, 184, .2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
.sb-item {
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(148, 163, 184, .14);
}

/* ---------- Page d'accueil ---------- */
.home {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  color: var(--home-ink);
  background:
    radial-gradient(900px 520px at 12% 4%, rgba(245, 158, 11, .32), transparent 60%),
    radial-gradient(760px 480px at 88% 12%, rgba(249, 115, 22, .16), transparent 58%),
    linear-gradient(160deg, #020617 0%, #1e293b 52%, #020617 100%);
}
.home-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image:
    linear-gradient(rgba(148, 163, 184, .09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, .09) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 78%);
}
.home-shell {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100%;
}
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.home-brand { display: flex; align-items: center; gap: 12px; }
.home-logo { width: 42px; height: 42px; filter: drop-shadow(0 6px 18px rgba(245, 158, 11, .45)); }
.home-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.home-brand-text small { font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; color: #94a3b8; }
.home-brand-text strong { font-size: 19px; font-weight: 800; letter-spacing: .02em; }
.home-brand-text b { color: #fdba74; }
.home-skip {
  border: 1px solid rgba(148, 163, 184, .3);
  background: rgba(255, 255, 255, .06);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.home-skip:hover { background: rgba(251, 146, 60, .18); border-color: #fdba74; transform: translateX(2px); }
.home-skip span { margin-left: 6px; color: #fdba74; }

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr);
  gap: 26px;
  align-items: center;
}
.home-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.home-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(253, 186, 116, .32);
  background: rgba(245, 158, 11, .13);
  color: #fed7aa;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.home-badge i { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 4px rgba(74, 222, 128, .16); }
.home-copy h1 {
  margin: 0;
  font-size: clamp(30px, 4.2vw, 52px);
  line-height: 1.06;
  font-weight: 850;
  letter-spacing: -.025em;
}
.home-copy h1 span {
  background: linear-gradient(90deg, #fdba74, #f59e0b 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.home-copy p { margin: 0; max-width: 56ch; color: #cbd5e1; font-size: 14.5px; line-height: 1.62; }
.home-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.home-btn {
  border-radius: 11px;
  padding: 11px 17px;
  font-weight: 750;
  font-size: 13px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, background .15s, border-color .15s;
}
.home-btn:hover { transform: translateY(-2px); }
.home-btn.primary {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, #fb923c, #ea580c);
  box-shadow: 0 12px 28px rgba(245, 158, 11, .38);
}
.home-btn.secondary {
  border: 1px solid rgba(253, 186, 116, .4);
  background: rgba(255, 255, 255, .07);
  color: #e2e8f0;
}
.home-btn.ghost { border: 1px solid transparent; background: transparent; color: #cbd5e1; }
.home-btn.ghost:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.home-check { display: inline-flex; align-items: center; gap: 8px; color: #94a3b8; font-size: 12px; cursor: pointer; }
.home-check input { accent-color: #fb923c; }

.home-preview {
  border-radius: 18px;
  border: 1px solid var(--home-line);
  background: linear-gradient(150deg, rgba(30, 41, 59, .92), rgba(15, 23, 42, .92));
  box-shadow: 0 26px 60px rgba(2, 8, 23, .48), inset 0 1px 0 rgba(255, 255, 255, .06);
  overflow: hidden;
  animation: homeFloat 7s ease-in-out infinite;
}
.home-preview-head, .home-preview-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #94a3b8;
}
.home-preview-head { border-bottom: 1px solid var(--home-line); }
.home-preview-foot { justify-content: flex-start; gap: 8px; border-top: 1px solid var(--home-line); }
.home-dots { display: flex; gap: 5px; }
.home-dots i { width: 7px; height: 7px; border-radius: 50%; background: #fb923c; opacity: .85; }
.home-dots i:nth-child(2) { background: #4ade80; } .home-dots i:nth-child(3) { background: #fbbf24; }
.home-preview-svg { display: block; width: 100%; height: auto; padding: 8px 14px; }
.home-grid-lines path { stroke: rgba(148, 163, 184, .07); stroke-width: 1; }
.home-wire { fill: none; stroke: #fb923c; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.home-node { fill: #fdba74; }
.home-box { fill: rgba(15, 41, 75, .95); stroke: #fb923c; stroke-width: 2; }
.home-box-label { fill: #e2e8f0; font: 700 14px var(--font); }
.home-motor-label { fill: #14532d; font: 800 13px var(--font); }
.home-rotor { stroke: #16a34a; stroke-width: 3; stroke-linecap: round; transform-origin: 180px 142px; animation: homeSpin 2.6s linear infinite; }
.home-arrow { fill: none; stroke: #4ade80; stroke-width: 3; stroke-linecap: round; }
.home-arrow-head { fill: #4ade80; }
.home-led { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 4px rgba(74, 222, 128, .14); }
@keyframes homeFloat { 50% { transform: translateY(-6px); } }
@keyframes homeSpin { to { transform: rotate(360deg); } }

.home-sims { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.home-sim {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto auto;
  gap: 2px 10px;
  text-align: left;
  padding: 14px;
  min-height: 118px;
  border-radius: 14px;
  border: 1px solid var(--home-line);
  background: rgba(255, 255, 255, .04);
  color: var(--home-ink);
  cursor: pointer;
  overflow: hidden;
  transition: transform .16s, border-color .16s, background .16s, box-shadow .16s;
}
.home-sim::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(251, 146, 60, .16), transparent 60%);
  opacity: 0;
  transition: opacity .16s;
  pointer-events: none;
}
.home-sim:hover { transform: translateY(-3px); border-color: rgba(253, 186, 116, .65); box-shadow: 0 14px 30px rgba(2, 8, 23, .32); }
.home-sim:hover::after { opacity: 1; }
.home-sim.selected {
  border-color: #fb923c;
  background: rgba(245, 158, 11, .14);
  box-shadow: 0 0 0 1px rgba(251, 146, 60, .45), 0 14px 30px rgba(2, 8, 23, .34);
}
.home-sim.selected::after { opacity: 1; }
.home-sim-num {
  grid-row: 1 / 4;
  align-self: start;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(251, 146, 60, .18);
  color: #fdba74;
  font: 800 12px var(--mono);
}
.home-sim.selected .home-sim-num { background: #fb923c; color: #fff; }
.home-sim-name { font-size: 15px; font-weight: 800; }
.home-sim-desc { font-size: 11.8px; color: #cbd5e1; line-height: 1.35; }
.home-sim-go { margin-top: 5px; font-size: 10.5px; font-weight: 800; color: #fdba74; text-transform: uppercase; letter-spacing: .1em; }
.home-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--home-line);
  font-size: 11px;
  color: #94a3b8;
}

/* ---------- Adaptation ---------- */
@media (max-width: 1180px) {
  .app { --lib-size: 210px; --insp-size: 280px; }
  .sim-picker label, .brand-slogan, .project-caption { display: none; }
  .topbar { flex-wrap: wrap; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .status .clock { display: none; }
  .home-shell { padding: 22px; }
  .home-hero { gap: 18px; }
  .home-preview-svg { padding: 4px 8px; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app {
    --lib-size: auto; --insp-size: auto; --console-size: 220px;
    --stage-size: 62vh;
    height: auto; min-height: 100vh; grid-template-columns: 1fr;
    grid-template-rows: auto var(--lib-size) var(--stage-size) var(--insp-size) var(--console-size);
    grid-template-areas: "top" "lib" "stage" "insp" "console";
  }
  .app.lib-collapsed { --lib-size: 36px; }
  .app.insp-collapsed { --insp-size: 36px; }
  .app.lib-collapsed .side-rail,
  .app.insp-collapsed .side-rail { writing-mode: horizontal-tb; height: 36px; padding: 0; transform: none; }
  .topbar { flex-wrap: wrap; padding: 8px 12px; height: auto; gap: 8px; }
  .status { margin-left: 0; }
  .library { max-height: 190px; border-right: 0; }
  .app.lib-collapsed .library { max-height: 36px; }
  .console { grid-column: 1; }
  .inspector { border-left: 0; }
  .doc-notice { flex-wrap: wrap; }
  .doc-notice-body { flex-basis: calc(100% - 30px); }
  .doc-notice .btn { margin-left: 30px; }
  .home-shell { padding: 18px 16px; gap: 16px; }
  .home-hero { grid-template-columns: 1fr; }
  .home-preview { max-width: 560px; }
  .home-sims { grid-template-columns: 1fr; }
  .home-sim { min-height: 0; }
  .home-actions .home-btn { flex: 1 1 180px; }
  .home-foot { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
