/* 360 Selector Viewer - main app styles */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #2b2b2b;
}

/* ===== Welcome overlay (tap to load app) ===== */
#welcome-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background-color: #2b2b2b;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    cursor: pointer;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

#welcome-overlay:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 4px;
}

#welcome-overlay.welcome-overlay-fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#welcome-overlay .welcome-overlay-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#welcome-overlay .welcome-overlay-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

#welcome-overlay .welcome-overlay-title {
    font-family: inherit;
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 700;
    color: #fff;
    margin: 0;
    letter-spacing: 0.02em;
}

#welcome-overlay .welcome-overlay-hint {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
    animation: welcome-overlay-pulse 1.8s ease-in-out infinite;
}

@keyframes welcome-overlay-pulse {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 1; }
}

@media (min-width: 769px) {
    #welcome-overlay { display: none; }
}

#layout {
    --sidebar-width: 390px;
    --sidebar-shift: calc(var(--sidebar-width) / 2);
    width: min(2400px, 100vw);
    height: clamp(400px, 100vh, 1200px);
    position: relative;
    background: #f0f0f0;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

.panel {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(200, 200, 200, 0.8);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 6px;
    padding: 12px;
}

/* ===== Sidebar ===== */
#sidebar {
    width: var(--sidebar-width);
    position: absolute;
    top: 20px;
    left: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
    z-index: 30;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: translateX(0);
    opacity: 1;
}

#layout.sidebar-collapsed {
    --sidebar-shift: 0px;
}

#layout.sidebar-collapsed #sidebar {
    transform: translateX(calc(-100% - 20px));
    opacity: 0;
    pointer-events: none;
}

#info-panel {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#info-panel.no-selection {
    display: none;
}

#info-panel .apt-title {
    font-size: 13px;
    font-weight: 600;
    color: #222;
}

#info-panel .info-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 2px;
}

#info-panel .plan-preview {
    position: relative;
    width: 100%;
    background: #e0e0e0;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    overflow: hidden;
}

#info-panel .plan-preview #plan-preview-img {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

#plan-preview-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    cursor: pointer;
}

#plan-preview-zoom-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

#plan-preview-zoom-btn:hover {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

#plan-preview-nav {
    position: absolute;
    bottom: 4px;
    right: 4px;
    z-index: 5;
    display: none;
    flex-direction: column;
    gap: 2px;
}

#plan-preview-nav.plan-preview-multi {
    display: flex;
}

#plan-preview-nav button {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

#plan-preview-nav button:hover:not(.active) {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

#plan-preview-nav button.active {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

#info-panel table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 4px;
}

#info-panel td {
    padding: 2px 8px;
    color: #444;
    border-bottom: 1px solid #bbb;
}

#info-panel td:first-child {
    color: #666;
    width: 45%;
}

#info-panel td:last-child {
    text-align: right;
}

#info-panel .details-toggle {
    cursor: pointer;
    user-select: none;
}

#info-panel .details-toggle td {
    color: #666;
    padding: 4px 0;
    border-bottom: none;
    text-align: left;
}

#info-panel .details-toggle + tr td {
    border-bottom: none;
    text-align: left;
}

#info-panel .details-toggle:hover td {
    color: #444;
}

#info-panel .expand-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    margin-right: 6px;
    vertical-align: middle;
    border-left: 4px solid currentColor;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    transition: transform 0.2s ease;
}

#info-panel .details-toggle.expanded .expand-arrow {
    transform: rotate(90deg);
}

#info-panel #details-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

#info-panel #details-body.expanded {
    max-height: 200px;
}

#info-panel #details-body .details-inner-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#info-panel #details-body .details-inner-table td {
    padding: 2px 0;
    color: #444;
}

#info-panel #details-body .details-inner-table td:first-child {
    color: #666;
    width: 45%;
    text-align: left;
}

#info-panel #details-body .details-inner-table td:last-child {
    text-align: right;
}

#info-panel #details-body .details-inner-table tr:last-child td {
    border-bottom: none;
}

#info-panel #price-history-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

#info-panel #price-history-body.expanded {
    max-height: 300px;
    overflow-y: auto;
}

#info-panel .price-history-empty {
    padding: 4px 0;
    color: #999;
    font-size: 12px;
    font-style: italic;
}

#info-panel .price-history-loading {
    padding: 4px 0;
    color: #999;
    font-size: 12px;
    font-style: italic;
}

#info-panel .price-history-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px solid #bbb;
}

#info-panel .price-history-entry:last-child {
    border-bottom: none;
}

#info-panel .ph-date {
    color: #666;
}

#info-panel .ph-price {
    color: #444;
    font-weight: 500;
}

#promotion-banner {
    margin-top: 8px;
    padding: 6px 12px;
    background: #c0392b;
    color: #fff;
    text-align: center;
    border-radius: 9px;
    cursor: pointer;
    transition: filter 0.15s;
}

#promotion-banner:hover {
    filter: brightness(1.15);
}

#promotion-banner .promo-dates {
    font-size: 11px;
    opacity: 0.85;
    margin-bottom: 4px;
}

#promotion-banner .promo-old-price {
    text-decoration: line-through;
    font-size: 11px;
    opacity: 0.9;
    margin-right: 6px;
}

#promotion-banner .promo-new-price {
    font-size: 18px;
    font-weight: 700;
}

.promo-old-price {
    text-decoration: line-through;
    font-size: 11px;
    color: #999;
}

.promo-table-price {
    font-weight: 500;
}

#apartment-table .col-price {
    text-align: right;
    white-space: normal;
}

#apartment-table .col-price.col-price-promo {
    min-height: 2.8em;
    padding-top: 6px;
    padding-bottom: 6px;
}

#info-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

#info-actions button {
    flex: 1;
    min-height: 36px;
    padding: 10px 0;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    border-radius: 9px !important;
    background: transparent !important;
    color: #555 !important;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

#info-actions button:hover {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.35) !important;
}

#info-actions #info-contact-btn {
    background: #222 !important;
    color: #fff !important;
    font-weight: 600 !important;
    border-color: #222 !important;
}

#info-actions #info-contact-btn:hover {
    background: #333 !important;
    border-color: #333 !important;
}

#filters-table-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    gap: 0;
}

#filters-panel {
    flex: 0 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 12px;
    position: relative;
    overflow: visible;
}

#filters-panel.collapsed {
    padding-bottom: 0;
    overflow: hidden;
}

#filters-header {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 0;
    margin: -12px -12px 0 -12px;
    padding: 0 0 0 12px;
    min-height: 40px;
    border-bottom: 1px solid rgba(200, 200, 200, 0.6);
}

#filters-panel.collapsed #filters-header {
    border-bottom: none;
}

#results-count {
    display: flex;
    align-items: center;
}

#filters-header-actions {
    display: flex;
    align-items: stretch;
    gap: 0;
    z-index: 1;
    border-left: 1px solid rgba(200, 200, 200, 0.6);
}

#filters-header-actions > * + * {
    border-left: 1px solid rgba(200, 200, 200, 0.6);
}

.filters-header-select {
    height: 100%;
    padding: 0 8px 0 20px;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 6px center;
    border: none;
    border-radius: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background-color 0.15s, color 0.15s;
}

.filters-header-select:hover {
    background-color: rgba(0, 0, 0, 0.12);
    color: #111;
}

.filters-header-select:focus {
    outline: none;
}

.filters-header-select option {
    background: #fff;
    color: #374151;
}

.filters-header-btn {
    height: 100%;
    padding: 0 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    background: transparent;
    border: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.filters-header-btn:hover {
    background: rgba(0, 0, 0, 0.12);
    color: #111;
}

#filters-collapse-btn {
    width: 32px;
    cursor: pointer;
    font-size: 18px;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 6px 0 0;
    transition: background 0.15s, color 0.15s;
    z-index: 1;
}

#filters-collapse-btn:hover {
    background: rgba(0, 0, 0, 0.12);
    color: #111;
}

#filters-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: visible;
    max-height: 600px;
    margin-top: 8px;
    opacity: 1;
    transition: max-height 0.3s ease, margin-top 0.3s ease, opacity 0.2s ease;
}

#filters-panel.collapsed #filters-body {
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    overflow: hidden;
}

#results-count {
    font-size: 12px;
    font-weight: 500;
    color: #111;
}

.filter-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: #333;
    overflow: visible;
}

.filter-header-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0 14px;
}

.filter-label {
    font-size: 12px;
    font-weight: 400;
    color: #9ca3af;
    flex-shrink: 0;
}

.filter-values {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    text-align: right;
    flex-shrink: 0;
}

.filter-select {
    flex: 1;
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
    color: #374151;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group.compact { flex: 0 0 auto; }

.dual-handle-slider {
    flex: 1;
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
    margin: 0 14px;
}

.slider-track {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: #999;
    border-radius: 1px;
    z-index: 0;
}

.filter-range-min { z-index: 3; }
.filter-range-max { z-index: 2; }

.slider-handle {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    border: 2px solid #999;
    box-shadow: none;
    cursor: pointer;
    transform: translate(-50%, -50%);
    z-index: 2;
    touch-action: none;
}

.slider-handle-min { z-index: 3; }
.slider-handle-max { z-index: 2; }

.slider-active-range {
    position: absolute;
    height: 2px;
    background: #999;
    border-radius: 1px;
    z-index: 0;
    opacity: 1;
    pointer-events: none;
}

.filter-range {
    position: absolute;
    width: 100%;
    height: 0;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
    margin: 0;
    padding: 0;
    opacity: 0;
}


.filter-heart-btn {
    padding: 0 12px;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
    gap: 5px;
    transition: background 0.15s, color 0.15s;
}

.filter-heart-btn:hover {
    background: rgba(0, 0, 0, 0.12);
}

.filter-heart-icon { font-size: 26px; color: #ef4444; line-height: 1; }
.filter-heart-count { font-size: 11px; font-weight: 500; color: #6b7280; line-height: 1; }
.filter-heart-btn.active { background-color: rgba(33, 150, 243, 0.12); }
.filter-heart-btn.active .filter-heart-icon { color: #60a5fa; }

#table-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    border-top: 1px solid rgba(200, 200, 200, 0.6);
}

#table-panel .table-scroll {
    overflow: auto;
    scrollbar-width: none;
}

#table-panel .table-scroll::-webkit-scrollbar {
    width: 0;
    height: 0;
}

#apartment-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

#apartment-table th,
#apartment-table td {
    text-align: left;
    padding: 8px 8px;
    height: auto;
    font-size: 13px;
    line-height: 1.4;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

#apartment-table th:first-child,
#apartment-table td:first-child {
    padding-left: 12px;
}

#apartment-table th:last-child,
#apartment-table td:last-child {
    padding-right: 12px;
}

#apartment-table th {
    font-size: 12px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #9ca3af;
    position: static;
    background: transparent;
    z-index: auto;
    border-bottom: 1px solid #e8e8e8;
}

#apartment-table tbody tr {
    cursor: pointer;
    transition: background-color 0.12s ease;
}

#apartment-table tbody tr:nth-child(even) {
    background: transparent;
}

#apartment-table tbody tr:hover {
    background: #f9fafb;
}

#apartment-table tbody tr.selected {
    background: rgba(33, 150, 243, 0.15);
    box-shadow: inset 3px 0 0 #2196f3;
}

#apartment-table tbody td {
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

#apartment-table .col-rooms {
    width: 1%;
    white-space: nowrap;
    text-align: center;
    padding-left: 4px;
    padding-right: 4px;
}

#apartment-table .col-price {
    text-align: right;
}

#apartment-table tbody td:first-child {
    font-weight: 600;
    color: #111827;
}

#apartment-table tbody td.id-available {
    color: #1a8a3f;
    font-weight: 600;
}

#apartment-table tbody td.id-sold {
    color: #c0392b;
    font-weight: 600;
}

#apartment-table tbody td.id-reserved {
    color: #b8860b;
    font-weight: 600;
}

#apartment-table .heart {
    cursor: pointer;
    font-size: 16px;
    color: #ef4444;
    user-select: none;
    transition: color 0.15s ease, background 0.15s ease;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#apartment-table .heart:hover {
    color: #f87171;
    background: rgba(0, 0, 0, 0.06);
}

#apartment-table .heart.filled {
    color: #ef4444;
}

#apartment-table td.btn-cell {
    padding: 0;
    width: 26px;
    position: relative;
}

#apartment-table td.btn-cell + td.btn-cell {
    border-left: none;
}

#apartment-table .card-btn,
#apartment-table .contact-btn {
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    opacity: 0.7;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none !important;
    background: transparent !important;
    border-radius: 0;
    padding: 0;
    line-height: 1;
}

#apartment-table .card-btn:hover,
#apartment-table .contact-btn:hover {
    color: #374151;
    opacity: 1;
    background: rgba(0, 0, 0, 0.08) !important;
}

#apartment-table .contact-btn {
    font-size: 13px;
}

/* Cards panel (apartment list card view) */
#cards-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: auto;
    padding: 0;
    border-top: 1px solid rgba(200, 200, 200, 0.6);
    scrollbar-width: none;
}

#cards-panel::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.apartment-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 130px;
    padding: 0;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.apartment-card:hover {
    background: #f9fafb;
}

.apartment-card.selected {
    background: rgba(33, 150, 243, 0.15);
    box-shadow: inset 3px 0 0 #2196f3;
}

.card-minimap {
    flex: 0 0 45%;
    max-width: 45%;
    min-height: 130px;
    background: transparent;
    border-right: 1px solid #e8e8e8;
    overflow: hidden;
    position: relative;
}

.card-minimap img {
    position: absolute;
    inset: 5px 5px 5px 16px;
    width: calc(100% - 21px);
    height: calc(100% - 10px);
    object-fit: contain;
    display: block;
}

.card-info {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8px 12px;
    gap: 2px;
}

.card-id {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 2px;
}

.card-id.id-available {
    color: #1a8a3f;
}

.card-id.id-sold {
    color: #c0392b;
}

.card-id.id-reserved {
    color: #b8860b;
}

.card-data {
    font-size: 12px;
    color: #6b7280;
}

.card-price {
    font-size: 12px;
    font-weight: 500;
    color: #374151;
}

.card-actions {
    flex: 0 0 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 6px;
    border-left: 1px solid #f3f4f6;
}

.card-actions .card-btn,
.card-actions .contact-btn,
.card-actions .heart {
    cursor: pointer;
    font-size: 22px;
    color: #6b7280;
    opacity: 0.7;
    border: none !important;
    background: transparent !important;
    border-radius: 4px;
    width: 36px;
    height: 36px;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
    user-select: none;
}

.card-actions .card-btn:hover,
.card-actions .contact-btn:hover,
.card-actions .heart:hover {
    color: #374151;
    opacity: 1;
    background: rgba(0, 0, 0, 0.08) !important;
}

.card-actions .heart {
    color: #ef4444;
}

.card-actions .heart:hover {
    color: #f87171;
}

.card-actions .heart.filled {
    color: #ef4444;
}

/* Card overlay - main viewing area only (next to sidebar, not covering it) */
#card-overlay {
    position: absolute;
    top: 20px;
    left: calc(20px + var(--sidebar-width) + 10px);
    right: 20px;
    bottom: 20px;
    z-index: 50;
    display: none;
    padding: 12px;
    overflow: hidden;
}

#layout.sidebar-collapsed #card-overlay {
    left: 20px;
}

#card-overlay.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 36px;
}

#card-overlay-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

#card-overlay-close:hover {
    background: rgba(0, 0, 0, 0.12);
    color: #111;
}

#card-overlay-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: none;
    z-index: 0;
}

#card-overlay-pdf {
    flex: 1;
    width: 100%;
    border: none;
    border-radius: 4px;
    background: #fff;
    display: none;
    z-index: 0;
}

/* Plan zoom overlay - auto-sized, centered in viewer area */
#plan-zoom-overlay {
    position: absolute;
    top: 20px;
    left: calc(20px + var(--sidebar-width) + 10px);
    right: 20px;
    bottom: 20px;
    z-index: 50;
    display: none;
    padding: 12px;
    padding-top: 36px;
    overflow: hidden;
    margin: auto;
}

#layout.sidebar-collapsed #plan-zoom-overlay {
    left: 20px;
}

#plan-zoom-overlay.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

#plan-zoom-overlay-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

#plan-zoom-overlay-close:hover {
    background: rgba(0, 0, 0, 0.12);
    color: #111;
}

#plan-zoom-overlay-image {
    display: block;
    z-index: 0;
    transform-origin: center center;
}

/* Contact overlay */
#contact-overlay {
    position: absolute;
    top: 20px;
    left: calc(20px + var(--sidebar-width) + 10px);
    bottom: 20px;
    width: 400px;
    max-width: calc(100% - var(--sidebar-width) - 50px);
    z-index: 50;
    display: none;
    padding: 0;
    overflow: hidden;
}

#layout.sidebar-collapsed #contact-overlay {
    left: 20px;
    max-width: calc(100% - 40px);
}

#contact-overlay.visible {
    display: flex;
    flex-direction: column;
    padding: 16px 24px 24px;
}

#contact-overlay-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

#contact-overlay-close:hover {
    background: rgba(0, 0, 0, 0.12);
    color: #111;
}

#contact-overlay-title {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.contact-feedback {
    margin-top: 12px;
    font-size: 14px;
    color: #166534;
}
.contact-feedback.contact-feedback--error {
    color: #b91c1c;
}
.contact-feedback.hidden {
    display: none;
}

.contact-consents {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.1);
}
.contact-consents-title {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 8px 0;
}
.contact-consent-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 11px;
    color: #4b5563;
    margin-bottom: 6px;
    cursor: pointer;
}
.contact-consent-label input {
    flex-shrink: 0;
    margin-top: 2px;
}
.contact-consent-label span {
    line-height: 1.35;
    user-select: none;
}

#contact-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    overflow-y: auto;
}

#contact-form label {
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    margin-top: 4px;
}

#contact-form input,
#contact-form textarea {
    padding: 8px 10px;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 6px;
    font-size: 13px;
    background: rgba(255,255,255,0.7);
    color: #1f2937;
    outline: none;
    transition: border-color 0.15s;
}

#contact-form input:focus,
#contact-form textarea:focus {
    border-color: #3b82f6;
}

#contact-form textarea {
    resize: vertical;
    min-height: 60px;
}

.contact-submit-btn {
    margin-top: 10px;
    padding: 9px 16px;
    border: none;
    border-radius: 6px;
    background: #3b82f6;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.contact-submit-btn:hover {
    background: #2563eb;
}

#sidebar button:not(.view-mode-btn):not(.filters-header-btn):not(.filter-heart-btn),
#sidebar select:not(.filters-header-select),
#sidebar input[type="range"] {
    font-size: 12px;
    padding: 4px 6px;
    border: 1px solid #d6d6d6;
    border-radius: 4px;
    background: #ffffff;
    color: #222;
}

#sidebar #plan-preview-zoom-btn,
#sidebar #plan-preview-nav button {
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
}
#sidebar #plan-preview-zoom-btn:hover,
#sidebar #plan-preview-nav button:hover:not(.active) {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}
#sidebar #plan-preview-nav button.active {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

#sidebar-toggle-btn {
    position: absolute;
    left: calc(20px + var(--sidebar-width));
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 48px;
    padding: 0;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(200, 200, 200, 0.8);
    border-left: none;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    transition: background-color 0.2s ease, color 0.2s ease, left 0.3s ease;
    user-select: none;
    z-index: 45;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

#sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 1);
    color: #444;
}

#sidebar-toggle-btn:active {
    background: rgba(235, 235, 235, 1);
}

#layout.sidebar-collapsed #sidebar-toggle-btn {
    left: 0;
    border-left: 1px solid rgba(200, 200, 200, 0.8);
    border-radius: 0 5px 5px 0;
}

#image-type-panel {
    position: absolute;
    top: 20px;
    right: 58px;
    display: flex;
    gap: 0;
    z-index: 40;
}

#image-type-panel:empty,
#image-type-buttons:empty {
    display: none;
}

#image-type-buttons {
    display: flex;
    gap: 0;
    padding: 2px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid #ddd;
    border-radius: 6px;
}

.image-type-btn {
    height: 28px;
    padding: 0 14px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
}

.image-type-btn:hover:not(.active):not(:disabled) {
    background: rgba(0, 0, 0, 0.06);
    color: #222;
}

.image-type-btn.active {
    background: #fff;
    color: #222;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.image-type-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

#overlay-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: 6px;
    padding: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    color: #555;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

#overlay-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #222;
}

#overlay-toggle-btn .overlay-icon {
    width: 18px;
    height: 18px;
}

#overlay-toggle-btn .overlay-hidden-icon {
    display: none;
}

#overlay-toggle-btn.overlay-hidden .overlay-visible {
    display: none;
}

#overlay-toggle-btn.overlay-hidden .overlay-hidden-icon {
    display: block;
}

#overlay-toggle-btn.overlay-hidden {
    opacity: 0.7;
}

#fullscreen-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: 0;
    padding: 0;
    z-index: 41;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    color: #555;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

#fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #222;
}

#fullscreen-btn .fs-icon {
    width: 18px;
    height: 18px;
}

#fullscreen-btn .fs-compress {
    display: none;
}

#fullscreen-btn.expanded .fs-expand {
    display: none;
}

#fullscreen-btn.expanded .fs-compress {
    display: block;
}

:fullscreen #fullscreen-btn .fs-expand,
:-webkit-full-screen #fullscreen-btn .fs-expand {
    display: none;
}

:fullscreen #fullscreen-btn .fs-compress,
:-webkit-full-screen #fullscreen-btn .fs-compress {
    display: block;
}

#viewer {
    --viewer-shift: 0px;
    --viewer-scale: 1;
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #000;
    overflow: hidden;
    user-select: none;
    cursor: url('logo/rotateLogo_2_cursor.svg') 40 40, grab;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

#viewer.dragging {
    cursor: url('logo/rotateLogo_2_cursor.svg') 40 40, grabbing;
}

#viewer #frame {
    width: auto;
    height: 100%;
    max-width: none;
    display: block;
    opacity: 0;
    transform: translateX(var(--viewer-shift)) scale(var(--viewer-scale));
    transform-origin: center;
    transition: opacity 0.3s ease;
}

#viewer.ready #frame {
    opacity: 1;
}

#viewer #svg-overlay {
    position: absolute;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#viewer.ready #svg-overlay {
    opacity: 1;
}

#hotspot-icons {
    position: absolute;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#viewer.ready #hotspot-icons {
    opacity: 1;
}

@keyframes hotspot-bounce {
    0%   { transform: translateY(0) scaleY(0.92); }
    8%   { transform: translateY(0) scaleY(1); }
    35%  { transform: translateY(-16px) scaleY(1); }
    55%  { transform: translateY(-4px); }
    70%  { transform: translateY(0); }
    78%  { transform: translateY(0) scaleY(0.92); }
    100% { transform: translateY(0) scaleY(0.92); }
}

#viewer #hotspot-icons .tour-hotspot-wrap {
    position: absolute;
    transform: translate(-50%, -100%);
    pointer-events: auto;
    cursor: pointer;
}

#viewer #hotspot-icons .tour-hotspot-wrap .tour-hotspot-icon {
    display: block;
    width: 44px;
    height: auto;
    max-width: 44px;
    object-fit: contain;
    opacity: 0.75;
    filter: blur(0.5px);
    transition: opacity 0.2s, filter 0.2s;
}

#viewer #hotspot-icons .tour-hotspot-wrap:hover .tour-hotspot-icon {
    opacity: 1;
    filter: brightness(1.25);
    animation: hotspot-bounce 0.55s linear infinite;
    transform-origin: center bottom;
}

@keyframes hotspot-shine-sweep {
    0%        { background-position: 250% 0; opacity: 0; }
    1%        { background-position: 250% 0; opacity: 1; }
    35%       { background-position: -150% 0; opacity: 1; }
    36%, 100% { background-position: -150% 0; opacity: 0; }
}

#viewer #hotspot-icons .tour-hotspot-wrap.idle-shine::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        110deg,
        transparent 30%,
        rgba(255, 255, 255, 0.2) 45%,
        rgba(255, 255, 255, 0.35) 50%,
        rgba(255, 255, 255, 0.2) 55%,
        transparent 70%
    );
    background-size: 200% 100%;
    opacity: 0;
    animation: hotspot-shine-sweep 4s linear infinite;
    pointer-events: none;
    -webkit-mask-image: var(--icon-src);
    mask-image: var(--icon-src);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

#viewer #hotspot-icons .hotspot-label {
    position: absolute;
    transform: translate(-50%, -100%);
    background: rgba(255, 255, 255, 0.9);
    color: #222;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

#viewer #hotspot-icons .hotspot-label::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translate(-50%, 100%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid rgba(255, 255, 255, 0.9);
}

#viewer #hotspot-icons .hotspot-label:hover {
    background: rgba(255, 255, 255, 1);
}

#viewer #hotspot-icons .hotspot-label:hover::after {
    border-top-color: rgba(255, 255, 255, 1);
}

#view-mode-bar {
    display: flex;
    align-items: center;
    gap: 0;
    margin: -12px -12px 8px -12px;
    padding: 2px 6px;
    min-height: 40px;
    background: transparent;
    border-bottom: 1px solid rgba(200, 200, 200, 0.6);
    border-radius: 5px 5px 0 0;
}

#info-id-header {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    padding: 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#info-id-header.status-available { color: #1a8a3f; }
#info-id-header.status-sold { color: #c0392b; }
#info-id-header.status-reserved { color: #b8860b; }

.view-mode-btn {
    flex: 0 0 68px;
    height: 28px;
    padding: 0;
    text-align: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    outline: none;
}

.view-mode-btn:hover:not(.active) {
    background: rgba(0, 0, 0, 0.06);
    color: #222;
}

.view-mode-btn.active {
    background: #fff;
    color: #222;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

#tour-view, #dollhouse-view {
    position: absolute;
    inset: 0;
    display: none;
    z-index: 1;
    touch-action: none;
}

#tour-view {
    background: #1a1a1a;
}

#tour-view.active-view {
    display: block;
}

#dollhouse-view {
    display: none;
    align-items: center;
    justify-content: center;
    background: #555;
    cursor: url('logo/rotateLogo_2_cursor.svg') 40 40, grab;
    user-select: none;
    padding-left: calc(var(--sidebar-width) + 30px);
}

#layout.sidebar-collapsed #dollhouse-view {
    padding-left: 0;
}

#dollhouse-view.active-view {
    display: flex;
}

#dollhouse-view.dragging {
    cursor: url('logo/rotateLogo_2_cursor.svg') 40 40, grabbing;
}

#dollhouse-canvas {
    display: block;
}

#dollhouse-no-dollhouse {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
    z-index: 5;
}

#dollhouse-no-dollhouse.visible {
    display: flex;
}

#dollhouse-level-bar {
    position: absolute;
    bottom: 20px;
    left: calc(50% + var(--sidebar-width, 0px) / 2);
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 6px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    padding: 4px 8px;
}

#layout.sidebar-collapsed #dollhouse-level-bar {
    left: 50%;
}

#dollhouse-level-bar.visible {
    display: flex;
}

#dollhouse-level-bar button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 14px;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
}

#dollhouse-level-bar button:disabled {
    opacity: 0.3;
    cursor: default;
}

#dollhouse-level-bar button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
}

#dollhouse-level-title {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    white-space: nowrap;
}

#pannellum-wrapper {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: calc(-1 * var(--sidebar-width, 0px));
}

#layout.sidebar-collapsed #pannellum-wrapper {
    right: 0;
}

.pnlm-about-msg { display: none !important; }

/* Hide loading overlay when switching tour scenes (scenes are preloaded) */
#tour-view .pnlm-load-box { display: none !important; }

#tour-style-switcher {
    position: absolute;
    bottom: 20px;
    left: calc(50% + var(--sidebar-width, 0px) / 2);
    transform: translateX(-50%);
    z-index: 10;
    display: none;
    align-items: center;
    gap: 0;
    padding: 2px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid #ddd;
    border-radius: 6px;
}

#layout.sidebar-collapsed #tour-style-switcher {
    left: 50%;
}

#tour-style-switcher.visible {
    display: flex;
}

.tour-style-btn {
    height: 28px;
    padding: 0 14px;
    background: transparent;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.tour-style-btn:hover:not(.active):not(:disabled) {
    background: rgba(0, 0, 0, 0.06);
    color: #222;
}

.tour-style-btn.active {
    background: #fff;
    color: #222;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.tour-style-btn:disabled {
    opacity: 0.4;
    cursor: default;
}
.pnlm-hotspot { cursor: pointer; }
.pnlm-scene .pnlm-sprite {
    width: 30px; height: 30px;
}

#tour-no-tour {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
    z-index: 5;
}

#tour-minimap {
    position: absolute;
    right: 20px;
    bottom: 20px;
    width: 260px;
    height: 260px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    z-index: 10;
    cursor: pointer;
    display: none;
}

#minimap-tab-bar {
    position: absolute;
    right: 20px;
    bottom: 290px;
    display: none;
    align-items: center;
    gap: 2px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    padding: 1px 3px;
}

#minimap-tab-bar button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 7px;
    padding: 1px 3px;
    border-radius: 2px;
    cursor: pointer;
    line-height: 1;
}
#minimap-tab-bar button:disabled {
    opacity: 0.3;
    cursor: default;
}
#minimap-tab-bar button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
}
#minimap-tab-title {
    color: rgba(255, 255, 255, 0.8);
    font-size: 7px;
    white-space: nowrap;
}

#back-btn-bar {
    position: absolute;
    top: 20px;
    left: calc(20px + var(--sidebar-width) + 10px);
    display: none;
    align-items: center;
    gap: 0;
    padding: 2px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid #ddd;
    border-radius: 6px;
    z-index: 40;
    transition: left 0.3s ease;
}

#layout.sidebar-collapsed #back-btn-bar {
    left: 20px;
}

#back-btn {
    height: 28px;
    padding: 0 14px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
}

#back-btn:hover { background: rgba(0, 0, 0, 0.06); color: #222; }
#back-btn:active { transform: scale(0.97); }

/* Polygon styles — vector-effect keeps stroke in screen pixels */
.apartment-polygon {
    fill: rgba(76, 175, 80, 0.08);
    stroke: #4caf50;
    stroke-width: 1px;
    vector-effect: non-scaling-stroke;
    cursor: pointer;
    transition: stroke-width 0.2s ease, fill 0.2s ease;
    pointer-events: auto;
}

.apartment-polygon.status-available {
    fill: rgba(76, 175, 80, 0.08);
    stroke: #4caf50;
}

.apartment-polygon.status-sold {
    fill: rgba(244, 67, 54, 0.08);
    stroke: #f44336;
}

.apartment-polygon.status-reserved {
    fill: rgba(255, 193, 7, 0.08);
    stroke: #ffc107;
}

.apartment-polygon:hover {
    fill: rgba(76, 175, 80, 0.25);
    stroke-width: 2px;
}

.apartment-polygon.status-available:hover {
    fill: rgba(76, 175, 80, 0.25);
}

.apartment-polygon.status-sold:hover {
    fill: rgba(244, 67, 54, 0.25);
}

.apartment-polygon.status-reserved:hover {
    fill: rgba(255, 193, 7, 0.25);
}

.apartment-polygon.is-hovered {
    fill: rgba(76, 175, 80, 0.25);
    stroke-width: 2px;
}

.apartment-polygon.status-available.is-hovered {
    fill: rgba(76, 175, 80, 0.25);
}

.apartment-polygon.status-sold.is-hovered {
    fill: rgba(244, 67, 54, 0.25);
}

.apartment-polygon.status-reserved.is-hovered {
    fill: rgba(255, 193, 7, 0.25);
}

@keyframes pulseOpacity {
    0%, 100% { fill-opacity: 0.25; }
    50% { fill-opacity: 0.85; }
}

.apartment-polygon.selected {
    stroke-width: 3px;
    fill: rgba(76, 175, 80, 0.3);
    animation: pulseOpacity 0.5s ease-in-out infinite;
}

.apartment-polygon.status-sold.selected {
    fill: rgba(244, 67, 54, 0.3);
}

.apartment-polygon.status-reserved.selected {
    fill: rgba(255, 193, 7, 0.3);
}

/* Polygon tooltip styles */
#polygon-tooltip {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    display: none;
}

#polygon-tooltip.visible {
    display: block;
}

#tooltip-box {
    position: absolute;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 12px;
    max-width: 220px;
    min-width: 160px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    color: #111;
    line-height: 1.4;
    white-space: normal;
}

#tooltip-box.arrow-left::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(-100%, -50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 7px solid rgba(255, 255, 255, 0.92);
}

#tooltip-box.arrow-right::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 0;
    transform: translate(100%, -50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 7px solid rgba(255, 255, 255, 0.92);
}

#tooltip-box .tooltip-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
}

#tooltip-box .tooltip-item {
    display: inline-flex;
    flex-wrap: wrap;
}

#tooltip-box .tooltip-label {
    color: #666;
    margin-right: 2px;
}

#tooltip-box .tooltip-value {
    font-weight: 600;
    color: #111;
}

.tooltip-minimap {
    position: relative;
    width: 100%;
    height: 110px;
    border-radius: 3px;
    margin-bottom: 6px;
    background: #f3f4f6;
}
.tooltip-minimap img {
    position: absolute;
    inset: 4px;
    width: calc(100% - 8px);
    height: calc(100% - 8px);
    object-fit: contain;
    display: block;
}

#hierarchy-panel {
    position: absolute;
    left: calc(20px + var(--sidebar-width) + 10px);
    bottom: 20px;
    width: fit-content;
    max-width: 240px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 40;
    padding: 2px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: left 0.3s ease;
}

#layout.sidebar-collapsed #hierarchy-panel {
    left: 20px;
}

#hierarchy-menu {
    display: flex;
    flex-direction: column;
    gap: 0;
}

#hierarchy-menu .hierarchy-item {
    height: 28px;
    padding: 0 14px;
    background: transparent;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
}

#hierarchy-menu .hierarchy-item:hover:not(.current) {
    background: rgba(0, 0, 0, 0.06);
    color: #222;
}

#hierarchy-menu .hierarchy-item.current {
    background: #fff;
    color: #222;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

#loading, #error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 18px;
    z-index: 10;
}

#error {
    color: #f44;
    display: none;
}

/* ===== DAAKO logo watermark ===== */
.daako-logo {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 120px;
    height: auto;
    display: block;
    z-index: 200;
    opacity: 1;
    user-select: none;
    line-height: 0;
    transition: filter 0.15s ease;
    pointer-events: auto;
}

.daako-logo:hover {
    filter: brightness(1.3);
}

.daako-logo img {
    width: 100%;
    height: auto;
    display: block;
}

/* ===== Mobile layout (<=640px) ===== */
@media (max-width: 640px) {
    body {
        min-height: 100vh;
        align-items: stretch;
    }

    #layout {
        --sidebar-width: 0px;
        --sidebar-shift: 0px;
        width: 100%;
        height: 1000px;
        min-height: unset;
        max-height: 1000px;
        display: flex;
        flex-direction: column;
        overflow: auto;
    }

    #sidebar {
        position: relative;
        top: auto;
        left: auto;
        bottom: auto;
        width: 100%;
        transform: none;
        opacity: 1;
        pointer-events: auto;
        display: flex;
        flex-direction: column;
        gap: 0;
        overflow: visible;
        z-index: 20;
        padding: 0;
    }

    #layout.sidebar-collapsed #sidebar {
        transform: none;
        opacity: 1;
        pointer-events: auto;
    }

    #viewer {
        height: 35vh;
        min-height: 35vh;
        flex-shrink: 0;
        order: -1;
    }

    #tour-view,
    #dollhouse-view {
        position: relative;
        width: 100%;
        height: 35vh;
        min-height: 35vh;
        flex-shrink: 0;
        order: -1;
        inset: auto;
    }

    #dollhouse-view.active-view {
        display: flex;
    }

    #layout.view-expanded #tour-view,
    #layout.view-expanded #dollhouse-view {
        position: fixed;
        inset: 0;
        height: 100%;
        min-height: 100%;
        z-index: 50;
    }

    #layout.view-expanded #sidebar {
        display: none;
    }

    #layout.view-expanded #back-btn-bar {
        position: fixed;
        z-index: 51;
    }

    #layout.view-expanded #fullscreen-btn {
        position: fixed;
        z-index: 51;
    }

    #sidebar-toggle-btn {
        display: none;
    }

    #back-btn-bar {
        top: 5px;
        left: 5px;
        padding: 1px 2px;
        border-radius: 4px;
    }

    #layout.sidebar-collapsed #back-btn-bar {
        left: 5px;
    }

    #back-btn {
        height: 20px;
        padding: 0 6px;
        font-size: 9px;
        border-radius: 3px;
    }

    #hierarchy-panel {
        display: none !important;
    }

    #image-type-panel {
        top: 5px;
        right: 42px;
    }

    #fullscreen-btn {
        top: 5px;
        right: 5px;
        width: 22px;
        height: 22px;
        border-radius: 4px;
        display: none;
    }

    #fullscreen-btn .fs-icon {
        width: 12px;
        height: 12px;
    }

    #tour-view.active-view ~ #fullscreen-btn {
        display: flex;
    }

    #overlay-toggle-btn {
        width: 22px;
        height: 22px;
        border-radius: 4px;
    }

    #overlay-toggle-btn .overlay-icon {
        width: 12px;
        height: 12px;
    }

    .image-type-btn {
        height: 20px;
        padding: 0 6px;
        font-size: 9px;
    }

    #image-type-buttons {
        border-radius: 4px;
    }

    #pannellum-wrapper {
        right: 0;
    }

    #layout.sidebar-collapsed #pannellum-wrapper {
        right: 0;
    }

    #tour-style-switcher {
        left: 50%;
        transform: translateX(-50%) scale(0.5);
        transform-origin: center bottom;
        bottom: 10px;
    }

    #layout.sidebar-collapsed #tour-style-switcher {
        left: 50%;
    }

    #tour-minimap {
        right: 10px;
        bottom: 10px;
        width: 120px;
        height: 120px;
    }

    #minimap-tab-bar {
        right: 10px;
        bottom: 140px;
        padding: 1px 2px;
        border-radius: 2px;
        gap: 2px;
    }

    #minimap-tab-bar button {
        font-size: 6px;
        padding: 0 2px;
    }

    #minimap-tab-title {
        font-size: 6px;
    }

    #dollhouse-view {
        padding-left: 0;
    }

    #layout.sidebar-collapsed #dollhouse-view {
        padding-left: 0;
    }

    #dollhouse-level-bar {
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
    }

    #layout.sidebar-collapsed #dollhouse-level-bar {
        left: 50%;
    }

    #filters-table-panel {
        flex: none;
        overflow: visible;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    #info-panel {
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
    }

    #filters-panel {
        padding: 12px 20px;
    }

    #filters-body {
        max-height: 280px;
    }

    .slider-handle {
        width: 20px;
        height: 20px;
    }

    .slider-handle::before {
        content: '';
        position: absolute;
        top: -10px;
        left: -10px;
        right: -10px;
        bottom: -10px;
    }

    .dual-handle-slider {
        margin: 0 10px;
        height: 30px;
    }

    #info-panel .plan-preview {
        /* aspect-ratio set dynamically via JS from image dimensions */
    }

    #viewer #hotspot-icons .tour-hotspot-wrap .tour-hotspot-icon {
        width: 22px;
        max-width: 22px;
    }

    #viewer #hotspot-icons .hotspot-label {
        font-size: 6px;
        padding: 2px 5px 4px;
        border-radius: 3px;
    }

    #viewer #hotspot-icons .hotspot-label::after {
        border-left: 3px solid transparent;
        border-right: 3px solid transparent;
        border-top: 3px solid rgba(255, 255, 255, 0.9);
    }

    .pnlm-scene .pnlm-sprite {
        width: 15px !important;
        height: 15px !important;
    }

    .pnlm-hotspot > div {
        width: 25px !important;
        height: 25px !important;
    }

    .pnlm-hotspot > div > div {
        font-size: 9px !important;
        bottom: 20px !important;
        padding: 2px 5px !important;
        border-radius: 3px !important;
    }

    .daako-logo {
        width: 60px;
        height: auto;
        bottom: 0;
        right: 0;
        top: auto;
    }
}
