/* ===== CSS Variables & Theme ===== */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.1);
    --secondary: #10b981;
    --secondary-hover: #059669;
    --accent: #f59e0b;
    --danger: #ef4444;

    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-glass: rgba(30, 41, 59, 0.8);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border: #334155;
    --border-light: #475569;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    --sidebar-width: 280px;
    --navbar-height: 60px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --bg-glass: rgba(255, 255, 255, 0.9);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-light: #cbd5e1;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.15);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Typography ===== */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
}

h4 {
    font-size: 0.875rem;
    font-weight: 600;
}

/* ===== Navigation ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 1000;
    gap: 2rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.nav-brand i {
    font-size: 1.5rem;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.nav-links a {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-fast);
}

.nav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav-links a.active {
    color: var(--primary);
    background: var(--primary-light);
}

.nav-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-menu {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1rem;
    z-index: 999;
}

.mobile-menu.active {
    display: flex;
}

.mobile-menu a {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.mobile-menu a:hover,
.mobile-menu a.active {
    background: var(--bg-tertiary);
    color: var(--primary);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-success {
    background: var(--secondary);
    color: white;
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* ===== Main Layout ===== */
.main-content {
    display: flex;
    margin-top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
}

.right-sidebar {
    border-right: none;
    border-left: 1px solid var(--border);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
}

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.sidebar-header h2 i {
    color: var(--primary);
}

/* ===== Panel ===== */
.panel {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-mode-panel {
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.sidebar-mode-panel:not(.hidden) {
    animation: fadeIn var(--transition-fast);
}

.room-templates-panel {
    display: grid;
    gap: 1rem;
}

.custom-template-builder {
    display: grid;
    gap: 0.75rem;
}

.room-template-card.custom-template-card {
    padding: 0.55rem;
    border-style: dashed;
    text-align: left;
}

.room-template-preview.custom-template-card__preview {
    min-height: 146px;
    padding: 0.3rem 0.6rem 0.15rem 0.15rem;
}

.room-template-illustration.custom-template-card__illustration {
    width: 88%;
}

.custom-template-card__copy {
    display: grid;
    gap: 0.12rem;
    padding: 0.15rem 0.65rem 0.65rem;
}

.custom-template-card__copy strong {
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.3;
}

.custom-template-card__copy small {
    color: var(--text-secondary);
    font-size: 0.7rem;
    line-height: 1.35;
}

.custom-template-card__plus {
    fill: var(--secondary);
    stroke: rgba(255, 255, 255, 0.92);
    stroke-width: 2;
}

.custom-template-card__plus-mark {
    fill: none;
    stroke: #ffffff;
    stroke-width: 3.5;
    stroke-linecap: round;
}

.room-template-card.custom-template-card.is-drawing {
    border-style: solid;
    border-color: rgba(16, 185, 129, 0.72);
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.08) 0%, rgba(15, 23, 42, 0.1) 100%);
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.34), 0 18px 32px rgba(15, 23, 42, 0.22);
}

.room-template-card.custom-template-card.has-template {
    border-style: solid;
}

.room-templates-copy {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.room-templates-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.architecture-panel {
    display: grid;
    gap: 0.85rem;
}

.architectural-catalog {
    display: grid;
    gap: 0.9rem;
    padding-top: 0.2rem;
}

.architectural-catalog-section {
    display: grid;
    gap: 0.55rem;
}

.architectural-catalog-heading {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.architectural-items-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.architectural-opening-card,
.architectural-opening-btn {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.55rem;
    min-height: 54px;
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font: inherit;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.architectural-opening-card:hover,
.architectural-opening-card:focus-visible,
.architectural-opening-btn:hover,
.architectural-opening-btn:focus-visible {
    outline: none;
    border-color: rgba(99, 102, 241, 0.56);
    background: rgba(99, 102, 241, 0.12);
}

.architectural-opening-card:active {
    transform: translateY(1px);
}

.architectural-opening-card.is-active,
.architectural-opening-card[aria-pressed="true"],
.architectural-opening-btn.is-active,
.architectural-opening-btn[aria-pressed="true"] {
    border-color: rgba(99, 102, 241, 0.72);
    background: rgba(99, 102, 241, 0.18);
    color: var(--primary);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.42);
}

.architectural-opening-card[disabled] {
    cursor: not-allowed;
    opacity: 0.48;
}

.architectural-opening-preview {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(148, 163, 184, 0.34);
    border-radius: 7px;
    background: rgba(15, 23, 42, 0.22);
}

.architectural-opening-preview i {
    color: #93c5fd;
    font-size: 1rem;
}

.architectural-opening-card.is-active .architectural-opening-preview i {
    color: currentColor;
}

.architectural-opening-info {
    min-width: 0;
    display: grid;
    gap: 0.12rem;
    text-align: left;
}

.architectural-opening-name {
    overflow: hidden;
    color: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.architectural-opening-size {
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 0.68rem;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.architectural-opening-card.is-active .architectural-opening-size {
    color: currentColor;
    opacity: 0.74;
}

[data-theme="light"] .architectural-opening-card,
[data-theme="light"] .architectural-opening-btn {
    background: rgba(15, 23, 42, 0.03);
}

[data-theme="light"] .architectural-opening-card.is-active,
[data-theme="light"] .architectural-opening-card[aria-pressed="true"],
[data-theme="light"] .architectural-opening-btn.is-active,
[data-theme="light"] .architectural-opening-btn[aria-pressed="true"] {
    color: #4338ca;
    background: rgba(79, 70, 229, 0.12);
}

[data-theme="light"] .architectural-opening-preview {
    background: rgba(241, 245, 249, 0.72);
}

.room-template-card {
    width: 100%;
    display: grid;
    align-content: start;
    min-width: 0;
    gap: 0;
    padding: 0.4rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(15, 23, 42, 0.08) 100%);
    border: 1px solid var(--border);
    border-radius: 18px;
    color: inherit;
    text-align: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.room-template-card[draggable="true"] {
    cursor: grab;
}

.room-template-card:hover {
    border-color: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.24);
}

.room-template-card:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light), 0 14px 26px rgba(15, 23, 42, 0.2);
}

.room-template-card.is-selected,
.room-template-card[aria-pressed="true"] {
    border-color: rgba(99, 102, 241, 0.55);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.06) 0%, rgba(15, 23, 42, 0.1) 100%);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.4), 0 18px 32px rgba(15, 23, 42, 0.26);
}

.room-template-card.is-dragging {
    cursor: grabbing;
    opacity: 0.72;
    transform: scale(0.98);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.2);
}

.room-template-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 0.83;
    min-height: 128px;
    border-radius: 14px;
    overflow: visible;
    border: 1px solid transparent;
    background: transparent;
    display: grid;
    align-items: stretch;
    justify-items: start;
    box-sizing: border-box;
    padding: 0.78rem 0.82rem 0.95rem 0.2rem;
    box-shadow: none;
}

.room-template-card:hover .room-template-preview,
.room-template-card.is-selected .room-template-preview,
.room-template-card[aria-pressed="true"] .room-template-preview {
    border-color: transparent;
}

.room-template-illustration {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: visible;
    display: block;
    justify-self: start;
    align-self: stretch;
    transform-origin: left center;
    filter: drop-shadow(0 6px 9px rgba(15, 23, 42, 0.09));
}

.room-template-shadow {
    fill: rgba(15, 23, 42, 0.08);
}

.room-template-floor {
    stroke: #bfd0e3;
    stroke-width: 1.4;
    stroke-linejoin: round;
}

.room-template-wall {
    stroke: rgba(255, 255, 255, 0.96);
    stroke-width: 1.55;
    stroke-linejoin: round;
}

.room-template-wall--back {
    opacity: 0.98;
}

.room-template-wall--front {
    opacity: 1;
}

.room-template-rim {
    fill: none;
    stroke: #ffffff;
    stroke-width: 2.15;
    stroke-linecap: round;
    stroke-linejoin: round;
}

[data-theme="light"] .room-template-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(241, 245, 249, 0.94) 100%);
    border-color: rgba(203, 213, 225, 0.95);
}

[data-theme="light"] .room-template-card.is-selected,
[data-theme="light"] .room-template-card[aria-pressed="true"] {
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.4), 0 16px 30px rgba(148, 163, 184, 0.24);
}

[data-theme="light"] .room-template-preview {
    border-color: transparent;
    background: transparent;
}

[data-theme="light"] .room-template-floor {
    stroke: #b5c8df;
}

[data-theme="light"] .room-template-wall {
    stroke: rgba(255, 255, 255, 0.96);
}

/* Design presets (inline swatch before color input) */
.preset-swatch {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    background: var(--bg-tertiary);
    background-size: cover;
    background-position: center;
    cursor: pointer;
    padding: 0;
    transition: var(--transition-fast);
}

.preset-swatch:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.preset-inline-grid {
    display: none;
    margin: 0.4rem 0 0.4rem;
    max-height: 160px;
    overflow-y: auto;
}

.preset-inline-grid.open {
    display: grid;
}

.preset-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.preset-item {
    position: relative;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 0.4rem;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: var(--transition-fast);
    overflow: hidden;
    min-height: 64px;
    flex: 0 0 68px;
}

.preset-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.preset-item.active {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.preset-thumb {
    width: 100%;
    height: 40px;
    border-radius: var(--radius-sm);
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border);
}

.preset-label {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    line-height: 1.1;
}

/* ===== Input Groups ===== */
.input-group {
    margin-bottom: 1rem;
}

.input-group:last-child {
    margin-bottom: 0;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-with-icon {
    position: relative;
}

.input-with-icon input {
    padding-right: 2.5rem;
}

.input-unit {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.75rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition-fast);
    direction: ltr;
    unicode-bidi: plaintext;
    font-variant-numeric: tabular-nums;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-glow);
}

/* ===== Color Picker ===== */
.color-group {
    margin-bottom: 1rem;
}

.color-group:last-child {
    margin-bottom: 0;
}

.color-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

input[type="color"] {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 2px;
    background: var(--bg-tertiary);
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius-sm);
}

.color-hex {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.material-select {
    margin-top: 0.5rem;
}

/* ===== 3D Viewer ===== */
.viewer-container {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.viewer-page .main-content {
    margin-top: 0;
    height: 100vh;
}

.viewer-page .viewer-container {
    height: 100vh;
}

#canvas3d {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
}

#canvas3d canvas {
    display: block;
}

/* ===== 2D Wall Path Editor ===== */
.wall-path-editor {
    position: absolute;
    inset: 0;
    z-index: 12;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
    touch-action: none;
    user-select: none;
}

.wall-path-editor[hidden] {
    display: none;
}

.wall-path-editor.is-active {
    pointer-events: all;
    cursor: crosshair;
}

.wall-path-editor__path,
.wall-path-editor__wall-shadow,
.wall-path-editor__preview,
.wall-path-editor__preview-shadow {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.wall-path-editor__footprint-preview {
    fill: rgba(201, 215, 232, 0.84);
    stroke: rgba(183, 200, 220, 0.92);
    stroke-width: 1.5;
    filter: drop-shadow(0 8px 12px rgba(15, 23, 42, 0.18));
    vector-effect: non-scaling-stroke;
}

.wall-path-editor__wall-shadow {
    stroke: rgba(15, 23, 42, 0.32);
    stroke-width: 18;
    filter: blur(0.35px);
}

.wall-path-editor__path {
    stroke: #eef1f4;
    stroke-width: 14;
    filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.24));
}

.wall-path-editor__preview-shadow {
    stroke: rgba(15, 23, 42, 0.22);
    stroke-width: 18;
}

.wall-path-editor__preview {
    stroke: rgba(236, 239, 242, 0.78);
    stroke-width: 14;
}

.wall-path-editor__vertex {
    fill: #ffffff;
    stroke: #0f766e;
    stroke-width: 3;
    vector-effect: non-scaling-stroke;
}

.wall-path-editor__vertex--start {
    fill: #d1fae5;
    stroke: #059669;
}

.wall-path-editor__length-background {
    fill: rgba(15, 23, 42, 0.94);
    stroke: rgba(148, 163, 184, 0.55);
    stroke-width: 1;
}

.wall-path-editor__length-text {
    fill: #f8fafc;
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: 700;
}

.wall-drawing-hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.16);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.wall-drawing-hud[hidden] {
    display: none;
}

.wall-drawing-hud__copy {
    display: grid;
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.35;
}

.wall-drawing-hud__copy strong {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.wall-drawing-hud__copy strong i {
    color: var(--secondary);
}

.wall-drawing-hud__copy span {
    color: var(--text-secondary);
    font-size: 0.7rem;
    line-height: 1.4;
}

.wall-drawing-hud__length {
    min-width: 4.8rem;
    color: var(--secondary);
    font-size: 0.9rem;
    font-weight: 700;
    text-align: right;
}

.wall-drawing-hud__actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 0.45rem;
}

[data-theme="light"] .wall-drawing-hud {
    background: rgba(241, 245, 249, 0.9);
}

[data-theme="light"] .wall-path-editor__wall-shadow,
[data-theme="light"] .wall-path-editor__preview-shadow {
    stroke: rgba(71, 85, 105, 0.28);
}

.viewer-toolbar-wrap {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 60;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.viewer-toolbar-wrap::-webkit-scrollbar {
    height: 0;
}

.viewer-toolbar {
    display: flex;
    gap: 0.75rem;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    flex: 0 0 auto;
    flex-wrap: nowrap;
    max-width: 100%;
    margin: 0 auto;
    overflow: visible;
    position: relative;
    z-index: 1;
}

.viewer-buy-panel {
    position: absolute;
    right: 1.25rem;
    bottom: 1.25rem;
    width: min(320px, calc(100% - 2.5rem));
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: grid;
    gap: 0.6rem;
    z-index: 20;
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-lg);
}

.buy-panel-header {
    display: grid;
    gap: 0.2rem;
}

.buy-panel-title {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.buy-panel-subtitle {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.buy-panel-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.viewer-buy-panel .btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.toolbar-group {
    display: flex;
    gap: 0.25rem;
    position: relative;
    overflow: visible;
}

.toolbar-group:not(:last-child) {
    padding-right: 0.75rem;
    border-right: 1px solid var(--border);
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.65rem;
    height: 34px;
    min-height: 34px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.1;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
    flex: 0 0 auto;
}

.toolbar-btn i {
    font-size: 0.9rem;
}

.toolbar-btn[data-editor-mode] {
    min-width: 3.5rem;
}

.toolbar-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.toolbar-btn.active {
    background: var(--primary);
    color: white;
}

.toolbar-btn.btn-success {
    background: var(--secondary);
    color: white;
}

.toolbar-btn.btn-success:hover {
    background: var(--secondary-hover);
}

.toolbar-dropdown {
    position: relative;
    flex: 0 0 auto;
    overflow: visible;
    z-index: 50;
    isolation: isolate;
}

.floor-switcher-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    max-width: 40px;
    max-height: 40px;
    padding: 0;
    gap: 0;
    flex: 0 0 40px;
}

.floor-switcher-trigger i {
    font-size: 0.95rem;
    line-height: 1;
    flex: 0 0 auto;
}

.floor-switcher.open .floor-switcher-trigger,
.floor-switcher-trigger[aria-expanded="true"] {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.floor-switcher-trigger:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.floor-switcher-menu {
    position: absolute;
    top: calc(100% + 0.55rem);
    left: 0;
    width: min(270px, calc(100vw - 1.5rem));
    padding: 0.5rem;
    background: var(--bg-glass);
    backdrop-filter: blur(22px);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius-lg) - 2px);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top left;
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
    z-index: 400;
    will-change: opacity, transform;
}

.floor-switcher.open .floor-switcher-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.floor-switcher-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0.6rem 0.65rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.floor-switcher-menu-header span:first-child {
    max-width: 165px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.floor-switcher-list {
    display: grid;
    gap: 0.28rem;
}

.floor-switcher-option {
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.7rem;
    padding: 0.72rem 0.8rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
}

.floor-switcher-option i {
    font-size: 0.84rem;
    color: var(--text-muted);
}

.floor-switcher-option-body {
    min-width: 0;
    display: grid;
    gap: 0.08rem;
}

.floor-switcher-option-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-primary);
}

.floor-switcher-option-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.floor-switcher-option-badge {
    justify-self: end;
    min-width: 0;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.floor-switcher-option-actions {
    display: inline-flex;
    align-items: center;
    justify-self: end;
    gap: 0.25rem;
}

.floor-switcher-option:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.floor-switcher-option:hover i {
    color: var(--text-primary);
}

.floor-switcher-option.active {
    background: var(--primary-light);
    border-color: rgba(99, 102, 241, 0.22);
}

.floor-switcher-option.active i,
.floor-switcher-option.active .floor-switcher-option-badge {
    color: var(--primary);
}

.floor-switcher-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.floor-switcher-icon-btn i {
    font-size: 0.82rem;
    color: currentColor;
}

.floor-switcher-icon-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.floor-switcher-icon-btn.danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.floor-switcher-icon-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.floor-switcher-option:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
}

.floor-switcher-option.add-floor-option {
    margin-top: 0.35rem;
    border-top: 1px solid var(--border);
    padding-top: 0.9rem;
}

.floor-switcher-option.add-floor-option .floor-switcher-option-label {
    color: var(--text-primary);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loader {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Furniture Panel ===== */
.furniture-search {
    position: relative;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.furniture-search input {
    padding-right: 2.5rem;
}

.furniture-search i {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.tool-category-panel {
    display: grid;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.tool-category-section {
    display: grid;
    gap: 0.65rem;
}

.tool-category-title {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.furniture-categories,
.architecture-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.category-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.category-btn i {
    color: currentColor;
    font-size: 0.82rem;
}

.category-btn:hover {
    background: var(--border-light);
}

.category-btn.active,
.category-btn.is-active,
.category-btn[aria-pressed="true"] {
    background: var(--primary);
    color: white;
}

.furniture-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    max-height: 300px;
    overflow-y: auto;
}

.furniture-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    cursor: grab;
    transition: var(--transition-fast);
    text-align: center;
}

.furniture-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.furniture-item.is-active,
.furniture-item[aria-pressed="true"] {
    border-color: rgba(99, 102, 241, 0.72);
    background: rgba(99, 102, 241, 0.18);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.42);
}

.furniture-item:active {
    cursor: grabbing;
}

.catalog-furniture-item {
    touch-action: none;
    user-select: none;
    -webkit-user-drag: none;
}

.catalog-furniture-item.is-catalog-drag-pending {
    border-color: var(--primary);
}

.catalog-furniture-item.is-catalog-drag-source {
    opacity: 0.58;
    transform: scale(0.98);
    cursor: grabbing;
}

body.is-catalog-furniture-dragging,
body.is-catalog-furniture-dragging * {
    user-select: none !important;
}

#canvas3d.is-catalog-drop-target,
#canvas3d.is-catalog-drop-target canvas {
    cursor: copy !important;
}

#canvas3d.is-catalog-drop-invalid,
#canvas3d.is-catalog-drop-invalid canvas {
    cursor: not-allowed !important;
}

.furniture-item i {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    display: block;
}

.furniture-item span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.furniture-item .opening-size {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.68rem;
}

.furniture-custom-badge {
    margin-top: 0.35rem;
}

/* Objects List */
.objects-list {
    padding: 1rem 1.25rem;
    min-height: 150px;
}

.object-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.object-item i {
    color: var(--primary);
}

.object-item .name {
    flex: 1;
    font-size: 0.8125rem;
}

.object-item .actions {
    display: flex;
    gap: 0.25rem;
}

.object-item button {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.object-item button:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.object-item button.delete:hover {
    color: var(--danger);
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.empty-state span {
    font-size: 0.75rem;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal.catalog-drag-passthrough {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: none !important;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow: hidden;
    transform: translateY(20px);
    transition: var(--transition-normal);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header h2 i {
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1.25rem;
    border-top: 1px solid var(--border);
}

.modal .btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.upload-tile {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    padding: 1.5rem;
    width: 100%;
    max-width: 360px;
    margin: 0 auto 1rem;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-fast);
    flex-direction: column;
    gap: 0.75rem;
}

.upload-tile:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.upload-tile:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.upload-tile-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.upload-tile-empty p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.upload-tile-empty span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.upload-plus {
    font-size: 2.5rem;
    color: var(--primary);
    line-height: 1;
}

.upload-tile-filled {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.upload-tile.has-file .upload-tile-empty {
    display: none;
}

.upload-tile.has-file .upload-tile-filled {
    display: flex;
}

.upload-file-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    word-break: break-word;
}

.upload-file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.inline-error,
.inline-message {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.5rem;
    display: none;
}

.inline-error.active,
.inline-message.active {
    display: block;
}

/* Furniture Library Grid */
.furniture-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

/* ===== Architectural Opening Size Panel ===== */
.architectural-opening-size-panel {
    position: fixed;
    z-index: 1450;
    width: min(250px, calc(100vw - 24px));
    display: grid;
    gap: 0.85rem;
    padding: 0.95rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
}

.architectural-opening-size-panel[hidden] {
    display: none;
}

.architectural-opening-size-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.architectural-opening-size-kicker,
.architectural-opening-size-style span,
.architectural-opening-size-input > span {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0;
}

.architectural-opening-size-header strong,
.architectural-opening-size-style strong {
    display: block;
    font-size: 0.95rem;
    line-height: 1.25;
    color: var(--text-primary);
}

.architectural-opening-size-style {
    display: grid;
    gap: 0.1rem;
    padding: 0.65rem 0.7rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.architectural-opening-size-close {
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.architectural-opening-size-close:hover,
.architectural-opening-size-close:focus-visible {
    color: var(--text-primary);
    border-color: var(--primary);
    outline: none;
}

.architectural-opening-size-input {
    display: grid;
    gap: 0.35rem;
}

.architectural-opening-size-input input {
    height: 40px;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
}

@media (max-width: 768px) {
    .architectural-opening-size-panel {
        left: 0.75rem !important;
        right: 0.75rem;
        top: auto !important;
        bottom: 0.75rem;
        width: auto;
    }
}
/* ===== Toast Notifications ===== */
.toast-container {
    display: none; /* hide toast messages */
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid var(--secondary);
}

.toast.success i {
    color: var(--secondary);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.error i {
    color: var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--accent);
}

.toast.warning i {
    color: var(--accent);
}

.toast-content {
    flex: 1;
}

.toast-content p {
    font-size: 0.875rem;
    font-weight: 500;
}

.toast-content span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Responsive Design ===== */
@media (max-width: 1200px) {
    .sidebar {
        width: 260px;
    }
}

@media (max-width: 992px) {
    .nav-links {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }

    .left-sidebar {
        position: fixed;
        left: -300px;
        top: var(--navbar-height);
        bottom: 0;
        z-index: 100;
        transition: var(--transition-normal);
        width: 280px;
    }

    .left-sidebar.active {
        left: 0;
    }

    .right-sidebar {
        position: fixed;
        right: -300px;
        top: var(--navbar-height);
        bottom: 0;
        z-index: 100;
        transition: var(--transition-normal);
        width: 280px;
    }

    .right-sidebar.active {
        right: 0;
    }

    .viewer-container {
        width: 100%;
    }

    .viewer-toolbar-wrap {
        top: 0.75rem;
        left: 0.75rem;
        right: 0.75rem;
    }

    .viewer-toolbar {
        gap: 0.6rem;
    }

    .floor-switcher-trigger {
        width: 40px;
        min-width: 40px;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 1rem;
    }

    .nav-brand span {
        display: none;
    }

    .nav-actions .btn span {
        display: none;
    }

    .viewer-toolbar-wrap {
        top: 0.5rem;
        left: 0.5rem;
        right: 0.5rem;
    }

    .viewer-toolbar {
        gap: 0.5rem;
    }

    .floor-switcher-trigger {
        width: 40px;
        min-width: 40px;
    }

    .floor-switcher-menu {
        width: min(250px, calc(100vw - 1.25rem));
    }

    .viewer-buy-panel {
        left: 0.75rem;
        right: 0.75rem;
        width: auto;
    }

    .furniture-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
}

/* ===== Auth Pages ===== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-primary) 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}

.auth-header .logo i {
    font-size: 2rem;
}

.auth-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.social-login {
    display: flex;
    gap: 0.75rem;
}

.social-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.social-btn:hover {
    background: var(--border);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Checkbox */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.checkbox-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ===== Dashboard ===== */
.dashboard-layout {
    display: flex;
    margin-top: var(--navbar-height);
    min-height: calc(100vh - var(--navbar-height));
}

.dashboard-sidebar {
    width: 250px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
}

.dashboard-menu {
    list-style: none;
}

.dashboard-menu li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.dashboard-menu li a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dashboard-menu li a.active {
    background: var(--primary-light);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

.dashboard-menu li a i {
    width: 20px;
    text-align: center;
}

.dashboard-main {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-size: 1.75rem;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.purple {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary);
}

.stat-icon.orange {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
}

.stat-icon.red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.stat-content h3 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.stat-content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Data Table */
.data-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.data-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.data-card-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.data-table tr:hover {
    background: var(--bg-tertiary);
}

.data-table .actions {
    display: flex;
    gap: 0.5rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* ===== Projects Page ===== */
.projects-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    margin-top: var(--navbar-height);
}

.projects-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition-fast);
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.project-thumbnail {
    height: 180px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.project-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project-thumbnail i {
    font-size: 3rem;
    color: var(--text-muted);
}

.project-info {
    padding: 1.25rem;
}

.project-info h3 {
    margin-bottom: 0.5rem;
}

.project-info p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.project-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.project-actions {
    display: flex;
    gap: 0.5rem;
}

/* ===== Library Page ===== */
.library-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    margin-top: var(--navbar-height);
}

.library-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.library-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition: var(--transition-fast);
    cursor: pointer;
}

.library-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.library-item i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.library-item h3 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.library-item p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Utility Classes ===== */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease;
}

.animate-slideUp {
    animation: slideUp 0.3s ease;
}

/* ===== Radial Menu ===== */
.radial-menu {
    position: fixed;
    width: 200px;
    height: 200px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.5);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1500;
}

.radial-menu.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    pointer-events: none;
}

.radial-menu.is-rotating .radial-btn:not([data-action="rotate"]) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.radial-menu.is-rotating .radial-btn[data-action="rotate"] {
    transition: none !important;
    animation: none !important;
}

.radial-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    --radial-transform: translate(-50%, -50%) rotate(var(--angle, 0deg)) translate(82px) rotate(calc(-1 * var(--angle, 0deg)));
    transform: var(--radial-transform) scale(1);
}

.radial-btn:hover {
    background: var(--primary);
    color: white;
    transform: var(--radial-transform) scale(1.15);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.radial-btn[data-action="rotate"]:hover {
    cursor: all-scroll !important;
}

.radial-btn[data-action="rotate"]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.94);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: none;
}

.radial-btn[data-action="rotate"]:hover::after,
.radial-btn[data-action="rotate"]:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

.radial-btn[data-action="delete"]:hover {
    background: var(--danger);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.radial-btn[data-action="buy"]:hover {
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.45);
}

/* Distinct style for buy/link button */
.radial-btn[data-action="buy"] {
    background: linear-gradient(135deg, #111827, #1f2937);
    border-color: #2d3748;
    color: #e5e7eb;
}

.radial-btn[data-action="scaleUp"]:hover,
.radial-btn[data-action="scaleDown"]:hover {
    background: var(--secondary);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.door-radial-menu {
    width: 190px;
    height: 190px;
}

.door-radial-menu .radial-btn {
    --radial-transform: translate(-50%, -50%) rotate(var(--angle, 0deg)) translate(76px) rotate(calc(-1 * var(--angle, 0deg)));
}

.radial-btn[data-action="doorSize"] { --angle: -90deg; }
.radial-btn[data-action="doorToggle"] { --angle: -18deg; }
.radial-btn[data-action="doorColor"] { --angle: 54deg; }
.radial-btn[data-action="doorDelete"] { --angle: 126deg; }
.radial-btn[data-action="openingCopy"] { --angle: 198deg; }

.door-radial-menu.is-window .radial-btn[data-action="doorToggle"] { --angle: 0deg; }
.door-radial-menu.is-window .radial-btn[data-action="doorColor"] { --angle: 90deg; }
.door-radial-menu.is-window .radial-btn[data-action="doorDelete"] { --angle: 180deg; }
.door-radial-menu.is-window .radial-btn[data-action="openingCopy"] {
    display: none;
}

.radial-btn[data-action="doorSize"]:hover {
    background: var(--secondary);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.radial-btn[data-action="doorToggle"]:hover {
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.42);
}

.radial-btn[data-action="openingCopy"]:hover {
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.42);
}

.radial-btn[data-action="doorColor"]:hover {
    background: var(--primary);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.radial-btn[data-action="doorDelete"]:hover {
    background: var(--danger);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.door-radial-menu.active .radial-btn[data-action="doorSize"] { animation: popInRadial 0.24s ease 0.04s both; }
.door-radial-menu.active .radial-btn[data-action="doorToggle"] { animation: popInRadial 0.24s ease 0.08s both; }
.door-radial-menu.active .radial-btn[data-action="doorColor"] { animation: popInRadial 0.24s ease 0.12s both; }
.door-radial-menu.active .radial-btn[data-action="doorDelete"] { animation: popInRadial 0.24s ease 0.16s both; }
.door-radial-menu.active .radial-btn[data-action="openingCopy"] { animation: popInRadial 0.24s ease 0.2s both; }

.room-template-context-toolbar {
    position: fixed;
    width: 148px;
    height: 148px;
    z-index: 1500;
    pointer-events: none;
}

.room-template-context-toolbar[hidden] {
    display: none;
}

.room-template-context-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--text-primary);
    --radial-transform: translate(
        calc(-50% + var(--template-action-x, 0px)),
        calc(-50% + var(--template-action-y, 0px))
    );
}

.room-template-context-btn.is-danger:hover,
.room-template-context-btn.is-danger:focus-visible {
    background: var(--danger);
    color: white;
}

.room-template-context-toolbar .room-template-context-btn[data-action="rotate"] {
    --template-action-x: 0px;
    --template-action-y: -48px;
}

.room-template-context-toolbar .room-template-context-btn[data-action="duplicate"] {
    --template-action-x: 50px;
    --template-action-y: -8px;
}

.room-template-context-toolbar .room-template-context-btn[data-action="delete"] {
    --template-action-x: -50px;
    --template-action-y: -8px;
}

.room-template-context-toolbar .room-template-context-btn[data-action="rotate"]:hover,
.room-template-context-toolbar .room-template-context-btn[data-action="rotate"]:focus-visible {
    cursor: all-scroll !important;
}

.room-template-context-toolbar.active .room-template-context-btn[data-action="rotate"] {
    animation: popInRadial 0.3s ease 0.05s both;
}

.room-template-context-toolbar.active .room-template-context-btn[data-action="duplicate"] {
    animation: popInRadial 0.3s ease 0.1s both;
}

.room-template-context-toolbar.active .room-template-context-btn[data-action="delete"] {
    animation: popInRadial 0.3s ease 0.15s both;
}

/* Even radial placement (7 items) */
.radial-btn[data-action="color"] { --angle: -90deg; }
.radial-btn[data-action="rotate"] { --angle: -38.571deg; }
.radial-btn[data-action="scaleUp"] { --angle: 12.857deg; }
.radial-btn[data-action="scaleDown"] { --angle: 64.285deg; }
.radial-btn[data-action="delete"] { --angle: 115.714deg; }
.radial-btn[data-action="buy"] { --angle: 167.143deg; }
.radial-btn[data-action="move"] { --angle: 218.571deg; }

/* Staggered animation for buttons (keep radial placement while scaling) */
.radial-menu.active .radial-btn[data-action="color"] { animation: popInRadial 0.3s ease 0.05s both; }
.radial-menu.active .radial-btn[data-action="rotate"] { animation: popInRadial 0.3s ease 0.1s both; }
.radial-menu.active .radial-btn[data-action="scaleUp"] { animation: popInRadial 0.3s ease 0.15s both; }
.radial-menu.active .radial-btn[data-action="scaleDown"] { animation: popInRadial 0.3s ease 0.2s both; }
.radial-menu.active .radial-btn[data-action="delete"] { animation: popInRadial 0.3s ease 0.25s both; }
.radial-menu.active .radial-btn[data-action="buy"] { animation: popInRadial 0.3s ease 0.3s both; }
.radial-menu.active .radial-btn[data-action="move"] { animation: popInRadial 0.3s ease 0.35s both; }

@keyframes popInRadial {
    from {
        opacity: 0;
        transform: var(--radial-transform) scale(0);
    }
    to {
        opacity: 1;
        transform: var(--radial-transform) scale(1);
    }
}

/* ===== Color Presets ===== */
.color-presets {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    padding: 0.5rem;
}

.color-preset {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    border: 3px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.color-preset:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

.color-preset.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== Move Mode Indicator ===== */
.move-mode-indicator {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.move-mode-indicator.active {
    opacity: 1;
    visibility: visible;
}

/* ===== Collision Warning ===== */
.collision-warning {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 1rem 2rem;
    border-radius: var(--radius-lg);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-fast);
}

.collision-warning.active {
    opacity: 1;
    visibility: visible;
}

/* Existing wall/floor preset tiles also act as drag sources. */
.preset-item.is-architectural-material-source {
    cursor: grab;
    touch-action: none;
}

.preset-item.is-material-drag-pending {
    border-color: var(--primary);
}

.preset-item.is-material-drag-source {
    opacity: 0.58;
    cursor: grabbing;
}

.material-drag-preview {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 190px;
    padding: 7px 10px 7px 7px;
    color: #f8fafc;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1.2;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);
    transform: translate3d(-9999px, -9999px, 0);
}

.material-drag-preview-swatch {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 6px;
    background-size: cover;
}

body.is-architectural-material-dragging,
body.is-architectural-material-dragging * {
    cursor: grabbing !important;
}

#canvas3d.is-material-drop-valid {
    cursor: copy !important;
}

#canvas3d.is-material-drop-invalid {
    cursor: not-allowed !important;
}


