/* BreakerBoxx UI Styles */
:root {
    --phase-l1: #8B4513;
    --phase-l2: #1a1a1a;
    --phase-l3: #808080;
    --phase-n: #2196F3;
    --phase-pe: #4CAF50;
    --bg-primary: #f5f5f5;
    --bg-card: #ffffff;
    --bg-sidebar: #2d2d2d;
    --text-primary: #333333;
    --text-light: #ffffff;
    --border: #ddd;
    --error: #e53935;
    --warning: #ff9800;
    --info: #2196F3;
    --accent: #1976D2;
    --slot-empty: #e0e0e0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--bg-sidebar);
    color: var(--text-light);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Main layout */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Panel view */
.panel-view {
    flex: 1;
    padding: 1.5rem;
    overflow: auto;
}

.cabinet-container {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.cabinet-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
    color: var(--text);
}

.earthing-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
}

.earthing-badge.existing {
    background: #666;
}

.existing-marker {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: #e65100;
    color: #fff;
    letter-spacing: 0.05em;
}

/* DIN rail SVG */
.cabinet-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
}

.din-rail-svg {
    display: block;
    max-width: 100%;
    cursor: pointer;
}

.din-rail-svg .rail-bg {
    fill: #f0f0f0;
    stroke: #bbb;
    stroke-width: 1;
}

.din-rail-svg .rail-label {
    font-size: 12px;
    font-weight: 600;
    fill: #555;
}

.din-rail-svg .slot-empty {
    fill: rgba(0, 0, 0, 0.02);
    stroke: #bbb;
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
    cursor: pointer;
}

.din-rail-svg .slot-empty:hover {
    fill: rgba(25, 118, 210, 0.12);
    stroke: var(--accent);
    stroke-width: 2;
    cursor: pointer;
}

.din-rail-svg .slot-number {
    font-size: 10px;
    fill: #999;
    font-weight: 400;
    user-select: none;
}

.din-rail-svg .slot-empty-group:hover .slot-number {
    fill: var(--accent);
    font-weight: 600;
}

.din-rail-svg .component-rect {
    stroke-width: 1.5;
    rx: 2;
    ry: 2;
    cursor: pointer;
    transition: opacity 0.15s;
}

.din-rail-svg .component-rect:hover {
    opacity: 0.85;
    stroke-width: 2.5;
}

.din-rail-svg .component-label {
    font-size: 9px;
    fill: white;
    pointer-events: none;
    font-weight: 500;
}

.din-rail-svg .component-rating {
    font-size: 8px;
    fill: rgba(255,255,255,0.9);
    pointer-events: none;
}

.din-rail-svg .component-category {
    font-size: 7px;
    fill: rgba(255,255,255,0.75);
    pointer-events: none;
    text-transform: uppercase;
}

/* Sidebar */
.sidebar {
    width: 360px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-content {
    padding: 1rem;
    flex: 1;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

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

.btn-primary:hover {
    background: #1565C0;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #c62828;
}

.btn-secondary {
    background: #e0e0e0;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* Safety panel */
.safety-panel {
    border-top: 1px solid var(--border);
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.safety-panel h3 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.safety-issue {
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.3rem;
    border-radius: 4px;
    font-size: 0.8rem;
    border-left: 3px solid;
}

.safety-issue.error {
    background: #ffebee;
    border-left-color: var(--error);
    color: #b71c1c;
}

.safety-issue.warning {
    background: #fff3e0;
    border-left-color: var(--warning);
    color: #e65100;
}

.safety-issue.info {
    background: #e3f2fd;
    border-left-color: var(--info);
    color: #0d47a1;
}

/* Home page */
.home-page {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.project-list {
    list-style: none;
}

.project-list li {
    background: var(--bg-card);
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.project-list li:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Modal/dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    min-width: 400px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.modal h2 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

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

/* Language selector */
.lang-select {
    background: rgba(255,255,255,0.15);
    color: var(--text-light);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.lang-select option {
    background: var(--bg-sidebar);
    color: var(--text-light);
}

/* Editor tabs */
.editor-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.editor-tabs .tab {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: #888;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.editor-tabs .tab:hover {
    color: var(--text-primary);
}

.editor-tabs .tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Wire sizing calculator */
.wire-sizing-panel {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    max-width: 600px;
}

.wire-sizing-panel h3 {
    margin-bottom: 1rem;
}

.wire-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.wire-results {
    margin-top: 1.5rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

.result-label {
    color: #666;
}

.result-value {
    font-variant-numeric: tabular-nums;
}

.result-ok {
    color: #4CAF50;
}

.result-warn {
    color: var(--error);
    font-weight: 600;
}

/* Schedule and BOM tables */
.schedule-panel,
.bom-panel {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    overflow-x: auto;
}

.schedule-panel h3,
.bom-panel h3 {
    margin-bottom: 1rem;
}

.schedule-table,
.bom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.schedule-table th,
.bom-table th {
    background: #f5f5f5;
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    border-bottom: 2px solid var(--border);
}

.schedule-table td,
.bom-table td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

.schedule-table tr:hover,
.bom-table tr:hover {
    background: #fafafa;
}

/* Panel link indicators */
.link-indicator {
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

.link-indicator.incoming {
    background: #e3f2fd;
    color: #1565c0;
}

.link-indicator.outgoing {
    background: #fff3e0;
    color: #e65100;
}

/* Panel links SVG connector */
.panel-links-svg {
    margin: 1rem 0;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.panel-link-line {
    stroke: var(--accent);
    stroke-width: 2;
}

.panel-link-arrow {
    fill: var(--accent);
}

.panel-link-label {
    font-size: 12px;
    fill: var(--text-primary);
}

/* Add sub-panel section */
.add-panel-section {
    margin-top: 1rem;
    padding: 1rem 0;
}

.add-panel-form {
    margin-top: 0.75rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Textarea styling */
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

/* Settings tab icon */
.settings-tab {
    font-size: 1.1rem;
}

/* Touch-friendly targets */
@media (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.6rem 1.2rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        min-height: 44px;
        font-size: 1rem;
    }

    .editor-tabs .tab {
        min-height: 44px;
        padding: 0.6rem 1rem;
    }

    .lang-select {
        min-height: 44px;
        padding: 0.4rem 0.6rem;
    }

    .din-rail-svg .slot-empty {
        /* Ensure slots are easily tappable — handled by SLOT_PX = 44 */
    }

    /* Show plus sign always on touch (no hover) */
    .din-rail-svg .slot-number {
        fill: #999;
    }
}

/* Preset quick-add grid */
.preset-section-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.preset-recent {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 0.5rem 0.4rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    text-align: center;
}

.preset-btn:hover {
    border-color: var(--accent);
    background: rgba(25, 118, 210, 0.06);
    box-shadow: 0 1px 4px rgba(25, 118, 210, 0.15);
}

.preset-btn:active {
    background: rgba(25, 118, 210, 0.12);
}

.preset-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.preset-subtitle {
    font-size: 0.7rem;
    color: #888;
    margin-top: 0.15rem;
}

/* Preset category colours */
.preset-mcb {
    border-left: 4px solid #1976D2;
}

.preset-rcd {
    border-left: 4px solid #7B1FA2;
}

.preset-rcbo {
    border-left: 4px solid #00796B;
}

.preset-fuse {
    border-left: 4px solid #E65100;
}

.preset-misc {
    border-left: 4px solid #546E7A;
}

@media (pointer: coarse) {
    .preset-btn {
        min-height: 56px;
    }
}

/* Template cards */
.template-section {
    margin-top: 2rem;
}

.template-section h3 {
    margin-bottom: 0.75rem;
    color: var(--fg);
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
}

.template-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
    color: var(--fg);
}

.template-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.template-card-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.template-card-desc {
    font-size: 0.82rem;
    color: var(--fg-muted, #888);
    line-height: 1.3;
}

.template-card-hint {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 500;
    margin-top: 0.25rem;
}

/* ===== High-contrast mode ===== */
body.high-contrast {
    --bg-primary: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #000000;
    --text-primary: #000000;
    --text-light: #ffffff;
    --border: #000000;
    --error: #cc0000;
    --warning: #b45000;
    --info: #0050b4;
    --accent: #003399;
    --slot-empty: #ffffff;
    font-size: 1.125rem;
}

body.high-contrast .header {
    border-bottom: 3px solid #ffffff;
}

body.high-contrast .btn {
    background: #000000;
    color: #ffffff;
    border: 2px solid #000000;
    font-weight: 700;
}

body.high-contrast .btn:hover {
    background: #222222;
}

body.high-contrast .btn-primary {
    background: #003399;
    border-color: #003399;
}

body.high-contrast .btn-primary:hover {
    background: #002266;
}

body.high-contrast .btn-danger {
    background: #cc0000;
    border-color: #cc0000;
}

body.high-contrast .btn-danger:hover {
    background: #990000;
}

body.high-contrast .btn-secondary {
    background: #333333;
    color: #ffffff;
    border-color: #000000;
}

body.high-contrast .btn-secondary:hover {
    background: #444444;
}

body.high-contrast .sidebar {
    border-left: 3px solid #000000;
}

body.high-contrast .form-group input,
body.high-contrast .form-group select,
body.high-contrast .form-group textarea {
    border: 2px solid #000000;
    background: #ffffff;
    color: #000000;
}

body.high-contrast .form-group label {
    color: #000000;
    font-weight: 700;
}

/* DIN rail high contrast */
body.high-contrast .din-rail-svg .rail-bg {
    fill: #ffffff;
    stroke: #000000;
    stroke-width: 2;
}

body.high-contrast .din-rail-svg .rail-label {
    fill: #000000;
    font-weight: 700;
}

body.high-contrast .din-rail-svg .slot-empty {
    fill: #ffffff;
    stroke: #000000;
    stroke-width: 2;
    stroke-dasharray: none;
}

body.high-contrast .din-rail-svg .slot-empty:hover {
    fill: #ddddff;
    stroke: #003399;
    stroke-width: 3;
}

body.high-contrast .din-rail-svg .slot-number {
    fill: #000000;
    font-weight: 700;
}

body.high-contrast .din-rail-svg .component-rect {
    stroke-width: 3;
}

body.high-contrast .din-rail-svg .component-rect:hover {
    stroke-width: 4;
}

body.high-contrast .din-rail-svg .component-label {
    font-weight: 700;
    font-size: 10px;
}

body.high-contrast .din-rail-svg .component-rating {
    font-weight: 600;
    font-size: 9px;
}

body.high-contrast .din-rail-svg .component-category {
    font-weight: 600;
    font-size: 8px;
}

/* Safety panel high contrast */
body.high-contrast .safety-panel {
    border-top: 3px solid #000000;
}

body.high-contrast .safety-issue {
    border-left-width: 5px;
    font-weight: 600;
}

body.high-contrast .safety-issue.error {
    background: #ffffff;
    border-left-color: #cc0000;
    color: #cc0000;
}

body.high-contrast .safety-issue.warning {
    background: #ffffff;
    border-left-color: #b45000;
    color: #b45000;
}

body.high-contrast .safety-issue.info {
    background: #ffffff;
    border-left-color: #0050b4;
    color: #0050b4;
}

/* Tables high contrast */
body.high-contrast .schedule-table th,
body.high-contrast .bom-table th {
    background: #000000;
    color: #ffffff;
    border-bottom: 3px solid #000000;
}

body.high-contrast .schedule-table td,
body.high-contrast .bom-table td {
    border-bottom: 2px solid #000000;
}

body.high-contrast .schedule-table tr:hover,
body.high-contrast .bom-table tr:hover {
    background: #eeeeee;
}

/* Cards and panels high contrast */
body.high-contrast .cabinet-container,
body.high-contrast .wire-sizing-panel,
body.high-contrast .schedule-panel,
body.high-contrast .bom-panel {
    border: 2px solid #000000;
    box-shadow: none;
}

body.high-contrast .project-list li {
    border: 2px solid #000000;
    box-shadow: none;
}

body.high-contrast .project-list li:hover {
    background: #eeeeee;
    box-shadow: none;
}

body.high-contrast .modal {
    border: 3px solid #000000;
    box-shadow: none;
}

body.high-contrast .modal-overlay {
    background: rgba(0, 0, 0, 0.75);
}

body.high-contrast .lang-select {
    background: #000000;
    color: #ffffff;
    border: 2px solid #ffffff;
    font-weight: 700;
}

body.high-contrast .editor-tabs {
    border-bottom: 3px solid #000000;
}

body.high-contrast .editor-tabs .tab {
    color: #000000;
    font-weight: 700;
}

body.high-contrast .editor-tabs .tab.active {
    color: #003399;
    border-bottom-color: #003399;
    border-bottom-width: 3px;
}

body.high-contrast .preset-btn {
    border: 2px solid #000000;
}

body.high-contrast .preset-btn:hover {
    border-color: #003399;
    background: #eeeeee;
}

body.high-contrast .preset-label {
    color: #000000;
}

body.high-contrast .preset-subtitle {
    color: #333333;
}

body.high-contrast .result-label {
    color: #000000;
}

body.high-contrast .result-ok {
    color: #006600;
    font-weight: 700;
}

body.high-contrast .result-warn {
    color: #cc0000;
    font-weight: 700;
}

body.high-contrast .link-indicator {
    font-weight: 700;
    border: 2px solid #000000;
}

body.high-contrast .template-card {
    border: 2px solid #000000;
}

body.high-contrast .template-card:hover {
    border-color: #003399;
    box-shadow: none;
    background: #eeeeee;
}

/* Contrast toggle button styling */
.contrast-toggle {
    min-width: 2.2rem;
    text-align: center;
    font-weight: 700;
}

/* ===== Floor Plan Editor ===== */
.floor-plan-editor {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fp-tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
}

.fp-tab {
    padding: 0.4rem 0.8rem;
    border: none;
    background: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: #888;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.fp-tab:hover {
    color: var(--text-primary);
}

.fp-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.fp-tab-add {
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.4rem 0.6rem;
}

.fp-inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.fp-inline-form input {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
}

.fp-empty {
    padding: 3rem;
    text-align: center;
    color: #888;
}

.fp-workspace {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fp-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.fp-main-area {
    display: flex;
    gap: 0.75rem;
}

.fp-palette {
    width: 120px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 700px;
    overflow-y: auto;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.fp-palette-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 0.25rem;
}

.fp-palette-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.fp-palette-btn:hover {
    border-color: var(--accent);
    background: rgba(25, 118, 210, 0.06);
}

.fp-palette-btn.active {
    border-color: var(--accent);
    background: rgba(25, 118, 210, 0.12);
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

.fp-palette-label {
    font-size: 0.65rem;
    color: #666;
    text-align: center;
    line-height: 1.1;
}

.fp-canvas-container {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    overflow: auto;
}

.fp-canvas {
    display: block;
    width: 100%;
    height: auto;
    min-height: 500px;
    cursor: crosshair;
}

.fp-room {
    fill: rgba(200, 220, 240, 0.3);
    stroke: #666;
    stroke-width: 1.5;
    cursor: move;
}

.fp-room.selected {
    stroke: var(--accent);
    stroke-width: 2.5;
    fill: rgba(25, 118, 210, 0.08);
}

.fp-room-label {
    font-size: 12px;
    fill: #444;
    font-weight: 500;
    pointer-events: none;
}

.fp-resize-handle {
    fill: var(--accent);
    cursor: se-resize;
    opacity: 0.8;
}

.fp-resize-handle:hover {
    opacity: 1;
}

.fp-symbol {
    cursor: move;
}

.fp-symbol-label {
    font-size: 9px;
    fill: #555;
    pointer-events: none;
}

.fp-edit-panel {
    width: 200px;
    flex-shrink: 0;
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fp-edit-panel h4 {
    font-size: 0.9rem;
    margin: 0;
}

/* High contrast overrides for floor plan */
body.high-contrast .fp-room {
    fill: rgba(0, 0, 0, 0.05);
    stroke: #000;
    stroke-width: 2;
}

body.high-contrast .fp-room.selected {
    stroke: #003399;
    stroke-width: 3;
}

body.high-contrast .fp-room-label {
    fill: #000;
    font-weight: 700;
}

body.high-contrast .fp-palette-btn {
    border: 2px solid #000;
}

body.high-contrast .fp-palette-btn.active {
    border-color: #003399;
    background: #eeeeee;
}

body.high-contrast .fp-canvas-container {
    border: 2px solid #000;
}

/* Responsive sidebar */
@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 50vh;
        border-left: none;
        border-top: 1px solid var(--border);
    }
}

/* --- Keyboard shortcut help overlay --- */
.shortcut-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.shortcut-modal {
    background: var(--bg, #fff);
    color: var(--fg, #222);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.shortcut-modal h3 {
    margin: 0 0 1rem;
}

.shortcut-modal table {
    width: 100%;
    border-collapse: collapse;
}

.shortcut-modal td {
    padding: 0.35rem 0.5rem;
}

.shortcut-modal td:first-child {
    white-space: nowrap;
    text-align: right;
    padding-right: 1rem;
}

.shortcut-modal kbd {
    display: inline-block;
    background: var(--surface, #eee);
    border: 1px solid var(--border, #ccc);
    border-radius: 3px;
    padding: 0.1rem 0.4rem;
    font-family: monospace;
    font-size: 0.85em;
}

.shortcut-dismiss {
    margin: 1rem 0 0;
    text-align: center;
    font-size: 0.85em;
    opacity: 0.7;
}

/* ── Connection Toolbar ─────────────────────────────────────────── */
.connection-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #1a1a2e;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.connection-tool-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.connection-options {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #252545;
    border-radius: 4px;
}
.connection-options select,
.connection-options input {
    padding: 0.15rem 0.3rem;
    font-size: 0.8rem;
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #444;
    border-radius: 3px;
}
.connection-status {
    font-size: 0.8rem;
    color: #FFD700;
    margin-left: 0.5rem;
}
.connection-list {
    padding: 0.25rem 0.5rem;
    margin-top: 0.25rem;
}
