/* FlatPlan Studio — design system + layout.
 *
 * Paper-and-ink light theme, graphite dark theme. One semantic palette for
 * system-dynamics meaning: stocks (ink blue), flows (teal), reinforcing loops
 * (vermilion), balancing loops (blue). Numbers are tabular everywhere. */

:root {
    --bg: #f3f2ee;
    --panel: #faf9f6;
    --surface: #ffffff;
    --canvas: #fcfbf8;
    --grid: rgba(22, 24, 29, 0.07);
    --ink: #16181d;
    --ink-2: #3a3f47;
    --muted: #6c717a;
    --faint: #a0a4ab;
    --line: #e4e1d9;
    --line-2: #d4d0c6;
    --hover: rgba(22, 24, 29, 0.045);
    --press: rgba(22, 24, 29, 0.08);

    --accent: #2b59c3;
    --accent-ink: #ffffff;
    --accent-soft: rgba(43, 89, 195, 0.1);
    --live: #f76707;

    --stock: #2b59c3;
    --stock-fill: rgba(43, 89, 195, 0.16);
    --flow: #0b7285;
    --aux: #495057;
    --conn: rgba(73, 80, 87, 0.5);
    --R: #e8590c;
    --B: #1c7ed6;
    --good: #2f9e44;
    --bad: #e03131;

    --s1: #2b59c3; --s2: #e8590c; --s3: #2f9e44; --s4: #ae3ec9;
    --s5: #f59f00; --s6: #0b7285; --s7: #c2255c; --s8: #5c940d;

    --shadow-1: 0 1px 2px rgba(22, 24, 29, 0.06), 0 1px 1px rgba(22, 24, 29, 0.04);
    --shadow-2: 0 12px 40px rgba(22, 24, 29, 0.14), 0 2px 8px rgba(22, 24, 29, 0.06);

    --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
    --r: 8px;
    --r-sm: 6px;
    --bar-h: 52px;
    --lever-w: 292px;
    --files-w: 300px;
    --insp-w: 336px;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0d0f13;
    --panel: #12151a;
    --surface: #171b21;
    --canvas: #0f1216;
    --grid: rgba(233, 235, 239, 0.06);
    --ink: #e9ebef;
    --ink-2: #c3c8d0;
    --muted: #8a919b;
    --faint: #5c636d;
    --line: #242930;
    --line-2: #323841;
    --hover: rgba(233, 235, 239, 0.05);
    --press: rgba(233, 235, 239, 0.09);
    --accent: #7b96ff;
    --accent-ink: #0d0f13;
    --accent-soft: rgba(123, 150, 255, 0.14);
    --live: #ff8a3d;
    --stock: #7b96ff;
    --stock-fill: rgba(123, 150, 255, 0.2);
    --flow: #3bc9db;
    --aux: #adb5bd;
    --conn: rgba(173, 181, 189, 0.42);
    --R: #ff8a4c;
    --B: #4dabf7;
    --good: #51cf66;
    --bad: #ff6b6b;
    --s1: #7b96ff; --s2: #ff8a4c; --s3: #51cf66; --s4: #da77f2;
    --s5: #fcc419; --s6: #3bc9db; --s7: #f06595; --s8: #94d82d;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 16px 48px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="xp"]):not([data-theme="w2k"]) {
        --bg: #0d0f13; --panel: #12151a; --surface: #171b21; --canvas: #0f1216;
        --grid: rgba(233, 235, 239, 0.06);
        --ink: #e9ebef; --ink-2: #c3c8d0; --muted: #8a919b; --faint: #5c636d;
        --line: #242930; --line-2: #323841;
        --hover: rgba(233, 235, 239, 0.05); --press: rgba(233, 235, 239, 0.09);
        --accent: #7b96ff; --accent-ink: #0d0f13; --accent-soft: rgba(123, 150, 255, 0.14);
        --live: #ff8a3d; --stock: #7b96ff; --stock-fill: rgba(123, 150, 255, 0.2);
        --flow: #3bc9db; --aux: #adb5bd; --conn: rgba(173, 181, 189, 0.42);
        --R: #ff8a4c; --B: #4dabf7; --good: #51cf66; --bad: #ff6b6b;
        --s1: #7b96ff; --s2: #ff8a4c; --s3: #51cf66; --s4: #da77f2;
        --s5: #fcc419; --s6: #3bc9db; --s7: #f06595; --s8: #94d82d;
        --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-2: 0 16px 48px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    background: var(--bg);
    color: var(--ink);
    font: 13px/1.45 var(--font);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
input, select { font: inherit; color: inherit; }
kbd {
    font: 11px/1 var(--mono);
    padding: 2px 5px;
    border: 1px solid var(--line-2);
    border-bottom-width: 2px;
    border-radius: 4px;
    color: var(--muted);
    background: var(--surface);
}
code { font-family: var(--mono); font-size: 0.92em; }
svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }

/* ── Controls ─────────────────────────────────────────────────────── */
.icon-btn, .ghost-btn, .primary-btn, .link-btn, .model-btn {
    border: 0; background: none; cursor: pointer; border-radius: var(--r-sm);
    display: inline-flex; align-items: center; gap: 6px;
    transition: background .12s, color .12s, box-shadow .12s;
}
.icon-btn { width: 30px; height: 30px; justify-content: center; color: var(--ink-2); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover, .ghost-btn:hover, .model-btn:hover { background: var(--hover); }
.icon-btn:active, .ghost-btn:active { background: var(--press); }
.icon-btn.toggle[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.ghost-btn { height: 30px; padding: 0 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.ghost-btn svg { width: 15px; height: 15px; }
.primary-btn {
    height: 30px; padding: 0 14px; background: var(--accent); color: var(--accent-ink);
    font-weight: 600; box-shadow: var(--shadow-1);
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:disabled { opacity: .55; cursor: progress; }
.primary-btn.big { height: 42px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.link-btn { color: var(--accent); font-weight: 500; padding: 2px 4px; }
.link-btn:hover { text-decoration: underline; }
select {
    height: 28px; border: 1px solid var(--line-2); background: var(--surface);
    border-radius: var(--r-sm); padding: 0 24px 0 8px; appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 13px) 12px, calc(100% - 9px) 12px;
    background-size: 4px 4px; background-repeat: no-repeat; cursor: pointer;
}
input[type="text"], input[type="search"], input[type="number"] {
    border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r-sm);
    height: 28px; padding: 0 8px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── Layout ───────────────────────────────────────────────────────── */
#app { height: 100%; display: flex; flex-direction: column; }
#bar {
    height: var(--bar-h); flex: none; display: flex; align-items: center; gap: 10px;
    padding: 0 12px 0 14px; border-bottom: 1px solid var(--line); background: var(--panel);
    position: relative; z-index: 5;
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; color: var(--accent); stroke-width: 1.7; }
.brand b { font-weight: 650; }
.brand span { font-weight: 450; }
/* the model: its name (click: rename) and the arrow (the library), one control to the eye */
.model-pick { display: inline-flex; align-items: center; margin-left: 6px; min-width: 0; max-width: 280px; border-radius: var(--r); transition: max-width .22s ease; }
.model-name-btn { height: 32px; min-width: 0; padding: 0 4px 0 10px; border: 0; background: none; border-radius: var(--r) 0 0 var(--r); display: inline-flex; align-items: center; font: inherit; font-weight: 600; font-size: 13.5px; color: var(--ink); cursor: pointer; transition: background .12s; }
.model-name-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-pick.renamable .model-name-btn { cursor: text; }
.model-pick.renamable .model-name-btn:hover span { text-decoration: underline dotted var(--faint); text-underline-offset: 4px; }
.model-name-btn:hover { background: var(--hover); }
.model-btn { height: 32px; width: 26px; padding: 0; justify-content: center; border-radius: 0 var(--r) var(--r) 0; }
.model-btn svg { width: 12px; height: 12px; flex: none; color: var(--muted); }
/* The bar in three: what you work on and where in the work (left), the run
   (middle), who is here and the tools (right). */
.bar-left { display: flex; align-items: center; gap: 8px; flex: none; min-width: 0; }
.bar-mid { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.bar-right { display: flex; align-items: center; gap: 4px; flex: none; }
.bar-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.more-btn { width: 30px; height: 30px; color: var(--ink-2); }
.more-btn svg { width: 16px; height: 16px; }
.more-btn svg .fill { fill: currentColor; stroke: none; }
.kbd-btn kbd { margin-left: 2px; }
.admin-link { transition: background .12s, color .12s, opacity .25s; }
.admin-link.arriving { opacity: 0; }
.menu-who { padding: 8px 10px 4px 26px; color: var(--muted); font-size: 12px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.transport { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 10px; min-width: 200px; }
.transport .icon-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--bg); flex: none; }
.transport .icon-btn:hover { background: var(--ink-2); }
.transport .icon-btn svg { width: 14px; height: 14px; }
.transport .icon-btn svg path { fill: currentColor; stroke: none; }
.transport select.speed { height: 26px; padding: 0 6px; width: auto; font: 600 11.5px var(--mono); background-image: none; text-align: center; flex: none; color: var(--ink-2); }
.transport .scrub { min-width: 90px; }
.transport .i-pause { display: none; }
.transport.playing .i-pause { display: block; }
.transport.playing .i-play { display: none; }
.scrub { flex: 1; height: 28px; position: relative; cursor: pointer; touch-action: none; }
.scrub-track { position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.scrub-fill { height: 100%; width: 0; background: var(--live); }
.scrub-knob {
    position: absolute; top: 7px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--live); box-shadow: var(--shadow-1); left: 0;
}
.clock { font: 600 13px/1 var(--mono); min-width: 80px; white-space: nowrap; flex: none; }
.clock-u { color: var(--muted); font-weight: 400; margin-left: 5px; }

.engine { display: inline-flex; align-items: center; gap: 6px; font: 12px/1 var(--mono); color: var(--muted); padding: 0 8px; white-space: nowrap; }
/* the engine time a steady width as it changes each run ("820 µs", "2.9 ms", "12 ms") */
#engine-ms { display: inline-block; min-width: 6ch; font-variant-numeric: tabular-nums; }
.engine .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.engine.live .dot { background: var(--live); box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 25%, transparent); }
.engine.busy .dot { animation: pulse .8s ease-in-out infinite; background: var(--live); }
@keyframes pulse { 50% { opacity: .35; } }

/* The side panels are slats side by side — the files, then the parameters
   (nearest the diagram: tweaked most) on the left, the inspector on the
   right — each its own column, each folded to a rail you click to unfold,
   by itself; the columns glide. */
#app {
    --rail-w: 30px;
    --c-levers: var(--lever-w); --c-files: var(--files-w); --c-insp: var(--insp-w);
}
#app.hide-files { --c-files: var(--rail-w); }
#app.hide-insp { --c-insp: var(--rail-w); }
#work {
    flex: 1; min-height: 0; display: grid;
    transition: grid-template-columns .22s cubic-bezier(.2,.7,.2,1);
    grid-template-columns: var(--c-files) minmax(0, 1fr) var(--c-insp);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "files tiles insp";
}
#app.hide-files #files > :not(.rail), #app.hide-insp #inspector > :not(.rail) { display: none !important; }
.rail { display: none; }
#app.hide-files #files > .rail, #app.hide-insp #inspector > .rail {
    display: flex; flex: 1; align-items: flex-start; justify-content: center; padding: 14px 0 0; width: 100%;
    border: 0; background: none; color: var(--muted); cursor: pointer;
}
.rail:hover { background: var(--hover); color: var(--ink); }
.rail span { writing-mode: vertical-rl; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.fold-btn { width: 24px; height: 24px; flex: none; }
.fold-btn svg { width: 14px; height: 14px; }
.panel-head { gap: 6px; }
.panel-head #levers-reset, .panel-head .fold-btn { margin-left: auto; }
.panel-head #levers-reset:not([hidden]) + .fold-btn { margin-left: 0; }
.insp-bar { padding-bottom: 0; }
/* Before a model is open the gallery is the whole workspace. */
#app.no-model #work { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tiles"; }
#app.no-model #levers, #app.no-model #files, #app.no-model #inspector, #app.no-model .tile-root, #app.no-model #ws-bar { display: none; }
.panel { background: var(--panel); min-height: 0; display: flex; flex-direction: column; }
/* The Parameters, a tab: the window's room, scrolled */
#levers.levers-tab { flex: 1; min-height: 0; background: transparent; }
#files { grid-area: files; border-right: 1px solid var(--line); min-width: 0; }
#inspector { grid-area: insp; border-left: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; }
/* ── Tiles ─────────────────────────────────────────────────────────── */
.tiles { grid-area: tiles; position: relative; min-height: 0; min-width: 0; background: var(--bg); overflow: hidden; }
.tile-root { position: absolute; inset: 0; display: flex; padding: 4px; }
.tile-root > * { flex: 1 1 0; }
.tile {
    display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
    transition: border-color .12s, box-shadow .12s;
}
.tile.focused { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.tile-head { display: flex; align-items: center; gap: 2px; height: 30px; padding: 0 4px 0 6px; border-bottom: 1px solid var(--line); flex: none; }
/* A window of tabs: the views side by side, the chosen one marked. */
.tile-tabs { display: flex; align-items: stretch; gap: 2px; height: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tile-tab { position: relative; display: flex; align-items: center; color: var(--muted); transition: color .2s ease; }
.tile-tab-l { height: 100%; border: 0; background: none; cursor: pointer; padding: 0 9px; font: 600 12px/1 var(--font); color: inherit; white-space: nowrap; }
.tile-tab-x { flex: none; width: 16px; height: 16px; margin: 0 4px 0 -5px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--faint); display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .15s ease, background-color .15s ease, color .15s ease; }
.tile-tab-x svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.tile-tab.on .tile-tab-x, .tile-tab:hover .tile-tab-x, .tile-tab-x:focus-visible { opacity: 1; }
.tile-tab-x:hover { background: var(--hover); color: var(--ink); }
.tile-tab::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 1px; background: var(--accent); transform: scaleX(0); transition: transform .22s cubic-bezier(.2,.7,.2,1); }
.tile-tab.on { color: var(--ink); }
.tile-tab.on::after { transform: scaleX(1); }
.tile-tab:hover:not(.on) { color: var(--ink); }
.tile-tab-add { height: 22px; align-self: center; width: 26px; border: 0; background-color: transparent; background-image: none; padding: 0; text-align: center; font-weight: 600; color: var(--faint); cursor: pointer; }
.tile-tab-add:hover { background-color: var(--hover); color: var(--ink); }
@keyframes tab-in { from { opacity: 0; transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .tile-tab, .tile-tab::after { transition: none; } }
.tile-btn { border: 0; background: none; color: var(--faint); width: 24px; height: 22px; border-radius: 5px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.tile-btn svg { width: 13px; height: 13px; }
.tile-btn:hover { background: var(--hover); color: var(--ink); }
.tile:not(:hover):not(.focused) .tile-btn { opacity: 0; }
.tile-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.tile-viewport { position: absolute; inset: 0; background: var(--canvas); }
.tile-parking { display: none; }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ws-bar { position: relative; display: inline-flex; gap: 2px; background: var(--hover); padding: 2px; border-radius: 8px; margin-left: 4px; }
/* The highlight under the chosen workspace glides to the next one. */
.ws-pill { position: absolute; left: 2px; top: 2px; height: 26px; width: 0; border-radius: 6px; background: var(--surface); box-shadow: var(--shadow-1);
    transition: transform .26s cubic-bezier(.2,.7,.2,1), width .26s cubic-bezier(.2,.7,.2,1); pointer-events: none; }
.ws-btn { position: relative; border: 0; background: none; cursor: pointer; height: 26px; padding: 0 10px; border-radius: 6px; font: 550 12px/1 var(--font); color: var(--muted); display: inline-flex; align-items: center; gap: 5px; transition: color .2s ease; }
.ws-btn kbd { border: 0; background: none; padding: 0; font-size: 10.5px; color: var(--faint); }
.ws-btn .ws-name { white-space: nowrap; display: inline-flex; }
.ws-btn .ws-rest { display: inline-block; max-width: 7em; overflow: hidden; transition: max-width .22s ease, opacity .18s ease; }
.ws-btn.on { color: var(--ink); }
/* a layout of one's own: the + after them */
.ws-add { position: relative; border: 0; background: none; cursor: pointer; width: 24px; height: 26px; border-radius: 6px; font: 400 16px/1 var(--font); color: var(--faint); transition: color .15s ease, background .15s ease; }
.ws-add:hover { color: var(--ink); background: var(--surface); }
.ws-btn:hover:not(.on) { color: var(--ink); }
.ws-btn .count { margin-left: 1px; }
@media (prefers-reduced-motion: reduce) { .ws-pill { transition: none; } }

.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; }
.panel-head h2, .sheet-head h2 { font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.search { position: relative; margin: 0 12px 8px; }
.search svg { position: absolute; left: 9px; top: 7px; width: 14px; height: 14px; color: var(--faint); }
.search input { width: 100%; padding-left: 28px; height: 30px; }

/* ── Levers ───────────────────────────────────────────────────────── */
.lever-list { overflow-y: auto; flex: 1; padding: 0 6px 16px; }
.lever-group { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 12px 8px 4px; display: flex; justify-content: space-between; }
.lever {
    padding: 8px 8px 10px; border-radius: var(--r); position: relative;
    transition: background .12s;
}
.lever:hover { background: var(--hover); }
.lever.changed::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--live); }
.lever-top { display: flex; align-items: center; gap: 6px; }
.lever-name {
    flex: 1; min-width: 0; font-weight: 550; cursor: pointer; line-height: 1.25; align-self: center;
    overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word;
}
.lever-name:hover { color: var(--accent); }
.lever-val {
    width: 84px; text-align: right; font: 12.5px/1 var(--mono); border: 1px solid transparent; background: none;
    border-radius: 4px; padding: 3px 4px; height: auto;
}
.lever-val:hover { border-color: var(--line-2); }
.lever-val:focus { border-color: var(--accent); background: var(--surface); }
.lever-reset { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; visibility: hidden; }
.lever.changed .lever-reset { visibility: visible; }
.lever-reset:hover { color: var(--ink); }
.lever-meta { display: flex; justify-content: space-between; font: 10.5px/1 var(--mono); color: var(--faint); margin-top: 3px; }
.lever-impact { height: 3px; border-radius: 2px; background: var(--accent); opacity: .6; margin-top: 5px; transition: width .4s; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: none; margin: 6px 0 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track {
    height: 4px; border-radius: 2px;
    background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--p, 50%), var(--line-2) var(--p, 50%));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-2); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; margin-top: -5px;
    background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow-1);
    transition: transform .1s;
}
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.2); }
input[type="range"]:focus { box-shadow: none; }
.lever-more { display: block; margin: 8px auto; }
.lever-empty { color: var(--faint); padding: 18px 12px; font-size: 12px; }

/* ── Stage ────────────────────────────────────────────────────────── */
.viewport-host, .viewport { position: absolute; inset: 0; }
.viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.viewport-2d { cursor: default; }
.viewport-2d.panning { cursor: grabbing; }
.viewport-2d.over { cursor: pointer; }
.view3d { visibility: hidden; }
.view3d-overlay { visibility: hidden; cursor: grab; }
.seg { display: inline-flex; background: var(--hover); border-radius: 7px; padding: 2px; gap: 2px; align-self: center; }
.seg-btn { border: 0; background: none; cursor: pointer; font: 600 11.5px/1 var(--font); padding: 6px 8px; border-radius: 5px; color: var(--muted); }
.seg-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.preset { height: 26px; align-self: center; font-size: 12px; margin: 0 2px; }
.stage-tools {
    position: absolute; right: 10px; bottom: 10px; z-index: 3; display: flex; gap: 2px; padding: 3px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-1);
}
.stage-tools .sep { width: 1px; background: var(--line); margin: 4px 3px; }
.stage-hud { position: absolute; left: 10px; top: 10px; right: 10px; z-index: 3; display: flex; gap: 8px; align-items: flex-start; pointer-events: none; }
.stage-hud > * { pointer-events: auto; }
.chip {
    display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 6px 0 10px; border-radius: 14px;
    background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); font-weight: 550; font-size: 12px;
}
.chip button { border: 0; background: var(--hover); color: var(--muted); width: 18px; height: 18px; border-radius: 50%; cursor: pointer; line-height: 1; }
.loop-chip {
    margin-left: auto; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); font-size: 12px; max-width: 360px;
}
.loop-chip .lp { font: 700 12px/1 var(--mono); padding: 4px 6px; border-radius: 5px; color: #fff; }
.loop-chip .lp.R { background: var(--R); } .loop-chip .lp.B { background: var(--B); }
.loop-chip .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }

.story {
    position: absolute; left: 12px; bottom: 60px; z-index: 3; width: min(460px, calc(100% - 24px));
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-2);
    padding: 12px 14px 10px; animation: rise .35s ease-out;
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.story-when { font: 600 11px/1 var(--mono); color: var(--live); letter-spacing: .02em; }
.story-head { font-size: 15px; font-weight: 650; margin: 6px 0 2px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.story-head .lp { font: 700 11px/1 var(--mono); padding: 4px 6px; border-radius: 4px; color: #fff; }
.story-share { font-size: 12px; font-weight: 500; color: var(--muted); }
.story p { margin: 6px 0; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.story-path { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-bar { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.tooltip {
    position: absolute; pointer-events: none; z-index: 4; min-width: 150px; max-width: 260px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2);
    padding: 8px 10px; font-size: 12px;
}
.tooltip .tt-name { font-weight: 600; }
/* A control's hint: its name, its keys, what it does (data-tip). */
.btn-tip { position: fixed; z-index: 90; max-width: 260px; padding: 7px 10px; border-radius: 8px; background: var(--ink); color: var(--surface);
    font: 500 12px/1.35 var(--font); box-shadow: 0 6px 18px rgba(0, 0, 0, .18); pointer-events: none;
    opacity: 0; transform: translateY(3px); transition: opacity .14s ease, transform .14s ease; visibility: hidden; }
.btn-tip.shown { visibility: visible; }
.btn-tip.on { opacity: 1; transform: none; }
.btn-tip b { font-weight: 650; }
.btn-tip .bt-keys { margin-left: 8px; white-space: nowrap; }
.btn-tip kbd { display: inline-block; min-width: 1.5em; margin-left: 2px; padding: 0 4px; border-radius: 4px; text-align: center;
    background: color-mix(in srgb, var(--surface) 18%, transparent); font: 600 11px/1.6 var(--font); }
.btn-tip .bt-more { margin-top: 2px; opacity: .78; }
.tooltip .tt-val { font: 600 15px/1.3 var(--mono); }
.tooltip .tt-kind { color: var(--muted); font-size: 11px; }
.tooltip canvas { display: block; width: 100%; height: 34px; margin-top: 4px; }

.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; background: var(--canvas); z-index: 5; }
.empty-card { max-width: 860px; width: 100%; }
.empty h1 { font-size: 30px; letter-spacing: -0.025em; margin: 0 0 8px; font-weight: 700; }
.empty p { color: var(--ink-2); font-size: 15px; max-width: 620px; margin: 0 0 22px; }
.empty em { font-style: normal; color: var(--accent); font-weight: 600; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.gallery-head { grid-column: 1 / -1; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 10px 0 0; }
.gallery-head:first-child { margin-top: 0; }
.gallery-empty { grid-column: 1 / -1; padding: 6px 0; }
.search.model-search { margin: 0 0 12px; max-width: 360px; }
.gallery .card[hidden], .gallery-head[hidden] { display: none; }
.card {
    border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px; text-align: left; cursor: pointer;
    display: flex; flex-direction: column; gap: 8px; transition: border-color .12s, box-shadow .12s, transform .12s;
}
.card:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.card.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card canvas { width: 100%; height: 96px; border-radius: 6px; background: var(--canvas); display: block; }
.card .c-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .c-meta { font: 11px/1.2 var(--mono); color: var(--muted); }

/* ── Inspector ────────────────────────────────────────────────────── */
.insp-empty { padding: 28px 18px; color: var(--muted); }
.insp-empty .hint { color: var(--faint); font-size: 12px; }
#insp { padding: 14px 16px 24px; }
.insp-head { display: flex; align-items: center; gap: 8px; }
.insp-head h2 { font-size: 16px; margin: 0; flex: 1; letter-spacing: -0.01em; line-height: 1.25; }
.kind-badge { font: 600 10px/1 var(--mono); text-transform: uppercase; letter-spacing: .06em; padding: 4px 6px; border-radius: 4px; color: #fff; background: var(--aux); }
.kind-badge.stock { background: var(--stock); } .kind-badge.flow { background: var(--flow); }
.insp-value { display: flex; align-items: baseline; gap: 6px; margin: 10px 0 2px; flex-wrap: wrap; }
.big-num { font: 650 26px/1.1 var(--mono); letter-spacing: -0.02em; }
.units { color: var(--muted); }
.delta { font: 600 12px/1 var(--mono); padding: 3px 6px; border-radius: 4px; }
.delta.up { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.delta.down { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.now { margin: 8px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--live); border-radius: var(--r-sm); padding: 7px 10px; }
.now b { font-weight: 650; color: var(--ink); }
.now .lp { font: 700 10px/1 var(--mono); padding: 2px 4px; border-radius: 3px; color: #fff; margin-right: 2px; vertical-align: 1px; }
.insp-chart { width: 100%; height: 150px; display: block; margin: 8px 0 6px; }
.sub { font-size: 10.5px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); margin: 14px 0 6px; }
.eqn { font: 12.5px/1.6 var(--mono); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; word-break: break-word; }
.eqn .ref { color: var(--accent); cursor: pointer; border-radius: 3px; }
.eqn .ref:hover { background: var(--accent-soft); }
.eqn .ref sub { font-size: 10px; color: var(--muted); margin-left: 2px; vertical-align: baseline; font-weight: 500; }
.eqn .integ { color: var(--muted); }
.eqn .init { display: block; margin-top: 4px; color: var(--muted); font-size: 11.5px; }
.eqn .gf-note { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; font-family: var(--font); }
.eqn canvas { display: block; width: 100%; height: 70px; margin-top: 6px; }
.doc-wrap p { margin: 0; color: var(--ink-2); font-size: 12.5px; max-height: 120px; overflow-y: auto; }
.rel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.rel > div { min-width: 0; }
.rel-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rel-list li { padding: 4px 6px; border-radius: 5px; cursor: pointer; font-size: 12px; display: flex; gap: 6px; align-items: center; min-width: 0; }
.rel-list li span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.rel-list li:hover { background: var(--hover); }
.rel-list li .k { width: 7px; height: 7px; border-radius: 2px; flex: none; background: var(--aux); }
.rel-list li .k.stock { background: var(--stock); } .rel-list li .k.flow { background: var(--flow); border-radius: 50%; }
.rel-list li.none { color: var(--faint); cursor: default; }
.rel-list li.none:hover { background: none; }
.rel-list .lp { font: 700 10px/1 var(--mono); padding: 3px 4px; border-radius: 4px; color: #fff; flex: none; }
.lp.R { background: var(--R); } .lp.B { background: var(--B); }

/* ── Dock ─────────────────────────────────────────────────────────── */
.count { font: 600 10px/1 var(--mono); background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 2px 5px; margin-left: 3px; }
.dock-spacer { flex: 1; }
.dock-note { color: var(--muted); font-size: 12px; }
.scope-bar, .why-bar, .scen-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; flex: none; flex-wrap: wrap; color: var(--ink-2); }
.goal-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 550; padding: 4px 8px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface); }
.goal-toggle:has(input:checked) { border-color: var(--live); color: var(--live); background: color-mix(in srgb, var(--live) 8%, var(--surface)); }
.goal-toggle input { accent-color: var(--live); margin: 0; }
.fan-toggle:has(input:checked) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.fan-toggle input { accent-color: var(--accent); }
.goal-result { font-size: 12px; color: var(--ink-2); flex: 1 1 240px; min-width: 0; }
.goal-result b { font-family: var(--mono); }
.goal-result.miss { color: var(--bad); }
.scope { flex: 1; min-height: 0; overflow-x: auto; overflow-y: hidden; display: flex; gap: 10px; padding: 0 14px 12px; }
.plot {
    flex: 1 0 300px; max-width: 560px; min-width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
    display: flex; flex-direction: column; position: relative; min-height: 0;
}
.plot-head { display: flex; align-items: center; gap: 6px; padding: 7px 8px 0 10px; font-weight: 600; font-size: 12px; }
.plot-head .sw { width: 10px; height: 3px; border-radius: 2px; flex: none; }
.plot-head .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
/* The model's own graphs, after the pinned ones */
/* (the row scrolls sideways: the section's name stands up, a divider) */
.scope-sec { flex: none; align-self: stretch; writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; padding: 0 2px; border-right: 1px solid var(--line); color: var(--muted); font: 650 10.5px/1 var(--font); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.plot-model .plot-head .t { cursor: default; }
.plot-head .plot-kind { color: var(--faint); font-weight: 500; font-size: 11px; }
.plot.flash { animation: plot-flash 1.2s ease; }
@keyframes plot-flash { 0%, 40% { box-shadow: 0 0 0 2px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .plot.flash { animation: none; outline: 2px solid var(--accent); } }
.plot-head .v { font: 600 12px/1 var(--mono); color: var(--ink-2); }
.plot-head button { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; border-radius: 4px; }
.plot-head button:hover { color: var(--ink); background: var(--hover); }
.plot canvas { flex: 1; min-height: 0; width: 100%; display: block; touch-action: none; }
.plot.goal canvas { cursor: ns-resize; }
.scope-hint { color: var(--faint); padding: 20px; }

/* Tornado */
.placeholder { color: var(--faint); padding: 18px 16px; max-width: 620px; }
.placeholder b { color: var(--ink-2); }

/* Why */
.why { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(180px, min(38%, 380px)) minmax(0, 1fr); gap: 12px; padding: 0 14px 12px; }
.why-list { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 4px; }
.loop-row { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 9px; cursor: pointer; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 8px; align-items: center; }
.loop-row:hover { border-color: var(--line-2); }
.loop-row.sel { border-color: var(--ink); box-shadow: 0 0 0 2px var(--accent-soft); }
.loop-row .lp { font: 700 11px/1 var(--mono); padding: 4px 5px; border-radius: 4px; color: #fff; }
.loop-row .path { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loop-row .share { font: 600 12px/1 var(--mono); }
.loop-row .bar { grid-column: 1 / -1; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.loop-row .bar i { display: block; height: 100%; }
.why-chart { position: relative; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; }
.why-chart canvas { flex: 1; width: 100%; min-height: 0; display: block; }
.why-chart .plot-head { padding-bottom: 2px; }

/* Scenarios */
.scenarios { flex: 1; overflow-x: auto; display: flex; gap: 10px; padding: 0 14px 12px; align-items: stretch; }
.scen {
    flex: 0 0 240px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; position: relative;
}
.scen.on { box-shadow: inset 0 3px 0 var(--c); }
.scen-top { display: flex; align-items: center; gap: 8px; }
.scen-top .sw { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: none; }
.scen-top .nm { font-weight: 650; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scen-top button { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 15px; }
.scen-top button:hover { color: var(--ink); }
.scen-diff { font: 11.5px/1.5 var(--mono); color: var(--ink-2); overflow-y: auto; flex: 1; }
.scen-diff .d { display: flex; justify-content: space-between; gap: 8px; }
.scen-diff .d span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font); }
.scen-actions { display: flex; gap: 4px; }
.scen-actions label { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; color: var(--muted); cursor: pointer; }

/* ── Overlays ─────────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(6px); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.sheet { width: min(920px, 100%); max-height: 78vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-2); padding: 16px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { flex: none; }
.sheet-head .hint { color: var(--faint); font-size: 12px; flex: 1; min-width: 0; }
.sheet-head .add-file { margin-left: auto; cursor: pointer; }
/* (A touch screen drops no files: the button adds them.) */
@media (pointer: coarse) { .sheet-head .drop-hint { display: none; } }
.palette { width: min(620px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-2); overflow: hidden; }
.palette input { width: 100%; height: 50px; border: 0; border-bottom: 1px solid var(--line); background: none; font-size: 16px; padding: 0 18px; border-radius: 0; box-shadow: none; }
.palette input:focus { box-shadow: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.palette li.sel { background: var(--accent-soft); }
.palette li .pk { font: 600 10px/1 var(--mono); text-transform: uppercase; color: var(--muted); width: 58px; flex: none; }
.palette li .pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette li .pv { font: 12px/1 var(--mono); color: var(--muted); }
.palette li mark { background: none; color: var(--accent); font-weight: 700; }

.gate { margin-top: 8vh; width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-2); padding: 28px; text-align: center; }
.gate h1 { margin: 0; font-size: 26px; font-weight: 450; letter-spacing: -0.02em; }
.gate h1 b { font-weight: 700; }
.gate p { color: var(--ink-2); }
.gate .fine { font-size: 12px; color: var(--muted); }
.gate .err { color: var(--bad); }
.drop { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--accent) 12%, transparent); border: 3px dashed var(--accent); font-size: 22px; font-weight: 700; color: var(--accent); pointer-events: none; }
/* Above the diagram's toolbar (its top sits 53px up), and in and out with
   a fade rather than a pop. */
/* A message is only words: taps and clicks go through it to what lies under
   (on a phone it covers part of the diagram while it is read). */
.toast { position: fixed; bottom: 68px; left: 50%; transform: translateX(-50%); z-index: 40; background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 10px; box-shadow: var(--shadow-2); font-weight: 550; max-width: 80vw; pointer-events: none;
    transition: opacity .18s ease, transform .22s cubic-bezier(.2,.7,.2,1), visibility 0s; }
.toast[hidden] { display: block; opacity: 0; visibility: hidden; transform: translate(-50%, 8px); pointer-events: none;
    transition: opacity .18s ease, transform .22s ease, visibility 0s .22s; }
@media (prefers-reduced-motion: reduce) { .toast, .toast[hidden] { transition: none; } }
.toast.has-act:not([hidden]) { pointer-events: auto; }
.toast-act { margin-left: 8px; padding: 2px 10px; border: 1px solid color-mix(in srgb, var(--bg) 45%, transparent); border-radius: 7px; background: none; color: inherit; font: inherit; cursor: pointer; }
.toast-act:hover { background: color-mix(in srgb, var(--bg) 16%, transparent); }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 1180px) {
    :root { --insp-w: 290px; --lever-w: 260px; --files-w: 260px; }
}
@media (max-width: 920px) {
    .tiles { height: 120vh; }
    .tile { min-height: 300px; }
    .bar-left { flex-wrap: wrap; }
    body { overflow: auto; }
    #app { height: auto; min-height: 100%; }
    #bar { flex-wrap: wrap; height: auto; padding: 8px 12px; row-gap: 6px; }
    .bar-mid { order: 5; flex-basis: 100%; }
    .transport { max-width: none; }
    .bar-right { margin-left: auto; }
    .bar-right .kbd-btn kbd, .engine { display: none; }
    #work { display: flex; flex-direction: column; }
    #files { order: 3; max-height: 48vh; border-right: 0; border-top: 1px solid var(--line); }
    #inspector { order: 4; border-left: 0; border-top: 1px solid var(--line); }
    .why { grid-template-columns: 1fr; grid-template-rows: 150px 1fr; }
    .model-pick { max-width: 52vw; }
}

/* A phone: the bar in two rows that fit the screen, never wider than it —
   the logo, the model, and the tools on the first; the three workspaces,
   sharing the width, on the second (the run's clock below them). */
@media (max-width: 640px) {
    #bar { display: flex; flex-wrap: wrap; align-items: center; column-gap: 4px; row-gap: 6px; padding: 6px 10px; overflow-x: clip; }
    .bar-left { display: contents; }
    .brand { order: 1; }
    .brand span { display: none; }
    .model-pick { order: 2; flex: 1 1 0; min-width: 0; max-width: none; }
    .model-name-btn { flex: 0 1 auto; font-size: 14px; }
    .slice-btn { order: 3; }
    .bar-right { order: 4; margin-left: auto; gap: 0; }
    .bar-right .share-btn { padding: 0 8px; }
    .admin-link .label { display: none; }
    .admin-link { padding: 0 8px; }
    .bar-sep { margin: 0 2px; }
    #ws-bar { order: 5; flex: 1 1 100%; margin-left: 0; display: flex; }
    #ws-bar[hidden] { display: none; }
    #ws-bar .ws-btn { flex: 1 1 0; justify-content: center; padding: 0 6px; }
    #scen-count { order: 6; }
    .bar-mid { order: 7; }
    #app, body { max-width: 100vw; overflow-x: clip; }
    /* The diagram's two toolbars fit its width: what a finger does itself
       (zooming: a pinch) leaves them, and so does the saved-state chip (the
       Save button, dimmed, says it). */
    /* The tiles fill exactly what is left of the screen below the bar, so the
       diagram's toolbars are always on it (a finger on the diagram moves the
       diagram, not the page). */
    .tiles { height: calc((100dvh - var(--bar-h, 120px) - 6px) * max(1, 1 + (var(--n, 1) - 2) * 0.6)); min-height: 360px; }
    .tile { min-height: 200px; }
    #edit-bar { gap: 1px; padding: 3px 4px; }
    .edit-status-chip { display: none; }
    .stage-tools [data-act="zin"], .stage-tools [data-act="zout"] { display: none; }
}
#edit-bar, .stage-tools { max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none; }
/* A touch screen: fields 16 px or larger (smaller, and the page is zoomed in to
   them when they take the focus); the stand-in that holds the keyboard. */
@media (pointer: coarse) {
    input:not([type="range"]):not([type="checkbox"]):not([type="radio"]), textarea, select { font-size: max(16px, 1em) !important; }
}
.kbd-keeper { position: fixed; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; font-size: 16px; pointer-events: none; }
#edit-bar::-webkit-scrollbar, .stage-tools::-webkit-scrollbar { display: none; }

/* The dock adapts to its own width (it is squeezed between the side panels). */
.pane { container-type: inline-size; }
@container (max-width: 560px) {
    .why { grid-template-columns: 1fr; grid-template-rows: minmax(90px, 40%) minmax(0, 1fr); }
    .plot { flex-basis: 240px; min-width: 220px; }
}

/* ── Reality ─────────────────────────────────────────────────────── */
.reality { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 14px 16px; display: flex; flex-direction: column; gap: 12px; font-size: 12.5px; }
.rl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rl-status { color: var(--muted); line-height: 1.45; }
.rl-status b { color: var(--ink); }
.rl-stale { color: var(--live); }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--ink-2); font-weight: 500; }
.ghost-btn.small, .primary-btn.small { height: 26px; font-size: 12px; padding: 0 9px; }
.rl-sec { display: flex; flex-direction: column; gap: 6px; }
.rl-h { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.rl-meta { font-weight: 500; text-transform: none; letter-spacing: 0; }
.rl-levers { display: flex; flex-direction: column; gap: 4px; }
.rl-lever { display: grid; grid-template-columns: auto 1fr auto; column-gap: 8px; row-gap: 3px; align-items: center; padding: 3px 0; }
.rl-lever .rl-lname { grid-column: 1 / 3; grid-row: 1; }
.rl-lever .rl-pinned { grid-column: 3; grid-row: 1; }
.rl-lever .rl-range { grid-column: 1; grid-row: 2; }
.rl-lever .rl-hist { grid-column: 2 / 4; grid-row: 2; }
.rl-lever.off { grid-template-columns: 1fr; opacity: .7; padding: 0; }
.rl-lname { display: flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.rl-range { display: inline-flex; align-items: center; gap: 3px; color: var(--faint); }
.rl-num { width: 74px; height: 24px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); padding: 0 5px; font: 500 11.5px var(--mono); color: var(--ink); }
.rl-hist { width: 100%; height: 22px; display: block; }
.rl-pinned { font: 600 11px var(--mono); color: var(--good); white-space: nowrap; }
.rl-evbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rl-form { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px dashed var(--line-2); border-radius: var(--r-sm); }
.rl-form textarea, .rl-form input[type=text], .rl-form input[type=number] { border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); padding: 4px 6px; font: 12px var(--mono); }
.rl-claim { display: grid; grid-template-columns: 1fr 70px 70px; gap: 6px; }
.rl-ev { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); }
.rl-ev.off { opacity: .55; }
.rl-evtop { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rl-evtop .sw, .rl-fam .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.rl-src { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.rl-evbot { display: flex; align-items: center; gap: 8px; }
.rl-evbot input[type=range] { width: 110px; }
.rl-bel { font: 600 11px var(--mono); color: var(--ink-2); width: 34px; }
.rl-z { font-size: 11px; color: var(--good); }
.rl-z.hot { color: var(--bad); font-weight: 600; }
.rl-empty, .rl-note { color: var(--muted); line-height: 1.45; }
.rl-rem { display: grid; grid-template-columns: minmax(80px, 1fr) 2fr 36px; gap: 8px; align-items: center; }
.rl-rname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-rbar { height: 6px; background: var(--hover); border-radius: 3px; overflow: hidden; }
.rl-rbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--good), var(--muted)); border-radius: 3px; }
.rl-rpct { font: 600 11px var(--mono); color: var(--ink-2); text-align: right; }
.rl-fam { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.rl-famlev { flex: 1; min-width: 0; font: 11.5px var(--mono); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-ask { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 0; }
.rl-ask:hover { color: var(--accent); }
.rl-q { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: #fff; font: 700 10px/16px var(--font); text-align: center; flex: none; }
.rl-gain { margin-left: auto; font: 600 11px var(--mono); color: var(--accent); }
.plot.pin canvas { cursor: crosshair; }
.lever-post { position: relative; height: 5px; margin: 3px 0 0; }
.lever-post i { position: absolute; top: 0; bottom: 0; background: var(--good); opacity: .55; border-radius: 3px; }
.lever-post b { position: absolute; top: -2px; width: 2px; height: 9px; margin-left: -1px; background: var(--good); border-radius: 1px; }

/* ── Individuals ─────────────────────────────────────────────────── */
.iv-stocks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.iv-note { color: var(--muted); line-height: 1.45; }
.iv-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.iv-chip { padding: 2px 8px; border-radius: 10px; background: var(--hover); font: 500 11.5px var(--font); }
.iv-chip.stock { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.iv-trait { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.iv-trait input[type=range] { width: 110px; }
.iv-cv, .iv-src { font: 600 11px var(--mono); color: var(--ink-2); }
.iv-cmp { display: grid; grid-template-columns: minmax(70px, 1fr) auto 48px; gap: 8px; align-items: baseline; }
.iv-cname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iv-cval { font: 11.5px var(--mono); color: var(--ink-2); }
.iv-cmp b { font: 700 12px var(--mono); text-align: right; color: var(--muted); }
.iv-cmp b.iv-hot { color: var(--live); }
.iv-plot { height: 190px; flex: none; }
.iv-hist { width: 100%; height: 120px; display: block; }

/* ── Live rooms ──────────────────────────────────────────────────── */
.room { display: flex; align-items: center; }
.room-people { display: flex; }
.avatar { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); color: #fff; font: 700 10.5px/22px var(--font); text-align: center; margin-left: -6px; cursor: pointer; padding: 0; box-shadow: var(--shadow-1); }
.avatar:first-child { margin-left: 0; }
.avatar.me { cursor: default; opacity: .85; }
.avatar.following { outline: 2px solid var(--accent); outline-offset: 1px; }
.edit-status { margin-top: 6px; font-size: 12px; color: var(--good); }
.edit-status.held { color: var(--bad); }
.edit-box { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.edit-box textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); padding: 6px 8px; font: 12px/1.5 var(--mono); resize: vertical; }
.edit-bar { display: flex; align-items: center; gap: 6px; }
.edit-bar .hint { color: var(--faint); font-size: 11px; }
.edit-note { margin: 0; font-size: 12px; color: var(--bad); line-height: 1.45; }
.edit-note:empty { display: none; }

/* ── Checks ──────────────────────────────────────────────────────── */
.ck-summary { line-height: 1.5; }
.ck-summary b { font-size: 13px; }
.ck-summary.good b { color: var(--good); }
.ck-summary.bad b { color: var(--bad); }
.ck-summary span { color: var(--muted); }
.ck-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; border: 0; background: none; padding: 5px 6px; border-radius: var(--r-sm); cursor: pointer; color: var(--ink); font: inherit; }
.ck-row:hover { background: var(--hover); }
.ck-row b { font-weight: 600; }
.ck-row span { color: var(--ink-2); font-size: 12px; }
.ck-hint { margin-left: auto; border: 1px solid currentColor; background: none; border-radius: 10px; padding: 1px 8px; font: 600 11px var(--mono); cursor: pointer; }
.ck-hint.good { color: var(--good); }
.ck-hint.bad { color: var(--bad); }
.insp-bar .ck-hint + .fold-btn { margin-left: 0; }
.unitcheck { margin: 4px 0 0; font-size: 12px; line-height: 1.45; }
.unitcheck.good { color: var(--good); }
.unitcheck.bad { color: var(--bad); }
.unitcheck.none { color: var(--muted); }

/* ── Decks ─────────────────────────────────────────────────────────── */
.deck-pick { max-width: 100%; }
.deck-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.deck-tpl {
    display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; padding: 8px 10px;
    border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); cursor: pointer;
}
.deck-tpl:hover { border-color: var(--accent); background: var(--accent-soft); }
.deck-tpl span { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.deck-title { font-size: 14px; font-weight: 650; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); }
.ghost-btn.danger { color: var(--bad); }
.deck-slides { display: flex; flex-direction: column; gap: 6px; }
.deck-slide { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.deck-slide.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.deck-shead { display: flex; align-items: center; gap: 4px; }
.deck-snum { font: 700 11px/1 var(--mono); color: var(--muted); min-width: 16px; }
.deck-stitle { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); font-weight: 600; font-size: 12.5px; padding: 3px 2px; }
.deck-stitle:focus, .deck-stext:focus { outline: 1px solid var(--accent); border-radius: 4px; }
.deck-stext { width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 4px; background: var(--canvas); color: var(--ink-2); font: 12px/1.45 var(--font); padding: 4px 6px; box-sizing: border-box; }
.deck-sbtn { width: 22px; height: 22px; font-size: 12px; color: var(--muted); }
.deck-stags { color: var(--muted); font-size: 11px; }
.deck-add { align-self: flex-start; }
.deck-help { color: var(--faint); font-size: 11.5px; line-height: 1.4; }

.deck-cap {
    position: absolute; left: 16px; bottom: 20px; z-index: 3; width: min(560px, calc(100% - 32px));
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-2);
    padding: 14px 16px 10px; animation: rise .35s ease-out;
}
.deck-cap h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -0.015em; line-height: 1.25; }
.deck-cap-by { font: 600 11px/1 var(--mono); color: var(--live); margin-bottom: 6px; }
.deck-cap-text p { margin: 6px 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.deck-num { font-family: var(--mono); font-weight: 650; color: var(--ink); }
.deck-live { font: 600 11px/1 var(--mono); color: var(--live); }

/* Presenting: the stage fills the window; the transport stays. */
#app.presenting #bar > :not(#transport) { display: none !important; }
#app.presenting #bar { justify-content: center; }
#app.presenting #transport { flex: 1; max-width: 760px; }
#app.presenting #work { grid-template-columns: 0 minmax(0, 1fr) 0; }
#app.presenting #levers, #app.presenting #files, #app.presenting #inspector { display: none; }
#tiles.staged .tile-head { display: none; }
#tiles.staged .tile { border-radius: 0; }

/* ── Matrix ────────────────────────────────────────────────────────── */
.mx-flow { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap; }
.mx-card {
    flex: 1 1 210px; min-width: 190px; display: flex; flex-direction: column; gap: 4px;
    border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 8px 10px;
}
.mx-card-h { display: flex; align-items: baseline; gap: 6px; margin-bottom: 2px; }
.mx-card-h b { font-size: 12.5px; }
.mx-card-h span { color: var(--muted); font-size: 11.5px; }
.mx-x, .mx-arrow { align-self: center; color: var(--faint); font-size: 18px; font-weight: 300; }
.mx-row { display: flex; align-items: center; gap: 6px; min-height: 24px; font-size: 12px; }
.mx-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }
.mx-meta.good { color: var(--good); } .mx-meta.warn { color: var(--live); }
.mx-x-btn { width: 22px; height: 22px; font-size: 12px; color: var(--muted); }
.mx-add { display: flex; gap: 4px; align-items: center; margin-top: 2px; }
.mx-add input { flex: 1; min-width: 0; height: 26px; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--canvas); color: var(--ink); font-size: 12px; }
.mx-metric { font-size: 11.5px; width: auto; flex: none; }
.mx-add-kpi { font-size: 11.5px; max-width: 100%; }
.mx-row .mx-x-btn { opacity: .45; }
.mx-row:hover .mx-x-btn { opacity: 1; }
.mx-hint { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.mx-result { display: flex; flex-direction: column; gap: 6px; }
.mx-verdict { font-size: 12.5px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--hover); }
.mx-verdict.good { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good); }
.mx-verdict.bad { background: color-mix(in srgb, var(--live) 12%, transparent); color: var(--live); }
.mx-verdict span { color: var(--ink-2); }
.mx-scroll { overflow-x: auto; }
.mx-grid { border-collapse: separate; border-spacing: 4px; font-size: 12px; }
.mx-grid th { font-weight: 600; color: var(--ink-2); text-align: left; padding: 2px 4px; white-space: nowrap; }
.mx-grid th.mx-corner { color: var(--muted); font-weight: 500; font-size: 11px; }
.mx-cell { min-width: 120px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 6px 8px; cursor: pointer; vertical-align: top; }
.mx-cell:hover { border-color: var(--accent); }
.mx-cell.moved { border-color: var(--live); box-shadow: 0 0 0 2px color-mix(in srgb, var(--live) 25%, transparent); }
.mx-cell.same { border-color: color-mix(in srgb, var(--good) 60%, var(--line)); }
.mx-v { display: flex; align-items: baseline; gap: 6px; }
.mx-v b { font: 650 14px/1.2 var(--mono); }
.mx-d { font: 600 11px/1 var(--mono); color: var(--muted); }
.mx-v2 { color: var(--muted); font-size: 11px; }
.mx-spark { display: block; width: 100%; height: 26px; margin-top: 4px; }
.mx-err { color: var(--bad); }
.mx-art { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 6px; border-radius: var(--r-sm); font-size: 12px; }
.mx-art.on { background: var(--accent-soft); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ── Ask ───────────────────────────────────────────────────────────── */
.ask-model { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--faint); }
.ask-row { display: flex; gap: 6px; }
.ask-row input { flex: 1; min-width: 0; height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: 12.5px; }
.ask-a { margin-top: 8px; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); animation: rise .25s ease-out; }
.ask-a p { margin: 0 0 6px; }
.ask-a.thinking { color: var(--muted); }
.ask-a.err { color: var(--bad); }
.ask-var { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
.ask-var:hover { text-decoration: underline; }
.ask-meta { color: var(--faint); font-size: 11px; margin-top: 2px; }
.ask-ctx { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.ask-ctx summary { cursor: pointer; }
.ask-item { padding: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-kind { font: 600 10px/1 var(--mono); text-transform: uppercase; color: var(--faint); display: inline-block; min-width: 38px; }

/* Drafted priors */
.rl-lever .rl-draft { grid-column: 1 / -1; }
.rl-draft { font-size: 11.5px; line-height: 1.45; padding: 5px 8px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--ink-2); display: flex; flex-direction: column; gap: 2px; }
.rl-draft.bad { background: color-mix(in srgb, var(--bad) 10%, transparent); flex-direction: row; justify-content: space-between; }
.rl-why { color: var(--muted); }
.rl-note { color: var(--faint); font-style: italic; }
.rl-ok { color: var(--good); }
.rl-warn { color: var(--live); font-weight: 600; }
.rl-draft-bar { display: flex; gap: 8px; align-items: center; margin-top: 2px; }

/* ── Editing ───────────────────────────────────────────────────────── */
#edit-bar {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 4;
    display: flex; align-items: center; gap: 3px; padding: 4px 6px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-2);
    animation: rise .2s ease-out;
}
.edit-tools { display: flex; gap: 2px; }
.edit-tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
#edit-bar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
#edit-bar .icon-btn:disabled { opacity: .35; }
.edit-status-chip { font: 600 11px/1 var(--mono); color: var(--muted); padding: 0 6px; white-space: nowrap; min-width: 8ch; text-align: center; transition: opacity .2s ease, color .2s ease; }
.edit-status-chip.busy { opacity: .45; }
.edit-status-chip.held { color: var(--live); }
.edit-rename {
    position: absolute; z-index: 5; width: 180px; height: 26px; padding: 0 6px; box-sizing: border-box;
    border: 1px solid var(--accent); border-radius: 6px; background: var(--surface); color: var(--ink);
    font: 600 12.5px var(--font); box-shadow: var(--shadow-2); text-align: center;
}
#app.editing canvas.viewport-2d[data-tool="stock"], #app.editing canvas.viewport-2d[data-tool="aux"] { cursor: copy; }
#app.editing canvas.viewport-2d[data-tool="flow"], #app.editing canvas.viewport-2d[data-tool="link"] { cursor: crosshair; }
.model-edit {
    display: flex; flex-direction: column; gap: 6px; margin: 10px 0 4px; padding: 10px;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: var(--r); background: var(--accent-soft);
}
.me-row { display: flex; flex-direction: column; gap: 3px; }
.me-row .sub { margin: 0; }
.me-row input, .me-row textarea {
    width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink); padding: 5px 7px; font: 12.5px/1.45 var(--mono);
}
.me-row textarea { resize: vertical; }
#me-doc { font-family: var(--font); }
.me-note { margin: 0; font-size: 11.5px; color: var(--muted); }
.me-note.held { color: var(--live); font-weight: 600; }
.edit-bar-row { display: flex; align-items: center; gap: 8px; }
.edit-bar-row .hint { font-size: 11px; color: var(--faint); }
.me-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.insp-empty .model-edit { text-align: left; margin-bottom: 14px; }
.card.card-new { border-style: dashed; background: transparent; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.card.card-new:hover { border-color: var(--accent); background: var(--accent-soft); }
.card-new .c-plus { height: 70px; display: grid; place-items: center; font: 300 34px/1 var(--font); color: var(--accent); }
.card-upload .c-plus svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ── Menus ─────────────────────────────────────────────────────────── */
.menu {
    position: fixed; z-index: 60; min-width: 170px; padding: 4px; display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2);
}
.menu-item { display: flex; align-items: center; gap: 6px; border: 0; background: none; cursor: pointer; text-align: left; padding: 6px 10px 6px 6px; border-radius: var(--r-sm); color: var(--ink); }
.menu-item:hover { background: var(--accent); color: var(--accent-ink); }
.menu-check { width: 14px; text-align: center; font-weight: 700; }
.menu-h { font: 600 10.5px/1 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 8px 10px 4px 26px; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 2px; }

/* ── A causal loop diagram: a drawing and its loops, nothing to run ── */
#app.cld #work { grid-template-columns: 0 minmax(0, 1fr) var(--c-insp); }
#app.cld #levers, #app.cld #files, #app.cld #loop-chip, #app.cld #why-run, #app.cld #slice-btn,
#app.cld .insp-value, #app.cld #insp-chart, #app.cld #insp-now, #app.cld #insp-unitcheck,
#app.cld #insp-eqn-wrap, #app.cld #insp-ask, #app.cld #insp-pin, #app.cld #insp-crowd, #app.cld #ck-hint,
#app.cld .me-row:has(#me-eqn), #app.cld .me-pair:has(#me-units) { display: none !important; }
.cld-sum { font-size: 12.5px; color: var(--ink-2); padding: 2px 2px 6px; }
.lp.U { background: var(--muted); }
/* The picked link's marks: open and close with a glide, a steady width
   while open (the bar never jumps). */
.edit-link { display: inline-flex; align-items: center; gap: 2px; overflow: hidden; white-space: nowrap;
    max-width: 0; opacity: 0; padding: 0; border-left: 0 solid var(--line); pointer-events: none;
    transition: max-width .24s cubic-bezier(.2,.7,.2,1), opacity .2s ease, padding .24s cubic-bezier(.2,.7,.2,1); }
.edit-link.open { max-width: 360px; opacity: 1; padding: 0 6px; border-left-width: 1px; pointer-events: auto; }
.edit-link-name { font-size: 12px; color: var(--ink-2); width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 4px; }
@media (prefers-reduced-motion: reduce) { .edit-link, .edit-status-chip { transition: none; } }
.link-mark { width: 26px; height: 26px; font: 700 14px/1 var(--font); color: var(--ink-2); }
.link-mark[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* ── Calibration: the Modelless drafter ─────────────────────────────── */
.rl-ml-map { line-height: 1.5; margin: 2px 0 6px; }
.rl-ml-edit { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.rl-ml-h { font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.rl-ml-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 12.5px; }
.rl-ml-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-family: var(--mono); font-size: 12px; }
.rl-ml-row select, .rl-ml-row input { min-width: 0; height: 28px; font: 12.5px var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 0 6px; }

/* ── Calibration: the reality layer's sources ──────────────────────── */
.src-row { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 8px; margin: 4px 0; background: var(--surface); }
.src-row.sel { border-color: var(--live); box-shadow: 0 0 0 2px color-mix(in srgb, var(--live) 20%, transparent); }
.src-top { display: flex; align-items: center; gap: 6px; }
.src-stone { width: 11px; height: 11px; flex: none; background: var(--live); clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%); }
.src-name { flex: 1; min-width: 0; border: 0; background: none; font: 600 12.5px var(--font); color: var(--ink); padding: 2px 0; }
.src-name:focus { outline: 1px solid var(--line-2); border-radius: 4px; }
.src-x { width: 22px; height: 22px; }
.src-links { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; padding-left: 17px; font-size: 12px; color: var(--ink-2); }
.src-link.model { color: var(--live); }
#src-add-name { flex: 1; min-width: 0; height: 28px; font: 12.5px var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 0 8px; }
.src-to { display: block; width: 100%; margin-top: 4px; height: 26px; padding: 0 8px; font: 12px var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }

/* ── Drag the outcome: its equifinal settings ─────────────────────── */
.equifinal { margin: 4px 0 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); font-size: 12.5px; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; }
.eq-head { display: flex; justify-content: space-between; gap: 8px; }
.eq-head b { font-weight: 600; color: var(--ink); }
.eq-spans { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.eq-span b { font-weight: 650; color: var(--ink); }
.eq-span.fixed { color: var(--accent); }
.eq-settings { display: flex; flex-wrap: wrap; gap: 6px; }
.eq-setting { border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r-sm); padding: 4px 8px; font: 12px var(--mono); color: var(--ink); cursor: pointer; }
.eq-setting:hover { border-color: var(--accent); }
.eq-n { font: 600 10.5px var(--font); color: var(--muted); margin-right: 6px; text-transform: uppercase; letter-spacing: .05em; }
.eq-got { color: var(--muted); }

/* ── Rooms: who can join ─────────────────────────────────────────── */
.room-lock { width: 26px; height: 26px; margin-left: 2px; color: var(--muted); }
.room-lock svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.room-lock:not(.locked) .shackle { transform: translate(2.5px, -1px); }
.room-lock.locked { color: var(--ink); }
.access-menu { width: 300px; padding: 10px; gap: 8px; }
.access-row { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--ink-2); }
#access-names { font: 12.5px var(--mono); padding: 6px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); resize: vertical; }
.access-note { margin: 0; font-size: 11.5px; color: var(--muted); }

/* ── Ask: the model's host ─────────────────────────────────────────── */
.ask-host { margin-left: 6px; font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 11px; }
.ask-host::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; background: currentColor; }
.ask-host.ok { color: var(--good); }
.ask-host.warm { color: var(--live); }
.ask-host.bad { color: var(--bad); }

/* ── What the engine replaced: a quiet note beside the model's name ──
   It takes no room until a model has something replaced, then opens to its
   width (the bar's other items glide along; nothing jumps), and stays. */
.replaced-note {
    display: inline-flex; align-items: center; gap: 5px; flex: none; box-sizing: border-box; height: 22px;
    max-width: 0; padding: 0; margin-left: -8px; border: 0 solid currentColor; border-radius: 11px; opacity: 0; overflow: hidden; visibility: hidden;
    background: none; color: var(--live); font: 600 11px var(--mono); white-space: nowrap; cursor: pointer;
    transition: max-width .24s ease, padding .24s ease, margin .24s ease, opacity .2s ease, background .12s, visibility 0s linear .24s;
}
.replaced-note.on { max-width: 13em; padding: 0 8px; margin-left: 0; border-width: 1px; opacity: 1; visibility: visible; transition-delay: 0s; }
.replaced-note:hover, .replaced-note[aria-expanded="true"] { background: color-mix(in srgb, var(--live) 12%, transparent); }
.replaced-note .rn-mark { font-size: 13px; line-height: 1; }
.replaced-menu { width: 330px; padding: 10px; gap: 8px; animation: replaced-in .16s ease; }
@keyframes replaced-in { from { opacity: 0; transform: translateY(-3px); } }
.replaced-why { margin: 0; font-size: 12px; line-height: 1.45; color: var(--ink-2); }
.replaced-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.replaced-list li { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 8px; align-items: baseline; font-size: 12.5px; line-height: 1.4; }
.replaced-list b { font: 600 11.5px var(--mono); color: var(--live); overflow-wrap: anywhere; }
.replaced-list span { color: var(--ink); }
[data-theme="xp"] #bar .replaced-note { color: #ffd98a; }
@media (max-width: 640px) { .replaced-note { order: 3; margin-left: -4px; } }
@media (prefers-reduced-motion: reduce) { .replaced-note, .replaced-menu { transition: none; animation: none; } }

/* ── Arrays: the slice shown ───────────────────────────────────────── */
.slice-btn { height: 30px; gap: 6px; max-width: 190px; margin-left: 2px; color: var(--ink-2); font-size: 12.5px; flex-shrink: 1; min-width: 0; }
@media (max-width: 1280px) { .slice-now { display: none; } }
.slice-btn svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; }
.slice-now { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.slice-menu { width: 320px; padding: 10px; gap: 8px; }
.slice-h { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.slice-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; align-items: center; gap: 8px; font-size: 12.5px; }
.slice-dim { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.slice-row select { min-width: 0; height: 28px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm); }
.slice-foot { display: flex; gap: 6px; justify-content: flex-end; padding-top: 4px; border-top: 1px solid var(--line); }
.insp-slice { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.insp-slice::before { content: "slice "; color: var(--faint); }
.elements { margin-top: 10px; }
.el-note { font-weight: 500; color: var(--faint); margin-left: 4px; }
.el-list { display: flex; flex-direction: column; max-height: 260px; overflow: auto; margin-top: 4px; }
.el-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 3px 6px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); font: 12px var(--font); text-align: left; cursor: pointer; }
.el-row:hover { background: var(--hover); }
.el-row.on { background: var(--accent-soft); color: var(--ink); }
.el-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.el-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.el-track { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.el-bar { display: block; height: 100%; background: var(--stock); border-radius: 3px; }
.el-bar.neg { background: var(--R); }
.el-v { font: 12px var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); min-width: 5.5em; text-align: right; }

/* ── Theme: Windows XP (Luna) ──────────────────────────────────────── */
:root[data-theme="xp"] {
    --bg: #ece9d8; --panel: #ece9d8; --surface: #ffffff; --canvas: #ffffff;
    --grid: rgba(0, 0, 0, 0.05);
    --ink: #000000; --ink-2: #1e1e1e; --muted: #5a5a5a; --faint: #8c8c8c;
    --line: #aca899; --line-2: #7f9db9;
    --hover: rgba(49, 106, 197, 0.10); --press: rgba(49, 106, 197, 0.18);
    --accent: #316ac5; --accent-ink: #ffffff; --accent-soft: rgba(49, 106, 197, 0.16);
    --live: #e46f14;
    --stock: #0a4fc4; --stock-fill: rgba(10, 79, 196, 0.14);
    --flow: #1f8f3f; --aux: #333333; --conn: rgba(50, 50, 50, 0.45);
    --R: #d64e12; --B: #0a4fc4; --good: #2e8b2e; --bad: #cc0000;
    --s1: #0a4fc4; --s2: #e46f14; --s3: #2e8b2e; --s4: #8e44ad; --s5: #c9960c; --s6: #1a8a8a; --s7: #c2185b; --s8: #6b8e23;
    --shadow-1: 1px 1px 2px rgba(0, 0, 0, 0.18); --shadow-2: 2px 3px 10px rgba(0, 0, 0, 0.3);
    --font: Tahoma, "Segoe UI", Verdana, Geneva, sans-serif; --mono: "Lucida Console", Consolas, Monaco, monospace;
    --r: 3px; --r-sm: 3px;
    --titlebar: linear-gradient(to bottom, #0997ff 0%, #0053ee 8%, #0050ee 40%, #0066ff 88%, #0066ff 93%, #005bff 95%, #003dd7 96%, #003dd7 100%);
    --titlebar-off: linear-gradient(to bottom, #7697e7 0%, #7e9ee3 10%, #94afe8 60%, #97b4e9 90%, #7996de 100%);
    --xp-button: linear-gradient(180deg, #ffffff 0%, #ecebe6 86%, #d6d0c5 100%);
    color-scheme: light;
}
[data-theme="xp"] body { font-size: 12px; -webkit-font-smoothing: auto; }
[data-theme="xp"] #bar { background: var(--titlebar); border-bottom: 1px solid #0831d9; }
[data-theme="xp"] #bar .brand, [data-theme="xp"] #bar .brand b, [data-theme="xp"] #bar .model-btn, [data-theme="xp"] #bar .model-name-btn,
[data-theme="xp"] #bar .clock, [data-theme="xp"] #bar .clock-u, [data-theme="xp"] #bar .engine, [data-theme="xp"] #bar .model-btn svg,
[data-theme="xp"] .bar-right > .icon-btn { color: #fff; text-shadow: 1px 1px #0f1089; }
[data-theme="xp"] #bar .brand svg { color: #fff; }
[data-theme="xp"] #bar .model-btn:hover, [data-theme="xp"] #bar .model-name-btn:hover, [data-theme="xp"] .bar-right > .icon-btn:hover { background: rgba(255, 255, 255, 0.18); }
[data-theme="xp"] .ws-bar { background: rgba(0, 0, 0, 0.18); border-radius: 3px; }
[data-theme="xp"] .ws-btn { color: #e6eeff; }
[data-theme="xp"] .ws-btn kbd { color: #b8cbf3; }
[data-theme="xp"] .ws-btn.on { background: #ece9d8; color: #000; box-shadow: inset 0 -2px #e46f14; }
[data-theme="xp"] .ws-pill, [data-theme="w2k"] .ws-pill { display: none; }
[data-theme="xp"] .transport .icon-btn { background: radial-gradient(circle at 50% 28%, #8fe28f 0%, #3c9a3c 55%, #2b7d2b 100%); color: #fff; box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.35); }
[data-theme="xp"] .scrub-track { background: rgba(255, 255, 255, 0.45); }
[data-theme="xp"] .engine .dot { background: #c9ddff; }
/* Push buttons: the white-to-beige face, the dark blue rim, the orange hover. */
[data-theme="xp"] .ghost-btn, [data-theme="xp"] .primary-btn, [data-theme="xp"] .seg-btn, [data-theme="xp"] .deck-tpl, [data-theme="xp"] .card.card-new {
    border: 1px solid #003c74; border-radius: 3px; background: var(--xp-button); color: #000; font-weight: normal; box-shadow: none; text-shadow: none;
}
[data-theme="xp"] .primary-btn { box-shadow: inset -1px 1px #cee7ff, inset 1px 2px #98b8ea, inset -2px 2px #bcd4f6, inset 1px -1px #89ade4, inset 2px -2px #89ade4; }
[data-theme="xp"] .ghost-btn:hover, [data-theme="xp"] .primary-btn:hover, [data-theme="xp"] .seg-btn:hover, [data-theme="xp"] .deck-tpl:hover {
    background: var(--xp-button); filter: none;
    box-shadow: inset -1px 1px #fff0cf, inset 1px 2px #fdd889, inset -2px 2px #fbc761, inset 2px -2px #e5a01a;
}
[data-theme="xp"] .ghost-btn:active, [data-theme="xp"] .primary-btn:active { background: linear-gradient(180deg, #cdcac3 0%, #e3e3db 8%, #e5e5de 94%, #f2f2f1 100%); }
[data-theme="xp"] .bar-right .ghost-btn { height: 24px; }
[data-theme="xp"] .icon-btn:hover { background: #fff; box-shadow: inset 0 0 0 1px #aca899; }
[data-theme="xp"] .link-btn { color: #0066cc; }
[data-theme="xp"] input[type="text"], [data-theme="xp"] input[type="search"], [data-theme="xp"] input[type="number"], [data-theme="xp"] select, [data-theme="xp"] textarea {
    border: 1px solid #7f9db9; border-radius: 0; background-color: #fff;
}
[data-theme="xp"] input:focus, [data-theme="xp"] select:focus, [data-theme="xp"] textarea:focus { box-shadow: none; border-color: #316ac5; }
/* Side panes: the task pane's blue, its group headers. */
[data-theme="xp"] #levers, [data-theme="xp"] #inspector { background: linear-gradient(to bottom, #d3dff9, #c4d4f6); border-color: #7f9db9; }
[data-theme="xp"] .panel-head { margin: 8px 8px 4px; padding: 6px 10px; border-radius: 3px 3px 0 0; background: linear-gradient(to right, #ffffff, #c6d3f7); }
[data-theme="xp"] .panel-head h2 { color: #215dc6; }
[data-theme="xp"] .lever { background: rgba(255, 255, 255, 0.55); margin: 0 2px 3px; border-radius: 3px; }
/* Windows: a blue frame, the Luna title bar, the caption buttons. */
[data-theme="xp"] .tiles { background: #3a6ea5; }
[data-theme="xp"] .tile { border: 3px solid #0831d9; border-top: 0; border-radius: 8px 8px 0 0; background: var(--panel); box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.35); }
[data-theme="xp"] .tile:not(.focused) { border-color: #7a96df; }
[data-theme="xp"] .tile.focused { box-shadow: 1px 2px 8px rgba(0, 0, 0, 0.45); }
[data-theme="xp"] .tile-head { height: 28px; border-bottom: 0; background: var(--titlebar-off); }
[data-theme="xp"] .tile.focused .tile-head { background: var(--titlebar); }
[data-theme="xp"] .tile-head .tile-tab, [data-theme="xp"] .tile-head .tile-tab-x, [data-theme="xp"] .tile-head .tile-tab-add { color: rgba(255, 255, 255, .78); }
[data-theme="xp"] .tile-head .tile-tab.on { color: #fff; text-shadow: 1px 1px #0f1089; }
[data-theme="xp"] .tile-head .tile-tab::after { background: #fff; }
[data-theme="xp"] .tile-btn { width: 21px; height: 21px; margin-left: 2px; border: 1px solid #fff; border-radius: 3px; color: #fff;
    background: radial-gradient(circle at 90% 90%, #0054e9 0%, #2263d5 55%, #4480f6 100%); }
[data-theme="xp"] .tile-btn:last-child { background: radial-gradient(circle at 90% 90%, #cc4600 0%, #dc6527 55%, #e8a584 100%); }
[data-theme="xp"] .tile-btn:hover { filter: brightness(1.15); }
[data-theme="xp"] .card { border-color: #aca899; border-radius: 3px; }
/* Tooltips and notes: the yellow balloon. */
[data-theme="xp"] .tooltip, [data-theme="xp"] #toast, [data-theme="xp"] .toast { background: #ffffe1; color: #000; border: 1px solid #000; border-radius: 6px; }
[data-theme="xp"] .menu { border: 1px solid #aca899; border-radius: 0; padding: 2px; box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.35); }
[data-theme="xp"] .menu-item { border-radius: 0; }

/* ── Theme: Windows 2000 (classic) ─────────────────────────────────── */
:root[data-theme="w2k"] {
    --bg: #d4d0c8; --panel: #d4d0c8; --surface: #ffffff; --canvas: #ffffff;
    --grid: rgba(0, 0, 0, 0.06);
    --ink: #000000; --ink-2: #000000; --muted: #404040; --faint: #808080;
    --line: #808080; --line-2: #404040;
    --hover: rgba(10, 36, 106, 0.08); --press: rgba(10, 36, 106, 0.16);
    --accent: #0a246a; --accent-ink: #ffffff; --accent-soft: rgba(10, 36, 106, 0.14);
    --live: #c05000;
    --stock: #000080; --stock-fill: rgba(0, 0, 128, 0.10);
    --flow: #008080; --aux: #000000; --conn: rgba(0, 0, 0, 0.5);
    --R: #800000; --B: #000080; --good: #008000; --bad: #ff0000;
    --s1: #000080; --s2: #800000; --s3: #008000; --s4: #800080; --s5: #808000; --s6: #008080; --s7: #c00060; --s8: #406000;
    --shadow-1: none; --shadow-2: none;
    --font: Tahoma, "MS Sans Serif", "Microsoft Sans Serif", Arial, sans-serif; --mono: "Courier New", Courier, monospace;
    --r: 0px; --r-sm: 0px;
    --titlebar: linear-gradient(90deg, #0a246a, #a6caf0);
    --titlebar-off: linear-gradient(90deg, #808080, #c0c0c0);
    --raised: inset -1px -1px #404040, inset 1px 1px #ffffff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
    --sunken: inset -1px -1px #ffffff, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #404040;
    --thin-up: inset -1px -1px #808080, inset 1px 1px #ffffff;
    --thin-down: inset -1px -1px #ffffff, inset 1px 1px #808080;
    color-scheme: light;
}
[data-theme="w2k"] *, [data-theme="w2k"] *::before, [data-theme="w2k"] *::after { border-radius: 0 !important; }
[data-theme="w2k"] body { font-size: 11px; -webkit-font-smoothing: none; }
[data-theme="w2k"] #bar { background: var(--panel); border-bottom: 0; box-shadow: var(--raised); }
[data-theme="w2k"] #bar .brand svg { color: #000080; }
[data-theme="w2k"] .ws-bar { background: none; padding: 0; gap: 0; }
[data-theme="w2k"] .ws-btn { color: #000; }
[data-theme="w2k"] .ws-btn kbd { color: #404040; }
[data-theme="w2k"] .ws-btn.on { background: repeating-conic-gradient(#ffffff 0% 25%, #d4d0c8 0% 50%) 0 0 / 2px 2px; box-shadow: var(--sunken); }
[data-theme="w2k"] .ws-btn:hover:not(.on) { box-shadow: var(--thin-up); }
[data-theme="w2k"] .transport .icon-btn { background: var(--panel); color: #000; box-shadow: var(--raised); }
[data-theme="w2k"] .scrub-track { background: #fff; box-shadow: var(--thin-down); height: 6px; top: 11px; }
[data-theme="w2k"] .scrub-knob { background: var(--panel); border: 0; box-shadow: var(--raised); width: 11px; height: 20px; top: 4px; margin-left: -5px; }
/* Buttons: raised, pressed in; the default one ringed in black. */
[data-theme="w2k"] .ghost-btn, [data-theme="w2k"] .primary-btn, [data-theme="w2k"] .seg-btn, [data-theme="w2k"] .deck-tpl,
[data-theme="w2k"] .tile-btn, [data-theme="w2k"] .card.card-new {
    border: 0; background: var(--panel); color: #000; font-weight: normal; box-shadow: var(--raised); filter: none;
}
[data-theme="w2k"] .primary-btn { box-shadow: 0 0 0 1px #000, var(--raised); }
[data-theme="w2k"] .ghost-btn:hover, [data-theme="w2k"] .primary-btn:hover, [data-theme="w2k"] .deck-tpl:hover { background: var(--panel); filter: none; }
[data-theme="w2k"] .ghost-btn:active, [data-theme="w2k"] .primary-btn:active, [data-theme="w2k"] .seg-btn:active, [data-theme="w2k"] .tile-btn:active { box-shadow: var(--sunken); }
[data-theme="w2k"] .icon-btn:hover { background: none; box-shadow: var(--thin-up); }
[data-theme="w2k"] .icon-btn:active, [data-theme="w2k"] .icon-btn.toggle[aria-pressed="true"], [data-theme="w2k"] .edit-tool[aria-pressed="true"] {
    background: repeating-conic-gradient(#ffffff 0% 25%, #d4d0c8 0% 50%) 0 0 / 2px 2px; box-shadow: var(--thin-down); color: #000;
}
[data-theme="w2k"] .link-btn { color: #0000ee; }
[data-theme="w2k"] input[type="text"], [data-theme="w2k"] input[type="search"], [data-theme="w2k"] input[type="number"], [data-theme="w2k"] select, [data-theme="w2k"] textarea {
    border: 0; background-color: #fff; box-shadow: var(--sunken);
}
[data-theme="w2k"] input:focus, [data-theme="w2k"] select:focus, [data-theme="w2k"] textarea:focus { box-shadow: var(--sunken); outline: 1px dotted #000; outline-offset: -4px; }
[data-theme="w2k"] input[type="range"]::-webkit-slider-runnable-track { background: #fff; box-shadow: var(--thin-down); height: 4px; }
[data-theme="w2k"] input[type="range"]::-webkit-slider-thumb { width: 11px; height: 20px; margin-top: -8px; border: 0; border-radius: 0; background: var(--panel); box-shadow: var(--raised); }
/* Panels and windows: bevels, and the navy-to-sky title bar. */
[data-theme="w2k"] #levers, [data-theme="w2k"] #inspector { border: 0; box-shadow: var(--raised); }
[data-theme="w2k"] .lever:hover { background: none; }
[data-theme="w2k"] .tiles { background: #3a6ea5; }
[data-theme="w2k"] .tile { border: 0; padding: 3px; background: var(--panel); box-shadow: var(--raised); }
[data-theme="w2k"] .tile.focused { box-shadow: var(--raised); }
[data-theme="w2k"] .tile-head { height: 20px; padding: 0 2px 0 4px; border-bottom: 0; background: var(--titlebar-off); }
[data-theme="w2k"] .tile.focused .tile-head { background: var(--titlebar); }
[data-theme="w2k"] .tile-head .tile-tab, [data-theme="w2k"] .tile-head .tile-tab-x, [data-theme="w2k"] .tile-head .tile-tab-add { color: rgba(255, 255, 255, .78); }
[data-theme="w2k"] .tile-head .tile-tab.on { color: #fff; }
[data-theme="w2k"] .tile-head .tile-tab::after { background: #fff; }
[data-theme="w2k"] .tile-btn { width: 16px; height: 14px; margin-left: 2px; }
[data-theme="w2k"] .tile-btn svg { width: 10px; height: 10px; stroke-width: 2; }
[data-theme="w2k"] .tile-body { box-shadow: var(--sunken); background: #fff; }
[data-theme="w2k"] .card, [data-theme="w2k"] .deck-slide, [data-theme="w2k"] .mx-card, [data-theme="w2k"] .mx-cell { border: 0; box-shadow: var(--raised); background: var(--panel); }
[data-theme="w2k"] .card:hover { transform: none; box-shadow: var(--raised); }
[data-theme="w2k"] .model-edit, [data-theme="w2k"] .rl-draft { border: 0; box-shadow: var(--sunken); background: var(--panel); }
[data-theme="w2k"] .tooltip, [data-theme="w2k"] #toast, [data-theme="w2k"] .toast { background: #ffffe1; color: #000; border: 1px solid #000; box-shadow: none; }
[data-theme="w2k"] .menu { border: 0; padding: 3px; background: var(--panel); box-shadow: var(--raised); }
[data-theme="w2k"] .menu-item:hover { background: #0a246a; color: #fff; }
[data-theme="w2k"] #edit-bar, [data-theme="w2k"] .stage-tools, [data-theme="w2k"] .loop-chip, [data-theme="w2k"] .chip, [data-theme="w2k"] .deck-cap, [data-theme="w2k"] .story {
    border: 0; background: var(--panel); box-shadow: var(--raised);
}

/* ── Group model building: the session panel (gmb.js) ─────────────────── */
.session h3 { margin: 0; font-size: 14px; }
.gmb-head { display: flex; flex-direction: column; gap: 8px; }
.gmb-steps { display: flex; flex-wrap: wrap; gap: 4px; }
.gmb-step { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 4px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 11.5px; cursor: pointer; }
.gmb-step:disabled { cursor: default; opacity: 1; }
.gmb-step.on { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.gmb-n { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--line); font-size: 10.5px; }
.gmb-step.on .gmb-n { background: var(--accent); color: var(--accent-ink); }
.gmb-count { font-size: 10.5px; color: var(--muted); }
.gmb-step.revealed .gmb-count::after { content: " ✓"; }
.gmb-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gmb-timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-2); min-width: 0; }
.gmb-timer.late { color: var(--live); }
.gmb-prompt { margin: 0; font-size: 13px; color: var(--ink); }
.gmb-body { display: flex; flex-direction: column; gap: 10px; }
.gmb-write { display: flex; gap: 6px; align-items: flex-end; }
.gmb-write textarea { flex: 1; resize: vertical; font: inherit; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); color: var(--ink); }
.gmb-board { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.gmb-group { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; max-width: 100%; }
.gmb-group h4 { flex-basis: 100%; margin: 0 0 2px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.gmb-note { position: relative; width: 132px; min-height: 64px; padding: 7px 8px 18px; border-radius: 3px; background: #fff3b0; color: #2a2616; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); font-size: 12px; line-height: 1.3; cursor: default; }
.gmb-note.mine { background: #ffe58a; }
.gmb-note.made { outline: 2px solid var(--accent); }
.gmb-note.picked { outline: 2px dashed var(--live); outline-offset: 2px; }
.session .gmb-board .gmb-note[data-id] { cursor: pointer; }
.gmb-note-by { position: absolute; left: 8px; bottom: 3px; font-size: 10.5px; opacity: 0.65; }
.gmb-made { margin-top: 4px; font-size: 10.5px; font-weight: 600; color: #1d3f8f; }
.gmb-x { position: absolute; right: 2px; top: 0; border: 0; background: transparent; color: inherit; opacity: 0.5; cursor: pointer; font-size: 14px; }
.gmb-x:hover { opacity: 1; }
.gmb-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gmb-tools input { min-width: 0; width: 150px; padding: 4px 7px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; }
.gmb-var { display: flex; gap: 8px; align-items: center; }
.gmb-canvas { width: 100%; max-width: 520px; aspect-ratio: 520 / 220; border: 1px solid var(--line); border-radius: 6px; background: var(--canvas); touch-action: none; cursor: crosshair; }
.gmb-legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gmb-who { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 11.5px; cursor: pointer; }
.gmb-who:disabled { cursor: default; }
.gmb-who i { width: 10px; height: 3px; border-radius: 2px; }
.gmb-mapstat { font-weight: 600; color: var(--ink-2); }
.gmb-dotsleft { font-size: 16px; letter-spacing: 2px; color: var(--accent); }
.gmb-cands { display: flex; flex-direction: column; gap: 3px; }
.gmb-cand { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; }
.gmb-cand:hover { background: var(--hover); }
.gmb-cand-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gmb-mydots { color: var(--accent); letter-spacing: 1px; min-width: 30px; text-align: right; }
.gmb-bar { height: 8px; border-radius: 4px; background: var(--accent); opacity: 0.55; }
.gmb-tally { min-width: 14px; text-align: right; }
.gmb-agenda { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 2px; color: var(--ink-2); }
.gmb-preview { max-height: 260px; overflow: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 11.5px; white-space: pre-wrap; }
.gmb-log summary { cursor: pointer; color: var(--muted); }
/* Renaming a causal loop diagram's word, in place and at its size. */
.edit-rename.word { font-weight: 700; border-width: 2px; border-radius: 8px; box-shadow: 0 0 0 4px var(--accent-soft); padding: 0 10px; }
/* A picked link: its name in the inspector; beside it on the diagram, the
   bend control — 0° marked in the middle of the track, lit while the link is
   pulled straight, and the reset next to the slider. */
.me-link .insp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.me-link .insp-head h2 { font-size: 14px; margin: 0; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-link .hint { margin: 0; }
.bend-pop { position: absolute; z-index: 6; left: 0; top: 0; display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-2);
    opacity: 0; transform: translateY(4px) scale(.98); pointer-events: none;
    transition: opacity .18s ease, transform .22s cubic-bezier(.2,.7,.2,1); }
.bend-pop.open { opacity: 1; transform: none; pointer-events: auto; }
.bend-track { position: relative; display: flex; width: 160px; }
.bend-track::before { content: ""; position: absolute; left: 50%; top: 50%; width: 2px; height: 12px; margin: -6px 0 0 -1px; border-radius: 1px;
    background: var(--line); pointer-events: none; transition: background .2s ease, height .2s ease, margin .2s ease; }
.bend-pop.straight .bend-track::before { background: var(--accent); height: 16px; margin-top: -8px; }
.bend-track input[type=range] { width: 100%; margin: 0; accent-color: var(--accent); position: relative; }
.bend-pop output { width: 58px; text-align: right; font: 600 12px/1 var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bend-pop .icon-btn:disabled { opacity: .35; cursor: default; }
@media (prefers-reduced-motion: reduce) { .bend-pop, .bend-track::before { transition: none; } }
/* A picked thing's look (looks.js): swatches, sliders pulled to 100%, type
   toggles; each row's reset there always, greyed when there is nothing to
   reset. */
.lk-box { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.lk-head { display: flex; align-items: center; justify-content: space-between; }
.lk-all:disabled { opacity: .35; cursor: default; }
.lk-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto 24px; align-items: center; gap: 8px; min-height: 26px; }
.lk-row > .sub { grid-column: 1; }
.lk-row .lk-sw, .lk-row .lk-seg { grid-column: 2 / 4; }
.lk-sw { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.lk-chip { width: 17px; height: 17px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
    transition: transform .15s ease, box-shadow .15s ease; }
.lk-chip:hover { transform: scale(1.15); }
.lk-chip.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--c); }
.lk-custom { width: 22px; height: 20px; padding: 0; border: 1px dashed var(--line-2); border-radius: 6px; background: none; cursor: pointer; }
.lk-custom.on { border-style: solid; border-color: var(--accent); }
.lk-track { position: relative; display: flex; }
.lk-track::before { content: ""; position: absolute; left: 50%; top: 50%; width: 2px; height: 10px; margin: -5px 0 0 -1px; border-radius: 1px; background: var(--line); pointer-events: none; transition: background .2s ease; }
.lk-row.mid .lk-track::before { background: var(--accent); }
.lk-track input[type=range] { width: 100%; margin: 0; accent-color: var(--accent); position: relative; }
.lk-val { width: 44px; text-align: right; font: 600 11.5px/1 var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lk-seg { display: inline-flex; gap: 2px; background: var(--hover); padding: 2px; border-radius: 7px; justify-self: start; }
.lk-tog { border: 0; background: none; cursor: pointer; min-width: 30px; height: 22px; padding: 0 7px; border-radius: 5px; font: 700 12px/1 var(--font); color: var(--muted); transition: background .15s ease, color .15s ease; }
.lk-tog[data-key="italic"] { font-style: italic; }
.lk-tog[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.lk-reset { width: 22px; height: 22px; grid-column: 4; }
.lk-reset:disabled { opacity: .3; cursor: default; }
@media (prefers-reduced-motion: reduce) { .lk-chip, .lk-tog, .lk-track::before { transition: none; } }
/* The Graphs' last card: add a graph. A search, and the names that match
   below it (they unfold as it takes focus). */
.plot-add { flex: 0 0 220px; min-width: 200px; max-width: 240px; border-style: dashed; justify-content: flex-start; gap: 6px; background: transparent; }
.plot-add-in { display: flex; align-items: center; gap: 6px; padding: 8px 8px 0; }
.plot-add-plus { font: 600 16px/1 var(--font); color: var(--faint); width: 16px; text-align: center; }
.plot-add-q { flex: 1; min-width: 0; height: 28px; }
.plot-add-list { display: flex; flex-direction: column; gap: 1px; padding: 0 6px 6px; overflow: auto; opacity: 0; transform: translateY(-3px);
    transition: opacity .16s ease, transform .2s ease; pointer-events: none; }
.plot-add.open .plot-add-list { opacity: 1; transform: none; pointer-events: auto; }
.plot-add-opt { border: 0; background: none; text-align: left; padding: 5px 8px; border-radius: 6px; font: 500 12.5px var(--font); color: var(--ink-2); cursor: pointer;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plot-add-opt:hover, .plot-add-opt:first-child { background: var(--hover); color: var(--ink); }
.plot-add-none { color: var(--faint); font-size: 12px; padding: 5px 8px; }
@media (prefers-reduced-motion: reduce) { .plot-add-list { transition: none; } }
/* Notes: the tool's cursor; a note written in place; the inspector's
   attached-to chips. */
#app.editing canvas.viewport-2d[data-tool="note"] { cursor: text; }
.edit-rename.note { height: auto; min-height: 40px; padding: 4px 6px; text-align: left; font-weight: 500; line-height: 1.25; resize: both; white-space: pre-wrap; }
.mn-to { display: flex; flex-wrap: wrap; gap: 4px; }
.mn-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 2px 2px 8px; border-radius: 12px; background: var(--hover); font-size: 12px; color: var(--ink-2); }
.mn-chip-x { border: 0; background: none; cursor: pointer; color: var(--faint); width: 18px; height: 18px; border-radius: 50%; line-height: 1; }
.mn-chip-x:hover { background: var(--line); color: var(--ink); }
.mn-panel textarea { width: 100%; box-sizing: border-box; }
/* The closed alpha: the gate signs in; a share link lets a guest join a
   group session (its name asked); a session guest sees the session and its
   diagram, not what is not theirs. */
.join-name { display: flex; flex-direction: column; gap: 6px; margin: 14px auto 12px; max-width: 280px; text-align: left; font-size: 12px; color: var(--muted); }
.join-name input { height: 36px; font-size: 14px; }
#app.session-guest #model-btn, #app.session-guest #slice-btn, #app.session-guest #ws-bar, #app.session-guest #room-btn,
#app.session-guest #palette-btn, #app.session-guest #edit-save, #app.session-guest #edit-done, #app.session-guest #levers { display: none; }
.gmb-guests { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.gmb-code { font: 700 13px/1 var(--mono); letter-spacing: .12em; padding: 4px 8px; border-radius: 6px; background: var(--hover); color: var(--ink); }

/* ── The workflow graph (workflow.js) ─────────────────────────────── */
.wf { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--canvas); }
.wf-levels { width: 100%; margin-top: 4px; }
.wf-zoomfit { display: inline-flex; align-items: center; gap: 6px; }
.wf-zoomfit svg { flex: none; }
.wf-add { display: inline-flex; align-items: center; gap: 5px; }
.wf-add svg { flex: none; }
#workflow { container-type: inline-size; }
.wf-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.wf-pick { max-width: 220px; }
.wf-grow { flex: 1; }
/* the status takes only the room left on the bar (never a row of its own) */
.wf-status { flex: 3 1 0; min-width: 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; transition: color .2s; }
.wf-status.busy { color: var(--ink-2); }
.wf-status.busy::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--accent); animation: wf-pulse 1.1s ease-in-out infinite; vertical-align: 1px; }
.wf-seen { border: 1px solid color-mix(in srgb, var(--s4) 55%, transparent); background: color-mix(in srgb, var(--s4) 10%, transparent); color: var(--ink-2); border-radius: 12px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.wf-main { flex: 1; display: flex; min-height: 0; }
.wf-canvas { position: relative; flex: 1; min-width: 0; overflow: hidden; outline: none; cursor: grab;
    background-image: radial-gradient(var(--grid) 1px, transparent 1px); background-size: 22px 22px; }
.wf-canvas.panning { cursor: grabbing; }
.wf-world { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; }
.wf-world.gliding { transition: transform .4s cubic-bezier(.2,.7,.2,1); }
.wf-links { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.wf-link { fill: none; stroke-width: 2.2; opacity: .55; pointer-events: stroke; cursor: pointer; transition: opacity .2s, stroke-width .2s; }
.wf-link:hover { opacity: .85; }
.wf-link.sel { opacity: 1; stroke-width: 3.2; }
.wf-link.idle { opacity: .2; }
.wf-link.flow { opacity: .95; stroke-dasharray: 7 6; animation: wf-flow .6s linear infinite; }
.wf-link.temp { stroke: var(--accent); stroke-dasharray: 5 5; opacity: .9; pointer-events: none; }
@keyframes wf-flow { to { stroke-dashoffset: -13; } }
@keyframes wf-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.wf-layer { position: absolute; left: 0; top: 0; }
.wf-hint { position: absolute; left: 10px; bottom: 8px; font-size: 11px; color: var(--faint); pointer-events: none; }
.wf-blank { position: absolute; left: 40px; top: 40px; width: 360px; color: var(--muted); z-index: 2; }
.wf-blank[hidden] { display: none; }
.wf-blank p { margin: 0 0 10px; }

.wf-node { position: absolute; width: 250px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
    box-shadow: var(--shadow-1); font-size: 12px; cursor: default;
    transition: left .35s cubic-bezier(.2,.7,.2,1), top .35s cubic-bezier(.2,.7,.2,1), opacity .25s, border-color .25s, box-shadow .25s, transform .25s; }
.wf-node.wide { width: 360px; }
.wf-node.entering, .wf-node.leaving { opacity: 0; transform: scale(.96); }
.wf-node.dragging { transition: opacity .25s, border-color .25s, box-shadow .25s; box-shadow: var(--shadow-2); z-index: 5; }
.wf-node.sel { border-color: color-mix(in srgb, var(--g) 70%, var(--line-2)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--g) 22%, transparent), var(--shadow-1); }
.wf-node.idle { opacity: .5; }
.wf-node.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line-2)); }
.wf-node.changed { box-shadow: 0 0 0 3px color-mix(in srgb, var(--s4) 35%, transparent), var(--shadow-1); }
.wf-head { display: flex; align-items: center; gap: 7px; padding: 7px 10px 6px; border-bottom: 1px solid var(--line); cursor: grab; user-select: none;
    background: linear-gradient(to bottom, color-mix(in srgb, var(--g) 9%, transparent), transparent); border-radius: 10px 10px 0 0; }
.wf-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--g); flex: none; transition: background .25s, box-shadow .25s; }
.wf-title { font-weight: 600; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-state { margin-left: auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; transition: color .25s; }
.wf-node.s-queued .wf-dot { background: var(--faint); }
.wf-node.s-running .wf-dot { animation: wf-pulse .9s ease-in-out infinite; box-shadow: 0 0 0 4px color-mix(in srgb, var(--g) 25%, transparent); }
.wf-node.s-running { border-color: color-mix(in srgb, var(--g) 60%, var(--line-2)); }
.wf-node.s-done .wf-state, .wf-node.s-cached .wf-state { color: var(--good); }
.wf-node.s-failed { border-color: var(--bad); }
.wf-node.s-failed .wf-state, .wf-node.s-stopped .wf-state { color: var(--bad); }
.wf-node.s-skipped { opacity: .6; }
.wf-ports { display: flex; justify-content: space-between; gap: 6px; padding: 5px 0; }
.wf-ins, .wf-outs { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.wf-port { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 11px; white-space: nowrap; transition: opacity .2s, color .2s; }
.wf-port.out { justify-content: flex-end; }
.wf-port.opt span { color: var(--muted); font-style: italic; }
.wf-pin { position: relative; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--g); background: var(--surface); flex: none; cursor: crosshair; transition: transform .15s, background .15s; }
/* a wider grip than the dot: a pin is easy to take up, zoomed out too */
.wf-port.out .wf-pin::before { content: ""; position: absolute; inset: -7px; border-radius: 50%; }
.wf-port.in .wf-pin { margin-left: -6px; cursor: default; }
.wf-port.out .wf-pin { margin-right: -6px; }
.wf-pin:hover { transform: scale(1.35); background: var(--g); }
.wiring .wf-port.in:not(.fits) { opacity: .3; }
.wiring .wf-port.in.fits .wf-pin { transform: scale(1.4); background: color-mix(in srgb, var(--accent) 35%, var(--surface)); border-color: var(--accent); }
.wf-sum { padding: 2px 10px 7px; color: var(--ink-2); line-height: 1.4; }
.wf-prev { max-height: 0; opacity: 0; overflow: hidden; padding: 0 10px; transition: max-height .35s ease, opacity .3s ease, padding .3s; }
.wf-prev.on { max-height: 900px; opacity: 1; padding: 0 10px 8px; }
.wf-chart { display: block; width: 100%; height: 92px; }
.wf-chart.tall { height: 150px; }
.wf-axes { color: var(--muted); font-size: 10.5px; margin-top: 3px; }
.wf-sec { margin-top: 6px; }
.wf-sec-h { font-size: 11px; color: var(--muted); margin: 8px 0 4px; }
.wf-ests { display: flex; flex-direction: column; gap: 5px; }
.wf-est { display: grid; grid-template-columns: 86px 1fr 52px; grid-template-rows: auto auto; column-gap: 6px; align-items: center; font-size: 11px; }
.wf-est-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.wf-est-v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.wf-est-r { grid-column: 2; color: var(--faint); font-size: 10px; }
.wf-range { position: relative; height: 10px; border-radius: 5px; background: var(--hover); border: 1px solid var(--line); }
.wf-range i, .wf-range b { position: absolute; top: 50%; transform: translate(-50%, -50%); border-radius: 50%; transition: left .4s cubic-bezier(.2,.7,.2,1); }
.wf-range i.from { width: 7px; height: 7px; border: 1.5px solid var(--muted); background: var(--surface); }
.wf-range i.to { width: 4px; height: 4px; background: var(--ink-2); }
.wf-range b { width: 10px; height: 10px; background: var(--g); box-shadow: 0 0 0 2px var(--surface); }
.wf-starts { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
.wf-starts th { text-align: left; color: var(--muted); font-weight: 500; padding: 2px 4px; }
.wf-starts td { padding: 2px 4px; border-top: 1px solid var(--line); }
.wf-starts .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.wf-table-wrap { overflow-x: auto; max-width: 100%; }
.wf-tab td.num { text-align: right; }
.wf-tab th, .wf-tab td { white-space: nowrap; }
.wf-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.wf-legend span { display: inline-flex; align-items: center; gap: 4px; }
.wf-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.wf-bars { display: grid; gap: 3px; margin-top: 4px; }
.wf-bar-row { display: grid; grid-template-columns: 34% 1fr auto; gap: 6px; align-items: center; font-size: 10.5px; color: var(--ink-2); }
.wf-bar-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-bar-v { font-variant-numeric: tabular-nums; color: var(--muted); }
.wf-bar-t { position: relative; height: 10px; }
.wf-bar-t .axis { position: absolute; top: -1px; bottom: -1px; width: 1px; background: var(--line-2); }
.wf-bar-t b { position: absolute; border-radius: 2px; opacity: .85; transition: left .4s ease, width .4s ease; }
.wf-suggest { display: block; }
.wf-suggest input { width: 100%; }
.wf-sc-name { flex: 1; min-width: 0; }
.wf-kept { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-2); }
.wf-kept span { min-width: 0; overflow-wrap: anywhere; }
.wf-kept button { flex: none; }
.wf-prog { height: 3px; margin: 0 10px 6px; border-radius: 2px; background: transparent; overflow: hidden; transition: background .3s; }
.wf-node.s-running .wf-prog, .wf-node.s-queued .wf-prog { background: var(--hover); }
.wf-prog i { display: block; height: 100%; width: 0; background: var(--g); border-radius: 2px; transition: width .3s ease; }
.wf-node:not(.s-running) .wf-prog i { opacity: 0; transition: width .3s ease, opacity .6s ease .3s; }
.wf-issue, .wf-by { max-height: 0; opacity: 0; overflow: hidden; padding: 0 10px; font-size: 11px; line-height: 1.35; transition: max-height .3s ease, opacity .25s ease, padding .25s; }
.wf-issue { color: var(--bad); }
.wf-by { color: color-mix(in srgb, var(--s4) 75%, var(--ink)); }
.wf-issue.on, .wf-by.on { max-height: 120px; opacity: 1; padding: 0 10px 7px; }

.wf-menu { position: absolute; z-index: 20; width: 300px; max-height: 420px; overflow: auto; background: var(--surface); border: 1px solid var(--line-2);
    border-radius: 10px; box-shadow: var(--shadow-2); padding: 6px; animation: wf-in .16s ease; }
@keyframes wf-in { from { opacity: 0; transform: translateY(-4px); } }
.wf-menu-h { font-size: 11px; color: var(--muted); padding: 2px 6px 6px; }
.wf-menu-i { display: grid; grid-template-columns: 10px 1fr; column-gap: 8px; width: 100%; text-align: left; padding: 6px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--ink); }
.wf-menu-i:hover { background: var(--hover); }
.wf-menu-small { width: 240px; }
.wf-menu-danger b { color: var(--bad); }
.wf-more { padding: 4px 9px; font-size: 15px; line-height: 1; }
.wf-menu-i i { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; grid-row: span 2; }
.wf-menu-i span { color: var(--muted); font-size: 11px; line-height: 1.35; }

/* the node library: searched, by group; an entry clicked or dragged */
.wf-lib { width: 320px; max-height: 460px; display: flex; flex-direction: column; overflow: hidden; transition: opacity .18s ease; }
.wf-lib.dragging { opacity: .35; }
.wf-lib-search { margin: 0 2px 6px; padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel); color: var(--ink); font: inherit; font-size: 12.5px; }
.wf-lib-search:focus { outline: none; border-color: var(--accent); }
.wf-lib-list { overflow: auto; min-height: 0; }
.wf-lib-gh { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 8px 6px 3px; }
.wf-lib-group:first-child .wf-lib-gh { padding-top: 2px; }
.wf-lib-none { color: var(--muted); font-size: 12px; padding: 6px; }
.wf-lib .wf-menu-i { touch-action: none; }
.wf-lib .wf-menu-i span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wf-lib .wf-menu-i:focus-visible { outline: none; background: var(--hover); }
.wf-lib-chip { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; display: flex; align-items: center; gap: 7px; padding: 6px 10px;
    background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow-2); font-size: 12.5px; color: var(--ink); animation: wf-in .12s ease; }
.wf-lib-chip i { width: 9px; height: 9px; border-radius: 50%; }

.wf-sheet { padding: 14px 16px 18px; font-size: 12.5px; animation: tab-in .18s ease; }
.wf-sh-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.wf-sh-head b { font-size: 14px; }
.wf-sw { width: 10px; height: 10px; border-radius: 50%; }
.wf-id { margin-left: auto; color: var(--faint); font-family: var(--mono); font-size: 11px; }
.wf-doc { color: var(--muted); margin: 0 0 10px; line-height: 1.45; }
.wf-issues { margin: 0 0 10px; padding-left: 18px; color: var(--bad); }
.wf-f { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; }
.wf-f-l { font-weight: 600; color: var(--ink-2); font-size: 12px; }
.wf-f-h { color: var(--faint); font-size: 11px; line-height: 1.35; }
.wf-f input[type="text"], .wf-f input[type="number"], .wf-f select, .wf-name { width: 100%; }
.wf-f input[type="checkbox"] { align-self: flex-start; }
.wf-table { width: 100%; font-family: var(--mono); font-size: 11.5px; resize: vertical; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); padding: 6px; }
.wf-kv { display: grid; grid-template-columns: 1fr 90px 22px; gap: 6px; align-items: center; }
.wf-kv span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-kv-add { display: flex; gap: 6px; align-items: center; }
.wf-kv-add .wf-add { flex: 1; }
.wf-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; border-radius: 4px; }
.wf-x:hover { color: var(--bad); background: var(--hover); }
.wf-prow { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface); }
.wf-prow-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.wf-prow-f { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.wf-prow-f input { width: 70px !important; }
.wf-prow-f select { width: auto !important; flex: 1; }
.wf-byline { color: var(--muted); font-size: 11px; margin: 4px 0 10px; }
.wf-remove { color: var(--bad); }
.wf-name { margin-bottom: 8px; }
.wf-describe { white-space: pre-wrap; font-family: var(--mono); font-size: 11px; line-height: 1.5; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 0 0 10px; }
.wf-log { margin: 0 0 12px; padding-left: 16px; color: var(--ink-2); font-size: 11.5px; line-height: 1.5; }
.wf-keptlist { list-style: none; margin: 0 0 12px; padding: 0; font-size: 11.5px; line-height: 1.5; }
.wf-kept-item { padding: 4px 0; border-bottom: 1px solid var(--line, rgba(0,0,0,.08)); transition: opacity .2s ease; }
.wf-kept-acts { display: inline-flex; gap: 4px; margin-left: 6px; }
.wf-faint { color: var(--faint); }
@media (prefers-reduced-motion: reduce) {
    .wf-node, .wf-prev, .wf-issue, .wf-by, .wf-prog i, .wf-range i, .wf-range b, .wf-bar-t b, .wf-world.gliding { transition: none; }
    .wf-link.flow, .wf-status.busy::before, .wf-node.s-running .wf-dot { animation: none; }
}
.wf-waves { display: flex; flex-direction: column; gap: 3px; margin-bottom: 4px; }
.wf-wave { display: grid; grid-template-columns: 48px 1fr auto; gap: 6px; align-items: center; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wf-wave-bar { position: relative; height: 8px; border-radius: 4px; background: var(--hover); overflow: hidden; }
.wf-wave-bar i, .wf-wave-bar b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; transition: width .4s ease; }
.wf-wave-bar i { background: color-mix(in srgb, var(--g) 22%, transparent); }
.wf-wave-bar b { background: var(--g); }
.wf-tornado { display: flex; flex-direction: column; gap: 2px; }
.wf-tn-row { display: grid; grid-template-columns: 38% 1fr; gap: 6px; align-items: center; font-size: 10.5px; color: var(--ink-2); }
.wf-tn-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-tn-bar { position: relative; height: 9px; }
.wf-tn-bar .axis { position: absolute; left: 50%; top: -1px; bottom: -1px; width: 1px; background: var(--line-2); }
.wf-tn-bar b { position: absolute; top: 1px; bottom: 1px; border-radius: 2px; opacity: .8; transition: left .4s ease, width .4s ease; }
.wf-range u { position: absolute; top: 1px; bottom: 1px; border-radius: 4px; background: color-mix(in srgb, var(--g) 28%, transparent); text-decoration: none; transition: left .4s ease, width .4s ease; }
.wf-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.wf-chip { display: inline-flex; align-items: center; gap: 2px; padding: 1px 2px 1px 7px; border: 1px solid var(--line-2); border-radius: 10px; font-size: 11px; background: var(--surface); max-width: 100%; }
.wf-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Naming a model where its name is ─────────────────────────────── */
.card { position: relative; }
.card .c-rename {
    position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
    background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--ink-2); border: 1px solid var(--line);
    opacity: 0; transform: translateY(-2px); transition: opacity .14s ease, transform .14s ease, background .12s;
}
.card .c-rename svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.card:hover .c-rename, .card:focus-within .c-rename, .card .c-rename:focus-visible { opacity: 1; transform: none; }
.card .c-rename:hover { background: var(--accent-soft); color: var(--accent); }
@media (pointer: coarse) { .card .c-rename { opacity: 1; transform: none; } }
.name-field {
    position: fixed; z-index: 60; transform: translateY(-50%); height: 32px; padding: 0 8px; border-radius: 7px;
    border: 1.5px solid var(--accent); background: var(--surface); color: var(--ink); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-2);
    opacity: 0; transition: opacity .12s ease;
}
.name-field.in { opacity: 1; }
.name-field:focus { outline: none; }
.name-hint {
    position: fixed; z-index: 60; margin-top: 6px; display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); background: var(--panel);
    padding: 2px 2px 2px 6px; border-radius: 5px; opacity: 0; transform: translateY(-3px); transition: opacity .2s ease .1s, transform .2s ease .1s; pointer-events: none;
}
.name-hint.in { opacity: 1; transform: none; }
.name-hint .nh-text { min-width: 0; flex: 1 1 auto; margin-right: 2px; }
.name-hint .nh-btn {
    pointer-events: auto; flex: none; width: 22px; height: 22px; padding: 0; display: grid; place-items: center; cursor: pointer;
    border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink-2); font: 600 12px/1 var(--font);
    transition: background .12s, color .12s, border-color .12s;
}
.name-hint .nh-keep:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.name-hint .nh-leave:hover { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); color: var(--bad); border-color: var(--bad); }

/* ── Feedback: a window docked at the bottom right ────────────────── */
.fb {
    position: fixed; right: 16px; bottom: 16px; z-index: 45; width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - var(--bar-h) - 32px); overflow-y: auto;
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-2); padding: 14px 16px 14px;
    display: flex; flex-direction: column; gap: 10px;
    opacity: 0; transform: translateY(10px); transition: opacity .18s ease, transform .22s cubic-bezier(.2,.7,.2,1);
}
.fb.fb-in { opacity: 1; transform: none; }
.fb.fb-out { opacity: 0; transform: translateY(10px); }
.fb-head { display: flex; align-items: center; justify-content: space-between; }
.fb-head h2 { font-size: 15px; margin: 0; }
.fb-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-kind { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12.5px; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.fb-kind:hover { border-color: var(--line-2); }
.fb-kind[aria-checked="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.fb-label { font-size: 12px; color: var(--muted); margin-bottom: -6px; }
.fb-text { width: 100%; resize: vertical; min-height: 96px; font: inherit; line-height: 1.45; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.fb-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fb-shot-row { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-shot-row .ghost-btn { border: 1px solid var(--line); cursor: pointer; gap: 6px; }
.fb-shot-row svg { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.fb-shot { display: flex; gap: 10px; align-items: flex-start; }
.fb-thumb { flex: none; width: 150px; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--canvas); cursor: zoom-in; }
.fb-thumb img { display: block; width: 100%; height: auto; }
.fb-shot-acts { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.fb-note { margin: 0; font-size: 12px; color: var(--muted); min-height: 1.2em; }
.fb-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.fb-what { font-size: 12px; color: var(--muted); margin-top: -4px; }
.fb-what summary { cursor: pointer; }
.fb-what dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 10px; margin: 8px 0 0; }
.fb-what dt { color: var(--muted); }
.fb-what dd { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.fb-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fb-who { font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .fb { right: 8px; left: 8px; bottom: 8px; width: auto; } }
@media (prefers-reduced-motion: reduce) { .fb, .fb.fb-out { transition: none; } }

/* marking the screenshot up */
.fbm { z-index: 55; align-items: center; padding: 16px; }
.fbm-sheet { width: min(1280px, 100%); max-height: 92vh; display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-2); padding: 12px; }
.fbm-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fbm-tools { display: flex; gap: 4px; }
.fbm-tool { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.fbm-tool[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.fbm-hint { flex: 1; color: var(--muted); font-size: 12px; }
.fbm-stage { min-height: 0; overflow: auto; display: grid; place-items: center; }
.fbm-canvas { max-width: 100%; max-height: calc(92vh - 80px); width: auto; height: auto; cursor: crosshair; border-radius: 6px; touch-action: none; }

/* ── Your account ─────────────────────────────────────────────────── */
.acct-layer { animation: acct-in .18s ease; }
.acct-layer .sheet { animation: acct-rise .22s cubic-bezier(.2,.7,.2,1); }
.acct-layer.acct-out { opacity: 0; transition: opacity .18s ease; }
@keyframes acct-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes acct-rise { from { transform: translateY(8px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .acct-layer, .acct-layer .sheet { animation: none; } .acct-layer.acct-out { transition: none; } }
.sheet.acct { width: min(680px, 100%); max-height: 84vh; }
.acct-body { display: flex; flex-direction: column; gap: 18px; }
.acct-wait, .acct-err { color: var(--muted); }
.acct-err { color: var(--bad); }
.acct-who { display: flex; gap: 14px; align-items: center; }
.acct-avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); font-size: 22px; font-weight: 700; }
.acct-id { min-width: 0; }
.acct-name { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 650; }
.acct-role { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: var(--hover); color: var(--muted); }
.acct-role.admin { background: var(--accent-soft); color: var(--accent); }
.acct-mail { color: var(--ink-2); overflow-wrap: anywhere; }
.acct-since { font-size: 12px; color: var(--muted); }
.acct-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.acct-stat { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); display: flex; flex-direction: column; }
.acct-stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.acct-stat span { font-size: 12px; color: var(--muted); }
.acct-sec { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.acct-sec h3 { margin: 0; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.acct-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.acct-row.end { justify-content: flex-end; align-items: center; }
.acct-row .acct-field { flex: 1 1 240px; }
.acct-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.acct-flabel { font-size: 12.5px; color: var(--ink-2); }
.acct-hint { font-size: 11.5px; color: var(--muted); }
.acct-field input { height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
.acct-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.acct-pw { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.acct-msg { margin: 0; flex: 1; font-size: 12.5px; color: var(--good); min-width: 0; }
.acct-msg.bad { color: var(--bad); }
.acct-fb { display: flex; flex-direction: column; gap: 8px; }
.acct-empty { margin: 0; color: var(--muted); font-size: 13px; }
.acct-fbi { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.acct-fbh { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; font-size: 12px; }
.acct-kind { font-weight: 600; color: var(--ink-2); }
.acct-when { color: var(--muted); flex: 1; }
.acct-status { padding: 1px 8px; border-radius: 999px; background: var(--hover); color: var(--muted); font-weight: 600; }
.acct-status.s-seen, .acct-status.s-planned { background: var(--accent-soft); color: var(--accent); }
.acct-status.s-done { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.acct-fbm { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.acct-reply { margin: 0; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; display: flex; flex-direction: column; gap: 2px; width: 100%; white-space: pre-wrap; }
.acct-rh { font-size: 11.5px; color: var(--accent); font-weight: 600; }
.acct-end { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 12px; }
.acct-danger { border: 1px solid color-mix(in srgb, var(--bad) 35%, var(--line)); border-radius: 10px; padding: 10px 12px; }
.acct-danger summary { cursor: pointer; color: var(--bad); font-weight: 600; }
.acct-danger p { color: var(--ink-2); font-size: 13px; }
.acct-sure { display: flex; align-items: center; gap: 8px; font-size: 13px; flex: 1 1 240px; }
.danger-btn { height: 34px; padding: 0 14px; border-radius: 8px; border: 0; background: var(--bad); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.danger-btn:disabled { opacity: .45; cursor: not-allowed; }
.shot-view { z-index: 56; align-items: center; cursor: zoom-out; }
.shot-view img { max-width: 94vw; max-height: 90vh; border-radius: 8px; box-shadow: var(--shadow-2); }
@media (max-width: 640px) { .acct-pw, .acct-stats { grid-template-columns: 1fr; } }

/* ── The bar fits its width: folded a step at a time (main.js, fitBar) ── */
#bar.fold-ws .ws-btn .ws-rest { max-width: 0; opacity: 0; }
#bar.fold-ws .ws-btn { padding: 0 8px; }
@media (min-width: 641px) {
    .brand span, .admin-link .label, .kbd-btn kbd, .replaced-note .label { display: inline-block; max-width: 12em; overflow: hidden; white-space: nowrap; vertical-align: middle; transition: max-width .22s ease, opacity .18s ease, margin .22s ease; }
}
#bar.fold-labels .brand span, #bar.fold-labels .admin-link .label, #bar.fold-labels .kbd-btn kbd, #bar.fold-labels .replaced-note .label { max-width: 0; opacity: 0; margin: 0; }
#bar.fold-labels .replaced-note { gap: 0; }
#bar.fold-labels .brand { gap: 0; }
#bar.fold-labels .model-pick { max-width: 190px; }
.engine, .transport .speed, .clock-u { transition: opacity .18s ease; }
#bar.fold-mid .engine, #bar.fold-mid .transport .speed { display: none; }
#bar.fold-mid .clock-u { display: none; }
@media (prefers-reduced-motion: reduce) { .ws-btn .ws-rest, .brand span, .admin-link .label, .kbd-btn kbd, .replaced-note .label, .model-pick { transition: none; } }

/* ── Sharing: the button while shared, its menu ───────────────────── */
.share-btn.on { color: var(--ink); gap: 6px; }
.share-btn.on::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 20%, transparent); }
.menu-item.danger { color: var(--bad); }
.menu-item.danger:hover { background: var(--bad); color: #fff; }
.menu-note { max-width: 240px; padding: 2px 10px 6px 26px; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
#app.leaving { opacity: .35; transition: opacity 1.2s ease; pointer-events: none; }

/* ── Deleting the account: one column, in the order it is done ────── */
.acct-del { display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.acct-del .acct-field { flex: none; }
.acct-del .acct-sure { flex: none; align-items: center; }
.acct-del .acct-sure input { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--bad); }
.acct-del-foot { display: flex; align-items: center; gap: 12px; }
.acct-del-foot .acct-msg { order: 2; }
.danger-btn:disabled { opacity: 1; background: transparent; color: color-mix(in srgb, var(--bad) 55%, var(--muted)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 35%, var(--line)); }
.danger-btn { transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
@media (pointer: coarse) { .name-field, .fb-text, .acct-field input { font-size: 16px !important; } }
@media (pointer: coarse) { .name-hint .nh-btn { width: 40px; height: 40px; font-size: 17px; border-radius: 8px; } .name-hint { gap: 6px; } }

/* ── The graphs' bar: two modes side by side, their words below ─────── */
.scope-modes { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mode-chip { display: inline-flex; align-items: center; }
.mode-chip .mode-opt {
    max-width: 0; opacity: 0; padding-left: 0; padding-right: 0; margin-left: 0; border-width: 0; overflow: hidden;
    transition: max-width .22s ease, opacity .18s ease, margin .22s ease, padding .22s ease;
}
.mode-chip.open .mode-opt { max-width: 180px; opacity: 1; margin-left: 6px; padding-left: 6px; padding-right: 6px; border-width: 1px; }
.mode-chip.lead.open .mode-opt { margin-left: 0; margin-right: 6px; }
.scope-notes { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .22s ease; padding: 0 14px; }
.scope-notes.has { grid-template-rows: 1fr; }
.scope-notes-in { overflow: hidden; min-height: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
.scope-notes.has .scope-notes-in { padding-bottom: 6px; }
.scope-notes .goal-result { flex: 0 1 auto; }
#goal-equifinal { transition: opacity .18s ease; }
#goal-equifinal.closing { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .mode-chip .mode-opt, .scope-notes { transition: none; } }

/* ── The data a model reads: a note beside its name, and its list ─────
   Like the replaced note: no room until the model reads files, then it
   opens to its width. Quiet when every file is given; warm when some are
   missing. */
.data-note { color: var(--ink-2); }
.data-note.short { color: var(--live); }
.data-note:hover, .data-note[aria-expanded="true"] { background: color-mix(in srgb, currentColor 12%, transparent); }
.data-note .dn-mark { width: 12px; height: 12px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; }
.data-note, .data-note .label { transition: max-width .24s ease, padding .24s ease, margin .24s ease, opacity .2s ease, background .12s, color .2s ease, visibility 0s linear .24s; }
.files-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 12px 14px; display: grid; align-content: start; gap: 12px; }
.fl-sec { display: grid; gap: 6px; }
.fl-h { display: flex; align-items: baseline; gap: 6px; font: 650 11px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0; }
.fl-h .fl-n { font: 600 10.5px var(--mono); letter-spacing: 0; color: var(--faint); }
.fl-why { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.fl-plain { display: flex; align-items: baseline; gap: 8px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12px; min-width: 0; transition: opacity .2s ease, background .2s ease; }
.fl-plain .dm-file { flex: 1; }
.fl-size { flex: none; font: 11px var(--mono); color: var(--faint); }
.fl-x { flex: none; width: 20px; height: 20px; border: 0; border-radius: 5px; background: none; color: var(--faint); cursor: pointer; font-size: 14px; line-height: 1; transition: background .12s, color .12s; }
.fl-x:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.fl-drop { display: grid; place-items: center; gap: 2px; padding: 14px 10px; border: 1.5px dashed var(--line-2); border-radius: 10px; color: var(--muted); font-size: 12px; text-align: center; cursor: pointer; transition: border-color .15s ease, background .15s ease, color .15s ease; }
.fl-drop b { color: var(--ink-2); font-weight: 600; }
.fl-drop:hover, .fl-drop.over, .files-body.over .fl-drop { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.files-body { transition: background .15s ease; }
.files-body.over { background: color-mix(in srgb, var(--accent) 5%, transparent); }
/* A file kept aside that may be for an input: its choices under its name. */
.fl-plain { flex-wrap: wrap; }
.fl-plain.fl-choose { border-color: color-mix(in srgb, var(--live) 45%, var(--line)); background: color-mix(in srgb, var(--live) 5%, var(--surface)); }
.fl-for { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.fl-for .dm-btn { font-family: var(--mono); font-size: 11.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* An input just given (one or several at once): a glow that fades. */
.dm-row.fresh { animation: dm-given 1.4s ease; }
@keyframes dm-given { 0%, 35% { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--surface)); } }
#files.flash { animation: files-flash .9s ease; }
@keyframes files-flash { 30% { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); } }
.dm-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.dm-row { display: grid; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); transition: border-color .2s ease, background .2s ease, opacity .2s ease; }
.dm-row.s-missing { border-color: color-mix(in srgb, var(--live) 45%, var(--line)); background: color-mix(in srgb, var(--live) 5%, var(--surface)); }
.dm-row.s-off { opacity: .72; }
.dm-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.dm-file { font: 600 12px var(--mono); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dm-state { margin-left: auto; flex: none; font: 600 10.5px var(--mono); letter-spacing: .02em; padding: 1px 6px; border-radius: 8px; border: 1px solid currentColor; transition: color .2s ease; }
.dm-state.s-used { color: var(--good); }
.dm-state.s-missing { color: var(--live); }
.dm-state.s-off, .dm-state.s-unread { color: var(--muted); }
.dm-meta { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 11.5px; color: var(--muted); min-width: 0; }
.dm-was { font-family: var(--mono); font-size: 11px; overflow-wrap: anywhere; }
.dm-note { font-size: 11.5px; color: var(--live); }
.dm-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; }
.dm-ask { flex: 1 1 100%; font-size: 12px; color: var(--ink-2); }
.dm-btn { height: 24px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-size: 12px; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.dm-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.dm-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.dm-btn.primary:hover { filter: brightness(1.08); }
.dm-btn.danger { border-color: var(--bad); color: var(--bad); }
.dm-btn.danger:hover { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.dm-use { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); cursor: pointer; margin-left: auto; }
.dm-switch { accent-color: var(--accent); margin: 0; }

/* A download's data paths: kept here, or as the model had them */
.pd-veil { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--ink) 18%, transparent); opacity: 0; transition: opacity .16s ease; }
.pd-veil.in { opacity: 1; }
.pd-box { width: 420px; max-width: 100%; display: grid; gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2); transform: translateY(4px); transition: transform .16s ease; }
.pd-veil.in .pd-box { transform: none; }
.pd-opt { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: start; padding: 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; transition: border-color .12s, background .12s; }
.pd-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pd-opt input { margin: 2px 0 0; accent-color: var(--accent); }
.pd-opt b { display: block; font-size: 12.5px; color: var(--ink); }
.pd-why { display: block; font-size: 12px; line-height: 1.45; color: var(--ink-2); overflow-wrap: anywhere; }
.pd-acts { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Duplicating a model: a copy mark beside the bin ─────────────── */
.card .c-copy {
    position: absolute; top: 8px; right: 72px; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
    background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--ink-2); border: 1px solid var(--line);
    opacity: 0; transform: translateY(-2px); transition: opacity .14s ease, transform .14s ease, background .12s, color .12s;
}
.card .c-copy svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.card:hover .c-copy, .card:focus-within .c-copy, .card .c-copy:focus-visible { opacity: 1; transform: none; }
.card .c-copy:hover { background: var(--accent-soft); color: var(--accent); }
@media (pointer: coarse) { .card .c-copy { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .card .c-copy { transition: none; } }

/* ── Deleting a model: a bin beside the pencil, a yes on the card ─── */
.card .c-delete {
    position: absolute; top: 8px; right: 40px; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
    background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--ink-2); border: 1px solid var(--line);
    opacity: 0; transform: translateY(-2px); transition: opacity .14s ease, transform .14s ease, background .12s, color .12s;
}
.card .c-delete svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.card:hover .c-delete, .card:focus-within .c-delete, .card .c-delete:focus-visible { opacity: 1; transform: none; }
.card .c-delete:hover { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); color: var(--bad); }
@media (pointer: coarse) { .card .c-delete { opacity: 1; transform: none; } }
.card .c-confirm {
    position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 12px;
    border-radius: inherit; background: color-mix(in srgb, var(--surface) 96%, transparent); text-align: left; cursor: default;
    opacity: 0; transition: opacity .15s ease;
}
.card .c-confirm.in { opacity: 1; }
.card .c-confirm.going { opacity: .6; pointer-events: none; }
.c-confirm .c-q { font-weight: 600; font-size: 13px; color: var(--ink); overflow-wrap: anywhere; }
.c-confirm .c-sub { font-size: 11.5px; line-height: 1.4; color: var(--ink-2); }
.c-confirm .c-acts { display: flex; gap: 6px; justify-content: flex-end; }
.c-confirm .c-no, .c-confirm .c-yes { height: 26px; padding: 0 12px; display: inline-grid; place-items: center; border-radius: 6px; border: 1px solid var(--line-2); font-size: 12px; cursor: pointer; transition: background .12s, color .12s; }
.c-confirm .c-no:hover { background: var(--accent-soft); }
.c-confirm .c-yes { border-color: var(--bad); background: var(--bad); color: var(--bg); }
.c-confirm .c-yes:hover { filter: brightness(1.08); }
@media (prefers-reduced-motion: reduce) { #files.flash, .dm-row.fresh { animation: none; } .data-note, .pd-veil, .pd-box, .card .c-delete, .card .c-confirm { transition: none; animation: none; } }

/* Find a variable on the diagram (the tile's magnifier, or /) */
.dg-find { position: fixed; z-index: 60; width: 280px; max-height: min(360px, calc(100vh - 16px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-2);
    border-radius: 10px; box-shadow: var(--shadow-2); padding: 6px; animation: wf-in .16s ease; }
.dg-find-in { margin: 0 0 6px; padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel); color: var(--ink); font: inherit; font-size: 12.5px; }
.dg-find-in:focus { outline: none; border-color: var(--accent); }
.dg-find-list { overflow: auto; min-height: 0; }
.dg-find-i { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; column-gap: 8px; width: 100%; text-align: left; padding: 5px 6px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--ink); font-size: 12.5px; }
.dg-find-i:hover, .dg-find-i:focus-visible { outline: none; background: var(--hover); }
.dg-find-i span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-find-i small { color: var(--faint); font-size: 10.5px; }
.dg-find-none { color: var(--muted); font-size: 12px; padding: 6px; }
.dg-k { width: 10px; height: 10px; border: 1.5px solid var(--muted); border-radius: 50%; }
.dg-k-stock { border-radius: 2px; }
.dg-k-view { width: 12px; border-radius: 2px; border-style: dashed; }
.dg-k-flow { border-radius: 0; border-width: 0 0 2px 0; height: 6px; }

/* A picker: a list to pick one from, searched (a model's workflows, decks) */
.pk-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 4px 8px 4px 10px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); color: var(--ink); font: inherit; font-size: 12.5px; cursor: pointer; }
.pk-btn:disabled { color: var(--muted); cursor: default; }
.pk-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-caret { flex: none; color: var(--muted); }
.pk-pop { position: fixed; z-index: 60; max-width: 360px; max-height: min(360px, calc(100vh - 16px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-2);
    border-radius: 10px; box-shadow: var(--shadow-2); padding: 6px; animation: wf-in .16s ease; }
.pk-search { margin: 0 0 6px; padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel); color: var(--ink); font: inherit; font-size: 12.5px; }
.pk-search:focus { outline: none; border-color: var(--accent); }
.pk-list { overflow: auto; min-height: 0; }
.pk-i { display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left; padding: 6px 8px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--ink); font-size: 12.5px; }
.pk-i:hover, .pk-i:focus-visible { outline: none; background: var(--hover); }
.pk-i.on { font-weight: 600; }
.pk-i-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-i small { margin-left: auto; color: var(--faint); font-size: 10.5px; flex: none; }
.pk-none { color: var(--muted); font-size: 12px; padding: 6px; }
.fl-search { width: 100%; box-sizing: border-box; margin: 0 0 8px; padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); color: var(--ink); font: inherit; font-size: 12.5px; }
.fl-search:focus { outline: none; border-color: var(--accent); }
.fl-none { color: var(--muted); font-size: 12px; margin: 0 0 8px; }

/* a narrow workflow window: its bar keeps one row, the words going first */
@container (max-width: 760px) { .wf-zoomfit span, .wf-add span { display: none; } .wf-bar { gap: 4px; } }
@container (max-width: 560px) { .wf-status { display: none; } }

/* A window's +: the views and panels by layer, in the 3D layers' colours */
.tile-add-menu { position: fixed; z-index: 60; width: 260px; max-height: calc(100vh - 16px); overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow-2); padding: 6px; animation: wf-in .16s ease; }
.tam-h { display: flex; align-items: center; gap: 7px; font: 600 10.5px/1 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 9px 8px 4px; }
.tam-h:first-child { padding-top: 3px; }
.tam-h i { width: 8px; height: 8px; border-radius: 2px; background: var(--layer); }
.tam-i { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 6px; width: 100%; padding: 6px 8px; border: 0; background: none; border-radius: 6px; text-align: left; color: var(--ink); font-size: 12.5px; cursor: pointer; }
.tam-i:hover, .tam-i:focus-visible { outline: none; background: var(--hover); }
.tam-i small { color: var(--faint); font-size: 10.5px; }
.tam-check { color: var(--accent); font-size: 11px; }
.tam-i.here { color: var(--muted); }

/* Policies: in the Parameters panel (a colour, a name, laid over or not) */
.pol-box { padding: 2px 14px 10px; border-bottom: 1px solid var(--line); }
.pol-h { margin-top: 6px; }
.pol-list { display: grid; gap: 1px; }
.pol-item { display: flex; align-items: center; gap: 6px; }
.pol-row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 5px 6px; border: 0; border-radius: 6px; background: none; color: var(--ink); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; transition: background-color .15s ease; }
.pol-row:hover, .pol-row:focus-visible { outline: none; background: var(--hover); }
.pol-row.sel { background: color-mix(in srgb, var(--c) 12%, transparent); }
.pol-row .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.pol-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pol-on { flex: none; margin: 0 4px 0 0; }
.pol-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pol-save { padding-inline: 8px; }
.pol-matrix { margin-left: auto; }
.pol-name-in { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; font-size: 12.5px; }
.pol-name-in:focus { outline: none; border-color: var(--accent); }
/* …and a policy picked, in the Inspector */
.insp-pol { padding: 14px 16px 18px; animation: tab-in .18s ease; }
.insp-pol .insp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.kind-badge.policy { background: var(--c); }
.pol-insp-name { flex: 1; min-width: 0; padding: 3px 6px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--ink); font: 650 16px/1.2 var(--font); }
.pol-insp-name:hover { border-color: var(--line-2); }
.pol-insp-name:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.insp-pol .sub { margin: 12px 0 4px; }
.pol-insp-acts { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.pol-insp-on { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }

/* A loop picked, in the Inspector */
.insp-loop { padding: 14px 16px 18px; animation: tab-in .18s ease; }
.insp-loop .insp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.insp-loop .insp-head h2 { font-size: 13px; font-weight: 600; margin: 0; }
.insp-loop .sub { margin: 12px 0 4px; }
.loop-path { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; font-size: 12.5px; }
.loop-path .arr { color: var(--faint); }
.loop-when { margin: 0; font: 12px/1.5 var(--mono); color: var(--ink-2); }

/* ── The causal diagram (causal.js): the pick, its causes left, its effects right ── */
.causal { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--canvas); }
.cz-bar { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; flex: none; border-bottom: 1px solid var(--line); background: var(--panel); min-width: 0; }
.cz-orders { display: inline-flex; align-items: center; gap: 2px; padding: 2px 2px 2px 8px; border-radius: 7px; background: var(--hover); flex: none; }
.cz-lab { font-size: 11.5px; color: var(--muted); margin-right: 4px; }
.cz-step { width: 22px; height: 22px; border: 0; border-radius: 5px; background: none; color: var(--ink-2); font: 600 14px/1 var(--font); cursor: pointer; display: grid; place-items: center; padding: 0; transition: background-color .12s, color .12s, box-shadow .12s; }
.cz-step:hover:not(:disabled), .cz-step:focus-visible { outline: none; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.cz-step:disabled { color: var(--faint); cursor: default; }
.cz-n { min-width: 16px; text-align: center; font: 650 12px/1 var(--font); color: var(--ink); }
.cz-note { flex: 1; min-width: 0; text-align: right; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cz-fit { width: 26px; height: 26px; flex: none; }
.cz-fit svg { width: 14px; height: 14px; }
.cz-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: none; cursor: grab; }
.cz-stage.panning { cursor: grabbing; }
.cz-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; fill: none; stroke: none; user-select: none; -webkit-user-select: none; }
.cz-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px 28px; text-align: center; color: var(--faint); font-size: 12.5px; pointer-events: none; opacity: 0; transition: opacity .25s ease; }
.cz-empty.on { opacity: 1; }
.cz-node { cursor: pointer; }
.cz-node.gone, .cz-e.gone { pointer-events: none; }
.cz-node:focus { outline: none; }
.cz-node .cz-box { fill: var(--surface); stroke: var(--line-2); stroke-width: 1; transition: stroke .15s ease, fill .15s ease; }
.cz-node:hover .cz-box, .cz-node:focus-visible .cz-box { stroke: var(--accent); }
.cz-node.focus .cz-box { stroke: var(--accent); stroke-width: 1.6; fill: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.cz-node .cz-t { fill: var(--ink); stroke: none; font: 500 12px var(--font); dominant-baseline: central; }
.cz-node.focus .cz-t { font: 650 13px var(--font); }
.cz-node .cz-k { fill: var(--aux); stroke: none; }
.cz-node.stock .cz-k { fill: var(--stock); }
.cz-node.flow .cz-k { fill: var(--flow); }
.cz-node.more .cz-k { display: none; }
.cz-node.more .cz-box { fill: transparent; stroke-dasharray: 3 3; }
.cz-node.more .cz-t { fill: var(--muted); text-anchor: middle; }
.cz-e { color: var(--conn); }
.cz-e .cz-l { fill: none; stroke: currentColor; stroke-width: 1.3; }
.cz-e .cz-a { fill: currentColor; stroke: none; }
.cz-e .cz-p { fill: currentColor; stroke: none; font: 700 11px var(--font); text-anchor: middle; dominant-baseline: central; }
/* a flow into or out of a stock: a pipe's colour, a pipe's weight */
.cz-e.pipe { color: color-mix(in srgb, var(--flow) 75%, transparent); }
.cz-e.pipe .cz-l { stroke-width: 2.2; }
/* against the ranks (a feedback through the pick), within one, or to what is
   summed up: dashed; a cause's link straight to an effect (around the pick): an arc, solid */
.cz-e.back .cz-l, .cz-e.side .cz-l, .cz-e.more .cz-l { stroke-dasharray: 4 3; }
.cz-e.over .cz-l { stroke-opacity: .5; }
.cz-e.hl { color: var(--accent); }
.cz-e.over.hl .cz-l { stroke-opacity: 1; }
/* each rank's heading, at the type's own size over its column (causal.js drawView) */
.cz-hdrs { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cz-hdr { position: absolute; left: 0; top: 0; white-space: nowrap; padding: 2px 6px; border-radius: 5px; font: 600 11px/1.2 var(--font); color: var(--muted); background: color-mix(in srgb, var(--canvas) 85%, transparent); }
/* a node pointed at: it, its links and its neighbours; the rest recede */
.cz-in { transition: opacity .15s ease; }
.cz-svg.hov .cz-node:not(.hl) > .cz-in { opacity: .45; }
.cz-svg.hov .cz-e:not(.hl) > .cz-in { opacity: .2; }
@media (prefers-reduced-motion: reduce) { .cz-in, .cz-empty, .cz-node .cz-box { transition: none; } }

/* The run's end and the years shown (ends.js): a quiet button beside the
   clock, marked when either is set; its sheet. */
.end-btn { flex: none; height: 24px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 7px; background: none; color: var(--muted); font: 600 11.5px var(--mono); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
.end-btn:hover, .end-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.end-btn.set { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--line-2)); }
.end-pop { position: fixed; z-index: 45; width: 300px; max-width: calc(100vw - 16px); box-sizing: border-box; display: grid; gap: 7px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); font-size: 12.5px;
  opacity: 0; transform: translateY(-4px); transition: opacity .15s ease, transform .15s ease; }
.end-pop.in { opacity: 1; transform: none; }
.ep-h { font: 650 11px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.ep-why { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.ep-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ep-in { width: 72px; height: 24px; box-sizing: border-box; padding: 0 6px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); color: var(--ink); font: 12px var(--mono); }
.ep-in:focus { outline: none; border-color: var(--accent); }
.ep-own { justify-self: start; }
@media (prefers-reduced-motion: reduce) { .end-pop { transition: none; } }

/* ── The windows on dockview-core (dock.js; stage 1, behind a flag) ───── */
.tiles.docked .dock-root { position: absolute; inset: 4px; }
#app.no-model .dock-root { display: none; }
.dock-root .dv-dockview { font: 600 12px/1 var(--font); }   /* its colours: stage 8, below */
.dock-body { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; min-height: 0; }
.dock-actions { display: flex; align-items: center; gap: 2px; height: 100%; padding: 0 4px; }
.dock-actions .tile-btn svg { width: 13px; height: 13px; }

/* An empty window (New window, nothing chosen yet): its + and a line */
.tile-empty { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; padding: 16px; text-align: center; animation: tab-in .2s ease both; }
.tile-empty-add { width: 40px; height: 40px; border-radius: 50%; border: 1px dashed var(--line-2); background: none; color: var(--ink-2); font: 400 22px/1 var(--font); cursor: pointer; transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.tile-empty-add:hover, .tile-empty-add:focus-visible { outline: none; background: var(--hover); border-color: var(--accent); color: var(--ink); }

/* a window moves by its header's empty part, a tab by itself: a hand says so */
.dock-root .dv-void-container { cursor: grab; }
.dock-root .dv-void-container:active { cursor: grabbing; }
.dock-root .dv-tab { cursor: grab; }

/* stage 2: dockview's windows wear tiles.js's markup (.tile-root, .tile[data-leaf],
   .tile-head, .tile-tabs, .tile-tab): its geometry stays dockview's */
.tiles.docked .dock-root.tile-root { display: block; padding: 0; }
.dock-root .dv-groupview.tile { border: 0; border-radius: 0; box-shadow: none; background: var(--panel); overflow: hidden; }
/* the focused window's ring as tiles.js draws it (its border, its halo: inside, a window's edge being dockview's) */
.dock-root .dv-groupview.tile { transition: box-shadow .12s; }
.dock-root .dv-groupview.tile.focused { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, var(--line)), inset 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.dock-root .dv-tabs-and-actions-container.tile-head { padding: 0; gap: 0; }
.dock-root .dv-tab { padding: 0; background: none; }
.dock-root .dv-tab .tile-tab { height: 100%; }
.dock-empty { height: 100%; justify-content: center; }

/* The Stack's layers menu: a checkbox per layer, over the 3D toolbar. */
.stack-layers-menu { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--panel, #fff); border: 1px solid var(--line, #ddd); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.14); font-size: 12px; opacity: 0; transform: translateY(4px); transition: opacity .16s ease, transform .16s ease; }
.stack-layers-menu.open { opacity: 1; transform: none; }
.stack-layers-menu label { display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 5px; cursor: pointer; }
.stack-layers-menu label:hover { background: var(--hover, rgba(0,0,0,.05)); }

/* Your rooms (⋯ › Your rooms): a row per room, its codes under it. */
.rooms-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rooms-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line, rgba(127,127,127,.2)); transition: opacity .18s ease, transform .18s ease; }
.rooms-row.rooms-going { opacity: 0; transform: translateX(12px); }
.rooms-main { min-width: 0; flex: 1; }
.rooms-code { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.rooms-code code { font-size: 12px; letter-spacing: .08em; }
.rooms-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
@media (prefers-reduced-motion: reduce) { .rooms-row { transition: none; } }

/* stage 8: dockview's own parts in the Studio's tokens, in every theme (light,
   dark, XP, 2000): none of dockview's light theme's colours left */
.dock-root, .dock-root.dockview-theme-light, .dock-root .dockview-theme-light, .dock-root .dv-dockview {
    color-scheme: inherit;
    --dv-group-view-background-color: var(--panel); --dv-tabs-and-actions-container-background-color: var(--panel);
    --dv-activegroup-visiblepanel-tab-background-color: var(--panel); --dv-activegroup-hiddenpanel-tab-background-color: var(--panel);
    --dv-inactivegroup-visiblepanel-tab-background-color: var(--panel); --dv-inactivegroup-hiddenpanel-tab-background-color: var(--panel);
    --dv-activegroup-visiblepanel-tab-color: var(--ink); --dv-activegroup-hiddenpanel-tab-color: var(--muted);
    --dv-inactivegroup-visiblepanel-tab-color: var(--ink-2); --dv-inactivegroup-hiddenpanel-tab-color: var(--muted);
    --dv-tab-divider-color: transparent; --dv-separator-border: var(--line); --dv-paneview-header-border-color: var(--line);
    --dv-background-color: var(--bg); --dv-icon-hover-background-color: var(--hover);
    --dv-scrollbar-background-color: var(--line-2); --dv-tabs-container-scrollbar-color: var(--line-2);
    --dv-drag-over-background-color: var(--accent-soft); --dv-drag-over-border-color: var(--accent);
    --dv-edge-dock-indicator-color: var(--accent); --dv-paneview-active-outline-color: var(--accent);
    /* the sash: as tiles.js's gutter, nothing until hovered, then the accent at half */
    --dv-sash-color: transparent; --dv-active-sash-color: color-mix(in srgb, var(--accent) 50%, transparent);
    --dv-active-sash-transition-delay: 0s; --dv-active-sash-transition-duration: .12s;
    --dv-floating-border: 1px solid var(--line); --dv-floating-box-shadow: 0 6px 20px rgba(0, 0, 0, .14);
    --dv-context-menu-background-color: var(--panel); --dv-context-menu-color: var(--ink);
    --dv-dnd-compass-color: var(--accent); --dv-dnd-compass-cell-color: var(--accent-soft);
    --dv-dnd-compass-active-cell-color: var(--accent); --dv-dnd-compass-edge-cell-color: var(--accent-soft);
    --dv-smart-guides-color: var(--accent); --dv-smart-guides-preview-color: var(--accent-soft);
}
.dock-root .dv-tabs-overflow-dropdown-default { color: var(--muted); font: 600 11px/1 var(--font); border-radius: 5px; }
.dock-root .dv-tabs-overflow-dropdown-default:hover { color: var(--ink); background: var(--hover); }
.dock-root .dv-tabs-overflow-container { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .14); }

/* a narrow window's header: its tabs keep the room; New window, the splits
   and Maximise wait in its ⋯, a small menu that fades in under it */
.dock-actions.right { position: relative; z-index: 5; }
.dock-more, .dock-more-l { display: none; }
.dock-more-items { display: contents; }
.dv-groupview.narrow .dock-more { display: inline-flex; }
.dv-groupview.narrow .dock-more-items { display: flex; flex-direction: column; gap: 1px; position: absolute; top: calc(100% + 2px); right: 4px; padding: 4px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .14);
    visibility: hidden; opacity: 0; transform: translateY(-4px); pointer-events: none;
    transition: opacity .16s ease, transform .16s ease, visibility 0s linear .16s; }
.dv-groupview.narrow .dock-actions.open .dock-more-items { visibility: visible; opacity: 1; transform: none; pointer-events: auto; transition: opacity .16s ease, transform .16s ease; }
.dv-groupview.narrow .dock-more-items .tile-btn { width: auto; height: 26px; padding: 0 10px 0 6px; gap: 8px; justify-content: flex-start; color: var(--ink-2); opacity: 1; margin: 0; }
.dv-groupview.narrow .dock-more-items .dock-more-l { display: inline; font: 500 12px/1 var(--font); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .dv-groupview.narrow .dock-more-items { transition: none; } }
