:root {
    --top-menu-h: 72px;
    --status-bar-h: 48px;
    --drawer-w: 0px;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: "Montserrat", "Segoe UI", Tahoma, sans-serif;
    color: #1e293b;
}

.top-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #cbd5e1;
    background: #f8fafc;
}

.viewport {
    position: fixed;
    top: var(--top-menu-h);
    bottom: var(--status-bar-h);
    left: var(--drawer-w);
    right: 0;
    width: calc(100vw - var(--drawer-w));
    height: calc(100dvh - var(--top-menu-h) - var(--status-bar-h));
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.viewport canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.cost-overlay {
    position: fixed;
    top: calc(var(--top-menu-h) + 10px);
    right: 12px;
    z-index: 35;
    background: rgba(15, 23, 42, 0.88);
    color: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    pointer-events: auto;
    cursor: pointer;
}

.quote-card {
    display: grid;
    gap: 4px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    padding: 10px;
}

.quote-card small {
    color: #64748b;
}

.quote-card strong {
    font-size: 1.1rem;
    color: #0f172a;
}

.quote-category-list {
    margin-top: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
}

.quote-category-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-top: 1px solid #e2e8f0;
    font-size: 0.85rem;
}

.quote-category-row:first-child {
    border-top: 0;
}

.stored-designs-list {
    display: grid;
    gap: 6px;
}

.stored-design-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 6px;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px;
    background: #ffffff;
}

.stored-design-action {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
}

button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    background: #f8fafc;
    color: #1e293b;
    cursor: pointer;
}

.top-menu button.active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.drawer-backdrop {
    position: fixed;
    inset: var(--top-menu-h) 0 var(--status-bar-h) 0;
    z-index: 25;
    background: rgba(15, 23, 42, 0.35);
}

.left-drawer {
    position: fixed;
    top: var(--top-menu-h);
    bottom: var(--status-bar-h);
    left: 0;
    width: min(320px, 84vw);
    z-index: 30;
    background: #ffffff;
    border-right: 1px solid #cbd5e1;
    transform: translateX(-100%);
    transition: transform 160ms ease;
    padding: 10px;
    box-sizing: border-box;
    overflow-y: auto;
}

.left-drawer.open {
    transform: translateX(0);
}

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}

#drawerTitle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.drawer-section {
    display: none;
    gap: 8px;
}

.drawer-section.active {
    display: grid;
}

.drawer-section h2 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.drawer-section label {
    font-size: 0.82rem;
    color: #475569;
}

.drawer-section input,
.drawer-section select {
    width: 100%;
    box-sizing: border-box;
    padding: 6px;
}

.slider-field {
    display: grid;
    gap: 6px;
}

.slider-field[hidden] {
    display: none !important;
}

.slider-field label {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.slider-field label strong {
    color: #0f172a;
    font-size: 0.82rem;
}

.slider-field input[type="range"] {
    width: 100%;
    padding: 0;
    accent-color: #0f172a;
    cursor: pointer;
}

.location-search-wrap {
    position: relative;
}

.location-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 60;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.15);
    max-height: 220px;
    overflow-y: auto;
}

.location-suggestions[hidden] {
    display: none !important;
}

.location-suggestion-item {
    width: 100%;
    border: 0;
    border-top: 1px solid #e2e8f0;
    border-radius: 0;
    background: #ffffff;
    color: #0f172a;
    text-align: left;
    justify-content: flex-start;
    padding: 8px 10px;
    font-size: 0.78rem;
    line-height: 1.3;
}

.location-suggestion-item:first-child {
    border-top: 0;
}

.location-suggestion-item:hover {
    background: #f8fafc;
}

.neighbor-selector {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.neighbor-cell {
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    color: #334155;
    font-size: 0.78rem;
}

.neighbor-cell.side {
    cursor: pointer;
    flex-direction: column;
    gap: 2px;
    padding: 4px;
}

.neighbor-cell.side.active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.neighbor-cell.center {
    background: #ffffff;
    font-weight: 600;
    text-align: center;
    padding: 6px;
}

.neighbor-cell.corner {
    border-style: dashed;
    color: transparent;
}

.neighbor-side-size {
    font-size: 0.78rem;
    font-weight: 600;
}

.flooring-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.furniture-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.booth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.flooring-filter {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
}

.furniture-filter {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
}

.booth-filter {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
}

.flooring-filter input[type="search"] {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}

.furniture-filter input[type="search"] {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}

.flooring-filter-types {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.furniture-filter-types {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.booth-filter-types {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-chip {
    padding: 6px 8px;
    font-size: 0.74rem;
    border-radius: 999px;
}

.filter-chip.active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.floor-card {
    display: grid;
    gap: 6px;
    padding: 6px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
}

.furniture-card {
    display: grid;
    gap: 6px;
    padding: 6px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    text-align: left;
    cursor: grab;
}

.booth-card {
    display: grid;
    gap: 6px;
    padding: 6px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    text-align: left;
    cursor: pointer;
}

.booth-card-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background-color: #f8fafc;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.booth-card-preview.no-image {
    display: grid;
    place-items: center;
    background-image: linear-gradient(135deg, #f8fafc, #e2e8f0);
    color: #475569;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.booth-card.active {
    border-color: #0f172a;
    box-shadow: inset 0 0 0 1px #0f172a;
}

.booth-card-title {
    font-size: 0.78rem;
    color: #334155;
}

.booth-card-meta {
    font-size: 0.68rem;
    color: #64748b;
}

.booth-details {
    margin-top: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    padding: 8px;
    display: grid;
    gap: 8px;
}

.booth-details small {
    color: #64748b;
    font-size: 0.72rem;
}

.booth-details p {
    margin: 0;
    color: #334155;
    font-size: 0.78rem;
    line-height: 1.35;
}

.booth-instance-editor {
    margin-top: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    padding: 8px;
    display: grid;
    gap: 8px;
}

.booth-autofit-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: #334155;
}

.booth-autofit-row input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.booth-instance-size-fields {
    display: grid;
    gap: 6px;
}

.booth-instance-size-fields[hidden] {
    display: none !important;
}

.booth-banner-fields {
    display: grid;
    gap: 6px;
}

.booth-banner-fields[hidden] {
    display: none !important;
}

.booth-banner-fields small {
    color: #64748b;
    font-size: 0.72rem;
}

.booth-banner-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.booth-banner-grid label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    color: #334155;
}

.booth-setup-options {
    display: grid;
    gap: 8px;
    padding-top: 4px;
}

.furniture-card.active {
    border-color: #0f172a;
    box-shadow: inset 0 0 0 1px #0f172a;
}

.furniture-card-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background-size: cover;
    background-position: center;
    background-color: #f8fafc;
}

.furniture-card-title {
    font-size: 0.78rem;
    color: #334155;
    line-height: 1.2;
}

.furniture-card-meta {
    font-size: 0.68rem;
    color: #64748b;
}

.floor-card.active {
    border-color: #0f172a;
    box-shadow: inset 0 0 0 1px #0f172a;
}

.floor-card-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background-size: cover;
    background-position: center;
    background-color: #f1f5f9;
}

.floor-card.none .floor-card-preview {
    background-image:
        linear-gradient(90deg, rgba(71, 85, 105, 0.18) 1px, transparent 1px),
        linear-gradient(rgba(71, 85, 105, 0.18) 1px, transparent 1px);
    background-size: 16px 16px;
}

.floor-card-label {
    font-size: 0.75rem;
    color: #334155;
    text-align: left;
    line-height: 1.2;
    word-break: break-word;
}

.floor-card-badge {
    justify-self: start;
    font-size: 0.65rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #475569;
    background: #e2e8f0;
    border-radius: 999px;
    padding: 2px 6px;
}

.apply-flooring {
    margin-top: 10px;
    width: 100%;
}

.sr-only-controls {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.status-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    padding: 8px 12px;
    border-top: 1px solid #cbd5e1;
    background: #f8fafc;
}

.selected-item-ui {
    position: fixed;
    z-index: 45;
    transform: translate(-50%, -120%);
}

#selectedItemGearButton {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    justify-content: center;
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
    padding: 0;
}

.selected-item-menu {
    margin-top: 6px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
    padding: 6px;
    display: flex;
    gap: 6px;
}

.selected-item-action {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    justify-content: center;
    padding: 0;
    background: #f8fafc;
    color: #1e293b;
    border-color: #cbd5e1;
}

.selected-item-action.danger {
    color: #b91c1c;
    border-color: #fecaca;
    background: #fff1f2;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, 0.45);
    padding: 16px;
    box-sizing: border-box;
}

.modal-backdrop[hidden] {
    display: none !important;
}

.modal-card {
    width: min(360px, 100%);
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.28);
    padding: 14px;
}

.modal-card h2 {
    margin: 0 0 6px;
    font-size: 1rem;
    color: #0f172a;
}

.modal-card p {
    margin: 0;
    font-size: 0.85rem;
    color: #475569;
}

.booth-setup-modal {
    width: min(420px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
    display: grid;
    gap: 8px;
}

.booth-setup-modal-head {
    display: flex;
    justify-content: flex-start;
}

.booth-setup-back {
    padding: 6px 9px;
}

.booth-setup-modal-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: min(52vh, 320px);
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background-color: #f8fafc;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.booth-setup-modal-preview.no-image {
    display: grid;
    place-items: center;
    background-image: linear-gradient(135deg, #f8fafc, #e2e8f0);
    color: #475569;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.modal-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-actions .danger {
    border-color: #b91c1c;
    background: #b91c1c;
    color: #ffffff;
}

#summaryOutput {
    font-size: 0.95rem;
}

#summaryMeta,
#statusText {
    color: #64748b;
    font-size: 0.8rem;
}

@media (max-width: 740px) {
    .top-menu {
        gap: 6px;
        padding: 8px;
    }
}

@media (min-width: 980px) {
    :root {
        --drawer-w: 320px;
    }

    .left-drawer {
        transform: translateX(0);
    }

    .drawer-backdrop {
        display: none;
    }

    #closeDrawerButton {
        display: none;
    }

    .apply-flooring {
        display: none;
    }

    #applyFurnitureButton {
        display: none;
    }

    #applyBoothButton {
        display: none;
    }
}
