/* CircuitCAD - Main Stylesheet */

/* Dark theme (default) */
:root {
    --workspace-rail-width: 72px;
    --bg-dark: #0e151d;
    --bg-darker: #0a1017;
    --bg-medium: #111a24;
    --bg-light: #1c2836;
    --bg-panel: #111a24;
    --border: #2b3949;
    --text: #dee8f7;
    --text-dim: #9cacbf;
    --accent: #3199ff;
    --accent-hover: #4a90e2;
    --wire-color: #55b2ff;
    --bus-color: #00aaff;
    --junction-color: #55b2ff;
    --grid-color: #172733;
    --grid-line: #243847;
    --canvas-bg: #0b151c;
    --symbol-color: #c5d4ed;
    --comment-indicator: #ffa500;
    --preview-color: #00ff00;
    --preview-highlight: rgba(0, 255, 0, 0.3);
    --annotation-placement-preview-color: #3fb950;
    --annotation-placement-preview-highlight: rgba(63, 185, 80, 0.18);
    --selection-rect-stroke: #58a6ff;
    --selection-rect-fill: rgba(88, 166, 255, 0.15);
    --shape-default-stroke: #00ccff;
    --ground-color: #c5d4ed;
    /* Power/ground wire colors */
    --power-color: #ff7076;
    --power-wire-color: #55b2ff;
    /* Annotation backgrounds */
    --annotation-bg: #1a1a2e;
    --annotation-bg-alt: #0a0a15;
    --annotation-bg-violation: #2a1515;
    --annotation-bg-i2c: #0a1520;
    /* Simulation / analysis colors */
    --sim-high: #00ff44;
    --sim-low: #0088ff;
    --sim-weak-high: #88ffaa;
    --sim-weak-low: #88aaff;
    --sim-floating: #666666;
    --sim-conflict: #ff0000;
    --sim-undefined: #ffaa00;
    --sim-voltage: #00ff88;
    --sim-current: #ffaa00;
    --sim-overcurrent: #ff4444;
    --sim-specs: #88aaff;
    --sim-time-constant: #ff9900;
    --sim-i2c: #00bfff;
    --sim-port-ref: #00bfff;
    /* Pin state colors */
    --pin-floating: #888888;
    --pin-driven-high: #00ff00;
    --pin-driven-low: #ff6600;
    /* Symbol edit mode */
    --symbol-edit-color: #ffcc00;
    --symbol-edit-pin: #ffa726;
    /* Component text labels */
    --ref-text-color: #e5eefb;
    --value-text-color: #c5d4ed;
    --part-number-color: #ff9800;
    --nopop-bg: #ff69b4;
    --data-status-partial: #ffaa00;
    --data-status-logic: #ffcc00;
    --data-status-minimal: #ff8800;
}

/* Light theme */
[data-theme="light"] {
    --bg-dark: #f6f8fa;
    --bg-darker: #e8eaed;
    --bg-medium: #ffffff;
    --bg-light: #f0f2f4;
    --bg-panel: #ffffff;
    --border: #d1d5db;
    --text: #24292f;
    --text-dim: #57606a;
    --accent: #0969da;
    --accent-hover: #0550ae;
    /* Canvas drawing colors - black for visibility */
    --wire-color: #1a1a1a;
    --bus-color: #1a1a1a;
    --junction-color: #1a1a1a;
    --grid-color: #e0e0e0;
    --grid-line: #c8c8c8;
    --canvas-bg: #fafafa;
    --symbol-color: #1a1a1a;
    --comment-indicator: #1a1a1a;
    --preview-color: #0066ff;
    --preview-highlight: rgba(0, 102, 255, 0.3);
    --annotation-placement-preview-color: #1a7f37;
    --annotation-placement-preview-highlight: rgba(26, 127, 55, 0.16);
    --selection-rect-stroke: #0066ff;
    --selection-rect-fill: rgba(0, 102, 255, 0.15);
    --shape-default-stroke: #0066cc;
    --ground-color: #1a1a1a;
    /* Power/ground wire colors */
    --power-color: #1a1a1a;
    --power-wire-color: #1a1a1a;
    /* Component text labels - all black for readability */
    --ref-text-color: #1a1a1a;
    --value-text-color: #1a1a1a;
    --part-number-color: #1a1a1a;
    --nopop-bg: #ff69b4;
    --data-status-partial: #cc7700;
    --data-status-logic: #b38600;
    --data-status-minimal: #aa5500;
    /* Annotation backgrounds */
    --annotation-bg: rgba(0, 0, 0, 0.06);
    --annotation-bg-alt: rgba(0, 0, 0, 0.04);
    --annotation-bg-violation: rgba(255, 68, 68, 0.08);
    --annotation-bg-i2c: rgba(0, 102, 204, 0.06);
    /* Simulation / analysis colors */
    --sim-high: #008a22;
    --sim-low: #0055cc;
    --sim-weak-high: #2d8a4e;
    --sim-weak-low: #3366aa;
    --sim-floating: #888888;
    --sim-conflict: #cc0000;
    --sim-undefined: #cc7700;
    --sim-voltage: #007744;
    --sim-current: #cc7700;
    --sim-overcurrent: #cc0000;
    --sim-specs: #3355aa;
    --sim-time-constant: #cc6600;
    --sim-i2c: #0077aa;
    --sim-port-ref: #0077aa;
    /* Pin state colors */
    --pin-floating: #888888;
    --pin-driven-high: #008800;
    --pin-driven-low: #cc4400;
    /* Symbol edit mode */
    --symbol-edit-color: #b38600;
    --symbol-edit-pin: #cc7700;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-dark); color: var(--text); overflow: hidden; height: 100vh; }

button, input, select, textarea { font-family: inherit; }

/* Allow text selection in inputs, textareas, modals, and menus */
input, textarea, .modal, .modal-content, .menu-content, .properties-panel, .sim-warning-item, .sim-net-item, .net-loading-row {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* Main Layout */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-width: 0; }

/* Header / Menu Bar */
.header {
    height: 52px;
    flex-shrink: 0;
    background: linear-gradient(110deg, var(--bg-darker), var(--bg-medium));
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 0;
    min-width: 0;
}
.header .logo {
    font-weight: 600;
    color: var(--text);
    font-size: 22px;
    padding: 0 20px 0 8px;
    margin-right: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}
.header .back-link {
    color: var(--text-dim);
    font-size: 12px;
    padding: 4px 10px;
    margin-right: 8px;
    text-decoration: none;
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    transition: background 0.15s, color 0.15s;
}
.header .back-link:hover {
    background: rgba(88,166,255,0.15);
    color: var(--accent);
}

/* Menu Bar */
.menu-bar {
    display: flex;
    align-items: center;
    height: 100%;
}
.menu-dropdown {
    position: relative;
    height: 100%;
}
.menu-trigger {
    padding: 0 12px;
    height: 100%;
    display: flex;
    align-items: center;
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
    border: none;
    background: none;
    transition: background 0.15s, color 0.15s;
}
.menu-trigger:hover,
.menu-dropdown:hover .menu-trigger,
.menu-dropdown.open .menu-trigger {
    background: var(--bg-light);
    color: var(--text);
}
.menu-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 64px);
    overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    padding: 4px 0;
    z-index: 1000;
}

/* Quick action buttons in menu bar */
.menu-quick-btn {
    padding: 0 10px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    border: none;
    background: none;
    transition: background 0.15s, color 0.15s;
}
.menu-quick-btn:hover {
    background: var(--bg-light);
    color: var(--text);
}
.menu-quick-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}
.menu-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}
.menu-dropdown.open .menu-content {
    display: block;
}
.menu-item {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    font-family: inherit;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.1s;
}
.menu-item:hover {
    background: var(--accent);
    color: #fff;
}
.menu-item .shortcut {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-dim);
    opacity: 0.7;
}
.menu-item:hover .shortcut {
    color: rgba(255,255,255,0.7);
}
.menu-item.disabled {
    opacity: 0.4;
    pointer-events: none;
}
.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 8px;
}
.menu-section-header {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: 6px 12px 4px;
    letter-spacing: 0.5px;
}
.menu-item svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* Filename display */
.filename-display {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin-left: 0;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 17%, var(--bg-dark)), var(--bg-dark));
    border-radius: 4px;
    font-size: 12px;
    color: var(--text);
    height: 34px;
    min-width: 0;
    max-width: 400px;
    border: 1px solid var(--border);
}
.filename-display #current-filename {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.filename-display #dirty-indicator {
    color: #f0883e;
    font-size: 10px;
}

/* Header right section */
.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding-right: 4px;
}
.header-stat {
    font-size: 11px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
}
.header-stat span {
    color: var(--text);
    font-weight: 500;
}
.header-right a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}
.header-right a:hover {
    background: var(--bg-light);
    color: var(--text);
}
.header-right .user-email {
    font-size: 11px;
    color: var(--accent);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header-right .tools-link {
    color: #8b949e !important;
    border: 1px solid #30363d;
}
.header-right .tools-link:hover {
    color: var(--text) !important;
    border-color: #484f58;
}
.header-right .logout-link {
    color: #f85149 !important;
}
.header-right .login-link {
    color: var(--accent) !important;
}

/* Account actions remain accessible in a compact header menu. */
.workspace-account { position: relative; flex-shrink: 0; }
.workspace-account > summary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 34px;
    list-style: none;
    cursor: pointer;
    border: 1px solid var(--accent);
    border-radius: 50%;
    color: var(--text);
    background: color-mix(in srgb, var(--accent) 32%, var(--bg-dark));
}
.workspace-account > summary::-webkit-details-marker { display: none; }
.workspace-account > summary svg { width: 20px; height: 20px; }
.workspace-account > summary:hover { background: color-mix(in srgb, var(--accent) 45%, var(--bg-dark)); }
.workspace-account-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 220px;
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 64px);
    overflow-y: auto;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg-panel);
    box-shadow: 0 12px 32px #0006;
}
.header-right .workspace-account-menu a { display: block; padding: 8px; }
.header-right .workspace-account-menu .user-email { display: block; max-width: 100%; padding: 8px; }

/* Main Content Area */
.main-content { display: flex; flex: 1; min-width: 0; min-height: 0; overflow: hidden; position: relative; }

/* Drawing toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    min-width: 0;
}
.tool-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-dim);
    transition: all 0.15s;
}
.tool-btn:hover { background: var(--bg-light); color: var(--text); }
.tool-btn.active { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 28%, var(--bg-dark)), color-mix(in srgb, var(--accent) 10%, var(--bg-dark))); color: var(--text); border: 1px solid var(--accent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 8%, transparent); }
.tool-btn svg { width: 20px; height: 20px; }
.tool-separator { width: 1px; height: 34px; background: var(--border); margin: 0 5px; flex-shrink: 0; }

/* Toggle buttons (auto-analyze, auto-delete) - different style from tool selection */
.tool-btn.toggle-btn { background: rgba(248, 81, 73, 0.15); color: #f85149; border: 1px solid #f85149; }
.tool-btn.toggle-btn:hover { background: rgba(248, 81, 73, 0.25); }
.tool-btn.toggle-btn.active { background: rgba(46, 160, 67, 0.2); color: #3fb950; border: 1px solid #3fb950; }
.tool-btn.toggle-btn.active:hover { background: rgba(46, 160, 67, 0.3); }

/* Tall tool button (for voltage divider, etc.) */
.tool-btn.tool-btn-tall { height: 60px; }
.tool-btn.tool-btn-tall svg { width: 22px; height: 48px; }

/* Quick components share the drawing toolbar's horizontal scroll area. */
.toolbar-secondary {
    flex: 0 0 auto;
    width: auto;
    height: 62px;
    margin: 0;
    padding: 0 0 0 8px;
    border-left: 1px solid var(--border);
    background: transparent;
}

/* Design metadata in the Design inspector */
.design-info-bar {
    display: flex;
    align-items: center;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    flex-shrink: 0;
}
.design-info-bar .design-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.design-info-bar .design-info-item label {
    color: var(--text-dim);
    font-size: 10px;
    white-space: nowrap;
}
.design-info-bar .design-info-item input,
.design-info-bar .design-info-item select {
    padding: 3px 6px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text);
    font-size: 11px;
    min-width: 80px;
}
.design-info-bar .design-info-item input:focus,
.design-info-bar .design-info-item select:focus {
    outline: none;
    border-color: var(--accent);
}
.design-info-bar .design-info-item input[type="text"] {
    width: 100%;
}
#design-author {
    width: 100%;
}
#design-revision {
    width: 100%;
}
.design-info-bar .design-info-item select {
    min-width: 50px;
    width: auto;
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--canvas-bg);
    /* Prevent browser default behaviors */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: none;
}
#schematic-canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: default;
    /* Prevent native drag-and-drop */
    -webkit-user-drag: none;
    user-drag: none;
}
/* Tool-specific cursors */
.canvas-container.tool-wire #schematic-canvas,
.canvas-container.tool-bus #schematic-canvas,
.canvas-container.tool-rectangle #schematic-canvas,
.canvas-container.tool-circle #schematic-canvas,
.canvas-container.tool-line #schematic-canvas { cursor: crosshair; }
.canvas-container.tool-rectangle #schematic-canvas *,
.canvas-container.tool-circle #schematic-canvas *,
.canvas-container.tool-line #schematic-canvas * { cursor: crosshair !important; }
.canvas-container.tool-select #schematic-canvas { cursor: default; }
.canvas-container.panning { cursor: grab; }
.canvas-container.panning:active { cursor: grabbing; }
.canvas-container.space-pan-ready { cursor: grab; }
.canvas-container.space-pan-ready:active { cursor: grabbing; }
.canvas-container.dragging #schematic-canvas { cursor: move; }

/* Canvas Area (contains canvas and page tabs) */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}
.canvas-area .canvas-container {
    flex: 1;
}

/* Page Tabs */
.page-tabs-container {
    height: 32px;
    flex-shrink: 0;
    background: var(--bg-medium);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 4px;
}
.page-tabs-nav {
    display: flex;
    align-items: center;
    gap: 2px;
}
.page-tabs-nav-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 12px;
    transition: all 0.15s;
}
.page-tabs-nav-btn:hover:not(.disabled) {
    background: var(--bg-light);
    color: var(--text);
}
.page-tabs-nav-btn.disabled {
    opacity: 0.3;
    cursor: default;
}
.page-tabs {
    display: flex;
    gap: 4px;
    overflow: hidden;
    flex: 1;
}
.page-tab {
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-dim);
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    white-space: nowrap;
    max-width: 120px;
    min-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.15s;
}
.page-tab:hover {
    background: var(--bg-light);
    color: var(--text);
}
.page-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.page-tab.add-page {
    padding: 6px 10px;
    font-weight: bold;
    font-size: 14px;
    background: transparent;
    border: 1px dashed var(--border);
    min-width: 32px;
    max-width: 32px;
}
.page-tab.add-page:hover {
    background: var(--bg-light);
    border-style: solid;
}
.page-tabs-info {
    font-size: 10px;
    color: var(--text-dim);
    margin-left: 8px;
    white-space: nowrap;
}

/* Properties Panel (right) */
.properties-panel {
    width: 285px;
    flex-shrink: 0;
    min-height: 0;
    background: linear-gradient(110deg, var(--bg-dark), var(--bg-panel));
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.panel-header {
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}
.panel-header .ai-symbol-btn {
    background: transparent;
    border: 1px solid #555;
    color: #4a9eff;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}
.panel-header .ai-symbol-btn:hover {
    background: rgba(74, 158, 255, 0.1);
    border-color: #4a9eff;
}
.panel-content { padding: 14px 16px; flex: 1; min-height: 0; overflow-y: auto; }
.prop-group { margin-bottom: 16px; }
.prop-group label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.prop-group input, .prop-group select {
    width: 100%;
    padding: 8px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 13px;
}
.prop-group input:focus, .prop-group select:focus { outline: none; border-color: var(--accent); }

/* Workspace navigation and presentation */
.workspace-logo { width: 30px; height: 30px; flex-shrink: 0; }
.workspace-search {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    width: clamp(120px, 21vw, 350px);
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-dark);
    color: var(--text-dim);
    cursor: pointer;
}
.workspace-search span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.workspace-search svg { width: 16px; height: 16px; flex-shrink: 0; }
.workspace-search kbd { margin-left: auto; white-space: nowrap; font-size: 11px; }
.workspace-toolbar {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 0;
    height: 76px;
    background: linear-gradient(110deg, var(--bg-dark), var(--bg-medium));
    border: 1px solid var(--border);
    border-radius: 9px 9px 0 0;
    position: relative;
    z-index: 30;
}
.primary-toolbar { flex: 0 1 auto; overflow-x: auto; scrollbar-width: thin; }
.primary-toolbar .tool-btn {
    width: 58px;
    min-width: 58px;
    height: 62px;
    flex-shrink: 0;
    flex-direction: column;
    gap: 7px;
    border: 1px solid transparent;
    color: var(--text);
}
.primary-toolbar .tool-btn.active { border-color: var(--accent); }
.primary-toolbar .tool-btn svg { width: 23px; height: 23px; }
.primary-toolbar .quick-parts-toolbar .tool-btn svg { width: 34px; height: 26px; }
.tool-label { font-size: 11px; font-weight: 400; white-space: nowrap; }
.workspace-toolbar-actions { display: flex; align-items: center; gap: 8px; padding: 0 12px; flex-shrink: 0; }
.workspace-toolbar-action,
.workspace-tools-more > summary,
.panel-close,
.workspace-status-zoom button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 32px;
    min-height: 32px;
    padding: 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;
    color: var(--text-dim);
    cursor: pointer;
}
.workspace-toolbar-action:hover,
.workspace-tools-more > summary:hover,
.panel-close:hover,
.workspace-status-zoom button:hover { background: var(--bg-light); color: var(--text); }
.workspace-toolbar-action svg,
.workspace-tools-more > summary svg,
.panel-close svg,
.workspace-status-zoom svg { width: 20px; height: 20px; flex-shrink: 0; }
.workspace-toolbar-actions select {
    height: 34px;
    max-width: 105px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    padding: 0 8px;
}
.workspace-tools-more { flex-shrink: 0; }
.workspace-toolbar > .orthogonal-move-toggle {
    width: 88px;
    height: 62px;
    flex-shrink: 0;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
}
.orthogonal-move-toggle .tool-label { white-space: normal; }
.workspace-tools-more > summary { list-style: none; }
.workspace-tools-more > summary::-webkit-details-marker { display: none; }
.workspace-tool-options {
    position: absolute;
    right: 8px;
    top: calc(100% + 4px);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: min(370px, calc(100vw - 24px));
    max-height: calc(100dvh - 150px);
    overflow-y: auto;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg-panel);
    box-shadow: 0 12px 32px #0006;
}
.workspace-tool-options .tool-btn { width: 74px; min-height: 64px; height: auto; flex-direction: column; gap: 5px; padding: 5px; }
.workspace-tool-options .tool-label { white-space: normal; font-size: 10px; }
.workspace-tool-options .tool-btn-tall svg { height: 34px; }
.simulate-action { flex-direction: column; height: 58px; font-size: 11px; }
.simulate-action svg { color: #71db91; }
.workspace-tool-options .tool-separator { display: none; }
.workspace-rail {
    width: var(--workspace-rail-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid var(--border);
    background: linear-gradient(90deg, var(--bg-dark), var(--bg-darker));
}
.workspace-nav-button {
    width: 100%;
    min-height: 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 8px 2px;
    border: 0;
    border-left: 3px solid transparent;
    background: transparent;
    color: var(--text-dim);
    font-size: 11px;
    text-decoration: none;
    cursor: pointer;
}
.workspace-nav-button svg { width: 23px; height: 23px; flex-shrink: 0; }
.workspace-nav-button span { max-width: 100%; font-size: 10px; }
.workspace-nav-button:hover { color: var(--text); background: var(--bg-light); }
.workspace-nav-button.active { border-left-color: var(--accent); color: var(--text); background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 17%, transparent), transparent); }
.workspace-nav-button.active svg { color: var(--accent); }
.library-panel .panel-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; min-height: 44px; }
.library-view-tabs { display: flex; gap: 5px; padding: 0 12px 9px; border-bottom: 1px solid var(--border); }
.library-view-label { flex: 1; font-size: 11px; color: var(--text-dim); align-self: center; }
.library-view-tabs button { flex: 0; white-space: nowrap; padding: 6px; border-radius: 4px; border: 1px solid transparent; background: transparent; color: var(--text-dim); cursor: pointer; font-size: 11px; }
.library-view-tabs button.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--bg-dark)); color: var(--text); }
.lib-symbol-preview { width: 36px; height: 30px; flex-shrink: 0; color: var(--symbol-color); }
.lib-item-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.document-strip { display: flex; align-items: center; min-width: 0; height: 40px; flex-shrink: 0; gap: 6px; padding: 3px 5px; border-bottom: 1px solid var(--border); background: var(--bg-dark); }
.inspector-tabs { display: flex; flex-shrink: 0; height: 44px; border-bottom: 1px solid var(--border); }
.inspector-tabs > button { flex: 1; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-dim); cursor: pointer; font-size: 13px; }
.inspector-tabs > button.active,
.inspector-tabs > button[aria-selected="true"] { border-bottom-color: var(--accent); background: var(--bg-medium); color: var(--text); }
.inspector-tabs > .panel-close { flex: 0 0 32px; }
#inspector-properties { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#inspector-design { flex: 1; min-height: 0; overflow-y: auto; }
#inspector-properties[hidden], #inspector-design[hidden] { display: none; }
.design-info-bar .design-info-item { flex-direction: column; align-items: stretch; }
.design-info-bar .design-info-item label { font-size: 12px; }
.design-info-bar .design-info-item input,
.design-info-bar .design-info-item select { min-width: 0; width: 100%; padding: 8px; font-size: 12px; }
.workspace-dock { height: 160px; max-height: 30%; flex-shrink: 0; display: flex; flex-direction: column; min-height: 36px; border-top: 1px solid var(--border); background: linear-gradient(110deg, var(--bg-dark), var(--bg-medium)); }
.workspace-dock-tabs { height: 36px; flex-shrink: 0; display: flex; align-items: stretch; gap: 6px; padding: 2px 5px 0; border-bottom: 1px solid var(--border); }
.workspace-dock-tabs button { padding: 0 12px; border: 1px solid transparent; border-radius: 4px 4px 0 0; background: transparent; color: var(--text-dim); font-size: 12px; cursor: pointer; }
.workspace-dock-tabs button.active,
.workspace-dock-tabs button[aria-selected="true"] { border-color: var(--border); background: color-mix(in srgb, var(--accent) 12%, var(--bg-dark)); color: var(--text); }
#workspace-dock-toggle { margin-left: auto; padding: 0 8px; }
#workspace-dock-toggle svg { width: 16px; height: 16px; }
.workspace-dock-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 14px; font-size: 12px; line-height: 1.65; }
.workspace-dock-body [hidden] { display: none; }
.workspace-message { display: flex; align-items: baseline; gap: 12px; padding: 2px 0; }
.workspace-message > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.workspace-message time { flex-shrink: 0; color: var(--text-dim); font-size: 10px; }
.workspace-message-info { color: var(--accent); }
.workspace-message-warning { color: var(--sim-undefined); }
.workspace-message-error, .workspace-message-critical { color: var(--sim-overcurrent); }
.workspace-message button { flex-shrink: 0; padding: 2px 7px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-light); color: var(--text); font: inherit; cursor: pointer; }
.workspace-message button:hover { border-color: var(--accent); }
.workspace-dock.collapsed { height: 36px; }
.workspace-dock.collapsed .workspace-dock-body { display: none; }
.workspace-status-zoom { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.workspace-status-zoom input[type="range"] { width: 120px; accent-color: var(--accent); }
.app.library-collapsed .library-panel,
.app.inspector-collapsed .properties-panel { display: none; }
body.board-analyzer-mode .workspace-dock { display: none; }
body.symbol-edit-mode .app .main-content { flex-wrap: nowrap; padding-top: 32px; }
body.symbol-edit-mode .app #symbol-mode-banner { position: absolute; top: 0; left: 0; right: 0; }
body.symbol-edit-mode .workspace-dock { display: none; }
body.symbol-edit-mode .app .main-content #symbol-mode-panel {
    position: relative;
    top: auto;
    right: auto;
    flex: 0 0 260px;
    width: 260px;
    max-width: calc(100% - 120px);
    min-height: 0;
    height: auto;
    margin: 0;
    padding: 14px;
    overflow-y: auto;
    align-self: stretch;
    border: 0;
    border-left: 1px solid color-mix(in srgb, #4caf50 50%, var(--border));
    border-radius: 0;
    background: var(--bg-panel);
    box-shadow: none;
}
button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* Panels become deliberate overlays while the drawing area keeps its space. */
@media (max-width: 1250px) {
    .header .logo { font-size: 18px; padding-right: 8px; }
    .menu-trigger { padding: 0 9px; }
    .header-right .user-email, .header-stat { display: none; }
    .workspace-search { width: 150px; }
    .workspace-search kbd { display: none; }
    .primary-toolbar .tool-btn { width: 59px; min-width: 59px; }
    .workspace-toolbar-actions { gap: 4px; padding: 0 6px; }
}
@media (max-width: 1050px) {
    .app .library-panel { display: none; }
    .app.library-open .library-panel { display: flex; position: absolute; left: 72px; top: 0; bottom: 0; width: 250px; z-index: 40; box-shadow: 12px 0 28px #0005; }
    .header .logo { font-size: 16px; }
    .workspace-search { width: 34px; padding: 8px; }
    .workspace-search span, .header .back-link { display: none; }
    .header-right { gap: 2px; }
    .header-right .tools-link { display: none; }
}
@media (max-width: 800px) {
    body.symbol-edit-mode .app .main-content #symbol-mode-panel { width: 220px; flex-basis: 220px; }
    .app .properties-panel { display: none; }
    .app.inspector-open .properties-panel { display: flex; position: absolute; right: 0; top: 0; bottom: 0; width: 285px; max-width: calc(100% - 72px); z-index: 45; box-shadow: -12px 0 28px #0005; }
    .app.library-open .properties-panel { display: none; }
    .header { height: 44px; padding: 0 4px; }
    .header .logo { padding: 0 4px; gap: 4px; font-size: 14px; }
    .workspace-logo { width: 23px; height: 23px; }
    .menu-trigger { padding: 0 7px; font-size: 12px; }
    .header-right .logout-link, .header-right .login-link { padding: 4px; font-size: 11px; }
    .workspace-toolbar { height: 67px; }
    .toolbar-secondary { height: 54px; }
    .primary-toolbar .tool-btn { height: 54px; min-width: 56px; width: 56px; gap: 5px; }
    .workspace-toolbar-actions { gap: 0; padding: 0 3px; }
    .workspace-toolbar-actions .workspace-toolbar-action { min-width: 29px; padding: 4px; }
    .workspace-toolbar-actions .workspace-toolbar-action span { display: none; }
    .workspace-toolbar-actions select { width: 70px; padding: 0 3px; }
    .workspace-status-zoom input[type="range"] { width: 70px; }
    .status-bar { padding: 0 8px; gap: 10px; }
}
@media (max-width: 660px) {
    .header .logo { font-size: 0; }
    .header .workspace-search { display: none; }
    .menu-trigger { padding: 0 6px; }
    .menu-content { position: fixed; top: 44px; left: 8px; }
    :root { --workspace-rail-width: 56px; }
    .workspace-nav-button { min-height: 62px; font-size: 9px; gap: 6px; }
    .workspace-nav-button span { font-size: 8px; }
    .app.library-open .library-panel { left: 56px; max-width: calc(100% - 56px); }
    .app.inspector-open .properties-panel { max-width: calc(100% - 56px); }
    .workspace-toolbar-actions { max-width: 210px; }
    .workspace-status-zoom input[type="range"] { width: 50px; }
    .page-tabs-info { display: none; }
}
@media (max-height: 600px) {
    .workspace-dock { height: 95px; max-height: 25%; }
    .workspace-dock.collapsed { height: 36px; }
    .workspace-nav-button { min-height: 58px; gap: 5px; }
    .toolbar-secondary { height: 54px; }
}

/* Power Sequencing Panel (in Properties panel) */
.power-sequence-panel .power-rails-table {
    font-size: 11px;
}
.btn-tiny {
    padding: 2px 8px;
    font-size: 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}
.btn-tiny:hover {
    opacity: 0.9;
}

/* Modern Modal Styles */
.modern-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.modern-modal-overlay.visible {
    opacity: 1;
}
.modern-modal {
    background: var(--bg-medium);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.2s ease;
}
.modern-modal-overlay.visible .modern-modal {
    transform: scale(1) translateY(0);
}
.modern-modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modern-modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.modern-modal-title {
    flex: 1;
}
.modern-modal-title h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}
.modern-modal-title p {
    font-size: 13px;
    color: var(--text-dim);
    margin: 4px 0 0;
}
.modern-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.modern-modal-close:hover {
    background: var(--bg-light);
    color: var(--text);
}
.modern-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}
.modern-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-dark);
}

/* Modern Buttons */
.modern-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
}
.modern-btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}
.modern-btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-1px);
}
.modern-btn-secondary {
    background: var(--bg-light);
    color: var(--text);
    border: 1px solid var(--border);
}
.modern-btn-secondary:hover {
    background: var(--bg-medium);
    border-color: var(--text-dim);
}
.modern-btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}
.modern-btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
}

/* Confirm Dialog */
.confirm-dialog {
    width: 420px;
}
.confirm-dialog-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.confirm-dialog-icon.warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}
.confirm-dialog-icon.danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}
.confirm-dialog-icon.info {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}
.confirm-dialog-icon svg {
    width: 28px;
    height: 28px;
}
.confirm-dialog-content {
    text-align: center;
    padding: 24px 24px 0;
}
.confirm-dialog-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px;
}
.confirm-dialog-content p {
    font-size: 14px;
    color: var(--text-dim);
    margin: 0;
    line-height: 1.5;
}
.confirm-dialog-actions {
    display: flex;
    gap: 12px;
    padding: 24px;
    justify-content: center;
}
.confirm-dialog-actions .modern-btn {
    min-width: 100px;
    justify-content: center;
}

/* Modern Table */
.modern-table {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.modern-table-header {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-dark);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.modern-table-body {
    max-height: 200px;
    overflow-y: auto;
}
.modern-table-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.modern-table-row:last-child {
    border-bottom: none;
}
.modern-table-row:hover {
    background: rgba(255, 255, 255, 0.03);
}
.rail-seq-num {
    width: 40px;
    color: var(--text-dim);
    font-size: 12px;
}
.rail-name-cell {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}
.rail-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.rail-voltage-cell {
    width: 70px;
    text-align: center;
    color: var(--accent);
    font-size: 13px;
}
.rail-delay-cell {
    width: 90px;
    text-align: center;
}
.rail-enabled-cell {
    width: 60px;
    display: flex;
    justify-content: center;
}

/* Modern Input */
.modern-input {
    width: 60px;
    padding: 6px 8px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    text-align: center;
    transition: border-color 0.15s;
}
.modern-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Modern Toggle */
.modern-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}
.modern-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.modern-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-dark);
    border-radius: 11px;
    transition: 0.2s;
    border: 1px solid var(--border);
}
.modern-toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}
.modern-toggle input:checked + .modern-toggle-slider {
    background: #10b981;
    border-color: #10b981;
}
.modern-toggle input:checked + .modern-toggle-slider:before {
    transform: translateX(18px);
}

/* Modern Section */
.modern-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.modern-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 12px;
}

/* Modern Timeline */
.modern-timeline {
    background: var(--bg-dark);
    border-radius: 10px;
    padding: 16px;
}
.modern-timeline-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.modern-timeline-row:last-child {
    margin-bottom: 0;
}
.timeline-order {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
}
.timeline-label {
    width: 60px;
    font-size: 12px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.timeline-bar-container {
    flex: 1;
    height: 20px;
    background: var(--bg-medium);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}
.timeline-bar-bg {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg, transparent, transparent 10px, rgba(255,255,255,0.03) 10px, rgba(255,255,255,0.03) 20px);
}
.timeline-bar-fill {
    position: absolute;
    top: 2px;
    bottom: 2px;
    border-radius: 8px;
}
.timeline-marker {
    position: absolute;
    top: 4px;
    bottom: 4px;
    width: 3px;
    border-radius: 2px;
    transform: translateX(-50%);
}
.timeline-value {
    width: 45px;
    text-align: right;
    font-size: 11px;
    color: var(--text-dim);
}

/* Modern Empty State */
.modern-empty-state {
    text-align: center;
    padding: 40px 20px;
}
.modern-empty-state p {
    font-size: 16px;
    font-weight: 500;
    margin: 16px 0 8px;
    color: var(--text);
}
.modern-empty-state span {
    font-size: 13px;
    color: var(--text-dim);
}

/* Modern Success State */
.modern-success-state {
    text-align: center;
    padding: 32px 20px;
}
.modern-success-state h3 {
    font-size: 18px;
    margin: 16px 0 8px;
    color: #10b981;
}
.modern-success-state p {
    font-size: 13px;
    color: var(--text-dim);
}

/* Modern Issues List */
.modern-issues-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.modern-issue-card {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
}
.issue-icon {
    flex-shrink: 0;
    padding-top: 2px;
}
.issue-content {
    flex: 1;
}
.issue-type {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.issue-message {
    font-size: 13px;
    color: var(--text);
    margin-top: 4px;
    line-height: 1.5;
}
.issue-component {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
}

/* Modern Toast */
.modern-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    opacity: 0;
    transition: all 0.3s ease;
}
.modern-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Component Library Panel */
.library-panel {
    width: 250px;
    flex-shrink: 0;
    min-height: 0;
    background: linear-gradient(110deg, var(--bg-dark), var(--bg-panel));
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.library-search {
    position: relative;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.library-search > svg { position: absolute; left: 22px; top: 17px; width: 16px; height: 16px; color: var(--text-dim); pointer-events: none; }
.library-search input {
    width: 100%;
    padding: 8px 8px 8px 34px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 12px;
}
.library-categories { flex: 1; min-height: 0; overflow-y: auto; }
.lib-category {
    border-bottom: 1px solid var(--border);
}
.lib-category-header {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.lib-category-header:hover { background: var(--bg-light); }
.lib-category-header svg { width: 12px; height: 12px; transition: transform 0.2s; }
.lib-category.expanded .lib-category-header svg { transform: rotate(90deg); }
.lib-items { display: none; padding: 4px 8px 8px 8px; }
.lib-category.expanded .lib-items { display: block; }
.lib-item {
    width: 100%;
    border: 0;
    background: transparent;
    font-family: inherit;
    text-align: left;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s;
}
.lib-item:hover { background: color-mix(in srgb, var(--accent) 15%, var(--bg-dark)); color: var(--text); }
.lib-item:active { transform: scale(0.98); }
.lib-item.dragging { opacity: 0.5; }

/* Status Bar */
.status-bar {
    height: 34px;
    flex-shrink: 0;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    background: var(--bg-medium);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 11px;
    color: var(--text-dim);
    gap: 16px;
}
.status-item { display: flex; align-items: center; gap: 4px; }

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 1000;
    display: none;
}
.context-menu.visible { display: block; }
.context-menu-item {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.context-menu-item:hover { background: var(--bg-light); }
.context-menu-item.danger { color: #f85149; }
.context-menu-separator { height: 1px; background: var(--border); margin: 4px 0; }
.context-menu-shape-item { display: none; }
.context-menu-wire-item { display: none; }
.context-menu-bus-type-item { display: none; }
.context-menu-output-state-item { display: none; }

/* Route Optimization Overlay */
.optimize-overlay {
    pointer-events: none;
}
.optimize-original-wire {
    stroke: #ff6b6b;
    stroke-width: 3;
    stroke-opacity: 0.4;
    stroke-dasharray: 5,5;
}
.optimize-path-glow {
    stroke: #00ffff;
    stroke-width: 8;
    stroke-opacity: 0.3;
    stroke-linecap: round;
}
.optimize-path-line {
    stroke: #00ffff;
    stroke-width: 3;
    stroke-linecap: round;
}
.optimize-endpoint {
    fill: #00ff88;
    fill-opacity: 0.8;
    stroke: #ffffff;
    stroke-width: 2;
}
.optimize-improvement-label {
    fill: #ffffff;
    font-size: 12px;
    font-weight: bold;
    font-family: system-ui, sans-serif;
}

/* Route Optimization Dialog */
.optimize-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    background: var(--bg-primary, #1a1a2e);
    border: 1px solid var(--border, #333);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    min-width: 300px;
}
.optimize-dialog-content {
    padding: 20px;
}
.optimize-dialog h3 {
    margin: 0 0 16px 0;
    color: var(--text-primary, #ffffff);
    font-size: 16px;
    font-weight: 600;
}
.optimize-stats {
    margin-bottom: 20px;
    padding: 12px;
    background: var(--bg-secondary, #0f0f1a);
    border-radius: 6px;
}
.optimize-stats p {
    margin: 4px 0;
    color: var(--text-secondary, #aaa);
    font-size: 13px;
}
.optimize-stats .improvement {
    color: #00cc66;
    font-weight: 600;
}
.optimize-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.optimize-actions .btn-primary {
    background: #00cc66;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}
.optimize-actions .btn-primary:hover {
    background: #00aa55;
}
.optimize-actions .btn-secondary {
    background: transparent;
    color: var(--text-secondary, #aaa);
    border: 1px solid var(--border, #333);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.optimize-actions .btn-secondary:hover {
    background: var(--bg-light, #2a2a3e);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.modal-overlay.visible { display: flex; }
#confirm-dialog-modal { z-index: 2100; }
/* Navigation views leave their toggle buttons available while open. */
.modal-overlay.workspace-navigation-view { left: var(--workspace-rail-width); }
.modal {
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-width: min(500px, calc(100vw - 24px));
    width: 90%;
    max-height: 85dvh;
    overflow-y: auto;
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 20px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #5a88ff; }
.btn-secondary { background: var(--bg-light); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-medium); }
.modal-close:hover { color: var(--text); }

/* Side Panel (right-side drawer) */
.side-panel-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.2);
    display: none;
    z-index: 2000;
}
.side-panel-overlay.visible { display: block; }
.side-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 320px;
    background: var(--bg-medium);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0,0,0,0.3);
}
.side-panel.right { right: 0; }
.side-panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.side-panel-header h2 { font-size: 14px; font-weight: 600; }
.side-panel-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.side-panel-body::-webkit-scrollbar {
    display: none;
}
.side-panel-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Page Modal */
#page-modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74, 144, 255, 0.15); }
#page-modal-input::placeholder { color: var(--text-dim); }

/* Hidden file input */
#file-input { display: none; }

/* Component styling */
.schematic-object { cursor: pointer; }
.schematic-object:hover { filter: brightness(1.2); }
.symbol { color: #ffcc00; }
.pin-marker { fill: #4a9eff; opacity: 0.9; }
.pin-marker:hover { opacity: 1; }

/* Clickable port reference labels */
.clickable-port-ref {
    cursor: pointer;
    transition: filter 0.15s;
}
.clickable-port-ref:hover {
    filter: brightness(1.4);
}
.clickable-port-ref:hover rect {
    stroke-width: 1;
}

/* Clickable ref/value labels */
.clickable-label {
    cursor: pointer;
    transition: fill 0.15s, filter 0.15s;
}
.clickable-label:hover {
    filter: brightness(1.4);
    text-decoration: underline;
}

/* Selection layer - pass through most events but allow wire handles */
#selection-layer {
    pointer-events: none;  /* Layer itself doesn't capture events */
}
#selection-layer .wire-handle {
    pointer-events: all;   /* Wire handles are still interactive for resizing */
}

/* Selection highlight */
.selected-highlight {
    stroke: #58a6ff;
    stroke-width: 2;
    stroke-dasharray: 5,3;
    fill: rgba(88, 166, 255, 0.1);
    animation: selection-pulse 1.5s ease-in-out infinite;
    pointer-events: none;  /* Allow clicks to pass through to objects below */
}
/* Line-based selection highlight for wires (follows the wire path) */
.selected-highlight-line {
    stroke: #58a6ff;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 8,4;
    fill: none;
    opacity: 0.5;
    animation: selection-pulse 1.5s ease-in-out infinite;
    pointer-events: none;
}
@keyframes selection-pulse {
    0%, 100% { stroke-opacity: 1; }
    50% { stroke-opacity: 0.5; }
}

/* Snap-to-pin indicator animation */
@keyframes snap-pulse {
    0%, 100% { r: 10; opacity: 0.8; }
    50% { r: 14; opacity: 0.5; }
}
.snap-indicator {
    animation: snap-pulse 0.6s ease-in-out infinite;
}
.junction-indicator {
    animation: snap-pulse 0.4s ease-in-out infinite;
}

/* Login Page Styles */
.login-card {
    background: #16213e;
    padding: 40px;
    border-radius: 12px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-card h1 { font-size: 24px; margin-bottom: 8px; color: #4a69bd; }
.login-card p { color: #8892b0; font-size: 14px; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #30363d;
    background: #0d1117;
    color: #c9d1d9;
    border-radius: 6px;
    font-size: 14px;
}
.form-group input:focus { outline: none; border-color: #4a69bd; }
.login-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #4a69bd, #6a89cc);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.login-btn:hover { opacity: 0.9; }
.error { color: #f85149; font-size: 13px; margin-bottom: 16px; }

/* Theme Toggle Button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-dim);
    transition: all 0.2s ease;
}
.theme-toggle:hover {
    background: var(--bg-light);
    color: var(--text);
    border-color: var(--accent);
}
.theme-toggle svg {
    width: 16px;
    height: 16px;
}
.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: block; }
[data-theme="light"] .theme-toggle .sun-icon { display: block; }
[data-theme="light"] .theme-toggle .moon-icon { display: none; }

/* Comment indicator on components */
.comment-indicator {
    cursor: pointer;
}
.comment-indicator circle {
    transition: fill 0.15s, r 0.15s;
}
.comment-indicator:hover circle {
    fill: #ff8c00;
}

/* Comment textarea in properties */
.prop-comment {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    resize: vertical;
    line-height: 1.4;
}
.prop-comment:focus {
    outline: none;
    border-color: var(--accent);
}
.prop-comment::placeholder {
    color: var(--text-dim);
}

/* Comment badge in properties */
.comment-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: var(--comment-indicator);
    color: #fff;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
}

/* Light theme specific adjustments */
[data-theme="light"] .menu-content {
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
[data-theme="light"] .context-menu {
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
[data-theme="light"] .modal {
    background: #ffffff;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

/* Schematic element colors - wire, bus, junction */
.wire-element {
    stroke: var(--wire-color);
}
.wire-element.power-wire {
    stroke: var(--power-wire-color) !important;
    stroke-width: 3 !important;
}
.wire-element.ground-wire {
    stroke: var(--ground-color) !important;
    stroke-width: 3 !important;
}
.bus-element {
    stroke: var(--bus-color);
}
.junction-element {
    fill: var(--junction-color);
    stroke: var(--wire-color);
}

/* Symbol colors for light theme */
[data-theme="light"] .symbol:not(.symbol-color-override) text {
    fill: #1a1a1a;
}
[data-theme="light"] .symbol:not(.no-pop):not(.symbol-color-override) path,
[data-theme="light"] .symbol:not(.no-pop):not(.symbol-color-override) line,
[data-theme="light"] .symbol:not(.no-pop):not(.symbol-color-override) rect,
[data-theme="light"] .symbol:not(.no-pop):not(.symbol-color-override) circle,
[data-theme="light"] .symbol:not(.no-pop):not(.symbol-color-override) polyline,
[data-theme="light"] .symbol:not(.no-pop):not(.symbol-color-override) polygon {
    stroke: #1a1a1a;
}

/* Hide number input spinners */
input.no-spinner::-webkit-outer-spin-button,
input.no-spinner::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input.no-spinner {
    -moz-appearance: textfield;
}

/* Analysis Mode Toggle and Dropdown */
.tool-btn-group {
    display: inline-block;
}

.analysis-layers-dropdown {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    min-width: 180px;
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 64px);
    overflow-y: auto;
    z-index: 1000;
}

.analysis-layers-dropdown .dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.analysis-layers-dropdown .dropdown-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.analysis-layers-dropdown .dropdown-close:hover {
    color: var(--text);
}

.analysis-layers-dropdown .dropdown-body {
    padding: 8px 0;
}

.analysis-layers-dropdown .checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-dim);
    transition: background 0.15s, color 0.15s;
}

.analysis-layers-dropdown .checkbox-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.analysis-layers-dropdown .checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Analysis mode button active state */
#analysis-mode-btn.active {
    background: #238636;
    color: #fff;
}

#analysis-mode-btn.active svg {
    stroke: #fff;
}

/* Analysis overlay visibility classes */
.analysis-hidden {
    display: none !important;
}

/* Analysis layer specific styling */
.analysis-voltage-label {
    pointer-events: none;
}

.analysis-i2c-label {
    pointer-events: none;
}

.analysis-warning-indicator {
    pointer-events: auto;
    cursor: help;
}

.css-part-item {
    width: 100%;
    text-align: left;
    min-height: 48px;
}
.css-part-item small {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 3px;
}
.css-parts-status,
.css-part-feedback {
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}
.css-symbol-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 8px;
}
.css-symbol-choices button {
    font: inherit;
    color: var(--text-primary);
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
}

/* Light theme adjustments */
[data-theme="light"] .analysis-layers-dropdown {
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* =================================
   Simulation Menu Styles
   ================================= */

/* Wider menu content for simulation menu */
.menu-content-wide {
    min-width: 280px;
}

/* Simulation menu badge (in menu trigger) */
.sim-menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 9px;
    margin-left: 6px;
    padding: 0 5px;
    background: #e74c3c;
    color: #fff;
}

.sim-menu-badge.warning {
    background: #f39c12;
}

.sim-menu-badge.ok {
    background: #27ae60;
}

/* Menu section styling */
.sim-menu-section {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.sim-menu-section:last-child {
    border-bottom: none;
}

.sim-menu-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

/* Simulation status */
.sim-menu-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.sim-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.sim-status-badge.sim-status-ok {
    background: rgba(39, 174, 96, 0.2);
    color: #27ae60;
}

.sim-status-badge.sim-status-error {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.sim-status-badge.sim-status-warning {
    background: rgba(243, 156, 18, 0.2);
    color: #f39c12;
}

.sim-status-badge.sim-status-idle {
    background: rgba(139, 148, 158, 0.2);
    color: var(--text-dim);
}

/* Warnings section */
.sim-menu-warnings {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sim-warning-count {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.sim-warning-count.critical {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

.sim-warning-count.warning {
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
}

.sim-warning-count.info {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent);
}

.sim-no-warnings {
    color: #27ae60;
    font-size: 12px;
    padding: 4px 0;
}

/* Warning list */
.sim-menu-warning-list {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.sim-warning-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    margin: 2px 0;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.15s;
}

.sim-warning-item:hover {
    background: var(--bg-hover);
}

.sim-warning-item.critical {
    background: rgba(231, 76, 60, 0.1);
}

.sim-warning-item.warning {
    background: rgba(243, 156, 18, 0.1);
}

.sim-warning-item .warning-icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.sim-warning-item .warning-text {
    flex: 1;
    color: var(--text);
}

.sim-warning-item .warning-location {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* Wire loading section */
.sim-menu-wire-loading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

.sim-menu-edit-btn {
    padding: 4px 10px;
    font-size: 11px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.sim-menu-edit-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

/* Clickable net list in simulation menu */
.sim-net-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s;
}

.sim-net-item:hover {
    background: var(--bg-hover, rgba(255,255,255,0.1));
}

.sim-net-item:hover .net-name {
    color: var(--accent);
}

.sim-net-item .net-name {
    color: var(--text);
    font-weight: 500;
}

.sim-net-item .net-cap {
    color: var(--text-dim);
    font-size: 10px;
}

/* Data status legend */
.sim-menu-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sim-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-dim);
}

.sim-legend-label {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

/* Actions section */
.sim-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sim-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.sim-action-btn:hover {
    background: var(--bg-hover);
}

.sim-action-btn svg {
    width: 14px;
    height: 14px;
    stroke: var(--text-dim);
}

.sim-action-btn .shortcut {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-dim);
    background: var(--bg-light);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Light theme adjustments for simulation menu */
[data-theme="light"] .sim-status-badge.sim-status-ok {
    background: rgba(39, 174, 96, 0.15);
}

[data-theme="light"] .sim-warning-count.critical {
    background: rgba(231, 76, 60, 0.12);
}

[data-theme="light"] .sim-warning-count.warning {
    background: rgba(243, 156, 18, 0.12);
}

/* =================================
   Help Modal - Tabbed Navigation
   ================================= */

/* Tutorial banner at top of help modal */
.help-tutorial-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.1), rgba(88, 166, 255, 0.05));
    border-bottom: 1px solid var(--border);
}
.tutorial-banner-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tutorial-banner-text strong {
    font-size: 14px;
    color: var(--text);
}
.tutorial-banner-text span {
    font-size: 12px;
    color: var(--text-dim);
}
.help-tutorial-banner .btn {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.help-tutorial-banner .btn svg {
    flex-shrink: 0;
}

/* Tab navigation bar */
.help-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 20px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.help-tabs::-webkit-scrollbar {
    display: none;
}

/* Individual tab buttons */
.help-tab {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.help-tab:hover {
    background: var(--bg-light);
    color: var(--text);
}
.help-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Tab content panels */
.help-panel {
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Quick Start header */
.quickstart-header {
    text-align: center;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.quickstart-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px 0;
}
.quickstart-header p {
    font-size: 14px;
    color: var(--text-dim);
    margin: 0;
}

/* Quick Start steps */
.quick-start-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.quick-start-step {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color 0.15s;
}
.quick-start-step:hover {
    border-color: var(--accent);
}
.step-number {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
}
.step-content h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 6px 0;
}
.step-content p {
    font-size: 13px;
    color: var(--text-dim);
    margin: 0;
    line-height: 1.5;
}
.step-content kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-family: monospace;
    font-size: 11px;
    color: var(--text);
}

/* Shortcuts table */
.shortcut-table {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.shortcut-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    font-size: 12px;
    color: var(--text-dim);
}
.shortcut-row kbd {
    display: inline-block;
    min-width: 70px;
    padding: 4px 8px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
    color: var(--text);
    text-align: center;
}
.shortcut-row span {
    color: var(--text);
}

/* Feature grid for Tools tab */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}
.feature-card {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.feature-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: var(--bg-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}
.feature-icon svg {
    stroke: currentColor;
    fill: none;
}
.feature-text strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.feature-text span {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.4;
}

/* Help text and list styling */
.help-text {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 12px;
    line-height: 1.5;
}
.help-list {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.8;
}
.help-list li {
    margin-bottom: 4px;
}
.help-list strong {
    color: var(--text);
}
.help-list kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-family: monospace;
    font-size: 11px;
    color: var(--text);
}

/* Category grid for Library tab */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}
.category-item {
    padding: 12px 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.category-item strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
}
.category-item span {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.4;
}

/* Analysis layers list */
.analysis-layers-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}
.analysis-layer-item {
    padding: 10px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.analysis-layer-item strong {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.analysis-layer-item span {
    font-size: 11px;
    color: var(--text-dim);
}

/* Storage comparison for Files tab */
.storage-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.storage-option {
    padding: 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.storage-option.highlight {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.05);
}
.storage-option h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 12px 0;
}
.storage-option.highlight h4 {
    color: var(--accent);
}
.storage-option .help-list {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
}

/* Export formats */
.export-formats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.export-format {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.export-format strong {
    min-width: 60px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}
.export-format span {
    font-size: 12px;
    color: var(--text-dim);
}

/* =================================
   Interactive Tutorial Overlay
   ================================= */

/* Main overlay - covers entire screen */
.tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none;
}

/* Spotlight effect - highlights target element */
.tutorial-spotlight {
    position: absolute;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75);
    border-radius: 8px;
    transition: all 0.3s ease;
    pointer-events: none;
}
.tutorial-spotlight::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid var(--accent);
    border-radius: 12px;
    animation: spotlight-pulse 1.5s ease-in-out infinite;
}
@keyframes spotlight-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Tooltip */
.tutorial-tooltip {
    position: absolute;
    width: 320px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    animation: tooltip-appear 0.3s ease;
}
@keyframes tooltip-appear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tooltip header */
.tutorial-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.tutorial-step-indicator {
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tutorial-close {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.tutorial-close:hover {
    background: var(--bg-light);
    color: var(--text);
}

/* Tooltip content */
.tutorial-tooltip h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 16px 16px 8px;
}
.tutorial-tooltip p {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.6;
    margin: 0 16px 16px;
}

/* Progress dots */
.tutorial-progress {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
}
.tutorial-dot {
    width: 8px;
    height: 8px;
    background: var(--bg-light);
    border-radius: 50%;
    transition: all 0.2s;
}
.tutorial-dot.active {
    background: var(--accent);
    transform: scale(1.2);
}
.tutorial-dot.completed {
    background: rgba(88, 166, 255, 0.5);
}

/* Navigation buttons */
.tutorial-nav {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-dark);
    border-radius: 0 0 12px 12px;
}
.tutorial-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}
.tutorial-btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    margin-left: auto;
}
.tutorial-btn-primary:hover {
    background: var(--accent-hover);
}
.tutorial-btn-secondary {
    background: var(--bg-light);
    color: var(--text);
    border-color: var(--border);
}
.tutorial-btn-secondary:hover {
    background: var(--bg-medium);
}
.tutorial-btn-end {
    background: rgba(248, 81, 73, 0.1);
    color: #f85149;
    border-color: rgba(248, 81, 73, 0.3);
}
.tutorial-btn-end:hover {
    background: rgba(248, 81, 73, 0.2);
}
.tutorial-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Light theme adjustments */
[data-theme="light"] .tutorial-spotlight {
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
}
[data-theme="light"] .tutorial-tooltip {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

/* Automatic color rules keep each rule target visually and semantically distinct. */
.automatic-color-rules-dialog {
    width: min(980px, 96vw);
    max-height: 88dvh;
    overflow: auto;
    background: var(--bg-panel, #1b2028);
    color: var(--text, #fff);
    border: 1px solid var(--border, #3b4350);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.automatic-color-rules-dialog h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.automatic-color-rules-help {
    margin: 0 0 16px;
    color: var(--text-dim, #aab4c2);
    line-height: 1.45;
}

.automatic-color-rules-header,
.automatic-color-rule {
    display: grid;
    grid-template-columns: 32px minmax(170px, 1.35fr) minmax(115px, 0.8fr) minmax(150px, 1fr) 58px 126px;
    gap: 8px;
    align-items: center;
}

.automatic-color-rules-header {
    padding: 0 4px 5px;
    color: var(--text-dim, #aab4c2);
    font-size: 13px;
    font-weight: 600;
}

.automatic-color-rule {
    margin: 8px 0;
}

.automatic-color-rule select,
.automatic-color-rule input[type="text"] {
    min-width: 0;
    min-height: 38px;
    padding: 7px 9px;
    font-size: 13px;
    color: var(--text);
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.automatic-color-rule .rule-enabled {
    width: 20px;
    height: 20px;
    justify-self: center;
}

.automatic-color-rule .rule-color {
    width: 54px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-light);
}

.automatic-color-rule-actions {
    display: grid;
    grid-template-columns: repeat(3, 36px);
    gap: 6px;
}

.automatic-color-rule-action {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    background: var(--bg-light);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.automatic-color-rule-action:hover {
    background: var(--bg-medium);
}

.automatic-color-rule-remove {
    color: #ff8b86;
}

.automatic-color-rules-footer {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    margin-top: 18px;
}

.automatic-color-rules-footer > span {
    display: flex;
    gap: 8px;
}

.automatic-color-rules-footer .btn {
    min-height: 40px;
    font-size: 14px;
}

@media (max-width: 800px) {
    .automatic-color-rules-header {
        display: none;
    }

    .automatic-color-rule {
        grid-template-columns: 32px minmax(150px, 1fr) minmax(110px, 0.75fr) 58px;
        grid-template-areas:
            "enabled target mode color"
            "value value actions actions";
        padding: 10px 0;
        border-top: 1px solid var(--border);
    }

    .automatic-color-rule .rule-enabled { grid-area: enabled; }
    .automatic-color-rule .rule-target { grid-area: target; }
    .automatic-color-rule .rule-mode { grid-area: mode; }
    .automatic-color-rule .rule-value { grid-area: value; }
    .automatic-color-rule .rule-color { grid-area: color; }
    .automatic-color-rule-actions { grid-area: actions; justify-self: end; }
}

@media (max-width: 520px) {
    .automatic-color-rules-dialog {
        width: 98vw;
        max-height: 94dvh;
        padding: 14px;
    }

    .automatic-color-rule {
        grid-template-columns: 32px minmax(0, 1fr) 58px;
        grid-template-areas:
            "enabled target target"
            "mode mode color"
            "value value value"
            "actions actions actions";
    }

    .automatic-color-rule-actions {
        justify-self: start;
    }

    .automatic-color-rules-footer,
    .automatic-color-rules-footer > span {
        flex-wrap: wrap;
    }
}

/* Admin-only AI assistant panel: docks beside the inspector without covering canvas. */
.assistant-panel {
    width: 300px;
    flex: 0 0 300px;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    overflow: hidden;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    font-size: 12px;
    color: var(--text);
}
.assistant-panel[hidden] { display: none; }
.assistant-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.assistant-heading { display: flex; align-items: center; gap: 7px; min-width: 0; }
.assistant-title { font-weight: 650; font-size: 13px; }
.assistant-presence { color: var(--success); font-size: 9px; }
.assistant-model-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.assistant-model-row .assistant-field-label { flex: 0 0 auto; color: var(--text-dim); }
.assistant-model-row .assistant-model { flex: 1 1 auto; min-width: 0; padding: 5px 8px; }
.assistant-image-profile {
    color: var(--text-dim);
    font-size: 10px;
    line-height: 1.35;
}
.assistant-status {
    padding: 2px 4px;
    color: var(--text-dim);
    min-height: 18px;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.assistant-conversation {
    flex: 1 1 auto;
    min-height: 120px;
    overflow-y: auto;
    border-block: 1px solid var(--border);
    padding: 12px 4px;
    background: color-mix(in srgb, var(--bg-dark) 72%, transparent);
    scrollbar-gutter: stable;
}
.assistant-message {
    width: fit-content;
    max-width: 92%;
    margin: 0 0 10px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--bg-medium);
    box-shadow: 0 2px 8px #0002;
}
.assistant-message-user {
    margin-left: auto;
    border-bottom-right-radius: 3px;
    border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
    background: color-mix(in srgb, var(--accent) 18%, var(--bg-medium));
}
.assistant-message-assistant {
    margin-right: auto;
    border-bottom-left-radius: 3px;
}
.assistant-message-meta {
    margin-bottom: 4px;
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 650;
    letter-spacing: .02em;
}
.assistant-message-body {
    color: var(--text);
    line-height: 1.45;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}
.assistant-message-attachment {
    display: block;
    margin-top: 7px;
    padding: 4px 7px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--bg-dark) 70%, transparent);
    color: var(--text-dim);
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.assistant-message-pending { opacity: .9; }
.assistant-progress-body::after {
    content: '  •••';
    color: var(--accent);
    animation: assistant-pulse 1.2s ease-in-out infinite;
}
@keyframes assistant-pulse {
    0%, 100% { opacity: .35; }
    50% { opacity: 1; }
}
.assistant-model,
.assistant-input,
.assistant-attachments {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 12px;
    padding: 8px;
}
.assistant-composer {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.assistant-input { min-height: 68px; max-height: 160px; resize: vertical; line-height: 1.4; }
.assistant-attachments {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.assistant-attachment-list { display: flex; flex-direction: column; gap: 6px; }
.assistant-attachment {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 7px;
    background: var(--bg-medium);
}
.assistant-attachment-preview { width: 30px; height: 30px; border-radius: 4px; object-fit: cover; }
.assistant-attachment-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.assistant-attachment-remove {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
}
.assistant-attachment-remove:hover { background: var(--bg-light); color: var(--text); }
.assistant-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 6px;
}
.assistant-controls button,
.assistant-attach-button {
    flex: 1 1 auto;
    min-height: 30px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-light);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    user-select: none;
}
.assistant-controls .assistant-send { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
.assistant-controls .assistant-build {
    flex-basis: 100%;
    background: color-mix(in srgb, var(--success, #2ea043) 24%, var(--bg-light));
    border-color: var(--success, #2ea043);
    font-weight: 650;
}
.assistant-controls button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
@media (max-width: 1050px) {
    .assistant-panel {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 300px;
        max-width: calc(100% - var(--workspace-rail-width));
        z-index: 44;
        box-shadow: -12px 0 28px #0005;
    }
}
@media (max-width: 660px) {
    .assistant-panel { width: 260px; flex-basis: 260px; }
}
@media (max-height: 600px) {
    .assistant-panel { gap: 6px; padding: 8px; overscroll-behavior: contain; }
    .assistant-conversation { min-height: 56px; }
    .assistant-input { min-height: 44px; }
    .assistant-status { display: none; }
}
/* Opt-in diagnostic recording and read-only admin replay. */
.debug-session-action.active {
    color: #fff;
    background: #b4232f;
    border-color: #ef6370;
}

.debug-session-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: max-content;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--border-color, #344658);
    border-radius: 0.4rem;
    color: var(--text-primary, #eef5fc);
    font-size: 0.78rem;
}

.debug-session-indicator[hidden] {
    display: none;
}

.debug-session-indicator button {
    border: 0;
    background: transparent;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.debug-record-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: #ef4052;
    box-shadow: 0 0 0 0 rgba(239, 64, 82, 0.5);
    animation: debug-record-pulse 1.5s infinite;
}

.debug-session-indicator.sending .debug-record-dot {
    background: #58a6ff;
    animation: none;
}

@keyframes debug-record-pulse {
    70% { box-shadow: 0 0 0 0.45rem rgba(239, 64, 82, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 64, 82, 0); }
}

.debug-consent-dialog,
.debug-feedback-dialog,
.debug-reports-dialog {
    width: min(92vw, 42rem);
    max-height: 88vh;
    overflow: auto;
    padding: 1.25rem;
}

.debug-feedback-dialog {
    width: min(92vw, 38rem);
}

.debug-feedback-dialog label {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.9rem;
    font-weight: 600;
}

.debug-feedback-comment {
    width: 100%;
    min-height: 7rem;
    resize: vertical;
    padding: 0.65rem;
    border: 1px solid var(--border-color, #344658);
    border-radius: 0.4rem;
    background: var(--surface-elevated, #13202d);
    color: inherit;
    font: inherit;
    font-weight: 400;
}

.debug-feedback-hint,
.debug-feedback-error {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
}

.debug-feedback-hint {
    opacity: 0.75;
}

.debug-feedback-error {
    color: #ff7b72;
}

.debug-feedback-images,
.debug-report-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: 0.65rem;
    margin-top: 0.65rem;
}

.debug-feedback-image {
    display: grid;
    gap: 0.35rem;
    min-width: 0;
    padding: 0.4rem;
    border: 1px solid var(--border-color, #344658);
    border-radius: 0.4rem;
}

.debug-feedback-image img,
.debug-report-images img {
    display: block;
    width: 100%;
    height: 6rem;
    object-fit: contain;
    border-radius: 0.25rem;
    background: #07131e;
}

.debug-feedback-image span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
}

.debug-feedback-image button,
.debug-report-delete {
    border: 1px solid #cf4655;
    border-radius: 0.35rem;
    background: transparent;
    color: #ff9aa5;
    cursor: pointer;
}

.debug-modal-actions .btn-danger,
.debug-reports-header .btn-danger {
    border-color: #cf4655;
    background: #8f1d2c;
    color: #fff;
}

.debug-reports-dialog {
    width: min(96vw, 75rem);
    max-width: min(96vw, 75rem);
}

.debug-modal-actions,
.debug-reports-header,
.debug-replay-controls {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.debug-modal-actions {
    justify-content: flex-end;
    margin-top: 1rem;
}

.debug-reports-header {
    justify-content: space-between;
}

.debug-reports-header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.debug-reports-body {
    display: grid;
    grid-template-columns: minmax(14rem, 20rem) 1fr;
    gap: 1rem;
    min-height: 28rem;
}

.debug-report-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    overflow: auto;
}

.debug-report-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.65rem;
    border: 1px solid var(--border-color, #344658);
    border-radius: 0.4rem;
    background: var(--surface-elevated, #13202d);
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.debug-report-row-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.35rem;
}

.debug-report-row-wrap .debug-report-row {
    min-width: 0;
}

.debug-report-delete {
    padding: 0.45rem;
}

.debug-report-row span {
    opacity: 0.75;
    font-size: 0.78rem;
}

.debug-report-viewer {
    min-width: 0;
    overflow: hidden;
}

.debug-report-feedback {
    margin-bottom: 0.65rem;
    padding: 0.65rem;
    border: 1px solid var(--border-color, #344658);
    border-radius: 0.4rem;
    background: var(--surface-elevated, #13202d);
}

.debug-report-feedback h3,
.debug-report-feedback p {
    margin: 0;
}

.debug-report-feedback p {
    margin-top: 0.4rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.debug-replay-controls {
    flex-wrap: wrap;
    margin-bottom: 0.65rem;
}

.debug-replay-controls input[type="range"] {
    flex: 1 1 14rem;
}

.debug-replay-controls button {
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--border-color, #344658);
    border-radius: 0.35rem;
    background: var(--surface-elevated, #13202d);
    color: inherit;
    cursor: pointer;
}

.debug-replay-controls button:disabled {
    cursor: default;
    opacity: 0.45;
}

.debug-replay-canvas {
    display: block;
    width: 100%;
    height: 24rem;
    border: 1px solid var(--border-color, #344658);
    background: #07131e;
}

.debug-replay-detail {
    max-height: 16rem;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (max-width: 800px) {
    .debug-reports-body {
        grid-template-columns: 1fr;
    }
}
