/* ============================================
   Roomwork - Professional CAD-Style CSS
   ============================================ */

:root {
    /* The colours are set on the root by the ThemeManager from the table in src/render/themes.js (--bg-*, --border-*, --text-*,
       --accent-*, --constraint-*, tints, overlay, shadows, --focus-width, --panel-width, --canvas-bg) and --text-scale, the size
       of the text of the page (every font size here is calc(Npx * var(--text-scale))) */
    --primary: var(--accent-fill);
    --border-color: var(--border-default);

    /* Typography */
    --font-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --toolbar-height: 52px;
    --status-height: 32px;

    /* Effects */
    --transition-fast: 0.1s ease;
    --transition-normal: 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-ui);
    font-size: calc(13px * var(--text-scale));
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ============================================
   Toolbar
   ============================================ */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--toolbar-height);
    padding: 0 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    gap: 8px;
    flex-shrink: 0;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: calc(14px * var(--text-scale));
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.logo svg {
    color: var(--accent-primary);
}

.tool-group {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 3px;
    gap: 2px;
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.tool-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tool-btn.active {
    background: var(--accent-fill);
    color: white;
}

.tool-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
    margin: 0 4px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    min-width: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: calc(12px * var(--text-scale));
    font-weight: 500;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.action-btn:not(:has(span)) {
    width: 34px;
    padding: 0;
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-default);
}

.action-btn.primary {
    background: var(--accent-fill);
    border-color: var(--accent-fill);
    color: white;
}

.action-btn.primary:hover {
    background: var(--accent-fill-hover);
    border-color: var(--accent-fill-hover);
}

/* Related buttons joined into one segmented control */
.button-group {
    display: flex;
    align-items: center;
}

.button-group .action-btn,
.button-group .history-wrap {
    border-radius: 0;
}

.button-group > :not(:first-child) .action-btn,
.button-group > .action-btn:not(:first-child) {
    margin-left: -1px;
}

.button-group > :first-child,
.button-group > :first-child.action-btn {
    border-radius: 6px 0 0 6px;
}

.button-group > :last-child,
.button-group > :last-child .action-btn {
    border-radius: 0 6px 6px 0;
}

.button-group .action-btn:hover,
.button-group .action-btn:focus-visible {
    position: relative;
    z-index: 1;
}

.btn.btn-danger {
    color: var(--accent-error);
    border-color: var(--error-border);
}

.btn.btn-danger:hover {
    background: var(--error-tint);
    border-color: var(--accent-error);
}

.action-btn.danger:hover {
    background: var(--error-tint);
    border-color: var(--accent-error);
    color: var(--accent-error);
}

/* Toolbar groups: the item used last, an arrow, and the list of the group */
.toolbar-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.split {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 3px;
    gap: 1px;
}

.split-main, .split-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.split-main {
    width: 34px;
    border-radius: 4px 0 0 4px;
}

.split-arrow {
    width: 18px;
    border-radius: 0 4px 4px 0;
}

.split-arrow::after {
    content: "";
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
}

.split-main:hover, .split-arrow:hover, .split-arrow[aria-expanded="true"] {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.split.active .split-main {
    background: var(--accent-fill);
    color: white;
}

.flyout, .more-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 2000;
    min-width: 250px;
    padding: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.flyout[hidden], .more-menu[hidden] {
    display: none;
}

.flyout-title {
    margin: 4px 8px 6px;
    color: var(--text-tertiary);
    font-size: calc(10px * var(--text-scale));
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.flyout .flyout-item, .more-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 32px;
    padding: 0 8px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: calc(12px * var(--text-scale));
    text-align: left;
    cursor: pointer;
}

.flyout .flyout-item:hover, .more-item:hover {
    background: var(--bg-hover);
}

.flyout .flyout-item svg {
    flex: none;
    color: var(--text-secondary);
}

.flyout .flyout-item.current {
    background: var(--accent-tint, var(--bg-hover));
}

.flyout .flyout-item.active {
    background: var(--accent-fill);
    color: white;
}

.flyout .flyout-item.active svg {
    color: inherit;
}

.flyout-label {
    flex: 1;
}

.flyout kbd, .palette kbd {
    padding: 0 5px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: calc(11px * var(--text-scale));
}

.flyout .flyout-item.active kbd {
    background: transparent;
    border-color: currentColor;
    color: inherit;
}

/* The more menu */
.more-wrap {
    position: relative;
}

.more-menu {
    left: auto;
    right: 0;
    min-width: 200px;
}

.more-item.current {
    background: var(--accent-tint, var(--bg-hover));
    font-weight: 600;
}

.more-item.danger {
    color: var(--accent-error);
}

.more-item.danger:hover {
    background: var(--error-tint);
}

.more-divider {
    margin: 4px 0;
    border: 0;
    border-top: 1px solid var(--border-subtle);
}

/* The command search */
.palette-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 12vh;
    background: var(--overlay, rgba(0, 0, 0, 0.4));
}

.palette-overlay[hidden] {
    display: none;
}

.palette {
    display: flex;
    flex-direction: column;
    width: min(560px, calc(100vw - 32px));
    max-height: 60vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.palette input {
    height: 44px;
    padding: 0 16px;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: calc(14px * var(--text-scale));
    outline: none;
}

.palette ul {
    list-style: none;
    overflow-y: auto;
    padding: 6px;
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 34px;
    padding: 0 10px;
    border-radius: 5px;
    color: var(--text-primary);
    cursor: pointer;
}

.palette-item.selected {
    background: var(--accent-fill);
    color: white;
}

.palette-label {
    flex: 1;
}

.palette-group {
    color: var(--text-tertiary);
    font-size: calc(11px * var(--text-scale));
}

.palette-item.selected .palette-group {
    color: inherit;
}

.palette-item.selected kbd {
    background: transparent;
    border-color: currentColor;
    color: inherit;
}

.palette-empty {
    padding: 14px 10px;
    color: var(--text-tertiary);
    text-align: center;
}

/* Narrow windows: labels go first, then the name of the furniture list */
@media (max-width: 1100px) {
    .btn-label:not(.btn-label-keep) {
        display: none;
    }
    .toolbar-tools, .toolbar-right {
        gap: 4px;
    }
}

@media (max-width: 900px) {
    .logo span, .furniture-picker .furniture-name, .furniture-picker .furniture-caret {
        display: none;
    }
    .furniture-picker {
        min-width: 0;
    }
    .toolbar {
        padding: 0 8px;
        gap: 4px;
    }
    .split-main, .tool-btn {
        width: 30px;
    }
    .split-arrow {
        width: 14px;
    }
    .toolbar-tools {
        gap: 4px;
    }
}

@media (max-width: 760px) {
    .btn-label {
        display: none;
    }
}

/* ============================================
   Main Content Layout
   ============================================ */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Panels */
.panel {
    width: var(--panel-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.panel-right {
    border-right: none;
    border-left: 1px solid var(--border-subtle);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.panel-header h3 {
    font-size: calc(11px * var(--text-scale));
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.panel-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.panel-action.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.panel-actions {
    display: flex;
    gap: 2px;
}

.panel-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.panel-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 12px;
}

.panel-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
    color: var(--text-tertiary);
    gap: 12px;
}

.empty-state svg {
    opacity: 0.5;
}

.empty-state p {
    font-size: calc(12px * var(--text-scale));
    line-height: 1.5;
}

/* ============================================
   Canvas Container
   ============================================ */
.canvas-container {
    flex: 1;
    position: relative;
    background: var(--canvas-bg);
    overflow: hidden;
}

#mainCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Dimension Input Overlay */
/* Status Bar */
.status-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--status-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 12px;
    font-size: calc(11px * var(--text-scale));
    z-index: 10;
}

.status-left, .status-center, .status-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.status-item {
    white-space: nowrap;
}

.status-hint {
    color: var(--text-tertiary);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.snap-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.snap-icon.active {
    background: var(--accent-success);
    box-shadow: 0 0 6px var(--accent-success);
}

.zoom-btn {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: calc(14px * var(--text-scale));
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

#zoomSlider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
}

#zoomSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
}

/* ============================================
   Properties Panel Content
   ============================================ */
.property-group {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.property-group:last-of-type {
    border-bottom: none;
}

.property-group-title {
    font-size: calc(11px * var(--text-scale));
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.property-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 26px;
    margin-bottom: 4px;
}

/* a row of small buttons that wraps in a narrow panel (align, distribute) */
.property-row.arrange {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
}

.property-label {
    font-size: calc(12px * var(--text-scale));
    color: var(--text-secondary);
}

.layer-row {
    display: grid;
    grid-template-columns: 1fr 40px 40px 40px;
    align-items: center;
    justify-items: center;
    min-height: 26px;
    margin-bottom: 2px;
}

.layer-row > :first-child {
    justify-self: start;
}

.layer-head {
    min-height: 18px;
    font-size: calc(10px * var(--text-scale));
    color: var(--text-tertiary);
}

.layer-name {
    display: block;
    font-family: var(--font-mono);
    font-size: calc(10px * var(--text-scale));
    color: var(--text-tertiary);
}

.layer-row input[type="color"] {
    width: 28px;
    height: 20px;
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    background: none;
    cursor: pointer;
}

.property-value {
    font-family: var(--font-mono);
    font-size: calc(12px * var(--text-scale));
    color: var(--text-primary);
}

.property-input {
    width: 88px;
    padding: 4px 6px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: calc(12px * var(--text-scale));
    text-align: right;
}

/* The furniture picker: a button with the symbol of the chosen item, and its list */
.furniture-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    min-width: 150px;
    padding: 0 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font: inherit;
    font-size: calc(12px * var(--text-scale));
    cursor: pointer;
}

.furniture-picker:hover {
    background: var(--bg-hover);
}

.furniture-picker .furniture-name {
    flex: 1;
    text-align: left;
    white-space: nowrap;
}

.furniture-caret {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-tertiary);
}

.furniture-symbol {
    flex: none;
    width: 40px;
    height: 28px;
    color: var(--furniture-color, var(--text-primary));
}

.furniture-picker .furniture-symbol {
    width: 30px;
    height: 22px;
}

.furniture-menu {
    position: fixed;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    width: 300px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.furniture-menu[hidden] {
    display: none;
}

.furniture-search {
    margin: 8px;
    height: 30px;
    padding: 0 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    font: inherit;
    font-size: calc(12px * var(--text-scale));
}

.furniture-list {
    overflow-y: auto;
    padding: 0 4px 6px;
}

.furniture-heading {
    padding: 8px 8px 4px;
    color: var(--text-tertiary);
    font-size: calc(10px * var(--text-scale));
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.furniture-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: calc(12px * var(--text-scale));
    text-align: left;
    cursor: pointer;
}

.furniture-option:hover, .furniture-option:focus-visible {
    background: var(--bg-hover);
}

.furniture-option[aria-selected="true"] {
    background: var(--accent-fill);
    color: white;
}

.furniture-option .furniture-name {
    flex: 1;
}

.furniture-size {
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: calc(10px * var(--text-scale));
}

.furniture-option[aria-selected="true"] .furniture-size {
    color: inherit;
}

.furniture-empty {
    padding: 16px 8px;
    color: var(--text-tertiary);
    text-align: center;
}

select.property-input,
.property-input.property-text {
    width: 170px;
    text-align: left;
}

.property-input:disabled {
    opacity: 0.55;
}

.panel-intro {
    margin: 0 0 12px;
}

.panel-hint {
    margin-top: 6px;
    font-size: calc(11px * var(--text-scale));
    line-height: 1.4;
    color: var(--text-tertiary);
}

.property-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 calc(var(--focus-width) - 2px) var(--accent-primary);
}

.property-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.property-unit {
    min-width: 2.4em;
    font-size: calc(11px * var(--text-scale));
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.constraint-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: calc(10px * var(--text-scale));
    font-weight: 500;
    text-transform: uppercase;
}

.constraint-badge.horizontal {
    color: var(--constraint-horizontal);
    border: 1px solid var(--constraint-horizontal);
}

.constraint-badge.vertical {
    color: var(--constraint-vertical);
    border: 1px solid var(--constraint-vertical);
}

.constraint-badge.length {
    color: var(--constraint-length);
    border: 1px solid var(--constraint-length);
}

.constraint-badge.angle {
    color: var(--constraint-angle);
    border: 1px solid var(--constraint-angle);
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.preset-btn {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: calc(11px * var(--text-scale));
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.15s ease;
}

.preset-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--primary);
}

.preset-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.lock-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-left: 4px;
    flex-shrink: 0;
}

.lock-btn:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-color: var(--primary);
}

.lock-btn.locked {
    background: var(--constraint-length);
    color: white;
    border-color: var(--constraint-length);
}

.constraint-toggles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 4px;
}

.constraint-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: calc(12px * var(--text-scale));
    cursor: pointer;
    transition: all 0.15s ease;
}

.constraint-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--text-tertiary);
}

.constraint-toggle .constraint-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-weight: 600;
    font-size: calc(11px * var(--text-scale));
    font-family: var(--font-mono);
}

.constraint-toggle .constraint-name {
    font-size: calc(11px * var(--text-scale));
}

.constraint-toggle.active {
    border-color: var(--primary);
    background: var(--accent-tint);
}

.constraint-toggle.active .constraint-letter {
    background: var(--primary);
    color: white;
}

/* Specific constraint colors when active */
.constraint-toggle#toggleH.active .constraint-letter {
    background: var(--constraint-horizontal);
}

.constraint-toggle#toggleV.active .constraint-letter {
    background: var(--constraint-vertical);
}

.constraint-toggle#toggleL.active .constraint-letter {
    background: var(--constraint-length);
}

.constraint-toggle#toggleA.active .constraint-letter {
    background: var(--constraint-angle);
}

/* ============================================
   Element List
   ============================================ */
.element-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 2px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.element-list-item:hover {
    background: var(--bg-hover);
}

.room-group {
    margin-bottom: 6px;
}

.room-group .room-row {
    margin-bottom: 0;
    padding-left: 6px;
}

.room-toggle,
.room-toggle-spacer {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.room-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.room-toggle:hover {
    background: var(--hover-overlay);
}

.room-toggle svg {
    transition: transform var(--transition-fast);
}

.room-toggle.expanded svg {
    transform: rotate(90deg);
}

.room-children {
    margin: 2px 0 0 18px;
    padding-left: 8px;
    border-left: 1px solid var(--border-default);
}

.room-children .element-list-item {
    background: transparent;
    padding: 6px 8px;
}

.room-children .element-list-item:hover {
    background: var(--bg-hover);
}

.room-children .element-list-item.selected {
    background: var(--accent-fill);
}

.wall-children {
    margin: 0 0 2px 18px;
    padding-left: 8px;
    border-left: 1px solid var(--border-default);
}

.element-count {
    min-width: 18px;
    padding: 1px 6px;
    border-radius: 9px;
    background: var(--bg-active);
    color: var(--text-secondary);
    font-size: calc(10px * var(--text-scale));
    font-weight: 600;
    text-align: center;
}

.element-list-item.selected .element-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.element-list-item.selected {
    background: var(--accent-fill);
    color: white;
}

.element-list-item.selected .element-type {
    color: rgba(255, 255, 255, 0.85);
}

.element-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.element-list-item.selected .element-icon {
    color: white;
}

.element-info {
    flex: 1;
    min-width: 0;
}

.element-name {
    font-size: calc(12px * var(--text-scale));
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.element-type {
    font-size: calc(10px * var(--text-scale));
    color: var(--text-tertiary);
}

.element-constraints {
    display: flex;
    gap: 4px;
}

.constraint-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.constraint-dot.horizontal {
    background: var(--constraint-horizontal);
}

.constraint-dot.vertical {
    background: var(--constraint-vertical);
}

.constraint-dot.length {
    background: var(--constraint-length);
}

.constraint-dot.angle {
    background: var(--constraint-angle);
}

/* Constraints Legend */
.constraint-info {
    padding: 12px;
}

.constraint-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: calc(11px * var(--text-scale));
    color: var(--text-secondary);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.legend-color.constrained {
    background: var(--constraint-locked);
}

.legend-color.unconstrained {
    background: var(--unconstrained);
    border: 1px dashed var(--text-tertiary);
}

/* ============================================
   Context Menu
   ============================================ */
.context-menu {
    position: fixed;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    padding: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: calc(12px * var(--text-scale));
    text-align: left;
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.context-item:hover {
    background: var(--bg-hover);
}

.context-item svg {
    color: var(--text-tertiary);
}

.context-item .shortcut {
    margin-left: auto;
    font-size: calc(10px * var(--text-scale));
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.context-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 8px;
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal {
    width: 320px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h4 {
    font-size: calc(14px * var(--text-scale));
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: calc(20px * var(--text-scale));
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
}

.input-group {
    margin-bottom: 16px;
}

.input-group:last-child {
    margin-bottom: 0;
}

.input-group label {
    display: block;
    font-size: calc(12px * var(--text-scale));
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.plot-styles {
    font-size: calc(12px * var(--text-scale));
    color: var(--text-secondary);
}

.plot-styles summary {
    cursor: pointer;
    margin-bottom: 8px;
}

.plot-grid {
    display: grid;
    grid-template-columns: 1fr 84px;
    align-items: center;
    gap: 6px 8px;
    margin-bottom: 10px;
}

.plot-grid label {
    margin: 0;
}

.plot-grid input {
    justify-self: end;
    width: 84px;
    padding: 4px 6px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: calc(12px * var(--text-scale));
}

.plot-grid input[type="color"] {
    height: 24px;
    padding: 0;
    cursor: pointer;
}

.input-with-unit {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    overflow: hidden;
}

.input-with-unit:focus-within {
    border-color: var(--accent-primary);
}

.input-with-unit input {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: calc(14px * var(--text-scale));
    outline: none;
}

.input-with-unit .unit {
    padding: 0 12px;
    color: var(--text-tertiary);
    font-size: calc(12px * var(--text-scale));
    background: var(--bg-hover);
    height: 100%;
    display: flex;
    align-items: center;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: calc(12px * var(--text-scale));
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-primary {
    background: var(--accent-fill);
    border: 1px solid var(--accent-fill);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-fill-hover);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 3000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    font-size: calc(13px * var(--text-scale));
    animation: toastIn 0.3s ease;
}

.toast.success {
    border-color: var(--accent-success);
}

.toast.error {
    border-color: var(--accent-error);
}

.toast.info {
    border-color: var(--accent-primary);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-active);
}

/* ============================================
   Selection & Focus States
   ============================================ */
::selection {
    background: var(--accent-fill);
    color: white;
}

input:focus, button:focus {
    outline: none;
}

button:focus-visible,
select:focus-visible,
input[type="checkbox"]:focus-visible,
input[type="range"]:focus-visible {
    outline: var(--focus-width) solid var(--border-focus);
    outline-offset: 2px;
}

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

/* Prevent text selection during drag */
.canvas-container {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ============================================
   Utility Classes
   ============================================ */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Panel sections for left panel */
.panel-section {
    border-bottom: 1px solid var(--border-color);
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section .panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}



/* Vertical element styles on canvas */
.vertical-element {
    stroke-dasharray: 4, 2;
}

.vertical-stairs {
    fill: rgba(139, 92, 246, 0.2);
    stroke: rgb(139, 92, 246);
}

.vertical-elevator {
    fill: rgba(245, 158, 11, 0.2);
    stroke: rgb(245, 158, 11);
}

.vertical-void {
    fill: rgba(107, 114, 128, 0.1);
    stroke: rgb(107, 114, 128);
}

/* ============================================
   Building Wizard Modal
   ============================================ */
.modal-wide {
    width: 480px;
    max-width: 95vw;
}

.wizard-description {
    color: var(--text-secondary);
    font-size: calc(13px * var(--text-scale));
    margin-bottom: 16px;
    line-height: 1.5;
}

.wizard-section {
    margin-bottom: 20px;
}

.wizard-section h5 {
    font-size: calc(12px * var(--text-scale));
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.wizard-row {
    display: flex;
    gap: 16px;
}

.wizard-row .input-group {
    flex: 1;
}

.wizard-row .input-group label {
    display: block;
    font-size: calc(12px * var(--text-scale));
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.wizard-row .input-with-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wizard-row .input-with-unit input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: calc(14px * var(--text-scale));
    font-family: var(--font-mono);
}

.wizard-row .input-with-unit input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--accent-ring);
}

.wizard-row .input-with-unit .unit {
    font-size: calc(12px * var(--text-scale));
    color: var(--text-tertiary);
    min-width: 35px;
}

.wizard-preview {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 16px;
    margin-top: 8px;
}

.wizard-preview .preview-label {
    font-size: calc(11px * var(--text-scale));
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 8px;
}

.wizard-preview #wizardPreview {
    font-size: calc(13px * var(--text-scale));
    color: var(--text-primary);
}

/* Status bar: the snap indicator is a button, and shows when snapping is off */
#snapIndicator {
    cursor: pointer;
}

#snapIndicator.snap-off {
    color: var(--accent-warning);
}

#snapIndicator.snap-off .snap-icon {
    opacity: 0.4;
}

/* History and checkpoints */
.history-wrap { position: relative; }

.history-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
}

.history-panel[hidden] { display: none; }

.history-panel h4 {
    margin: 0 0 6px;
    font-size: calc(11px * var(--text-scale));
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
}

.history-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    max-height: 240px;
    overflow-y: auto;
}

.checkpoint-row { display: flex; gap: 4px; }

.history-item {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: calc(12px * var(--text-scale));
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover { background: var(--bg-hover); }
.history-item.current { background: var(--accent-fill); color: #fff; }
.history-item.future { color: var(--text-tertiary); font-style: italic; }

.history-remove {
    width: 26px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.history-remove:hover { background: var(--bg-hover); color: var(--accent-error); }

.history-empty { padding: 6px 8px; font-size: calc(12px * var(--text-scale)); color: var(--text-tertiary); }

.checkpoint-add { display: flex; gap: 6px; margin-bottom: 8px; }

.checkpoint-add input {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid var(--border-default);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font: inherit;
    font-size: calc(12px * var(--text-scale));
}

/* ============================================
   Help
   ============================================ */
.modal-help {
    width: 540px;
    max-width: 96vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}

.help-body {
    overflow-y: auto;
    font-size: calc(13px * var(--text-scale));
    line-height: 1.5;
}

.help-body h2 { font-size: calc(16px * var(--text-scale)); margin: 0 0 8px; }
.help-body p, .help-body ol, .help-body ul { margin: 0 0 10px; }
.help-body ol, .help-body ul { padding-left: 20px; }

.help-scene { margin: 12px 0; }
.help-frame { border: 1px solid var(--border-default); border-radius: 4px; overflow: hidden; }
.help-caption { font-size: calc(12px * var(--text-scale)); color: var(--text-tertiary); }
.help-controls { display: flex; gap: 8px; margin: 6px 0; }
.help-look { font-size: calc(12px * var(--text-scale)); color: var(--text-secondary); margin: 6px 0 0; }
/*$vite$:1*/