/* ==========================================================================
   Ordinate 2D — professional editor chrome (dark / light)
   ========================================================================== */

:root {
    --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
    --font-figure: "STIX Two Text", "Times New Roman", Times, serif;

    --radius: 2px;
    --radius-sm: 2px;
    --titlebar-h: 34px;
    --ribbon-tabs-h: 28px;
    --ribbon-body-h: 70px;
    --commandbar-h: 28px;
    --statusbar-h: 24px;
    --explorer-w: 248px;
    --props-w: 300px;
    --row-h: 24px;
    --ease: cubic-bezier(0.2, 0, 0, 1);
}

[data-theme="dark"] {
    color-scheme: dark;
    --logo-blue: #8fb0ff; --logo-orange: #f59e5b;
    --bg-app: #1d1e21;
    --bg-panel: #242528;
    --bg-panel-alt: #2a2b2f;
    --bg-input: #1a1b1e;
    --bg-hover: #303236;
    --bg-pressed: #36383d;
    --bg-viewport: #191a1d;
    --border: #323438;
    --border-strong: #40434a;
    --text: #e2e4e7;
    --text-dim: #a0a5ab;
    --text-faint: #6c7177;
    --accent: #3d8bfd;
    --accent-hover: #5c9dff;
    --accent-weak: rgba(61, 139, 253, 0.16);
    --accent-text: #8ab8ff;
    --danger: #e5484d;
    --success: #30a46c;
    --warning: #f5a524;
    --shadow-pop: 0 8px 28px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.03) inset;
    --scroll-thumb: #3b3e44;
    --code-keyword: #c792ea;
    --code-string: #a5d6a7;
    --code-number: #f78c6c;
    --code-comment: #7d848c;
    --code-function: #82aaff;
    --code-class: #ffcb6b;
}

[data-theme="light"] {
    color-scheme: light;
    --logo-blue: #1e40af; --logo-orange: #c2410c;
    --bg-app: #eceef1;
    --bg-panel: #ffffff;
    --bg-panel-alt: #f6f7f9;
    --bg-input: #ffffff;
    --bg-hover: #eef1f4;
    --bg-pressed: #e3e7ec;
    --bg-viewport: #f5f6f8;
    --border: #e0e3e8;
    --border-strong: #cdd2d9;
    --text: #1f2328;
    --text-dim: #59616a;
    --text-faint: #8b939b;
    --accent: #2f7bea;
    --accent-hover: #1f6ad8;
    --accent-weak: rgba(47, 123, 234, 0.12);
    --accent-text: #1f6ad8;
    --danger: #d93036;
    --success: #218358;
    --warning: #c47f00;
    --shadow-pop: 0 10px 30px rgba(18, 24, 33, 0.16), 0 1px 3px rgba(18, 24, 33, 0.08);
    --scroll-thumb: #c9ced5;
    --code-keyword: #8b2fc9;
    --code-string: #22863a;
    --code-number: #b35900;
    --code-comment: #8b939b;
    --code-function: #1f5fbf;
    --code-class: #9a6700;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    overflow: clip;   /* hidden still allows programmatic scrolling (focus, scrollIntoView); clip does not */
    background: var(--bg-app);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 12px;
    line-height: 1.35;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--text-faint); }

#app {
    overflow: clip;
    display: grid;
    grid-template-rows: var(--titlebar-h) auto 1fr var(--commandbar-h) var(--statusbar-h);
    /* One column as wide as the window: an auto column grew to the canvas's last width, so after the window narrowed
       the whole studio stayed wider than it and its right edge was cut off. */
    grid-template-columns: minmax(0, 1fr);
    height: 100vh;
    width: 100vw;
}

/* ---------- Title bar ---------- */
#titlebar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 10px;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border);
    user-select: none;
}
.brand { display: flex; align-items: center; padding-right: 10px; color: var(--text); }
.brand .logo-inline { height: 15px; width: auto; display: block; }
.menubar { display: flex; gap: 2px; }
.menu-btn {
    padding: 4px 9px;
    border-radius: var(--radius);
    color: var(--text-dim);
}
.menu-btn:hover, .menu-btn.open { background: var(--bg-hover); color: var(--text); }
.titlebar-center { flex: 1; display: flex; justify-content: center; align-items: center; gap: 6px; min-width: 0; }
.scene-title { color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; cursor: text; padding: 2px 6px; border-radius: var(--radius); }
.scene-title:hover { background: var(--bg-hover); color: var(--text); }
.dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.titlebar-right { display: flex; align-items: center; gap: 8px; }

.mode-switch {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 1px;
}
.mode-option {
    padding: 3px 10px;
    border-radius: 1px;
    color: var(--text-dim);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}
.mode-option:hover { color: var(--text); background: var(--bg-hover); }
.mode-option.active { background: var(--accent); color: #fff; }
.mode-option.active .pro-badge { color: #fff; border-color: rgba(255,255,255,0.7); }
.pro-badge {
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 0 3px;
    border-radius: 1px;
    color: var(--accent-text);
    border: 1px solid var(--accent);
    line-height: 13px;
}

.icon-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: var(--text-dim);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.small { width: 22px; height: 22px; }
.icon-btn.small svg { width: 14px; height: 14px; }

/* ---------- Ribbon ---------- */
#ribbon { background: var(--bg-panel); border-bottom: 1px solid var(--border); user-select: none; }
.ribbon-tabs { display: flex; gap: 2px; height: var(--ribbon-tabs-h); padding: 0 8px; align-items: flex-end; background: var(--bg-app); border-bottom: 1px solid var(--border); }
.ribbon-tab {
    padding: 0 12px;
    height: 26px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--text-dim);
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 0;
    position: relative;
    top: 1px;
}
.ribbon-tab:hover { color: var(--text); }
.ribbon-tab.active { background: var(--bg-panel); color: var(--text); border-color: var(--border); }
.ribbon-tab.active::after { content: ""; position: absolute; left: 8px; right: 8px; top: -1px; height: 2px; background: var(--accent); border-radius: 2px; }

/* The tools scroll sideways when the window is narrow. The scroll bar is hidden: it took its height from the fixed ribbon and
   covered the group captions (owner, 2026-10-09). The wheel scrolls it, and ‹ › buttons appear at an edge with more tools. */
.ribbon-body-wrap { position: relative; }
.ribbon-body {
    display: flex;
    align-items: stretch;
    height: var(--ribbon-body-h);
    padding: 4px 6px 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}
.ribbon-body::-webkit-scrollbar { display: none; }
.ribbon-scroll {
    position: absolute; top: 0; bottom: 0; width: 18px; display: none;
    align-items: center; justify-content: center; padding: 0; border: none;
    font-size: 16px; line-height: 1; color: var(--text-dim); background: var(--bg-panel); cursor: pointer; z-index: 2;
}
.ribbon-scroll:hover { color: var(--text); background: var(--bg-hover, var(--bg-panel)); }
.ribbon-scroll.left { left: 0; border-right: 1px solid var(--border); box-shadow: 4px 0 6px -4px rgba(0,0,0,.35); }
.ribbon-scroll.right { right: 0; border-left: 1px solid var(--border); box-shadow: -4px 0 6px -4px rgba(0,0,0,.35); }
.ribbon-scroll.show { display: flex; }
.ribbon-group {
    display: flex;
    flex-direction: column;
    padding: 0 6px;
    border-right: 1px solid var(--border);
}
.ribbon-group:last-child { border-right: none; }
.ribbon-group-tools { display: flex; align-items: flex-start; gap: 2px; flex: 1; }
.ribbon-group-tools.stacked { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, 24px); gap: 2px 4px; align-content: start; }
.ribbon-group-caption {
    text-align: center;
    font-size: 10px;
    color: var(--text-faint);
    padding: 1px 0 4px;
    white-space: nowrap;
}
.tool-btn {
    min-width: 54px;
    height: 48px;
    padding: 4px 6px 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    border-radius: var(--radius);
    color: var(--text);
    border: 1px solid transparent;
}
.tool-btn svg { width: 20px; height: 20px; color: var(--text-dim); stroke-width: 1.5; }
.tool-btn span { font-size: 11px; white-space: nowrap; color: var(--text-dim); }
.tool-btn.dropdown span { display: inline-flex; align-items: center; gap: 1px; }
.tool-btn .dd-chevron { width: 10px; height: 10px; stroke-width: 2; }
.tool-btn:hover { background: var(--bg-hover); }
.tool-btn:hover svg, .tool-btn:hover span { color: var(--text); }
.tool-btn.active, .tool-btn.pressed { background: var(--bg-pressed); border-color: transparent; box-shadow: inset 0 -2px 0 var(--accent); }
.tool-btn.active svg, .tool-btn.active span, .tool-btn.pressed svg, .tool-btn.pressed span { color: var(--text); }
.tool-btn:disabled { opacity: 0.4; cursor: default; background: none; }
.tool-btn.primary svg { color: var(--success); }
.tool-btn.danger-tool svg { color: var(--danger); }
.tool-btn.small {
    flex-direction: row;
    justify-content: flex-start;
    min-width: 0;
    height: 24px;
    padding: 0 7px;
    gap: 6px;
}
.tool-btn.small svg { width: 16px; height: 16px; }

/* ---------- Workspace & docks ---------- */
#workspace {
    position: relative;
    display: grid;
    grid-template-columns: 0 var(--explorer-w) 4px minmax(200px, 1fr) 4px var(--props-w) 0;   /* studio.js applyLayout sets it (edge-tab gutters at both ends) */
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
    min-width: 0;
}
#workspace > * { grid-row: 1; }
.dock-hidden { display: none !important; }

/* A closed panel leaves a tab on its edge of the workspace. */
.edge-tabs { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; min-width: 0; overflow: hidden; background: var(--bg-app, var(--bg-panel)); }
.edge-tabs:empty { display: none; }
.edge-tabs.left { align-items: flex-start; border-right: 1px solid var(--border); }
.edge-tabs.right { align-items: flex-end; border-left: 1px solid var(--border); }
.edge-tab {
    pointer-events: auto;
    writing-mode: vertical-rl;
    width: 23px;
    box-sizing: border-box;
    padding: 10px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}
/* Square against the window edge, rounded on the side that faces the workspace (the left tab is turned 180°, so its
   borders and corners are given mirrored). */
.edge-tabs.left .edge-tab { border-right: none; border-radius: 6px 0 0 6px; transform: rotate(180deg); }
.edge-tabs.right .edge-tab { border-right: none; border-radius: 6px 0 0 6px; }
.edge-tab:hover { color: var(--text); background: var(--bg-hover); }

/* Dragging a panel's title bar to the other side. */
body.dock-dragging, body.dock-dragging * { cursor: grabbing !important; user-select: none; }
.dock-drop-marker {
    position: absolute; z-index: 7; pointer-events: none; box-sizing: border-box;
    display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 8px;
    font-size: 12px; font-weight: 600; color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border: 2px dashed var(--accent);
}
.dock-panel .panel-title { cursor: grab; }

/* Hidden chrome (View menu). Each bar keeps its own row, so a hidden one leaves a 0 px row, not a shifted layout. */
#titlebar { grid-row: 1; }
#ribbon { grid-row: 2; }
#workspace { grid-row: 3; }
#commandbar { grid-row: 4; }
#statusbar { grid-row: 5; }
#app.ribbon-collapsed .ribbon-body { display: none; }
#app.hide-commandbar { --commandbar-h: 0px; }
#app.hide-commandbar #commandbar { display: none; }
#app.hide-statusbar { --statusbar-h: 0px; }
#app.hide-statusbar #statusbar { display: none; }

/* One side of the workspace holds one or two panels stacked (studio.js applyLayout); --dock-share is a panel's relative height. */
.dock-side {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    background: var(--bg-panel);
    overflow: hidden;
}
.dock-side.left { border-right: 1px solid var(--border); }
.dock-side.right { border-left: 1px solid var(--border); }
.dock-panel {
    display: flex;
    flex-direction: column;
    flex: var(--dock-share, 1) 1 0px;
    min-height: 90px;
    min-width: 0;
    background: var(--bg-panel);
    overflow: hidden;
}
.dock-resizer { cursor: col-resize; background: var(--bg-app); }
.dock-resizer:hover, .dock-resizer.dragging { background: var(--accent); }
.dock-split { flex: 0 0 4px; cursor: row-resize; background: var(--bg-app); }
.dock-split:hover, .dock-split.dragging { background: var(--accent); }

.panel-title {
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel-alt);
    user-select: none;
}
.panel-title-actions { display: flex; align-items: center; gap: 2px; }
.panel-subtitle { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text-faint); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-filter {
    position: relative;
    flex-shrink: 0;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}
.panel-filter input {
    width: 100%;
    height: 24px;
    padding: 0 8px 0 26px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
}
.panel-filter input:focus { border-color: var(--accent); }
.filter-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 13px; height: 13px; color: var(--text-faint); }

/* ---------- Explorer tree ---------- */
.tree { flex: 1; overflow: auto; padding: 4px 0 12px; outline: none; user-select: none; }
.tree-row {
    display: flex;
    align-items: center;
    height: 22px;
    padding-right: 6px;
    gap: 4px;
    cursor: default;
    color: var(--text);
    border-left: 2px solid transparent;
    white-space: nowrap;
}
.tree-row:hover { background: var(--bg-hover); }
.tree-row.selected { background: var(--accent); border-left-color: var(--accent); color: #fff; }
.tree-row.selected .tree-label,
.tree-row.selected .tree-icon,
.tree-row.selected .tree-twisty,
.tree-row.selected .tree-count,
.tree-row.selected .tree-action { color: #fff; }
.tree-row.selected:hover { background: var(--accent-hover); }
.tree-row.selected .tree-action:hover { background: rgba(255,255,255,0.18); color: #fff; }
.tree-row.dimmed .tree-label { color: var(--text-faint); }
.tree-twisty { width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-faint); }
.tree-twisty svg { width: 12px; height: 12px; transition: transform 0.12s var(--ease); }
.tree-row.collapsed .tree-twisty svg { transform: rotate(-90deg); }
.tree-twisty.empty { visibility: hidden; }
.tree-icon { width: 14px; height: 14px; color: var(--text-dim); }
.tree-icon.colored { stroke-width: 2; }
.tree-label { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tree-row.group .tree-label { font-weight: 600; color: var(--text-dim); }
.tree-count { color: var(--text-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.tree-actions { display: none; gap: 2px; }
.tree-row:hover .tree-actions, .tree-actions.pinned { display: inline-flex; }
.tree-action { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: 3px; color: var(--text-faint); }
.tree-action:hover { background: var(--bg-pressed); color: var(--text); }
.tree-action svg { width: 12px; height: 12px; }
.tree-rename {
    flex: 1;
    height: 18px;
    padding: 0 4px;
    background: var(--bg-input);
    border: 1px solid var(--accent);
    border-radius: 3px;
    outline: none;
}
.tree-empty { padding: 10px 14px; color: var(--text-faint); }

/* ---------- Property grid ---------- */
.property-grid { flex: 1; overflow: auto; padding-bottom: 16px; }
.prop-section { border-bottom: 1px solid var(--border); }
.prop-section-header {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 8px 0 4px;
    font-weight: 600;
    font-size: 11.5px;
    background: var(--bg-panel-alt);
    color: var(--text);
    user-select: none;
    cursor: default;
}
.prop-section-header svg { width: 12px; height: 12px; color: var(--text-faint); transition: transform 0.12s var(--ease); }
.prop-section.collapsed .prop-section-header svg { transform: rotate(-90deg); }
.prop-section.collapsed .prop-section-body { display: none; }
.prop-section-body { padding: 2px 0 4px; }
.prop-row {
    display: grid;
    grid-template-columns: 44% 1fr;
    align-items: center;
    min-height: var(--row-h);
    padding: 1px 8px 1px 18px;
    gap: 6px;
}
.prop-row:hover { background: color-mix(in srgb, var(--bg-hover) 60%, transparent); }
.prop-row.full { grid-template-columns: 1fr; padding-left: 10px; }
.prop-label {
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: none;
}
.prop-label.scrub { cursor: ew-resize; }
.prop-label.scrub:hover { color: var(--text); }
.prop-editor { display: flex; align-items: center; gap: 4px; min-width: 0; }
.prop-input {
    width: 100%;
    min-width: 0;
    height: 22px;
    padding: 0 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    font-variant-numeric: tabular-nums;
}
.prop-input:hover { border-color: var(--border-strong); }
.prop-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); }
.prop-input[readonly], .prop-input:disabled { color: var(--text-faint); background: transparent; border-color: transparent; }
.prop-number { position: relative; flex: 1; min-width: 0; display: flex; }
.prop-number .prop-input { padding-right: 34px; }
.prop-unit {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    font-size: 11px;
    pointer-events: none;
}
.prop-vec { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 100%; }
.prop-vec .prop-number .prop-input { padding-left: 16px; padding-right: 6px; }
.prop-axis { position: absolute; left: 5px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--text-faint); pointer-events: none; }
.prop-readout { color: var(--text); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.prop-readout.dim { color: var(--text-faint); }
.prop-readout.wrap { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.35; padding: 3px 2px; }
.prop-readout[data-tone="error"] { color: var(--danger); }
.prop-readout[data-tone="off"] { color: var(--text-faint); }
.prop-row.inactive .prop-label { color: var(--text-faint); }
.prop-row.inactive .prop-input:not(:placeholder-shown) { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text-faint) 70%, transparent); }
.prop-row.inactive .prop-input::placeholder { opacity: 0.5; }
.prop-consts { display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 2px 0; }
.prop-const { display: grid; grid-template-columns: minmax(0, 0.8fr) auto minmax(0, 1fr) minmax(0, 0.8fr) auto; align-items: center; gap: 4px; }
.prop-const .eq { color: var(--text-faint); }
.prop-const .x { width: 20px; height: 20px; padding: 0; color: var(--text-faint); background: none; border: none; border-radius: var(--radius-sm); }
.prop-const .x:hover { color: var(--danger); background: var(--bg-hover); }
.prop-const-new { display: flex; flex-direction: column; gap: 4px; padding: 6px; margin-top: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-input); }
.prop-const-new .prop-const > span:last-child { width: 20px; }
.prop-const-err { color: var(--danger); font-size: 11px; line-height: 1.3; }
.prop-const-err:empty { display: none; }
.prop-const-actions { display: flex; gap: 6px; }
select.prop-input { padding-right: 18px; cursor: pointer; }
.prop-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.prop-check input { appearance: none; width: 14px; height: 14px; border: 1px solid var(--border-strong); border-radius: 3px; background: var(--bg-input); display: grid; place-content: center; cursor: pointer; }
.prop-check input:checked { background: var(--accent); border-color: var(--accent); }
.prop-check input:checked::after { content: ""; width: 8px; height: 4px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.prop-color { display: flex; align-items: center; gap: 6px; width: 100%; }
.prop-color input[type="color"] { width: 22px; height: 22px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0; background: none; cursor: pointer; }
.prop-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.prop-color input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }
.prop-swatches { display: flex; gap: 3px; flex-wrap: wrap; }
.prop-swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.25); }
.prop-swatch:hover { transform: scale(1.15); }
.btn {
    height: 22px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-panel-alt);
    border: 1px solid var(--border-strong);
    color: var(--text);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn svg { width: 13px; height: 13px; }
.prop-buttons { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.prop-note { color: var(--text-faint); font-size: 11px; line-height: 1.45; padding: 4px 10px 6px 18px; }
.prop-empty { padding: 16px 14px; color: var(--text-faint); line-height: 1.5; }

.rope-end { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; }
.rope-end .prop-readout { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rope-end .btn { flex: none; }
.route-list { display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 2px 0; }
.route-node {
    display: grid;
    grid-template-columns: 16px 1fr auto;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.route-node .route-index { color: var(--text-faint); font-size: 10px; text-align: center; }
.route-node .route-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-node .route-sub { color: var(--text-faint); font-size: 10.5px; }
.route-actions { display: flex; gap: 2px; }
.route-actions .tree-action { width: 20px; height: 20px; }
.route-actions .tree-action.on { color: var(--accent-text); background: var(--accent-weak); }

/* ---------- Viewport ---------- */
#center-column { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* ---------- Editor area (workspace.js): tab groups, splits, floating windows ---------- */
#editor-area { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg-app); }
#eg-root { position: absolute; inset: 0; display: flex; }
#eg-root > * { flex: 1 1 0; }
#parking { display: none; }
.eg-split { display: flex; min-width: 0; min-height: 0; }
.eg-split.row { flex-direction: row; }
.eg-split.col { flex-direction: column; }
.eg-split > .eg-group, .eg-split > .eg-split { min-width: 120px; min-height: 90px; }
.eg-divider { flex: 0 0 4px; background: var(--border); z-index: 2; }
.eg-split.row > .eg-divider { cursor: col-resize; }
.eg-split.col > .eg-divider { cursor: row-resize; }
.eg-divider:hover { background: var(--accent); }
.eg-group { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-viewport); }
.eg-tabs {
    display: flex; align-items: stretch; flex: 0 0 28px; min-width: 0;
    background: var(--bg-panel); border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
}
.eg-tabs::-webkit-scrollbar { display: none; }
.eg-tab {
    display: flex; align-items: center; gap: 6px; padding: 0 6px 0 10px; max-width: 220px; min-width: 0; flex: 0 0 auto;
    color: var(--text-dim); border-right: 1px solid var(--border); cursor: default; user-select: none; position: relative;
}
.eg-tab svg { width: 13px; height: 13px; color: var(--text-faint); }
.eg-tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eg-tab:hover { background: var(--bg-hover); color: var(--text); }
.eg-tab.active { background: var(--bg-viewport); color: var(--text); }
.eg-group.focused .eg-tab.active::before, .float-win.focused .eg-tab.active::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent); }
.eg-tab.inactive-scene .eg-tab-name { font-style: italic; }
.eg-tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); flex: none; }
.eg-tab-close { width: 18px; height: 18px; display: grid; place-items: center; border-radius: var(--radius-sm); color: var(--text-faint); opacity: 0; flex: none; }
.eg-tab:hover .eg-tab-close, .eg-tab.active .eg-tab-close { opacity: 1; }
.eg-tab-close:hover { background: var(--bg-pressed); color: var(--text); }
.eg-tab-close svg { width: 11px; height: 11px; }
.eg-tabs-fill { flex: 1 1 auto; min-width: 12px; }
.eg-acts { display: flex; align-items: center; gap: 1px; padding: 0 4px; flex: none; }
.eg-act { width: 22px; height: 22px; display: grid; place-items: center; border-radius: var(--radius-sm); color: var(--text-faint); }
.eg-act:hover { background: var(--bg-hover); color: var(--text); }
.eg-act svg { width: 13px; height: 13px; }
.eg-body { position: relative; flex: 1 1 0; min-height: 0; min-width: 0; overflow: hidden; }
.eg-body > .scene-view, .eg-body > .pane-view, .eg-body > .eg-empty { position: absolute; inset: 0; }
.eg-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-faint); }
.scene-view { overflow: hidden; background: var(--bg-viewport); }
.scene-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.scene-overlay .view-controls, .scene-overlay #badge-time { pointer-events: auto; }
.doc-note {
    position: absolute; inset: 0; z-index: 5; display: flex; align-items: flex-start; justify-content: center; padding-top: 18px;
    background: color-mix(in srgb, var(--bg-viewport) 35%, transparent); cursor: pointer;
}
.doc-note > span {
    max-width: 80%; padding: 6px 12px; border-radius: var(--radius); background: var(--bg-panel); border: 1px solid var(--border-strong);
    color: var(--text-dim); box-shadow: var(--shadow-pop); font-size: 12px; line-height: 1.4;
}
.doc-note:hover > span { border-color: var(--accent); color: var(--text); }
.pane-view { display: flex; flex-direction: column; background: var(--bg-panel); }
.plots-pane, .table-pane { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
#float-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.float-win {
    position: absolute; pointer-events: auto; display: flex; flex-direction: column; min-width: 220px;
    background: var(--bg-panel); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: var(--shadow-pop); overflow: hidden;
}
.float-win.focused { border-color: color-mix(in srgb, var(--accent) 60%, var(--border-strong)); }
.float-win .eg-tabs { cursor: move; }
.float-win .eg-tab { cursor: default; }
.float-win.minimized { height: auto !important; }
.float-resize { position: absolute; z-index: 3; }
.float-resize.n, .float-resize.s { left: 6px; right: 6px; height: 6px; cursor: ns-resize; }
.float-resize.n { top: -3px; } .float-resize.s { bottom: -3px; }
.float-resize.e, .float-resize.w { top: 6px; bottom: 6px; width: 6px; cursor: ew-resize; }
.float-resize.e { right: -3px; } .float-resize.w { left: -3px; }
.float-resize.ne, .float-resize.nw, .float-resize.se, .float-resize.sw { width: 10px; height: 10px; }
.float-resize.ne { top: -3px; right: -3px; cursor: nesw-resize; } .float-resize.sw { bottom: -3px; left: -3px; cursor: nesw-resize; }
.float-resize.nw { top: -3px; left: -3px; cursor: nwse-resize; } .float-resize.se { bottom: -3px; right: -3px; cursor: nwse-resize; }
.float-win.minimized .float-resize { display: none; }
.drop-marker {
    position: absolute; z-index: 40; pointer-events: none; display: flex; align-items: center; justify-content: center;
    background: var(--accent-weak); border: 2px solid var(--accent); border-radius: 4px; color: var(--accent-text); font-weight: 600; font-size: 12px;
}
.drop-marker.float { border-style: dashed; }
body.tab-dragging, body.tab-dragging * { cursor: grabbing !important; }

/* ---------- The time bar (Research) and the Graphs tab ---------- */
.time-bar { display: flex; align-items: center; gap: 6px; padding: 4px 8px; min-width: 0; flex: 0 0 auto; background: var(--bg-panel); border-top: 1px solid var(--border-strong); }
body.mode-sandbox .time-bar { display: none; }
.plot-bar { position: relative; display: flex; align-items: center; gap: 6px; padding: 4px 8px; min-width: 0; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.plot-add-panel {
    position: absolute; left: 8px; top: calc(100% + 2px); z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px;
    background: var(--bg-panel); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: var(--shadow-pop);
}
.tl-btn {
    min-width: 24px; height: 22px; padding: 0 6px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--bg-input); color: var(--text); line-height: 1;
}
.tl-btn.wide { padding: 0 9px; }
.tl-btn .icon { width: 14px; height: 14px; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.8; }
.tl-btn.on { background: var(--accent-weak); border-color: var(--accent); }
.tl-btn:hover:not(:disabled) { background: var(--bg-hover); }
.tl-btn:disabled { opacity: 0.4; cursor: default; }
#tl-slider { flex: 1 1 auto; min-width: 80px; accent-color: var(--accent); }
.tl-time { font-family: var(--font-mono); font-size: 11px; color: var(--text); white-space: nowrap; }
.tl-mem { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; }
.plot-bar select, .plot-add-panel select {
    height: 22px; max-width: 170px;
    background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 4px;
}
.plot-wrap { position: relative; flex: 1 1 0; min-height: 0; min-width: 0; overflow-y: auto; overflow-x: hidden; }
/* The Graphs tab: the graphs, and beside them the graph editor (owner, 2026-10-09: the graph controls were all piled into the bar and
   Properties). The editor has the graph picker and three pages — Data (series, x axis, theory), Style, Axes — on a PropertyGrid. */
.plot-main { flex: 1 1 0; min-height: 0; display: flex; position: relative; }
.plots-pane, .table-pane { container-type: inline-size; }
.data-wrap { position: relative; }
/* a narrow pane (split side by side): the editor floats over the graphs' or the table's right edge instead of squeezing them */
@container (max-width: 600px) {
    .plot-editor { position: absolute; top: 0; right: 0; bottom: 0; width: min(320px, 92%); z-index: 5; box-shadow: var(--shadow-pop, -6px 0 16px rgba(0,0,0,.3)); }
}
.plot-editor { flex: 0 0 320px; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--border); background: var(--bg-panel); }
.plots-pane.editor-closed .plot-editor, .table-pane.editor-closed .plot-editor { display: none; }
.plot-editor .side-title { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 0; }
.plot-editor-head { display: flex; gap: 4px; align-items: center; padding: 6px 8px 4px; }
.plot-editor-head select { flex: 1 1 auto; min-width: 0; height: 24px; background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 4px; }
.plot-editor-tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border); }
.plot-page { flex: 1 1 0; padding: 5px 0 6px; border: none; border-bottom: 2px solid transparent; background: none; color: var(--text-dim); font-size: 11.5px; font-weight: 600; }
.plot-page:hover { color: var(--text); }
.plot-page.on { color: var(--text); border-bottom-color: var(--accent); }
.plot-editor-body { flex: 1 1 0; min-height: 0; overflow-y: auto; }
.plot-seg { display: inline-flex; }
.plot-seg .tl-btn { border-radius: 0; margin-left: -1px; }
.plot-seg .tl-btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.plot-seg .tl-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.plot-spacer { flex: 1 1 auto; }
.plot-series-list { display: flex; flex-direction: column; gap: 3px; width: 100%; }
.plot-series-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.plot-series-row .swatch { flex: 0 0 10px; height: 10px; border-radius: 3px; }
.plot-series-row .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plot-series-row .name.off { color: var(--text-dim); text-decoration: line-through; }
.plot-series-row .x { border: none; background: none; color: var(--text-faint); padding: 0 2px; }
.plot-series-row .x:hover { color: var(--danger); }
.plot-add-form { display: grid; grid-template-columns: 1fr; gap: 4px; width: 100%; }
.plot-add-form select { height: 24px; min-width: 0; background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 4px; }
.plot-add-form .row { display: flex; gap: 4px; }
.plot-add-form .row .tl-btn { flex: 1 1 0; }
#plot-canvas { display: block; cursor: col-resize; }
.scene-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.viewport-hint {
    position: absolute;
    top: 10px;
    left: 10px;
    max-width: calc(100% - 220px);
    padding: 5px 10px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
    border: 1px solid var(--border);
    color: var(--text-dim);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    pointer-events: none;
}
.viewport-hint kbd, .kbd {
    font-family: var(--font-mono);
    font-size: 10.5px;
    padding: 0 4px;
    border-radius: 3px;
    border: 1px solid var(--border-strong);
    background: var(--bg-input);
    color: var(--text);
}
.viewport-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    pointer-events: none;
}
/* a challenge in play mode (challenge.js, Stage 7.3): the brief over the canvas */
.challenge-banner {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(560px, calc(100% - 220px));
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 12px;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--bg-panel) 94%, transparent);
    border: 1px solid var(--border);
    border-left: 3px solid var(--success);
    font-size: 12px;
    color: var(--text);
    z-index: 5;
}
.challenge-banner .cb-goal { grid-column: 1; }
.challenge-banner .cb-meta { grid-column: 1; color: var(--text-dim); font-size: 11px; }
.challenge-banner .cb-status { grid-column: 1; font-weight: 600; }
.challenge-banner button { grid-column: 2; grid-row: 1 / span 3; }
.challenge-banner.solved { border-left-color: var(--success); }
.challenge-banner.solved .cb-status { color: var(--success); }
.challenge-banner.failed { border-left-color: var(--danger); }
.challenge-banner.failed .cb-status { color: var(--danger); }
@media (max-width: 700px) { .challenge-banner { max-width: calc(100% - 32px); top: 48px; } }
.badge-state { font-family: var(--font-ui); font-weight: 600; font-size: 10.5px; letter-spacing: 0.4px; text-transform: uppercase; display: inline-flex; align-items: center; gap: 5px; }
.badge-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-state.running { color: var(--success); }
.badge-state.paused { color: var(--warning); }
#badge-time { pointer-events: auto; cursor: pointer; border-radius: 3px; padding: 0 2px; }
#badge-time:hover { color: var(--text); background: var(--bg-hover); }
.tl-time { cursor: pointer; }
.tl-time:hover { text-decoration: underline; }
.time-dialog .dialog-note, .plot-dialog .dialog-note { color: var(--text-dim); font-size: 12px; line-height: 1.45; margin: 0 0 12px; }
.time-dialog .field-row, .plot-dialog .field-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 12.5px; }
.plot-dialog .field-row > span:first-child { min-width: 128px; color: var(--text-dim); }
.time-dialog input[type=number], .plot-dialog input[type=number], .plot-dialog input[type=text], .plot-dialog select {
    background: var(--bg-input, var(--bg)); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; font: inherit; width: 110px;
}
.plot-dialog input[type=text] { width: 220px; }
.plot-dialog .series-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 12px; }
.plot-dialog .series-row input[type=color] { width: 30px; height: 22px; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: none; }
.plot-dialog .series-row .series-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plot-dialog h4 { margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-faint); font-weight: 600; }
.plot-bar .plot-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }
.view-controls {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0;
    border-radius: var(--radius);
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
}
.zoom-readout { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); min-width: 44px; text-align: center; }
.axis-gizmo { position: absolute; left: 10px; bottom: 8px; width: 44px; height: 44px; pointer-events: none; opacity: 0.85; }
.axis-gizmo svg { width: 44px; height: 44px; stroke-width: 1.6; }
.axis-gizmo .axis-x { stroke: #e5484d; }
.axis-gizmo .axis-y { stroke: #30a46c; }
.axis-gizmo text { fill: var(--text-dim); stroke: none; font-size: 9px; font-family: var(--font-mono); }

.overlap-picker {
    position: fixed;
    z-index: 60;
    min-width: 170px;
    padding: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    box-shadow: var(--shadow-pop);
}
.overlap-picker-title { padding: 4px 8px 6px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-faint); }
.overlap-picker-item { display: block; width: 100%; text-align: left; padding: 5px 8px; border-radius: var(--radius-sm); }
.overlap-picker-item:hover, .overlap-picker-item.is-hover { background: var(--accent-weak); color: var(--accent-text); }

/* ---------- Command & status bars ---------- */
#commandbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
}
.cmd-icon { width: 14px; height: 14px; color: var(--text-faint); }
#command-input {
    flex: 1;
    height: 22px;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text);
}
#command-input::placeholder { color: var(--text-faint); }
.cmd-palette { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); padding: 1px 6px; border: 1px solid var(--border-strong); border-radius: 3px; background: var(--bg-input); }
.cmd-palette:hover { color: var(--text); border-color: var(--accent); }
#statusbar {
    display: flex;
    align-items: center;
    padding: 0 0 0 10px;
    background: var(--bg-app);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-dim);
    user-select: none;
}
.status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-text.error { color: var(--danger); }
.status-text.success { color: var(--success); }
.status-text.warn { color: var(--warning, #c98a00); }
.status-spacer { flex: 1; }
.status-item { padding: 0 10px; border-left: 1px solid var(--border); font-family: var(--font-mono); font-size: 10.5px; white-space: nowrap; height: 100%; display: flex; align-items: center; }

/* ---------- Menus, toasts, modals ---------- */
.menu-popup {
    position: fixed;
    z-index: 80;
    min-width: 220px;
    padding: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    max-height: calc(100vh - 16px);   /* a long menu (Docs) scrolls instead of running off the screen */
    overflow-y: auto;
}
.menu-item {
    display: grid;
    grid-template-columns: 18px 1fr auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    text-align: left;
    color: var(--text);
}
.menu-item svg { width: 14px; height: 14px; color: var(--text-dim); }
.menu-item:hover:not(:disabled) { background: var(--accent); color: #fff; }
.menu-item:hover:not(:disabled) svg, .menu-item:hover:not(:disabled) .menu-shortcut { color: #fff; }
.menu-item:disabled { color: var(--text-faint); cursor: default; }
.menu-shortcut { color: var(--text-faint); font-size: 11px; font-family: var(--font-mono); }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }
.menu-header { padding: 6px 8px 3px; font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-faint); }

.toast-host { position: fixed; right: 14px; bottom: calc(var(--statusbar-h) + var(--commandbar-h) + 12px); z-index: 90; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast {
    min-width: 220px;
    max-width: 360px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--accent);
    box-shadow: var(--shadow-pop);
    color: var(--text);
    animation: toast-in 0.18s var(--ease);
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.modal-host { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; }
.modal {
    width: min(620px, calc(100vw - 40px));
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: var(--shadow-pop);
    overflow: hidden;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.modal-body { padding: 14px 16px; overflow: auto; line-height: 1.55; color: var(--text-dim); }
.modal-body h4 { color: var(--text); font-size: 12px; margin: 12px 0 6px; }
.modal-body h4:first-child { margin-top: 0; }
.modal-body p { margin-bottom: 8px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); }
.shortcut-table { width: 100%; border-collapse: collapse; }
.shortcut-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); }
.shortcut-table td:first-child { width: 42%; white-space: nowrap; }
.example-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.example-card { width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-panel-alt); cursor: pointer; }
.example-card:hover { border-color: var(--accent); background: var(--accent-weak); }
.example-card strong { display: block; color: var(--text); font-size: 12px; margin-bottom: 2px; }
.example-card span { color: var(--text-faint); font-size: 11px; }
.example-card .tag { display: inline-block; margin-top: 6px; font-size: 9.5px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: var(--accent-text); }

/* ---------- Mode visibility ---------- */
body.mode-sandbox .research-only { display: none !important; }
body.mode-research .sandbox-only { display: none !important; }
body.mode-research #titlebar { border-bottom-color: var(--accent); }


/* ---------- Animation export dialog ---------- */
.rec-form { display: grid; grid-template-columns: 96px 1fr; gap: 8px 10px; align-items: center; }
.rec-form label { color: var(--text-dim); }
.rec-form select, .rec-form input[type="number"] {
    height: 24px; background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 6px; min-width: 0;
}
.rec-form input[type="number"] { width: 80px; }
.rec-inline { display: flex; align-items: center; gap: 6px; color: var(--text-dim); }
.rec-check { display: flex; align-items: center; gap: 6px; color: var(--text) !important; }
.rec-note { margin-top: 10px; color: var(--text-faint); font-size: 11px; }
.rec-bar { height: 8px; border-radius: 4px; background: var(--bg-input); border: 1px solid var(--border); overflow: hidden; margin-top: 8px; }
.rec-bar > div { height: 100%; width: 0; background: var(--accent); transition: width 0.1s linear; }
.tikz-preview {
    width: 100%; height: 280px; margin-top: 10px; resize: vertical;
    background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius);
    font-family: var(--font-mono); font-size: 10.5px; line-height: 1.4; padding: 8px; color: var(--text); white-space: pre; overflow: auto; font-variant-ligatures: none;
}

/* ---------- Describe a mechanism ---------- */
.describe-text {
    width: 100%; resize: vertical; padding: 8px;
    background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius);
    color: var(--text); font-family: var(--font-ui); font-size: 12.5px; line-height: 1.45;
}
.describe-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.describe-chip {
    padding: 2px 8px; border: 1px solid var(--border-strong); border-radius: 11px;
    color: var(--text-dim); background: var(--bg-panel-alt); font-size: 11px; text-align: left;
}
.describe-chip:hover { color: var(--text); background: var(--bg-hover); }

/* ---------- Parameter sweep ---------- */
.sweep-form { grid-template-columns: 84px 1fr; }
.sweep-form .rec-inline input[type="number"] { width: 78px; }
.sweep-outputs { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sweep-add { display: flex; gap: 4px; flex-wrap: wrap; }
.sweep-add select { height: 24px; max-width: 150px; background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius); }
.sweep-list { display: flex; flex-wrap: wrap; gap: 4px; }
.sweep-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 4px 1px 8px; border-radius: 10px; background: var(--accent-weak); color: var(--text); font-size: 11px; }
.sweep-chip button { color: var(--text-faint); padding: 0 3px; }
.sweep-chip button:hover { color: var(--danger); }
.sweep-pick { margin-bottom: 8px; color: var(--text-dim); }
.sweep-pick select { max-width: 70%; background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius); height: 24px; }
.sweep-chart { width: 100%; height: 240px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); }
.sweep-table-wrap { max-height: 220px; overflow: auto; margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.sweep-table { border-collapse: collapse; width: 100%; font-family: var(--font-mono); font-size: 11px; }
.sweep-table th, .sweep-table td { padding: 3px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.sweep-table th { position: sticky; top: 0; background: var(--bg-panel); color: var(--text-dim); font-weight: 600; }

/* ---------- Command palette (palette.js) ---------- */
.palette-host { position: fixed; inset: 0; z-index: 110; background: rgba(0,0,0,0.28); display: flex; justify-content: center; align-items: flex-start; padding-top: 11vh; }
.palette {
    width: min(620px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 14vh - 24px));
    display: flex; flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: var(--shadow-pop);
    overflow: hidden;
}
.palette-field { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.palette-field svg { width: 15px; height: 15px; color: var(--text-faint); flex: none; }
.palette-input { flex: 1; height: 40px; background: transparent; border: none; outline: none; color: var(--text); font-size: 14px; }
.palette-input::placeholder { color: var(--text-faint); }
.palette-list { overflow: auto; padding: 4px; min-height: 0; }
.palette-row { display: grid; grid-template-columns: 18px 1fr auto auto; gap: 8px; align-items: center; padding: 5px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12.5px; color: var(--text); }
.palette-row.selected { background: var(--accent-weak); color: var(--accent-text); }
.palette-row.disabled { opacity: 0.4; cursor: default; }
.palette-row.run .palette-label { font-family: var(--font-mono); font-size: 12px; }
.palette-icon svg { width: 14px; height: 14px; color: var(--text-dim); }
.palette-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-label mark { background: none; color: var(--accent); font-weight: 700; }
.palette-row.selected .palette-label mark { color: inherit; text-decoration: underline; }
.palette-on { margin-left: 6px; font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.palette-cat { font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.palette-key { min-width: 44px; text-align: right; }
.palette-empty { padding: 14px; color: var(--text-faint); font-size: 12px; text-align: center; }
.palette-foot { padding: 6px 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Data workspace: the table view of the dock (datatable.js) ---------- */
.data-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--border); min-width: 0; }
.data-bar select { height: 22px; max-width: 170px; background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 4px; }
.data-status { margin-left: auto; font-size: 10.5px; color: var(--text-faint); white-space: nowrap; }
.data-wrap { flex: 1 1 0; min-height: 0; display: flex; }
.data-scroll { flex: 1; overflow: auto; outline: none; position: relative; }
.data-table { border-collapse: separate; border-spacing: 0; font-family: var(--font-mono); font-size: 11px; min-width: 100%; user-select: none; }
.data-table thead { position: sticky; top: 0; z-index: 3; }
.data-table th, .data-table td { height: 20px; padding: 0 8px; white-space: nowrap; text-align: right; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.data-table thead th { height: auto; background: var(--bg-panel-alt); font-weight: 600; cursor: pointer; vertical-align: bottom; padding-top: 3px; padding-bottom: 2px; }
.data-table th .cname { display: block; color: var(--text); }
.data-table th .cunit { display: block; color: var(--text-faint); font-weight: 400; font-size: 10px; min-height: 12px; }
.data-table th.rowno { background: var(--bg-panel-alt); color: var(--text-faint); font-weight: 400; text-align: right; position: sticky; left: 0; z-index: 1; cursor: pointer; min-width: 38px; }
.data-table thead th.rowno { z-index: 4; }
.data-table tbody td { color: var(--text); cursor: cell; }
.data-table tbody td.nan { color: var(--text-faint); }
.data-table tr.stat td, .data-table tr.stat th { background: var(--bg-panel); color: var(--text-dim); height: 18px; font-style: italic; }
.data-table tr.stat th.rowno { font-style: normal; text-align: left; }
.data-table tr.stat:last-child td, .data-table tr.stat:last-child th { border-bottom: 2px solid var(--border-strong); }
.data-table th.sel, .data-table td.sel { background: var(--accent-weak); }
.data-table th.focus { box-shadow: inset 0 -2px 0 var(--accent); }
.data-table td.cell-sel { background: var(--accent-weak); outline: 1px solid var(--accent); outline-offset: -1px; }
/* zebra rows, the row of the time bar's time, the statistics of a selection (tinted), the selection summary (2026-10-09) */
.data-table tbody tr.odd td, .data-table tbody tr.odd th.rowno { background-image: linear-gradient(rgba(127,127,127,.055), rgba(127,127,127,.055)); }
.data-table tbody tr.now th.rowno { color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.data-table tbody tr.now td { box-shadow: inset 0 1px 0 rgba(61,139,253,.45), inset 0 -1px 0 rgba(61,139,253,.45); }
.data-table tr.stat td.sel-stat { color: var(--accent-text, var(--accent)); background: linear-gradient(var(--accent-weak), var(--accent-weak)), var(--bg-panel); font-style: normal; font-weight: 600; }
/* the header, the statistics rows and the row numbers are sticky: a tint over them is laid on an opaque colour, or the rows scrolling beneath show through (owner, 2026-10-09) */
.data-table th.sel { background: linear-gradient(var(--accent-weak), var(--accent-weak)), var(--bg-panel-alt); }
.data-status.sel-summary { color: var(--text); font-size: 11px; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.stat-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; font-size: 11.5px; }
.stat-picks label { display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.data-table th.bad .cname { color: var(--danger); }
.data-table th.warn .cname::after { content: " ⚠"; color: var(--warning); }
.data-table th.formula .cname { font-style: italic; }
.data-table tr.empty td { text-align: left; color: var(--text-faint); padding: 14px; border: none; font-family: var(--font-ui); }
.data-table tr.spacer td { padding: 0; border: none; height: auto; }
.data-dialog .seg { display: flex; margin-bottom: 10px; }
.data-dialog .seg .tl-btn { border-radius: 0; margin-left: -1px; }
.data-dialog .seg .tl-btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.data-dialog .seg .tl-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.data-dialog .field-row select { min-width: 220px; width: auto; }
.data-dialog input[type=text] { width: 260px; }
.formula-status { min-height: 18px; margin: 2px 0 6px 136px; font-size: 11.5px; color: var(--text-dim); }
.formula-status.ok { color: var(--success); }
.formula-status.warn { color: var(--warning); }
.formula-status.bad { color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px 136px; }
.chip { font-family: var(--font-mono); font-size: 11px; padding: 1px 7px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--bg-input); color: var(--text); }
.chip:hover { border-color: var(--accent); color: var(--accent-text); }

/* ---------------------------------------------------------------- Script tab (scripts.js, W5) */
.script-pane { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; background: var(--bg-panel); }
.script-bar { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; min-width: 0; }
.script-bar .script-run { color: var(--accent-text); font-weight: 600; }
.script-status { flex: 1 1 auto; min-width: 0; color: var(--text-dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.script-status[data-tone="error"] { color: var(--danger); }
.script-status[data-tone="busy"] { color: var(--accent-text); }
.script-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.script-editor { flex: 1 1 65%; min-height: 60px; overflow: hidden; position: relative; }
.script-editor .cm-editor { position: absolute; inset: 0; }
.script-editor .cm-scroller { font-family: var(--font-mono); line-height: 1.5; }
.script-fallback { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; border: 0; padding: 8px; background: var(--bg-input); color: var(--text); font: 13px/1.5 var(--font-mono); tab-size: 4; outline: none; }
.script-console { flex: 0 0 32%; min-height: 48px; overflow: auto; border-top: 1px solid var(--border); padding: 4px 8px; background: var(--bg-input); font: 12px/1.45 var(--font-mono); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.script-console .sc-err { color: var(--danger); }
.script-console .sc-info { color: var(--text-dim); }
.script-help pre { margin: 10px 0; padding: 8px 10px; background: var(--bg-input); border: 1px solid var(--border); font: 11.5px/1.5 var(--font-mono); overflow-x: auto; white-space: pre; }
.script-help code { font-family: var(--font-mono); font-size: 12px; }

/* New graph (datatable.js graphDialog, 2026-10-09) */
.graph-dialog { display: flex; flex-direction: column; gap: 10px; }
.graph-dialog .gd-row { display: grid; grid-template-columns: 140px 1fr; gap: 10px; align-items: start; }
.graph-dialog .gd-row > label { color: var(--text-dim); padding-top: 4px; font-weight: 600; }
.graph-dialog .gd-ys { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; max-height: 180px; overflow-y: auto; }
.graph-dialog .gd-ys label { display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.graph-dialog .gd-unit { color: var(--text-faint); font-size: 11px; }
.graph-dialog .gd-none { color: var(--text-faint); }
.graph-dialog .gd-off { opacity: 0.4; }
.graph-dialog .gd-add, .graph-dialog .gd-xq { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.graph-dialog select, .graph-dialog input[type=number] { height: 24px; background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 4px; max-width: 220px; }
.graph-dialog .gd-n { width: 70px; margin-left: 6px; }
.graph-dialog .gd-say { margin: 4px 0 0; padding: 8px 10px; border-radius: 6px; background: var(--bg-input); color: var(--text-dim); line-height: 1.5; }
.graph-dialog .gd-say b { color: var(--text); }
.graph-dialog .hidden { display: none !important; }

/* ---- the one tooltip (tooltip.js) ---- */
#app-tooltip { position: fixed; z-index: 100000; max-width: 340px; padding: 9px 12px; border-radius: 8px; background: #1b1d21; color: #f1f2f4; border: 1px solid rgba(255,255,255,.14); box-shadow: 0 6px 22px rgba(0,0,0,.45); font-size: 13px; line-height: 1.4; pointer-events: none; opacity: 0; transition: opacity .12s; white-space: normal; }
#app-tooltip.show { opacity: 1; }

/* ---- the Examples box ---- */
.ex-wrap { display: grid; grid-template-columns: 210px 1fr; gap: 14px; height: min(620px, calc(100vh - 190px)); }
.ex-side { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 4px; border-right: 1px solid var(--border); }
.ex-cat { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; padding: 7px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--text-dim); font: inherit; font-size: 12px; cursor: pointer; }
.ex-cat span { color: var(--text-faint); font-size: 10.5px; }
.ex-cat:hover { background: var(--bg-panel-alt); color: var(--text); }
.ex-cat.active { background: var(--accent-weak); color: var(--accent-text); font-weight: 600; }
.ex-main { display: flex; flex-direction: column; min-width: 0; }
.ex-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.ex-search { flex: 1 1 220px; min-width: 160px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-input, var(--bg-panel-alt)); color: var(--text); font: inherit; font-size: 12px; }
.ex-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.ex-pill { padding: 4px 9px; border: 1px solid var(--border); border-radius: 12px; background: transparent; color: var(--text-dim); font: inherit; font-size: 11px; cursor: pointer; }
.ex-pill:hover { border-color: var(--accent); }
.ex-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ex-list { flex: 1; overflow-y: auto; padding-right: 4px; }
.ex-group { margin: 12px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-faint); }
.ex-group:first-child { margin-top: 0; }
.ex-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ex-card .ex-blurb { display: block; margin-top: 3px; line-height: 1.4; }
.ex-kind { font-size: 9px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; padding: 1px 6px; border-radius: 8px; background: var(--bg-panel); border: 1px solid var(--border); color: var(--text-faint) !important; }
.ex-kind.script { color: var(--accent-text) !important; border-color: var(--accent); }
.ex-feats { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.ex-chip { font-size: 9.5px; padding: 1px 6px; border-radius: 8px; background: var(--bg-panel); border: 1px solid var(--border); color: var(--text-dim) !important; }
.ex-chip.research { color: var(--accent-text) !important; border-color: var(--accent); }
.ex-empty { color: var(--text-faint); padding: 24px 4px; }
.ex-foot { margin: 8px 0 0; font-size: 11px; color: var(--text-faint); }
@media (max-width: 760px) { .ex-wrap { grid-template-columns: 1fr; height: auto; } .ex-side { flex-direction: row; flex-wrap: wrap; border-right: 0; } }

/* ---- Presenter mode (presenter.js): the scene alone, with a large control bar --------------------------------------------- */
body.presenting #titlebar, body.presenting #ribbon, body.presenting #commandbar, body.presenting #statusbar,
body.presenting .dock-side, body.presenting .dock-resizer, body.presenting .time-bar,
body.presenting #eg-root .eg-tabs, body.presenting .edge-tabs { display: none !important; }
body.presenting #app { grid-template-rows: minmax(0, 1fr) !important; }
body.presenting #workspace { grid-row: 1 !important; display: flex !important; }
body.presenting #center-column { flex: 1 1 auto; min-width: 0; }
body.presenting .toast-host { bottom: 96px; }
body.pr-idle, body.pr-idle #physics-canvas { cursor: none; }
.presenter-bar {
    position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 120;
    display: flex; align-items: center; gap: 10px; padding: 10px 16px;
    background: color-mix(in srgb, var(--bg-panel) 94%, transparent); border: 1px solid var(--border-strong);
    border-radius: 14px; box-shadow: var(--shadow-pop); backdrop-filter: blur(6px);
    transition: opacity .35s ease;
}
.presenter-bar.hidden { display: none; }
.presenter-bar.idle { opacity: 0; pointer-events: none; }
.pr-btn {
    min-width: 52px; height: 48px; padding: 0 14px; font-size: 22px; line-height: 1;
    border: 1px solid var(--border-strong); border-radius: 10px; background: var(--bg-input); color: var(--text); cursor: pointer;
}
.pr-btn.wide { font-size: 17px; padding: 0 18px; }
.pr-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.pr-btn:hover:not(:disabled) { background: var(--bg-hover); }
.pr-btn.primary:hover:not(:disabled) { filter: brightness(1.1); background: var(--accent); }
.pr-btn:disabled { opacity: .35; cursor: default; }
.pr-step { min-width: 108px; text-align: center; font-size: 18px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.pr-step.dim { color: var(--text-faint); font-weight: 500; }
.pr-sep { width: 1px; height: 28px; background: var(--border-strong); }

/* ---------- Account (account.js; shown only when the server has the API) ---------- */
.account-btn { height: 24px; padding: 0 10px; border-radius: var(--radius); border: 1px solid var(--border-strong); color: var(--text); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.account-btn:hover { background: var(--bg-hover); }
.account-btn.signed-in { padding: 0; width: 26px; height: 26px; border: none; border-radius: 50%; }
.account-avatar { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.account-btn.signed-in:hover .account-avatar { box-shadow: 0 0 0 2px var(--bg-hover); }
.account-dialog .dialog-note { color: var(--text-dim); font-size: 12px; line-height: 1.45; margin: 0 0 12px; }
.account-dialog .btn.block { height: 30px; font-size: 12.5px; }
.account-dialog form { display: flex; flex-direction: column; gap: 6px; }
.account-label { display: block; font-size: 12px; color: var(--text-dim); margin: 2px 0; }
.account-dialog input[type=email] { width: 100%; height: 28px; padding: 0 8px; font: inherit; color: var(--text); background: var(--bg-input, var(--bg)); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.account-dialog input[type=email]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.account-google svg { width: 15px; height: 15px; }
.account-or { display: flex; align-items: center; gap: 8px; margin: 12px 0; color: var(--text-faint); font-size: 11px; }
.account-or::before, .account-or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.account-msg { min-height: 1.2em; margin: 8px 0 0; font-size: 12px; }
.account-msg.error { color: var(--danger); }
.account-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 12px; }
.account-table td { padding: 4px 0; vertical-align: top; color: var(--text); }
.account-table td:first-child { width: 110px; color: var(--text-dim); }
.account-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.account-actions a.btn { text-decoration: none; }

/* ---------- My Assets (assets.js) ---------- */
.assets-form { display: grid; grid-template-columns: 70px 1fr; gap: 8px 10px; align-items: center; font-size: 12.5px; }
.assets-form label { color: var(--text-dim); }
.assets-form input, .assets-form select, .assets-bar input, .assets-bar select {
    height: 26px; padding: 0 8px; font: inherit; color: var(--text); background: var(--bg-input, var(--bg));
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); min-width: 0;
}
.assets-form input:focus, .assets-bar input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.assets-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.assets-bar .assets-search { flex: 1; min-width: 140px; }
.assets-where { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.assets-where button { height: 24px; padding: 0 10px; font-size: 12px; color: var(--text-dim); }
.assets-where button.active { background: var(--accent); color: #fff; }
.assets-where-one { font-size: 12px; font-weight: 600; color: var(--text); }
.assets-usage { height: 4px; border-radius: 2px; background: var(--bg-hover); overflow: hidden; }
.assets-usage span { display: block; height: 100%; background: var(--accent); }
.assets-usage-text { font-size: 11px; color: var(--text-faint); margin: 4px 0 10px; }
.assets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; max-height: min(56vh, 520px); overflow: auto; padding: 2px; }
.assets-empty { grid-column: 1 / -1; padding: 24px 0; text-align: center; }
.asset-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 3px; background: var(--bg-panel); min-width: 0; }
.asset-card:hover { border-color: var(--border-strong); }
.asset-thumb { height: 96px; border-radius: var(--radius-sm); background: var(--bg-input, var(--bg)); display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid var(--border); margin-bottom: 4px; }
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; }
.asset-kind { font-size: 11px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: #6b7280; }
.asset-name { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-meta { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.asset-actions .btn { height: 20px; padding: 0 6px; font-size: 11px; }
.assets-bar .btn { height: 26px; }

/* ---------- Share links (share.js) and the player (presenter.js viewer) ---------- */
.presenter-bar.viewer { gap: 8px; padding: 7px 10px; bottom: 14px; border-radius: 12px; max-width: calc(100vw - 24px); }
.presenter-bar.viewer .pr-btn { white-space: nowrap; min-width: 38px; height: 36px; font-size: 17px; padding: 0 10px; border-radius: 8px; }
.presenter-bar.viewer .pr-btn.wide { font-size: 14px; padding: 0 12px; }
.presenter-bar.viewer .pr-step { min-width: 80px; font-size: 14px; }
.presenter-bar.viewer .pr-sep { height: 22px; }
.pr-title { font-size: 13px; font-weight: 600; color: var(--text); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-link { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
@media (max-width: 640px) { .pr-title, .presenter-bar.viewer .pr-sep { display: none; } }
.share-missing { max-width: 420px; margin: 18vh auto; padding: 0 16px; font: 15px/1.5 system-ui, sans-serif; color: var(--text); }
.share-missing h1 { font-size: 19px; margin-bottom: 8px; }
.share-missing a { color: var(--accent-text); }
.share-create { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px 80px; }
.share-create .btn { height: 26px; }
.share-result { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.share-result.hidden { display: none; }
.share-row { display: flex; gap: 6px; align-items: stretch; }
.share-row input, .share-row textarea { flex: 1; min-width: 0; font: 12px/1.4 "JetBrains Mono", ui-monospace, monospace; color: var(--text); background: var(--bg-input, var(--bg)); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 4px 8px; resize: none; }
.share-row .btn { height: auto; min-height: 26px; text-decoration: none; }
.share-list-title { margin-top: 16px !important; }
.share-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; }
.share-item { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; }
.share-item-text { flex: 1; min-width: 0; }
.share-item .btn { height: 22px; font-size: 11px; }
.prop-doc { margin-left: auto; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
            font-size: 10px; font-weight: 700; color: var(--text-faint); border: 1px solid var(--border-strong); text-decoration: none; opacity: 0; transition: opacity .12s; }
.prop-section-header:hover .prop-doc, .prop-doc:focus-visible { opacity: 1; }
.prop-doc:hover { color: var(--accent-text); border-color: var(--accent); }

/* Materials (materials.js, M1) */
.materials-editor { display: grid; grid-template-columns: 170px 1fr; gap: 14px; min-height: 300px; }
.mat-list { display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--border); padding-right: 10px; }
.mat-item { display: flex; align-items: center; gap: 8px; text-align: left; padding: 5px 8px; border-radius: var(--radius); color: var(--text); background: none; border: 1px solid transparent; font-size: 12px; }
.mat-item:hover { background: var(--bg-hover); }
.mat-item.active { background: var(--bg-pressed); border-color: var(--accent); }
.mat-swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border); flex: none; }
.mat-list-actions { display: flex; flex-direction: column; gap: 4px; margin-top: auto; padding-top: 10px; }
.mat-field { display: flex; align-items: center; gap: 6px; }
.mat-field input[type="number"] { width: 90px; }
.mat-unit, .mat-check { font-size: 11px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 4px; }
.mat-pairs { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.mat-pair { display: grid; grid-template-columns: 1fr 64px 64px 64px auto; gap: 4px; align-items: center; }
.mat-pair input { width: 100%; }
.mat-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
@media (max-width: 560px) { .materials-editor { grid-template-columns: 1fr; } .mat-list { border-right: none; padding-right: 0; } }
.materials-editor .assets-form { grid-template-columns: 100px 1fr; }

/* Courses (courses.js, B3) */
.courses-layout { display: grid; grid-template-columns: 220px 1fr; gap: 14px; min-height: 320px; }
.course-list { display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--border); padding-right: 10px; }
.course-list .mat-item { justify-content: space-between; }
.course-list input { width: 100%; }
.course-role { font-size: 11px; color: var(--text-dim); }
.course-title { margin: 0 0 4px; font-size: 15px; }
.course-sub { margin: 14px 0 6px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.course-invite { display: flex; gap: 6px; }
.course-invite input { flex: 1; min-width: 0; }
.course-members { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
.course-member { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; align-items: center; font-size: 12.5px; }
@media (max-width: 560px) { .courses-layout { grid-template-columns: 1fr; } .course-list { border-right: none; padding-right: 0; } }

/* Marketplace (market.js, C1) */
.market-tabs { display: flex; align-items: center; gap: 2px; margin-bottom: 10px; }
.market-tabs .market-site { margin-left: auto; }
.market-bar { display: grid; grid-template-columns: 2fr 1fr 1.4fr 1fr; gap: 6px; margin-bottom: 10px; }
.market-bar input, .market-bar select { width: 100%; }
.market-grid { max-height: 52vh; overflow: auto; }
.market-pager { display: flex; justify-content: space-between; margin-top: 8px; }
.market-detail-grid { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.market-pic { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.market-versions { margin: 0; padding-left: 18px; font-size: 12.5px; }
.m-chip-s { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--bg-pressed); font-size: 11.5px; }
.market-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.market-row .mat-actions { margin-top: 0; flex: none; }
.market-author { border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 6px; }
.market-publish { grid-template-columns: 110px 1fr; }
.market-publish textarea, .market-author textarea { width: 100%; font: inherit; resize: vertical; }
.market-terms { margin: 6px 0; font-size: 12.5px; }
.link-btn { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
@media (max-width: 640px) { .market-bar { grid-template-columns: 1fr 1fr; } .market-detail-grid { grid-template-columns: 1fr; } .market-row { flex-direction: column; align-items: flex-start; } }
.market-scroll { max-height: 56vh; overflow: auto; padding-right: 4px; }
.m-verified { display: inline-grid; place-items: center; width: 1.2em; height: 1.2em; border-radius: 50%; background: var(--accent); color: #fff; font: 700 0.68em/1 var(--font-ui, sans-serif); vertical-align: 0.1em; }
.market-dialog .asset-thumb img { object-fit: contain; background: #f4f6f8; }

/* Presenter extras (presenter.js, B5) */
.pr-btn.on { background: var(--accent); color: #fff; }
/* the laser replaces the pointer everywhere (canvas, overlays, labels: they set cursors of their own), except over the control bar */
body.pr-laser, body.pr-laser * { cursor: none !important; }
body.pr-laser .presenter-bar, body.pr-laser .presenter-bar * { cursor: default !important; }
.pr-laser-dot { position: fixed; z-index: 200; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; pointer-events: none;
    background: radial-gradient(circle, #ff3b30 0 35%, rgba(255, 59, 48, 0.45) 55%, rgba(255, 59, 48, 0) 72%); box-shadow: 0 0 14px 6px rgba(255, 59, 48, 0.45); }
.present-steps { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.present-step { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.present-head { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.present-view { color: var(--text-dim); margin-right: auto; }
.present-step textarea { width: 100%; resize: vertical; font: inherit; font-size: 12px; background: var(--bg-input, var(--bg)); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 4px; }
.exam-form { grid-template-columns: 90px 1fr; }
.exam-params { max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.exam-param .rec-inline input[type="number"] { width: 70px; }
.exam-param code { font-size: 11px; color: var(--text-dim); }
.exam-form textarea { width: 100%; font: inherit; resize: vertical; }

/* Look up (lookup.js): the moments a quantity had a value, with the others then */
.lookup-out { margin-top: 10px; }
.lookup-scroll { max-height: 320px; overflow: auto; }
.lookup-scroll .data-table { width: 100%; }
