﻿:root {
    --toolbar-height: 108px;
    --cad-font: "Segoe UI", system-ui, -apple-system, sans-serif;
    --cad-radius: 6px;
    --cad-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
    --cad-shadow-hover: 0 4px 14px rgba(15, 23, 42, 0.12);
    --cad-accent: #0d74c8;
    --ribbon-btn-size: 64px;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    background: #eef1f5;
    font-family: var(--cad-font);
    color: #1e293b;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Office-style CAD Ribbon ── */

.cad-ribbon,
#toolbar {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    background: #f3f4f6;
    border-bottom: 1px solid #d1d5db;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    position: relative;
    z-index: 100;
}

.cad-ribbon-main {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 5px 8px 3px;
    overflow-x: auto;
    overflow-y: visible;
}

.ribbon-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0 6px 4px;
    border-right: 1px solid #e2e8f0;
    flex-shrink: 0;
}

    .ribbon-section:last-child {
        border-right: none;
    }

.ribbon-section--shape-type {
    order: -1;
    margin-left: 0;
    align-self: stretch;
    justify-content: flex-end;
    padding: 0 10px 6px 4px;
    border-right: 1px solid #e2e8f0;
    min-width: 150px;
}

    .ribbon-section--shape-type .ribbon-section-title--shape {
        color: #334155;
        background: #e8edf3;
        border-radius: 4px;
        padding: 3px 10px;
        text-align: center;
    }

    .ribbon-section--shape-type .cad-shape-type-control {
        gap: 5px;
    }

    .ribbon-section--shape-type .cad-shape-type-select {
        min-width: 138px;
        padding: 8px 10px;
        display: block;
    }

.ribbon-section-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1.2;
    padding: 3px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

.ribbon-section--drawing .ribbon-section-title {
    color: #4f7800;
    background: #eef7d8;
}

.ribbon-section--objects .ribbon-section-title {
    color: #0867a9;
    background: #e5f2fc;
}

.ribbon-section--project .ribbon-section-title {
    color: #4b3a9a;
    background: #eeeafe;
}

.ribbon-section--view .ribbon-section-title {
    color: #c64a1b;
    background: #fff0e8;
}

.ribbon-section-title--shape {
    color: #475569;
    align-self: flex-start;
    width: 100%;
}

.ribbon-section-tools {
    display: flex;
    align-items: center;
    gap: 2px;
}

.cad-shape-type-control {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.cad-shape-type-label {
    display: block;
    width: 100%;
}

.cad-shape-type-select {
    width: 100%;
    min-width: 120px;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: var(--cad-radius);
    background: #fff;
    color: #1e293b;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .cad-shape-type-select:focus {
        outline: none;
        border-color: var(--cad-accent);
        box-shadow: 0 0 0 2px rgba(13, 116, 200, 0.18);
    }

.cad-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: var(--ribbon-btn-size);
    height: var(--ribbon-btn-size);
    padding: 4px 2px;
    border: 1px solid transparent;
    border-radius: var(--cad-radius);
    background: transparent;
    color: #334155;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    flex-shrink: 0;
}

    .cad-tool-btn:hover:not(:disabled) {
        background: #e2e8f0;
        transform: translateY(-1px);
        box-shadow: var(--cad-shadow);
        border-color: #cbd5e1;
    }

    .cad-tool-btn.active {
        background: #dbeafe;
        border-color: rgba(13, 116, 200, 0.35);
        box-shadow: inset 0 0 0 1px var(--cad-accent);
        color: #0f172a;
    }

    .cad-tool-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

.cad-tool-btn--help {
    opacity: 0.92;
}

.cad-tool-btn[data-tool="square"] {
    width: 108px;
}
.cad-tool-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 27px;
    height: 27px;
    line-height: 0;
}

    .cad-tool-icon svg {
        width: 24px;
        height: 24px;
        display: block;
    }

.cad-tool-label {
    font-size: 10px;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    max-width: 60px;
    letter-spacing: 0.01em;
    color: #475569;
}

.cad-options-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 18px;
    padding: 4px 12px;
    min-height: 28px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    font-size: 12px;
    color: #64748b;
}

.cad-options-item {
    min-width: 120px;
}

.cad-options-scale {
    font-weight: 600;
    color: #475569;
}

.cad-options-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease;
}

    .cad-options-toggle:hover {
        color: #1e293b;
    }

    .cad-options-toggle input {
        accent-color: var(--cad-accent);
    }

/* Insert object control */

.cad-tool-insert {
    display: flex;
    align-items: stretch;
}

.cad-floating-popup,
.insert-object-menu {
    position: fixed;
    z-index: 2000;
    min-width: 240px;
    max-width: min(320px, calc(100vw - 16px));
    max-height: min(360px, calc(100vh - 16px));
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--cad-radius);
    box-shadow: var(--cad-shadow-hover);
    padding: 8px;
}

    .insert-object-menu[hidden] {
        display: none;
    }

#cadPopovers {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2000;
}

    #cadPopovers .cad-floating-popup,
    #cadPopovers .insert-object-menu {
        pointer-events: auto;
    }

.cad-tool-insert.active .cad-tool-btn--insert,
.cad-tool-insert.active .cad-tool-menu-toggle {
    background: #dbeafe;
    border-color: rgba(13, 116, 200, 0.35);
    box-shadow: inset 0 0 0 1px var(--cad-accent);
}

.cad-tool-btn--insert {
    border-radius: var(--cad-radius) 0 0 var(--cad-radius);
    width: calc(var(--ribbon-btn-size) + 4px);
}

.cad-tool-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: var(--ribbon-btn-size);
    padding: 0;
    border: 1px solid transparent;
    border-left: 1px solid #e2e8f0;
    border-radius: 0 var(--cad-radius) var(--cad-radius) 0;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: background 0.15s ease;
}

    .cad-tool-menu-toggle:hover {
        background: #e2e8f0;
    }

.cad-tool-menu-chevron svg {
    width: 14px;
    height: 14px;
}

.object-picker-section + .object-picker-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e9ecef;
}

.object-picker-category {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 4px 8px 6px;
}

.object-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #1e293b;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, transform 0.15s ease;
}

    .object-picker-item:hover {
        background: #f1f5f9;
        transform: translateX(2px);
    }

    .object-picker-item.active {
        background: #e8f2fc;
        box-shadow: inset 0 0 0 1px #0d74c8;
    }

.object-picker-thumb {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background-color: #f8fafc;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

.object-picker-label {
    font-size: 13px;
    font-weight: 500;
}

#layout {
    display: flex;
    flex: 1 1 auto;
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
}

#canvasWrapper {
    position: relative;
    padding: 12px;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
}

#cadOverlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    overflow: hidden;
}

#drawingArea {
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: white;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    height: 100%;
    display: block;
    box-shadow: var(--cad-shadow);
}

.shape-group .shape-path {
    transition: stroke 0.1s ease;
}

.node-handle {
    cursor: pointer;
}

.decor-object {
    cursor: move;
}

/* ── Property Inspector (three-zone layout) ── */

.property-inspector,
#rightPanel {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 0 0 300px;
    width: 300px;
    min-width: 0;
    min-height: 0;
    align-self: stretch;
    border-left: 1px solid #e2e8f0;
    background: #f8fafc;
    overflow: hidden;
    box-shadow: -2px 0 12px rgba(15, 23, 42, 0.04);
    transition: flex-basis 0.2s ease, width 0.2s ease;
}

.property-inspector-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.inspector-collapse-btn {
    position: absolute;
    left: -11px;
    top: 50%;
    z-index: 20;
    transform: translateY(-50%);
    width: 22px;
    height: 44px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: var(--cad-radius) 0 0 var(--cad-radius);
    background: #fff;
    color: #64748b;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--cad-shadow);
    transition: background 0.15s ease, color 0.15s ease;
}

    .inspector-collapse-btn:hover {
        background: #f1f5f9;
        color: #1e293b;
    }

.property-inspector--collapsed {
    flex-basis: 0;
    width: 0;
    min-width: 0;
    border-left-color: transparent;
    overflow: visible;
}

    .property-inspector--collapsed .property-inspector-body {
        visibility: hidden;
        pointer-events: none;
    }

    .property-inspector--collapsed .inspector-collapse-btn {
        left: auto;
        right: 0;
        border-radius: var(--cad-radius) 0 0 var(--cad-radius);
    }

/* Materials zone — grows, scrolls internally */
.inspector-zone--materials {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

#texturePanel.material-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.material-panel-header {
    flex: 0 0 auto;
    padding: 14px 14px 12px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.material-panel-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 12px 16px;
}

.material-panel--contextual .material-panel-scroll,
.material-panel--contextual .material-search-input {
    display: none;
}

.material-contextual-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    text-align: center;
}

    .material-contextual-panel[hidden] {
        display: none;
    }

.material-contextual-message {
    margin: 0;
    max-width: 240px;
    font-size: 13px;
    line-height: 1.55;
    color: #64748b;
    font-weight: 500;
}

/* Borders zone — pinned below materials */
.inspector-zone--borders,
#borderPanel {
    flex: 0 0 auto;
    padding: 14px;
    background: #fff;
}

.border-panel--disabled .border-panel-form {
    display: none;
}

.border-panel--disabled .border-panel-hint {
    color: #64748b;
    font-weight: 500;
    line-height: 1.55;
    padding: 4px 0;
}

/* Statistics zone — pinned at bottom */
.inspector-zone--statistics,
#materialSummaryPanel {
    flex: 0 0 auto;
    padding: 14px;
    background: #fff;
    font-size: 13px;
    border-top: 1px solid #e2e8f0;
}

.material-panel-title {
    font-size: 15px;
    font-weight: 700;
    color: #212529;
    margin-bottom: 10px;
    letter-spacing: -0.01em;
}

.material-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: var(--cad-radius);
    font-size: 13px;
    background: #f8fafc;
    color: #1e293b;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .material-search-input:focus {
        outline: none;
        border-color: var(--cad-accent);
        background: #fff;
        box-shadow: 0 0 0 3px rgba(13, 116, 200, 0.15);
    }

.material-filters-slot {
    margin-top: 8px;
}

.material-category-section {
    margin-bottom: 8px;
}

.material-category-body {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.22s ease;
}

.material-category-section.collapsed .material-category-body {
    grid-template-rows: 0fr;
}

.material-category-body-inner {
    overflow: hidden;
    min-height: 0;
}

.material-category-section.collapsed .material-category-chevron {
    transform: rotate(-90deg);
}

.material-category-header {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 7px 6px;
    margin-bottom: 2px;
    border: none;
    border-radius: var(--cad-radius);
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

    .material-category-header:hover {
        background: #eef2f7;
    }

.material-category-label {
    flex: 1;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #334155;
}

.material-section-favorites .material-category-label,
.material-section-recent .material-category-label {
    color: #0d6efd;
}

.material-category-count {
    font-size: 11px;
    color: #868e96;
    background: #e9ecef;
    border-radius: 10px;
    padding: 2px 8px;
}

.material-category-chevron {
    flex-shrink: 0;
    width: 14px;
    font-size: 11px;
    color: #64748b;
    transition: transform 0.22s ease;
}

.material-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.material-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

    .material-card:hover {
        border-color: #adb5bd;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        transform: translateY(-1px);
    }

        .material-card:hover .material-card-preview {
            transform: scale(1.06);
        }

    .material-card.active {
        border-color: var(--cad-accent);
        box-shadow: 0 0 0 1px var(--cad-accent), 0 4px 14px rgba(13, 116, 200, 0.2);
    }

.material-card-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #e9ecef;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.2s ease;
}

.material-card-body {
    padding: 8px 8px 10px;
    min-height: 52px;
}

.material-card-name {
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    color: #212529;
    line-height: 1.3;
}

.material-card-dims {
    margin-top: 3px;
    font-size: 10px;
    color: #6c757d;
}

.material-card-heading {
    display: flex;
    align-items: flex-start;
    gap: 5px;
}

.material-card-name {
    flex: 1 1 auto;
}

.material-card-info {
    display: inline-flex;
    flex: 0 0 16px;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-top: -1px;
    padding: 0;
    border: 1px solid #8b9aab;
    border-radius: 50%;
    background: #fff;
    color: #62758a;
    font-family: Georgia, serif;
    font-size: 11px;
    font-style: italic;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.material-card-info:hover,
.material-card-info:focus-visible {
    border-color: var(--cad-accent);
    background: #eef6ff;
    color: var(--cad-accent);
    outline: none;
}

.material-description-popover {
    position: fixed;
    z-index: 10000;
    width: max-content;
    max-width: min(280px, calc(100vw - 24px));
    max-height: min(240px, calc(100vh - 24px));
    overflow-y: auto;
    padding: 11px 13px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    background: #263446;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    pointer-events: auto;
}

.material-description-popover::before {
    position: absolute;
    top: -5px;
    left: calc(50% - 5px);
    width: 9px;
    height: 9px;
    transform: rotate(45deg);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    background: #263446;
    content: "";
}

.material-description-popover.is-above::before {
    top: auto;
    bottom: -5px;
    transform: rotate(225deg);
}

.material-card-scale {
    margin-top: 2px;
    font-size: 10px;
    color: #868e96;
}

.material-card-favorite {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #f59f00;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

    .material-card-favorite:hover {
        background: #fff;
        transform: scale(1.05);
    }

.material-empty-state {
    padding: 24px 12px;
    text-align: center;
    font-size: 13px;
    color: #868e96;
}

@media (max-width: 1100px) {
    .property-inspector,
    #rightPanel {
        flex-basis: 260px;
        width: 260px;
    }

    .material-card-grid {
        grid-template-columns: 1fr;
    }
}

.dimension-label {
    pointer-events: auto;
    cursor: pointer;
    font-family: system-ui, sans-serif;
}

.dimension-label--preview .dimension-label-bg {
    stroke: #4dabf7;
    stroke-dasharray: 4 2;
}

.dimension-label--active .dimension-label-bg {
    stroke: #f97316;
    stroke-width: 2;
    filter: drop-shadow(0 2px 5px rgba(249, 115, 22, 0.4));
}

.dimension-label--active .dimension-label-text {
    font-size: 14px;
    font-weight: 700;
    fill: #1e293b;
}

.dimension-edit-input {
    position: absolute;
    pointer-events: auto;
    width: 72px;
    padding: 2px 6px;
    border: 2px solid #f97316;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.25);
    margin: 0;
    box-sizing: border-box;
}

.border-panel-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 10px;
    letter-spacing: -0.01em;
}

.border-panel-hint {
    font-size: 12px;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 8px;
}

.border-panel-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

    .border-panel-form[hidden] {
        display: none !important;
    }

.border-panel-hint[hidden] {
    display: none !important;
}

.border-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

    .cad-select,
    .border-field select {
        padding: 8px 10px;
        border: 1px solid #e2e8f0;
        border-radius: var(--cad-radius);
        font-size: 13px;
        background: #f8fafc;
        color: #1e293b;
        transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

        .cad-select:focus,
        .border-field select:focus {
            outline: none;
            border-color: var(--cad-accent);
            background: #fff;
            box-shadow: 0 0 0 3px rgba(13, 116, 200, 0.12);
        }

.border-field-static .border-edge-label {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
}

.border-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 4px 0;
}

    .border-color-swatches.is-locked {
        opacity: 0.85;
    }

.border-color-swatch {
    position: relative;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

    .border-color-swatch:hover:not(:disabled) {
        transform: scale(1.08);
        box-shadow: var(--cad-shadow-hover);
    }

    .border-color-swatch.active {
        border-color: var(--cad-accent);
        box-shadow: 0 0 0 2px rgba(13, 116, 200, 0.25);
    }

    .border-color-swatch:disabled {
        cursor: default;
    }

.border-swatch-check {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 14px;
    height: 14px;
    color: #fff;
    opacity: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
    transition: opacity 0.15s ease;
}

.border-color-swatch.active .border-swatch-check {
    opacity: 1;
}

.border-panel-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.cad-btn {
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: var(--cad-radius);
    background: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

    .cad-btn:hover:not(:disabled) {
        background: #f1f5f9;
        box-shadow: var(--cad-shadow);
    }

.cad-btn-primary {
    background: var(--cad-accent);
    border-color: var(--cad-accent);
    color: #fff;
}

    .cad-btn-primary:hover:not(:disabled) {
        background: #0b66b3;
        border-color: #0b66b3;
    }

.cad-btn-secondary {
    color: #475569;
}

.cad-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.border-btn {
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: var(--cad-radius);
    background: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.border-btn-primary {
    background: var(--cad-accent);
    border-color: var(--cad-accent);
    color: #fff;
}

.edge-hit {
    pointer-events: stroke;
}

.dimension-labels-layer {
    pointer-events: auto;
}

.edge-hits-layer {
    pointer-events: auto;
}

.edge-hit.hover {
    stroke: rgba(13, 110, 253, 0.35);
}

.edge-hit.selected {
    stroke: rgba(13, 110, 253, 0.65);
    stroke-width: 16;
}

.border-path {
    pointer-events: none;
}

.material-summary-subtitle {
    margin-top: 10px;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.material-row.border-row {
    color: #495057;
}

.material-total.border-total {
    margin-top: 4px;
    font-size: 12px;
}

.material-summary-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.material-row {
    margin: 3px 0;
    color: #343a40;
}

.material-total {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed #ced4da;
    font-weight: 700;
}

.help-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.5);
}

    .help-modal-overlay[hidden] {
        display: none;
    }

body.help-modal-open {
    overflow: hidden;
}

.help-modal-dialog {
    width: min(520px, 100%);
    max-height: min(80vh, 640px);
    overflow: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
}

.help-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 20px 0;
}

.help-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #212529;
}

.help-modal-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #6c757d;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

    .help-modal-close:hover {
        background: #f1f3f5;
        color: #212529;
    }

.help-modal-body {
    padding: 16px 20px 24px;
    font-size: 14px;
    line-height: 1.6;
    color: #495057;
}

    .help-modal-body p {
        margin: 0 0 12px;
    }

    .help-modal-body ol,
    .help-modal-body ul {
        margin: 0 0 12px;
        padding-left: 1.4em;
    }

    .help-modal-body li + li {
        margin-top: 6px;
    }

    .help-modal-body kbd {
        display: inline-block;
        padding: 2px 6px;
        border: 1px solid #ced4da;
        border-radius: 4px;
        background: #f8f9fa;
        font-family: inherit;
        font-size: 12px;
        font-weight: 600;
    }

@media (max-width: 900px) {
    :root {
        --ribbon-btn-size: 56px;
    }

    .cad-tool-label {
        font-size: 8px;
    }

    .ribbon-section--shape-type {
        min-width: 108px;
    }
}

/* =========================================================
   PROJECT EMAIL MODAL
   ========================================================= */

.project-email-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

    .project-email-modal.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

.project-email-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
}

.project-email-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(500px, 100%);
    padding: 32px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
    transform: translateY(12px) scale(0.98);
    transition: transform 0.2s ease;
}

.project-email-modal.is-open
.project-email-modal__dialog {
    transform: translateY(0) scale(1);
}

.project-email-modal__close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #64748b;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

    .project-email-modal__close:hover {
        background: #f1f5f9;
        color: #334155;
    }

.project-email-modal__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
    border-radius: 14px;
    background: #fff3e8;
    color: #f28c28;
    font-size: 25px;
}

.project-email-modal__dialog h2 {
    margin: 0 40px 8px 0;
    color: #1e293b;
    font-size: 24px;
    font-weight: 700;
}

.project-email-modal__description {
    margin: 0 0 24px;
    color: #64748b;
    font-size: 14px;
    line-height: 1.6;
}

.project-email-modal__field {
    margin-bottom: 17px;
}

    .project-email-modal__field label {
        display: block;
        margin-bottom: 7px;
        color: #334155;
        font-size: 13px;
        font-weight: 600;
    }

    .project-email-modal__field input {
        display: block;
        width: 100%;
        height: 46px;
        padding: 0 13px;
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        background: #fff;
        color: #1e293b;
        font-size: 14px;
        outline: none;
        transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

        .project-email-modal__field input:focus {
            border-color: #f28c28;
            box-shadow: 0 0 0 3px rgba(242, 140, 40, 0.12);
        }

        .project-email-modal__field input::placeholder {
            color: #94a3b8;
        }

.project-email-modal__message {
    min-height: 20px;
    margin: 5px 0 12px;
    font-size: 13px;
    line-height: 1.5;
}

    .project-email-modal__message.is-error {
        color: #dc2626;
    }

    .project-email-modal__message.is-success {
        color: #16a34a;
    }

.project-email-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.project-email-modal__cancel,
.project-email-modal__submit {
    min-height: 44px;
    padding: 0 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.project-email-modal__cancel {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
}

    .project-email-modal__cancel:hover {
        background: #f8fafc;
    }

.project-email-modal__submit {
    border: 1px solid #f28c28;
    background: #f28c28;
    color: #fff;
    box-shadow: 0 3px 8px rgba(242, 140, 40, 0.2);
}

    .project-email-modal__submit:hover {
        background: #e77e17;
    }

    .project-email-modal__submit:disabled,
    .project-email-modal__cancel:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

@media (max-width: 600px) {

    .project-email-modal {
        padding: 15px;
    }

    .project-email-modal__dialog {
        padding: 25px 20px;
    }

    .project-email-modal__actions {
        flex-direction: column-reverse;
    }

    .project-email-modal__cancel,
    .project-email-modal__submit {
        width: 100%;
    }
}

/* =========================================================
   DEVICE WARNING - MOBILE / TABLET
   ========================================================= */

.configurator-device-warning {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.96);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

    .configurator-device-warning.is-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

.configurator-device-warning__content {
    width: min(560px, 100%);
    padding: 42px 36px;
    background: #ffffff;
    border-radius: 18px;
    text-align: center;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.35);
}

.configurator-device-warning__icon {
    margin-bottom: 20px;
    font-size: 56px;
    line-height: 1;
}

.configurator-device-warning__content h1 {
    margin: 0 0 18px;
    color: #1e293b;
    font-size: 26px;
    font-weight: 700;
    line-height: 1.25;
}

.configurator-device-warning__content p {
    margin: 0 auto 14px;
    max-width: 480px;
    color: #475569;
    font-size: 16px;
    line-height: 1.6;
}

.configurator-device-warning__hint {
    margin-top: 22px !important;
    color: #ea580c !important;
    font-weight: 600;
}

.configurator-device-blocked {
    overflow: hidden;
}
.help-content {
    color: #475569;
    font-size: 14px;
    line-height: 1.6;
}

.help-section {
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid #e2e8f0;
}

    .help-section:last-child {
        margin-bottom: 0;
        border-bottom: 0;
    }

    .help-section h2 {
        margin: 0 0 14px;
        color: #1e293b;
        font-size: 20px;
        font-weight: 700;
    }

    .help-section h3 {
        margin: 20px 0 8px;
        color: #334155;
        font-size: 16px;
        font-weight: 700;
    }

    .help-section p {
        margin: 0 0 10px;
    }

    .help-section ul,
    .help-section ol {
        margin: 8px 0 14px;
        padding-left: 24px;
    }

    .help-section li {
        margin-bottom: 6px;
    }

.help-note {
    margin: 14px 0;
    padding: 12px 16px;
    border-left: 4px solid #ea580c;
    border-radius: 6px;
    background: #fff7ed;
    color: #475569;
}

.help-key-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
}

    .help-key-row span {
        margin-left: 4px;
    }

.help-content kbd {
    display: inline-block;
    min-width: 28px;
    padding: 3px 7px;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    border-radius: 5px;
    background: #f8fafc;
    color: #334155;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.help-workflow {
    padding-left: 26px;
}

    .help-workflow li {
        padding-left: 4px;
        margin-bottom: 10px;
    }

.help-shortcuts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.help-shortcut {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.help-shortcut__keys {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.help-shortcut strong {
    display: block;
    margin-bottom: 2px;
    color: #334155;
}

.help-shortcut p {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
}

.help-section--important {
    padding-bottom: 0;
}

@media (max-width: 700px) {
    .help-shortcuts {
        grid-template-columns: 1fr;
    }
}
