* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #121212;
    color: #e0e0e0;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1a1a1a;
    color: #e0e0e0;
    padding: 0 20px;
    height: 40px; /* Fixed height for precise dropdown alignment */
    gap: 20px;
    border-bottom: 1px solid #333333;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 20px;
    min-width: 0;
}

.top-bar h1 {
    font-size: 0.85rem;
    margin: 0;
    color: #d0d0d0;
    font-weight: 800;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
    line-height: 1;
}

.top-bar h1 img {
    display: block;
    flex-shrink: 0;
}

.nav-menus {
    display: flex;
    gap: 5px;
    height: 100%;
}

.top-bar-account {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.top-bar-account-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    min-width: 0;
}

.top-bar-account-name,
.top-bar-account-role {
    display: block;
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-bar-account-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #f8fafc;
}

.top-bar-account-role {
    font-size: 0.68rem;
    color: #94a3b8;
}

.top-bar-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 12px;
    border-radius: 6px;
    border: 1px solid #334155;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.top-bar-link:hover {
    background-color: #1e293b;
    border-color: #475569;
    color: #ffffff;
}

.top-bar-link-primary {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.top-bar-link-primary:hover {
    background-color: #1d4ed8;
    border-color: #1d4ed8;
}

.nav-menu-item {
    position: relative;
    height: 100%;
}

.nav-menu-btn {
    background: none;
    border: none;
    color: #b0b0b0;
    padding: 8px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: background 0.1s, color 0.1s;
    height: 40px;
    display: flex;
    align-items: center;
}

.nav-menu-btn:hover {
    color: #ffffff;
}

.nav-menu-btn.active {
    background-color: #242424;
    color: #ffffff;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 40px; /* Match top-bar height */
    left: 0;
    background-color: #242424;
    min-width: 220px;
    z-index: 2000;
    border: 1px solid #404040;
    border-top: none;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.dropdown-content.show {
    display: block;
}

.dropdown-item {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: #d4d4d4;
    padding: 10px 15px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-item:hover {
    background-color: #383838;
    color: #ffffff;
}

.dropdown-divider {
    height: 1px;
    background-color: #383838;
    margin: 4px 0;
}

/* Settings Modal */
.settings-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.settings-modal {
    background-color: #242424;
    border: 1px solid #404040;
    border-radius: 8px;
    width: 450px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.settings-header {
    padding: 12px 20px;
    border-bottom: 1px solid #404040;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1a1a1a;
}

.settings-header h2 {
    margin: 0;
    font-size: 1rem;
    color: #ffffff;
}

.settings-body {
    padding: 20px;
}

.settings-section {
    margin-bottom: 25px;
}

.settings-section h3 {
    font-size: 0.8rem;
    color: #909090;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 15px;
    border-bottom: 1px solid #333333;
    padding-bottom: 8px;
}

.settings-footer {
    padding: 12px 20px;
    border-top: 1px solid #404040;
    display: flex;
    justify-content: flex-end;
    background-color: #1a1a1a;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.left-panel {
    width: 260px;
    flex-shrink: 0;
    background-color: #1e1e1e;
    border-right: 1px solid #333333;
    overflow: visible;
    padding: 0;
    position: relative;
    /* Use a consistent timing and easing for both width and transform */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.panel-content {
    height: 100%;
    overflow-y: auto;
    padding: 15px;
    width: 260px; /* Fixed width to prevent content layout shifts during collapse */
    transition: opacity 0.3s ease;
}

.left-panel.collapsed {
    transform: translateX(-260px);
    width: 0;
}

.left-panel.collapsed .panel-content {
    opacity: 0;
    pointer-events: none;
}

.panel-toggle {
    position: absolute;
    top: 50%;
    left: 260px; /* Positioned exactly at the right edge of the 260px panel */
    transform: translateY(-50%);
    width: 20px;
    height: 60px;
    background-color: #1e1e1e;
    border: 1px solid #333333;
    border-left: none;
    border-radius: 0 4px 4px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #808080;
    z-index: 1001;
    transition: all 0.2s ease;
}

.panel-toggle:hover {
    background-color: #333333;
    color: #ffffff;
}

.panel-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.left-panel.collapsed .panel-toggle svg {
    transform: rotate(180deg);
}

.panel-section {
    margin-bottom: 16px;
    border: 1px solid #333333;
    border-radius: 4px;
    background-color: #1e1e1e;
    overflow: hidden;
}

.panel-section h2 {
    font-size: 0.75rem;
    color: #909090;
    background: #282828;
    padding: 8px 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    border-bottom: 1px solid #333333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.panel-section h2::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #94a3b8;
    transition: transform 0.3s ease;
}

.panel-section.is-collapsed h2::after {
    transform: rotate(-90deg);
}

.panel-section.is-collapsed > *:not(h2) {
    display: none !important;
}

.panel-section .component-group, 
.panel-section .input-group {
    padding: 12px 14px;
}

.component-group {
    border-bottom: 1px solid #334155;
    padding-bottom: 12px;
}

.component-group:last-child {
    border-bottom: none;
}

.component-group h3 {
    color: #94a3b8 !important;
    font-size: 0.75rem !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px !important;
    font-weight: 600;
}

.input-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.input-group.vertical-group {
    flex-direction: column;
    align-items: stretch;
}

.input-group.vertical-group label {
    margin-bottom: 6px;
    display: block;
}

.input-group:last-child {
    margin-bottom: 0;
}

.input-group label {
    font-size: 0.8rem;
    color: #a0a0a0;
}

.input-group input, .input-group select, .input-group textarea {
    width: 100px;
    padding: 6px 10px;
    background-color: #121212;
    border: 1px solid #333333;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.82rem;
    transition: border-color 0.1s;
}

.input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100px;
}

.input-container input {
    width: 100% !important;
    padding-right: 35px !important; /* Space for the unit */
}

.unit-badge {
    position: absolute;
    right: 8px;
    font-size: 0.65rem;
    color: #606060;
    pointer-events: none;
    font-weight: 600;
}

.input-group input:hover, .input-group select:hover, .input-group textarea:hover {
    border-color: #4a4a4a;
}

.input-group input:focus, .input-group select:focus, .input-group textarea:focus {
    outline: none;
    border-color: #606060;
}

.input-group select {
    width: 140px;
    cursor: pointer;
}

button {
    background-color: #404040;
    color: #ffffff;
    border: 1px solid #4a4a4a;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 500;
    transition: background 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover {
    background-color: #4a4a4a;
}

button:active {
    background-color: #333333;
    transform: translateY(0);
}

button:disabled {
    background-color: #222222;
    color: #555555;
    cursor: not-allowed;
    border-color: #282828;
}

.add-wall-btn, #btn-open-divider-modal, #btn-add-top, #btn-open-joint-modal, #btn-mode-corner, #btn-open-handle-modal, #btn-open-text-modal, #btn-open-custom-wall-mode {
    background-color: #334155;
    border: 1px solid #475569;
    width: 100%;
}

.add-wall-btn:hover, #btn-open-divider-modal:hover, #btn-add-top:hover, #btn-open-joint-modal:hover, #btn-mode-corner:hover, #btn-open-handle-modal:hover, #btn-open-text-modal:hover, #btn-open-custom-wall-mode:hover {
    background-color: #475569;
    border-color: #64748b;
}

.sidebar-action-button {
    justify-content: flex-start;
    text-align: left;
    padding-top: 5px;
    padding-bottom: 5px;
}

.sidebar-action-icon {
    width: 48px;
    height: 32px;
    max-width: 48px;
    max-height: 32px;
    flex: 0 0 32px;
    display: block;
    object-fit: contain;
    object-position: center;
}

.assembly-section .input-group {
    padding-top: 6px;
    padding-bottom: 6px;
    margin-bottom: 4px;
}

.wall-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.custom-wall-actions {
    margin-top: 10px;
}

#btn-open-custom-wall-mode {
    justify-content: center;
    text-align: center;
}

.item-list {
    list-style: none;
    margin-top: 10px;
}

.item-list li {
    background: #1a1a1a;
    border: 1px solid #333333;
    border-radius: 4px;
    color: #e0e0e0;
    padding: 10px;
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-list li:last-child {
    margin-bottom: 0;
}

.item-list li span {
    color: #f1f5f9;
    font-weight: 500;
}

.item-list button {
    background-color: #e74c3c;
    padding: 2px 6px;
    font-size: 0.8rem;
}

.item-list button:hover {
    background-color: #c0392b;
}

.divider-config {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hidden {
    display: none !important;
}

#finger-editor {
    background-color: #f9f9f9;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 10px;
}

#finger-editor h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.viewer-container {
    flex: 1;
    min-width: 0;
    position: relative;
    background-color: #ffffff;
}

#three-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background-color: #ffffff; /* Match Three.js scene background */
}

.custom-wall-sketch-overlay {
    position: absolute;
    inset: 0;
    z-index: 45;
    pointer-events: none;
}

#custom-wall-sketch-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: rgba(248, 250, 252, 0.95);
    pointer-events: auto;
    cursor: crosshair;
}

.custom-wall-sketch-overlay.awaiting-wall-selection #custom-wall-sketch-canvas {
    pointer-events: none;
    background: rgba(248, 250, 252, 0.55);
}

.custom-wall-sketch-toolbar,
.custom-wall-selection-panel,
.custom-wall-sketch-status {
    position: absolute;
    pointer-events: auto;
}

.custom-wall-sketch-toolbar {
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #404040;
    border-radius: 8px;
    background: #242424;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    flex-wrap: wrap;
    z-index: 2;
}

.sketch-toolbar-group {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-height: 46px;
    padding-right: 14px;
    margin-right: 2px;
    border-right: 1px solid #333333;
}

.sketch-toolbar-group:last-of-type {
    border-right: none;
    padding-right: 0;
    margin-right: 0;
}

.sketch-toolbar-label {
    font-size: 0.68rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    line-height: 1;
}

.sketch-toolbar-buttons {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sketch-toolbar-buttons-icons {
    gap: 8px;
}

.sketch-tool-btn,
.primary-sketch-btn,
.secondary-sketch-btn {
    border-radius: 4px;
    min-height: 32px;
    font-size: 0.8rem;
    font-weight: 500;
}

.sketch-tool-btn {
    background: #334155;
    border: 1px solid #475569;
    color: #f8fafc;
    padding: 6px 12px;
}

.sketch-tool-btn:hover {
    background: #475569;
    border-color: #64748b;
}

.sketch-tool-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.sketch-icon-btn {
    width: 38px;
    min-width: 38px;
    padding: 6px;
}

.sketch-icon-btn img {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.sketch-toggle {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: center;
    color: #a0a0a0;
    font-size: 0.78rem;
    padding: 6px 0 0;
}

.sketch-toggle input {
    width: auto;
}

.custom-wall-sketch-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    align-self: center;
    margin-left: 10px;
    padding-left: 12px;
    border-left: 1px solid #333333;
}

.custom-wall-selection-panel {
    top: 84px;
    left: 20px;
    width: 220px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #404040;
    background: #242424;
    color: #e0e0e0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.custom-wall-selection-panel.hidden {
    display: none;
}

.custom-wall-selection-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 6px;
}

.custom-wall-selection-text {
    color: #a0a0a0;
    font-size: 0.8rem;
    line-height: 1.45;
}

.custom-wall-sketch-status {
    left: 20px;
    bottom: 20px;
    min-width: 220px;
    padding: 10px 12px;
    border-radius: 6px;
    background: #242424;
    border: 1px solid #404040;
    border-left: 4px solid #334155;
    color: #d1d5db;
    font-size: 0.8rem;
    line-height: 1.45;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.primary-sketch-btn {
    background: #2563eb;
    border: 1px solid #2563eb;
    color: #ffffff;
    min-width: 118px;
}

.primary-sketch-btn:hover {
    background: #1d4ed8;
}

.secondary-sketch-btn {
    background: #333333;
    border: 1px solid #404040;
    color: #a0a0a0;
    min-width: 118px;
}

.secondary-sketch-btn:hover {
    background: #383838;
    color: #ffffff;
}

.custom-wall-sketch-overlay:not(.hidden) ~ .cursor-mode-bar {
    display: none;
}

#viewcube-container {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 120px;
    height: 120px;
}

.viewcube-home-btn {
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: #333;
    cursor: pointer;
    z-index: 10;
    transition: all 0.1s;
}

.viewcube-home-btn:hover {
    background-color: #ffffff;
    border-color: #999;
}

/* Modals & Overlays */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.modal-overlay.modal-centered {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

.modal-overlay.modal-centered .modal-container {
    position: relative;
    top: auto;
    left: auto;
    margin: 0;
    box-shadow: 0 15px 50px rgba(0,0,0,0.6);
}

.modal-container {
    pointer-events: auto;
    background: #242424;
    padding: 20px;
    border-radius: 8px;
    width: 300px;
    position: absolute;
    top: 5px;
    left: 5px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid #404040;
}

.modal-header {
    cursor: grab;
    margin: -20px -20px 15px -20px;
    padding: 12px 20px;
    background: #1a1a1a;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    border-bottom: 1px solid #404040;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 0.95rem;
    color: #ffffff;
    font-weight: 600;
}

.modal-body {
    color: #a0a0a0;
}

.modal-selection-text {
    font-size: 0.85rem;
    color: #808080;
    margin-bottom: 15px;
    min-height: 3em;
    line-height: 1.4;
}

.modal-footer {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.secondary-btn {
    background-color: #333333;
    color: #a0a0a0;
    border: 1px solid #404040;
}

.secondary-btn:hover {
    background-color: #383838;
    color: #ffffff;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.close-btn:hover {
    color: #333;
    background: none;
}

.properties-body {
    padding: 15px;
}

.properties-section h4 {
    margin: 0 0 12px 0;
    font-size: 0.75rem;
    color: #606060;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.properties-divider {
    height: 1px;
    background: #333333;
    margin: 15px 0;
}

.property-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.property-label {
    font-size: 0.85rem;
    color: #909090;
}

.property-value {
    font-size: 0.85rem;
    color: #e0e0e0;
}

.property-value.fixed {
    color: #d4a373;
    display: flex;
    align-items: center;
    gap: 6px;
}

.property-input {
    width: 100%; /* Take full width of container */
    background: #121212;
    border: 1px solid #333333;
    border-radius: 4px;
    color: #e0e0e0;
    padding: 4px 6px;
    font-size: 0.85rem;
    text-align: right;
}

.property-input.invalid {
    border-color: #e74c3c !important;
    background-color: #2c1a1a !important;
}

.property-unit {
    display: none; /* Obsolete now, using unit-badge */
}

.property-row .input-container {
    display: flex;
    align-items: center;
}

.property-toggle-row {
    gap: 12px;
}

.property-toggle {
    width: 18px;
    height: 18px;
    accent-color: #d4a373;
    cursor: pointer;
}

.property-shape-selector {
    display: flex;
    align-items: center;
    gap: 6px;
}

.property-shape-btn {
    background: #1a1a1a;
    border: 1px solid #333333;
    border-radius: 4px;
    padding: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.property-shape-btn:hover {
    border-color: #505050;
    background: #282828;
}

.property-shape-btn.active {
    border-color: #5f87ff;
    background: #2a3555;
    box-shadow: 0 0 0 1px rgba(95, 135, 255, 0.2);
}

.property-shape-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
    pointer-events: none;
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.tutorial-box {
    background: #242424;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    text-align: center;
    max-width: 400px;
    border: 1px solid #404040;
}

.tutorial-box h2 {
    margin-bottom: 15px;
    color: #ffffff;
}

.tutorial-box p {
    margin-bottom: 10px;
    text-align: left;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #a0a0a0;
}

.placement-btn {
    background: #1a1a1a;
    border: 1px solid #333333;
    border-radius: 4px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    width: 64px;
    height: 64px;
}

.placement-btn:hover {
    border-color: #505050;
    background: #282828;
}

.placement-btn.active {
    border-color: #606060;
    background: #383838;
}

.placement-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    filter: invert(0.8);
}

.placement-btn.active img {
    filter: invert(1);
}

/* Cursor Mode Icon Bar */
.cursor-mode-bar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #242424;
    padding: 4px;
    border-radius: 8px;
    display: flex;
    gap: 4px;
    border: 1px solid #404040;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    z-index: 50;
}

.mode-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    width: 36px;
    height: 36px;
}

.mode-btn:hover {
    background: #383838;
}

.mode-btn.active {
    background: #4a4a4a;
}

.mode-btn img {
    width: 22px;
    height: 22px;
    filter: brightness(0) invert(0.8);
    transition: filter 0.1s;
    object-fit: contain;
}

#btn-mode-measure img {
    width: 26px;
    height: 26px;
}

.mode-btn.active img {
    filter: brightness(0) invert(1);
}

.measure-selection-summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.measure-selection-chip {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid #3a3a3a;
    border-left: 5px solid #4b5563;
    border-radius: 8px;
    background: #2b2b2b;
    color: #ececec;
}

.measure-selection-chip:first-child {
    border-left-color: #10b981;
}

.measure-selection-chip:last-child {
    border-left-color: #f59e0b;
}

.measure-selection-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #b8b8b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.measure-results-section {
    border: 1px solid #3a3a3a;
    border-radius: 10px;
    background: #262626;
    padding: 12px;
}

.measure-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    font-weight: 600;
}

.measure-results-hint,
.measure-results-empty {
    font-size: 0.78rem;
    color: #a9a9a9;
}

.measure-results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.measure-result-button {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #3c3c3c;
    border-radius: 8px;
    background: #333333;
    color: #f3f4f6;
    cursor: pointer;
    transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}

.measure-result-button:hover {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
    background: #3a3f46;
}

.measure-result-label {
    font-size: 0.82rem;
    color: #d1d5db;
}

.measure-result-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #f9fafb;
}

.shape-btn {
    background: #1a1a1a;
    border: 1px solid #333333;
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    width: 64px;
    height: 64px;
}

.shape-btn:hover {
    border-color: #505050;
    background: #282828;
}

.shape-btn.active {
    border-color: #606060;
    background: #383838;
}

.shape-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: invert(0.8);
}

.shape-btn.active img {
    filter: invert(1);
}

/* Helper Classes */
.shortcut-text {
    opacity: 0.5;
    font-size: 0.75rem;
}

.input-group-start {
    justify-content: flex-start;
    gap: 10px;
}

.mb-15 {
    margin-bottom: 15px;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
}

.flex-between-small {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
    font-size: 0.85rem;
    margin-top: 5px;
}

.w-60 {
    width: 60px;
}

.p-2 {
    padding: 2px;
}

.w-100 {
    width: 100%;
}

.icon-16 {
    width: 16px;
    height: 16px;
}

.finger-spacing-hint {
    font-size: 0.75rem;
    color: #808080;
    margin-top: -8px;
    margin-bottom: 12px;
    text-align: right;
}

.mt-15-mb-10 {
    margin-top: 15px;
    margin-bottom: 10px;
}

.placement-label {
    font-size: 0.8rem;
    color: #a0a0a0;
    display: block;
    margin-bottom: 8px;
}

.flex-gap-8 {
    display: flex;
    gap: 8px;
}

.flex-1 {
    flex: 1;
}

.flex-2 {
    flex: 2;
}

/* Modal and Utility Extensions */
.z-1001 { z-index: 1001; }
.z-1002 { z-index: 1002; }
.z-1100 { z-index: 1100; }
.z-2000 { z-index: 2000; }

.modal-wall-shape { top: 100px; left: 100px; }
.modal-move { width: 250px; }
.modal-measure { width: 340px; }
.modal-properties { width: 280px; }
.modal-about { width: 320px; }
.modal-export {
    width: min(92vw, 520px);
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
}

.export-tab-list {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    padding: 0 2px;
    border-bottom: 1px solid #404040;
}

.export-tab-button {
    flex: 1;
    position: relative;
    padding: 11px 14px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    background: transparent;
    color: #b8b8b8;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transform: translateY(1px);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.export-tab-button:hover {
    background: #202020;
    color: #f2f2f2;
}

.export-tab-button.active {
    background: #2b2b2b;
    border-color: #5f5f5f;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    color: #ffffff;
}

.export-tab-button.active::after {
    content: "";
    position: absolute;
    left: -1px;
    right: -1px;
    bottom: -1px;
    height: 2px;
    background: #242424;
}

.export-tab-button:focus-visible {
    outline: none;
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.export-tab-panel {
    display: none;
}

.export-tab-panel.active {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.export-format-group,
.export-stroke-group,
.export-kerf-group {
    margin-bottom: 0;
}

.export-kerf-group {
    display: grid;
    grid-template-columns: 72px 120px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.export-kerf-group > label {
    margin: 0;
    line-height: 1.15;
}

.export-kerf-group .input-container {
    width: 120px;
}

.export-kerf-group .input-container input {
    min-width: 0;
    padding-right: 35px !important;
}

.export-radio-group {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.export-radio-option,
.export-checkbox-option {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d0d0d0;
    font-size: 0.9rem;
}

.export-radio-option {
    background: #1a1a1a;
    border: 1px solid #404040;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
}

.export-radio-option input,
.export-checkbox-option input {
    margin: 0;
}

.export-checkbox-option {
    cursor: pointer;
}

.export-helper-text {
    margin: 0;
    color: #9b9b9b;
    font-size: 0.8rem;
    line-height: 1.5;
}

.export-preview-panel {
    background: #1a1a1a;
    border: 1px solid #404040;
    border-radius: 10px;
    padding: 12px;
}

.export-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    color: #d0d0d0;
    font-size: 0.85rem;
    font-weight: 600;
}

.export-preview-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #2c2c2c;
    border: 1px solid #4a4a4a;
    color: #ffffff;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

.export-preview-canvas {
    display: block;
    width: 100%;
    height: 240px;
    background: #ffffff;
    border-radius: 8px;
}

.export-preview-size-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #2d2d2d;
}

.export-preview-size-label {
    color: #9f9f9f;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.export-preview-size-value {
    color: #f5f5f5;
    font-size: 0.9rem;
    font-weight: 600;
}

.export-preview-note {
    margin: 10px 0 0 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #909090;
}
.modal-corners { width: 320px; }

.corner-selection-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    color: #a0a0a0;
}

.checkbox-container input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-container.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.checkbox-container.disabled input {
    cursor: not-allowed;
}

.modal-handle {
    width: 340px;
}

.modal-text {
    width: 360px;
}

.modal-text .input-group {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
}

.modal-text .input-group > :not(label) {
    width: 100%;
    min-width: 0;
}

.modal-text .input-group input,
.modal-text .input-group select,
.modal-text .input-group textarea {
    width: 100%;
}

.text-font-picker {
    position: relative;
    width: 100%;
}

.text-font-trigger {
    width: 100%;
    min-height: 42px;
    background: #0a0a0a;
    border: 1px solid #4b5563;
    border-radius: 4px;
    color: #e5e7eb;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    text-align: left;
}

.text-font-trigger:hover {
    border-color: #64748b;
}

.text-font-trigger-preview {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
    text-align: left;
}

.text-font-trigger-caret {
    color: #94a3b8;
    flex-shrink: 0;
}

.text-font-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 6px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    z-index: 1200;
    padding: 6px;
}

.text-font-option {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #f3f4f6;
    padding: 10px 12px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 3px;
    cursor: pointer;
}

.text-font-option:hover,
.text-font-option.is-selected {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(96, 165, 250, 0.45);
}

.text-font-option-name {
    font-size: 1.05rem;
    line-height: 1.1;
    margin-bottom: 2px;
}

.text-font-option-meta {
    font-size: 0.72rem;
    color: #94a3b8;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.modal-text textarea {
    min-height: 84px;
    resize: vertical;
    font-family: inherit;
}

.modal-text input[readonly] {
    color: #cbd5e1;
}

.handle-offset-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.handle-offset-row select {
    flex: 1;
}

.handle-offset-row .input-container {
    width: 120px;
}

.corner-control-item {
    background: #1a1a1a;
    border: 1px solid #333333;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 10px;
}

.corner-control-item h4 {
    font-size: 0.8rem;
    color: #d4a373;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.text-center { text-align: center; }
.p-30-20 { padding: 30px 20px; }
.mt-10 { margin-top: 10px; }
.mt-5 { margin-top: 5px; }
.mt-15 { margin-top: 15px; }
.mt-30 { margin-top: 30px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.pt-20 { padding-top: 20px; }

.border-top { border-top: 1px solid #404040; }
.text-small { font-size: 0.8rem; }
.text-muted { color: #64748b; }
.text-large { font-size: 1.1rem; }
.font-bold { font-weight: 600; }

.btn-delete {
    width: 100%;
    background-color: #552222 !important;
    border-color: #663333 !important;
}
.btn-delete:hover {
    background-color: #663333 !important;
}

/* Notification System */
.notification-container {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.notification {
    background-color: #242424;
    color: #e0e0e0;
    padding: 12px 20px;
    border-radius: 6px;
    border-left: 4px solid #404040;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    min-width: 250px;
    max-width: 400px;
    pointer-events: auto;
    animation: slideIn 0.3s ease, fadeOut 0.5s ease 4.5s forwards;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification.success { border-left-color: #2ecc71; }
.notification.error { border-left-color: #e74c3c; }
.notification.warning { border-left-color: #f1c40f; }
.notification.info { border-left-color: #3498db; }

.notification.confirm {
    border-left-color: #9b59b6;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    animation: slideIn 0.3s ease; /* Remove auto-fade out for confirmations */
}

.prompt-notification {
    min-width: 320px;
}

.action-notification {
    min-width: 340px;
    max-width: 520px;
}

.notification-title {
    font-size: 1rem;
    font-weight: 700;
    color: #f8fafc;
}

.notification-message {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #cbd5e1;
}

.action-notification-actions {
    flex-wrap: wrap;
}

.action-notification-actions .confirm-btn,
.action-notification-actions a.confirm-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.prompt-notification-input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid #555;
    background-color: #1a1a1a;
    color: #e0e0e0;
    outline: none;
}

.prompt-notification-input:focus {
    border-color: #9b59b6;
    box-shadow: 0 0 0 1px rgba(155, 89, 182, 0.4);
}

.confirm-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: flex-end;
}

.confirm-btn {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: opacity 0.1s;
}

.confirm-btn:hover {
    opacity: 0.8;
}

.ok-btn {
    background-color: #9b59b6;
    color: white;
}

.cancel-btn {
    background-color: #404040;
    color: #e0e0e0;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Floating Gizmo Input */
.gizmo-floating-input {
    position: absolute;
    transform: translate(-50%, -100%);
    background: rgba(36, 36, 36, 0.9);
    border: 1px solid #00aaff;
    border-radius: 4px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.gizmo-floating-input input {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 0.9rem;
    width: 60px;
    text-align: right;
    outline: none;
}

.gizmo-floating-input .unit-text {
    font-size: 0.75rem;
    color: #808080;
    font-weight: 600;
}
