/* ============================================================
   Schaltkreis-Bauer 3.0. Werkzeug-spezifisches CSS
   ============================================================
   Hierarchy:
     1. Page shell + cursor classes
     2. Menubar (32 px) + dropdowns
     3. Toolbar (44 px) + buttons + toggles
     4. Shell grid (palette / canvas / inspector)
     5. Palette (icon-grid items + kbd)
     6. Canvas + statusbar + cursor classes
     7. Inspector (tabs, header, props grid, sim strip, footer)
     8. Scope dock
     9. Modal (export / import / share / restore)
    10. Search overlay
    11. Help overlay
    12. Tutorial overlay
    13. Toast
   All values are tokens (var(--…)). No hardcoded hex.
   ============================================================ */

/* ── 1. Page shell ─────────────────────────────────────── */

body.cb-page {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 13px;
    overflow: hidden;
}

/* ── 2. Menubar ────────────────────────────────────────── */

.cb-menubar-row {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 32px;
    display: flex;
    align-items: center;
    gap: var(--space-3xl);
    padding: 0 var(--space-3xl);
    background: var(--bg-navbar);
    border-bottom: 1px solid var(--border);
    z-index: 50;
    user-select: none;
}

.cb-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    text-decoration: none;
    font-size: 12px;
    font-weight: var(--font-semibold);
    color: var(--text-bright);
    letter-spacing: var(--tracking-label);
    flex-shrink: 0;
}
.cb-brand .mark {
    width: 18px; height: 18px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--text-on-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: var(--font-bold);
}
.cb-brand .brand-text { font-size: 12px; }

.cb-page-title {
    font-size: 12px;
    font-weight: var(--font-semibold);
    color: var(--text-muted);
    flex-shrink: 0;
    padding-right: var(--space-2xl);
    border-right: 1px solid var(--border);
    height: 18px;
    line-height: 18px;
}

.cb-menubar {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex: 1;
}

.cb-spacer { flex: 1; }

.cb-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast),
                border-color var(--transition-fast);
}
.cb-theme-toggle:hover {
    background: var(--bg-row-hover);
    color: var(--text-bright);
    border-color: var(--border-active);
}
.cb-theme-toggle .theme-icon {
    font-size: 13px;
    line-height: 1;
}

.cb-menubar__menu {
    position: relative;
}
.cb-menubar__label {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.cb-menubar__label:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.cb-menubar__menu--open > .cb-menubar__label {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent);
}

.cb-menubar__dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    min-width: 220px;
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--space-xs) 0;
    display: none;
    z-index: 60;
}
.cb-menubar__menu--open > .cb-menubar__dropdown { display: block; }

.cb-menubar__item {
    padding: 6px 14px;
    cursor: pointer;
    color: var(--text);
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2xl);
    position: relative;
    white-space: nowrap;
}
.cb-menubar__item:hover {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
}

.cb-menubar__sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.cb-menubar__kbd {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--bg);
}

/* Submenu */
.cb-menubar__item--sub::after {
    content: '▸';
    color: var(--text-muted);
    margin-left: auto;
}
.cb-menubar__sub-dropdown {
    position: absolute;
    top: 0; left: 100%;
    min-width: 220px;
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--space-xs) 0;
    display: none;
    z-index: 70;
}
.cb-menubar__item--sub:hover > .cb-menubar__sub-dropdown { display: block; }

/* ── 3. Toolbar ────────────────────────────────────────── */

.cb-toolbar {
    position: fixed;
    top: 32px; left: 0; right: 0;
    height: 44px;
    display: flex;
    align-items: center;
    gap: var(--space-2xl);
    padding: 0 var(--space-3xl);
    background: var(--bg-navbar);
    border-bottom: 1px solid var(--border);
    z-index: 49;
    user-select: none;
}

.cb-toolbar__group {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding-right: var(--space-2xl);
    border-right: 1px solid var(--border);
    height: 28px;
}
.cb-toolbar__group:last-child { border-right: none; }

.cb-toolbar__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border-active);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-height: 26px;
}
.cb-toolbar__btn:hover { border-color: var(--accent); color: var(--accent); }
.cb-toolbar__btn:disabled { opacity: 0.35; cursor: not-allowed; }
.cb-toolbar__btn:disabled:hover { border-color: var(--border-active); color: var(--text-dim); }

.cb-toolbar__btn--accent { border-color: var(--accent); color: var(--accent); }
.cb-toolbar__btn--accent:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.cb-toolbar__btn.cb-running {
    background: color-mix(in srgb, var(--color-insight) 18%, transparent);
    border-color: var(--color-insight);
    color: var(--color-insight);
}

.cb-toolbar__btn--active {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border-color: var(--accent);
    color: var(--accent);
}

.cb-icon { font-size: 11px; line-height: 1; }

/* ── 4. Shell grid ─────────────────────────────────────── */

.cb-shell {
    position: fixed;
    top: 76px; left: 0; right: 0; bottom: 0;
    display: grid;
    grid-template-columns: 200px 1fr 290px;
    grid-template-rows: minmax(0, 1fr);
    background: var(--bg);
    transition: grid-template-columns 220ms ease;
}

.cb-shell.cb-palette-collapsed   { grid-template-columns: 36px 1fr 290px; }
.cb-shell.cb-inspector-collapsed { grid-template-columns: 200px 1fr 36px; }
.cb-shell.cb-palette-collapsed.cb-inspector-collapsed {
    grid-template-columns: 36px 1fr 36px;
}

/* At narrow viewports the always-open palette+inspector squeeze the canvas
 * below ~600 px (200 + 290 + canvas = total). Force both rails collapsed
 * via media query so the workspace stays usable on ≤1100 px laptops/tablets.
 * The toggle buttons remain reachable to re-expand if the user really wants
 * a sidebar, but at <=1100 px they will overlap the canvas and the user has
 * presumably opted in. */
@media (max-width: 1100px) {
    .cb-shell,
    .cb-shell.cb-palette-collapsed,
    .cb-shell.cb-inspector-collapsed,
    .cb-shell.cb-palette-collapsed.cb-inspector-collapsed {
        grid-template-columns: 36px 1fr 36px;
    }
    .cb-shell .cb-palette__inner,
    .cb-shell .cb-inspector__inner { display: none; }
    .cb-shell .cb-palette__rail,
    .cb-shell .cb-inspector__rail { display: flex; }
}

/* ── Sidebar toggle ─────────────────────────────────── */

.cb-sidebar-toggle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 36px;
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    z-index: 10;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.cb-sidebar-toggle:hover { border-color: var(--accent); color: var(--accent); }
/* Sit flush against the inside edge of the parent. The earlier −10 px
   layout pushed the button half-way outside its overflow:hidden container,
   leaving only ~8 px of click target — a real-user reachability problem
   exposed by the audit suite. Centred-flush keeps the same nub-style
   visual while making the whole 22 px width interactive. */
.cb-sidebar-toggle--right { right: 0; }
.cb-sidebar-toggle--left  { left: 0; }

/* ── 5. Palette ────────────────────────────────────────── */

.cb-palette {
    position: relative;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow: hidden;
    min-height: 0;
    min-width: 0;
}
.cb-palette__inner {
    height: 100%;
    overflow-y: auto;
    padding: var(--space-2xl) var(--space-2xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-2xl);
}
.cb-palette__rail {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 36px;
    display: none;
}
.cb-shell.cb-palette-collapsed .cb-palette__inner { display: none; }
.cb-shell.cb-palette-collapsed .cb-palette__rail  { display: flex; }
.cb-shell.cb-palette-collapsed .cb-sidebar-toggle--right { right: 7px; }

.cb-palette-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}
.cb-palette__group-title {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--text-muted);
    margin: 0 0 var(--space-xs) 0;
    font-weight: var(--font-semibold);
}
.cb-palette__list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
}

.cb-palette__item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 4px 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 11px;
    cursor: grab;
    text-align: left;
    transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
    user-select: none;
    width: 100%;
    box-sizing: border-box;
}
.cb-palette__item:active { cursor: grabbing; }
.cb-palette__item:hover {
    border-color: var(--accent);
    color: var(--text-bright);
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-surface));
}
.cb-palette__icon {
    width: 32px; height: 18px;
    flex-shrink: 0;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cb-palette__icon canvas { display: block; }
.cb-palette__label { flex: 1; }
.cb-palette__kbd {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0 4px;
    border-radius: 3px;
    background: var(--bg);
}

.cb-palette__hint {
    position: relative;
    padding: var(--space-md) calc(var(--space-md) + 14px) var(--space-md) var(--space-md);
    background: color-mix(in srgb, var(--accent) 6%, transparent);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 10.5px;
    color: var(--text);
    line-height: 1.5;
}
.cb-palette__hint strong { color: var(--text-bright); font-weight: var(--font-semibold); }
.cb-palette__hint kbd {
    font-family: var(--font-mono);
    font-size: 9px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0 4px;
    border-radius: 3px;
}
.cb-palette__hint-close {
    position: absolute;
    top: 2px;
    right: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
}
.cb-palette__hint-close:hover {
    color: var(--text-bright);
    background: color-mix(in srgb, var(--text) 10%, transparent);
}

/* ── 6. Canvas area ─────────────────────────────────── */

.cb-canvas-area {
    position: relative;
    background: var(--bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.cb-canvas-wrap {
    flex: 1;
    position: relative;
    min-height: 400px;
}
#cb-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: default;
    outline: none;
}

#cb-canvas.cb-cursor-grab      { cursor: grab; }
#cb-canvas.cb-cursor-grabbing  { cursor: grabbing; }
#cb-canvas.cb-cursor-crosshair { cursor: crosshair; }
#cb-canvas.cb-cursor-move      { cursor: move; }
#cb-canvas.cb-cursor-cell      { cursor: cell; }
#cb-canvas.cb-cursor-default   { cursor: default; }

.cb-canvas-hint {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    color: var(--text-dim);
    pointer-events: none;
    text-align: center;
    line-height: 1.55;
    font-style: italic;
}
.cb-canvas-hint strong { color: var(--text); font-weight: var(--font-semibold); }
.cb-canvas-hint kbd {
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 3px;
}
.cb-canvas-hint.cb-hidden { display: none; }

/* Ink-theme canvas overlays. Canvas painting is theme-locked dark
 * (canvasTheme.ts CT.bg = #111), so any HTML overlay sitting on the
 * canvas must use canvas-aware (always-light) colors regardless of
 * the page theme. Without this override, --text-dim (#1c1408 in ink
 * mode) sits on a #111 canvas at ~1:1 contrast and becomes invisible. */
[data-theme="ink"] .cb-canvas-hint {
    color: rgba(255, 255, 255, 0.45);
}
[data-theme="ink"] .cb-canvas-hint strong {
    color: rgba(255, 255, 255, 0.85);
}
[data-theme="ink"] .cb-canvas-hint kbd {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.85);
}

/* Statusbar */
.cb-canvas-statusbar {
    height: 26px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2xl);
    padding: 0 var(--space-3xl);
    background: var(--bg-navbar);
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
}
.cb-statusbar-sep {
    width: 1px; height: 12px;
    background: var(--border);
}
.cb-statusbar-spacer { flex: 1; }
.cb-canvas-statusbar strong { color: var(--text); font-weight: var(--font-semibold); }

/* ── 7. Inspector ─────────────────────────────────────── */

.cb-inspector {
    position: relative;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    overflow: hidden;
}
.cb-inspector__inner {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.cb-inspector__rail {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 36px;
    display: none;
}
.cb-shell.cb-inspector-collapsed .cb-inspector__inner { display: none; }
.cb-shell.cb-inspector-collapsed .cb-inspector__rail  { display: flex; }
.cb-shell.cb-inspector-collapsed .cb-sidebar-toggle--left { left: 7px; }

.cb-inspector-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    height: 28px;
}
.cb-tab {
    flex: 1;
    padding: 0;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 11.5px;
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    height: 28px;
}
.cb-tab:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--accent) 4%, transparent);
}
.cb-tab--active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    font-weight: var(--font-semibold);
}

.cb-inspector-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-2xl);
}

.cb-inspector__empty {
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.55;
    font-style: italic;
}

.cb-inspector__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
}
.cb-inspector__header-name {
    font-size: 13px;
    font-weight: var(--font-semibold);
    color: var(--text-bright);
}
.cb-inspector__header-id {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

.cb-inspector__sim-strip {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-xs);
}
.cb-sim-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 0;
    gap: 2px;
}
.cb-sim-cell-l {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--text-muted);
    font-weight: var(--font-semibold);
}
.cb-sim-cell-v {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: var(--font-semibold);
    color: var(--text-bright);
}
.cb-sim-u .cb-sim-cell-v { color: var(--color-formula); }
.cb-sim-i .cb-sim-cell-v { color: var(--color-insight); }
.cb-sim-p .cb-sim-cell-v { color: var(--color-tip); }

.cb-inspector__grid {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: var(--space-xs) var(--space-md);
    align-items: center;
}
.cb-inspector__lab {
    font-size: 10.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    font-weight: var(--font-semibold);
    text-align: right;
}
.cb-inspector__val {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cb-inspector__value {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-bright);
}
.cb-input-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}
.cb-inspector__input {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-sm);
    padding: 3px 6px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    box-sizing: border-box;
    transition: border-color var(--transition-fast);
    max-width: 110px;
}
.cb-inspector__input:focus { outline: none; border-color: var(--accent); }
.cb-inspector__input.cb-input-invalid { border-color: var(--color-error); }
.cb-inspector__unit {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}
.cb-inspector__select {
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-sm);
    padding: 3px 6px;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 12px;
    box-sizing: border-box;
    cursor: pointer;
}

/* Quick presets */
.cb-quick-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.cb-quick-preset {
    padding: 2px 6px;
    background: transparent;
    border: 1px solid var(--border-active);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.cb-quick-preset:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.cb-quick-preset--active {
    border-color: var(--accent);
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    font-weight: var(--font-semibold);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.cb-quick-preset--active:hover {
    background: color-mix(in srgb, var(--accent) 28%, transparent);
}

/* Color swatches */
.cb-color-swatches {
    display: flex;
    gap: var(--space-xs);
}
.cb-color-swatch {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border-active);
    cursor: pointer;
    padding: 0;
    background-clip: content-box;
    transition: all var(--transition-fast);
}
.cb-color-swatch:hover { transform: scale(1.1); }
.cb-color-swatch--active {
    border-color: var(--text-bright);
    transform: scale(1.15);
    box-shadow: 0 0 0 2px var(--bg-sidebar), 0 0 6px 2px color-mix(in srgb, var(--text-bright) 50%, transparent);
}

/* Rotation buttons */
.cb-rot-buttons {
    display: flex;
    gap: 2px;
}
.cb-rot-btn {
    flex: 1;
    background: transparent;
    border: 1px solid var(--border-active);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10.5px;
    padding: 3px 0;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.cb-rot-btn:hover { border-color: var(--accent); color: var(--accent); }
.cb-rot-btn--active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
}

/* Inspector footer (action buttons) */
.cb-inspector__footer {
    display: flex;
    gap: var(--space-xs);
    padding-top: var(--space-xs);
    margin-top: auto;
    border-top: 1px solid var(--border);
}
.cb-action-btn {
    flex: 1;
    padding: 5px 8px;
    background: transparent;
    border: 1px solid var(--border-active);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.cb-action-btn:hover { border-color: var(--accent); color: var(--accent); }
.cb-action-btn--danger { border-color: var(--color-error); color: var(--color-error); }
.cb-action-btn--danger:hover {
    background: color-mix(in srgb, var(--color-error) 14%, transparent);
    border-color: var(--color-error);
    color: var(--color-error);
}
.cb-action-btn kbd {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0 4px;
    border-radius: 3px;
    background: var(--bg);
}

/* Sim tab */
.cb-sim-tab-head {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-bright);
    background: var(--bg-surface);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--accent);
}
.cb-sim-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 11px;
}
.cb-sim-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: var(--font-semibold);
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}
.cb-sim-table td {
    padding: 3px 6px;
    color: var(--text-bright);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.cb-sim-id { color: var(--accent) !important; font-weight: var(--font-semibold); }

/* Warning list */
.cb-warning-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column;
    gap: 4px;
}
.cb-warning-item {
    background: color-mix(in srgb, var(--color-warning) 10%, transparent);
    border-left: 2px solid var(--color-warning);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--text);
}

/* Circuit tab */
.cb-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}
.cb-status-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    text-align: center;
}
.cb-status-card__label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--text-muted);
    margin-bottom: 2px;
}
.cb-status-card__value {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-bright);
    font-weight: var(--font-bold);
}

.cb-type-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cb-type-list li {
    display: flex;
    justify-content: space-between;
    padding: 3px 6px;
    font-size: 11px;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.cb-type-name { color: var(--text); }
.cb-type-count {
    font-family: var(--font-mono);
    color: var(--text-bright);
    font-weight: var(--font-semibold);
}

.cb-inspector__multi-head {
    font-size: 12px;
    color: var(--text-bright);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border);
}
.cb-inspector__actions {
    display: flex;
    gap: var(--space-xs);
}

.cb-pot-pos {
    align-self: flex-end;
    font-size: 10.5px;
    color: var(--text-muted);
}

/* ── 8. Scope dock ─────────────────────────────────── */

.cb-scope-dock {
    height: 0;
    overflow: hidden;
    background: var(--bg-navbar);
    border-top: 1px solid var(--border);
    transition: height 220ms ease;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    /* min-height: 0 propagates the height-constraint into the flex
     * children (head + body). Without it, body's `flex: 1` defaults to
     * `min-height: auto` which expands to fit the canvas's intrinsic
     * content, blowing the canvas to 555+ px while the dock stays at
     * 240. Result: most of the trace was rendered below the visible
     * dock and clipped. */
    min-height: 0;
}
.cb-scope-dock.cb-show { height: 240px; }

.cb-scope-head {
    height: 24px;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 0 var(--space-2xl);
    border-bottom: 1px solid var(--border);
}
.cb-scope-title {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}
.cb-scope-window-label {
    margin-left: var(--space-md);
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}
.cb-scope-window-select {
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 10.5px;
    padding: 1px 4px;
    cursor: pointer;
}
.cb-scope-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    width: 22px; height: 22px;
}
.cb-scope-close:hover { color: var(--text-bright); }
.cb-scope-body {
    flex: 1;
    /* Same min-height: 0 reasoning as the dock: without it, body keeps
     * growing to its content-intrinsic size and the canvas explodes. */
    min-height: 0;
    position: relative;
    overflow: hidden;
}
#cb-scope-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* ── 9. Modal backdrop ─────────────────────────────── */

.cb-modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.cb-modal-backdrop.cb-show { display: flex; }
.cb-modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-lg);
    padding: var(--space-4xl);
    box-shadow: var(--shadow-md);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    gap: var(--space-2xl);
}
.cb-modal__title {
    font-size: 15px;
    font-weight: var(--font-semibold);
    color: var(--text-bright);
    margin: 0;
}
.cb-modal__textarea {
    width: 100%;
    flex: 1;
    min-height: 220px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-2xl);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.55;
    resize: vertical;
    box-sizing: border-box;
}
.cb-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
    flex-wrap: wrap;
}
.cb-modal__btn {
    padding: var(--space-md) var(--space-3xl);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: var(--font-medium);
    transition: all var(--transition-fast);
    background: transparent;
    border: 1px solid var(--border-active);
    color: var(--text);
}
.cb-modal__btn--accent {
    border-color: var(--accent);
    color: var(--accent);
}
.cb-modal__btn--accent:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.cb-modal__btn:hover:not(.cb-modal__btn--accent) { border-color: var(--text); }

/* ── 10. Search overlay ─────────────────────────────── */

.cb-search-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 110;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 14vh;
    backdrop-filter: blur(3px);
}
.cb-search-backdrop.cb-show { display: flex; }

.cb-search-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    width: 480px;
    max-width: 92%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.cb-search-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    color: var(--text-bright);
    font-family: var(--font-ui);
    font-size: 14px;
    outline: none;
}
.cb-search-input::placeholder { color: var(--text-dim); }

.cb-search-results {
    max-height: 340px;
    overflow-y: auto;
}
.cb-search-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 8px 14px;
    cursor: pointer;
    color: var(--text);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.cb-search-row:last-child { border-bottom: none; }
.cb-search-row--active {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
}
.cb-search-row-icon {
    width: 32px; height: 18px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cb-search-row-icon canvas { display: block; }
.cb-search-row-label {
    font-family: var(--font-ui);
    font-size: 12.5px;
}

/* ── 11. Help overlay ───────────────────────────────── */

.cb-help-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 105;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.cb-help-backdrop.cb-show { display: flex; }

.cb-help-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-lg);
    padding: var(--space-4xl);
    box-shadow: var(--shadow-md);
    max-width: 520px;
    width: 92%;
    max-height: 80vh;
    overflow-y: auto;
}
.cb-help-card h2 {
    margin: 0 0 var(--space-3xl) 0;
    font-size: 15px;
    color: var(--text-bright);
    font-weight: var(--font-semibold);
}
.cb-help-subhead {
    margin: var(--space-2xl) 0 var(--space-xs) 0;
    font-size: 11px;
    color: var(--accent);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}
.cb-help-subhead:first-of-type { margin-top: 0; }
.cb-help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: var(--space-md);
}
.cb-help-table td {
    padding: 4px 8px;
    color: var(--text);
    vertical-align: top;
}
.cb-help-table td:first-child {
    width: 130px;
    text-align: right;
}
.cb-help-table kbd {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-bright);
    background: var(--bg);
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid var(--border);
}
.cb-help-close {
    margin-top: var(--space-3xl);
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: var(--font-medium);
}
.cb-help-close:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* ── 12. Tutorial overlay ─────────────────────────── */

.cb-tutorial-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 95;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.cb-tutorial-backdrop.cb-show { display: flex; }

.cb-tutorial-card {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-lg);
    padding: var(--space-4xl);
    box-shadow: var(--shadow-md);
    max-width: 480px;
    width: 92%;
    display: flex;
    flex-direction: column;
    gap: var(--space-2xl);
}
.cb-tutorial-card h2 {
    margin: 0;
    font-size: 16px;
    color: var(--text-bright);
    font-weight: var(--font-semibold);
}
.cb-tutorial-card p {
    margin: 0;
    color: var(--text);
    font-size: 13px;
    line-height: 1.65;
}
.cb-tutorial-card p kbd {
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 3px;
}
.cb-tutorial-card p code {
    font-family: var(--font-mono);
    background: var(--bg);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    color: var(--accent);
}
.cb-tutorial-close {
    position: absolute;
    top: 8px; right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    width: 24px; height: 24px;
    border-radius: var(--radius-sm);
}
.cb-tutorial-close:hover { color: var(--text-bright); background: color-mix(in srgb, var(--text) 8%, transparent); }

.cb-tutorial-dots {
    display: flex;
    gap: var(--space-xs);
    justify-content: center;
}
.cb-tutorial-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--border-active);
}
.cb-tutorial-dot--active { background: var(--accent); }

.cb-tutorial-actions {
    display: flex;
    gap: var(--space-md);
    align-items: center;
    justify-content: flex-end;
}
.cb-tutorial-back, .cb-tutorial-next {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: var(--font-medium);
}
.cb-tutorial-back {
    background: transparent;
    border: 1px solid var(--border-active);
    color: var(--text);
}
.cb-tutorial-back:hover { border-color: var(--text); }
.cb-tutorial-next {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}
.cb-tutorial-next:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }

.cb-tutorial-skip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: auto;
    color: var(--text-muted);
    font-size: 11.5px;
    cursor: pointer;
    user-select: none;
}
.cb-tutorial-skip input {
    accent-color: var(--accent);
    width: 12px; height: 12px;
    cursor: pointer;
    margin: 0;
}

/* ── 13. Toast ──────────────────────────────────────── */

.cb-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translate(-50%, 6px);
    background: var(--bg-surface);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 8px 18px;
    border-radius: var(--radius-md);
    font-size: 12.5px;
    font-weight: var(--font-medium);
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
    z-index: 200;
}
.cb-toast--show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ── Scrollbar polish ─────────────────────────────── */

.cb-palette__inner::-webkit-scrollbar,
.cb-inspector-body::-webkit-scrollbar,
.cb-search-results::-webkit-scrollbar,
.cb-help-card::-webkit-scrollbar { width: 6px; }
.cb-palette__inner::-webkit-scrollbar-thumb,
.cb-inspector-body::-webkit-scrollbar-thumb,
.cb-search-results::-webkit-scrollbar-thumb,
.cb-help-card::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.cb-palette__inner::-webkit-scrollbar-track,
.cb-inspector-body::-webkit-scrollbar-track,
.cb-search-results::-webkit-scrollbar-track,
.cb-help-card::-webkit-scrollbar-track { background: transparent; }
