* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden], .hidden { display: none !important; }
:root { --paper: #faf9f4; --ink: #2d4036; --muted: #657167; --line: #dce0d6; --gold: #93784e; --text-primary: var(--ink); --text-secondary: var(--muted); }
body { height: 100vh; height: 100dvh; overflow: hidden; background: var(--paper); color: var(--ink); font: 14px/1.5 'Segoe UI', sans-serif; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: 1px solid transparent; background: transparent; min-height: 44px; padding: 10px 16px; border-radius: 8px; transition: background .18s, color .18s; }
button:hover { background: #e9ece3; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
button[aria-pressed="true"], button.active { background: var(--ink); color: #fff; }
#viewer-container { position: absolute; inset: 0; }
#viewer-container canvas { display: block; touch-action: none; }
.header { position: absolute; top: max(30px, env(safe-area-inset-top)); left: max(36px, env(safe-area-inset-left)); z-index: 10; pointer-events: none; }
.eyebrow { color: var(--gold); font-size: 10px; letter-spacing: 2.4px; }
.header h1 { font: 40px/1.2 Georgia, serif; letter-spacing: -1.4px; margin: 9px 0 8px; }
.header h1 span { font-style: italic; }
.header > p:last-child { font-size: 12px; color: var(--muted); }
.main-controls, .review-panel, .info-panel, .legend { background: rgba(250,249,244,.96); border: 1px solid rgba(255,255,255,.9); box-shadow: 0 8px 40px #243e3012; backdrop-filter: blur(18px); }
.main-controls { position: absolute; bottom: max(48px, env(safe-area-inset-bottom)); right: 50%; transform: translateX(50%); white-space: nowrap; z-index: 30; padding: 5px; display: flex; gap: 3px; border-radius: 12px; }
#reset-view span[aria-hidden] { font-size: 22px; vertical-align: -1px; margin-right: 5px; }
#availability-toggle[aria-pressed="true"] { background: #536d57; box-shadow: inset 0 0 0 2px #a7bca4; }
#views-toggle[aria-expanded="true"] { background: #e4e8dd; }
.review-panel { position: absolute; bottom: 116px; left: 50%; transform: translateX(-50%); width: min(850px, calc(100% - 48px)); z-index: 35; padding: 12px 16px 16px; border-radius: 16px; }
.review-heading { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; }
.review-heading button { font-size: 23px; padding: 0; width: 44px; }
.view-controls { display: flex; flex-wrap: wrap; gap: 5px; }
.view-controls button { font-size: 12px; background: #eeefe8; }
.view-controls button.active { background: var(--ink); }
#save-view { border: 1px solid var(--line); background: transparent; }
.orbit-hint { position: absolute; bottom: max(22px, env(safe-area-inset-bottom)); left: 32px; right: 32px; display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); pointer-events: none; }
.touch-hint { display: none; }
.info-panel { position: absolute; top: 108px; right: 32px; width: 320px; max-height: calc(100dvh - 180px); overflow-y: auto; z-index: 25; border-radius: 16px; padding: 26px; }
.info-panel h2 { font: 28px/1.25 Georgia, serif; margin: 10px 0 23px; padding-right: 20px; }
.info-panel .eyebrow { font-size: 9px; }
.info-content { display: flex; flex-direction: column; }
.info-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.info-row:last-child { border: 0; padding-bottom: 0; }
.label { font-size: 12px; color: var(--muted); }
.value { font-size: 13px; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
#flat-id { font-size: 11px; }
#flat-price { font: 23px Georgia, serif; }
.close-btn { position: absolute; top: 10px; right: 10px; width: 44px; font-size: 24px; padding: 0; }
.status-badge { font-size: 11px; padding: 5px 9px; border-radius: 5px; }
.status-available { background: #e1eee2; color: #235c37; }
.status-reserved { background: #f5ead2; color: #775513; }
.status-sold { background: #f2e1dc; color: #954c3e; }
.legend { position: absolute; left: 36px; top: 164px; z-index: 15; border-radius: 9px; padding: 12px 15px; display: flex; gap: 16px; }
.legend h3 { display: none; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.legend-color { width: 7px; height: 7px; border-radius: 50%; }
.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 22px; background: var(--paper); z-index: 100; }
.loading p { color: var(--muted); }
.spinner { width: 40px; height: 40px; border: 1px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
dialog::backdrop { background: #1b2b2580; backdrop-filter: blur(5px); }
dialog a { color: var(--ink); display: inline-flex; min-height: 44px; align-items: center; }
@media (max-width: 1000px) {
    .header h1 { font-size: 32px; }
    .review-panel { bottom: 116px; }
    .info-panel { top: 160px; max-height: calc(100dvh - 285px); }
    .legend { top: 140px; }
    .select-hint { display: none; }
    .orbit-hint { justify-content: center; }
}
@media (max-width: 600px) {
    .header { top: max(20px, env(safe-area-inset-top)); left: 22px; }
    .header h1 { font-size: 29px; margin: 7px 0; }
    .header .eyebrow { font-size: 8px; letter-spacing: 2px; }
    .header > p:last-child { display: none; }
    .main-controls { bottom: calc(18px + env(safe-area-inset-bottom)); max-width: calc(100% - 24px); width: 370px; justify-content: center; }
    .main-controls button { padding: 8px 12px; font-size: 12px; flex: 1; }
    .orbit-hint { bottom: calc(85px + env(safe-area-inset-bottom)); font-size: 10px; }
    .desktop-hint { display: none; }
    .touch-hint { display: inline; }
    .legend { left: 22px; top: 103px; gap: 10px; padding: 8px 10px; }
    .legend-item { font-size: 10px; }
    .review-panel { bottom: calc(83px + env(safe-area-inset-bottom)); width: calc(100% - 24px); max-height: 45dvh; overflow-y: auto; padding: 8px 12px 12px; }
    .view-controls { display: grid; grid-template-columns: 1fr 1fr; }
    .view-controls button { font-size: 11px; padding: 8px; }
    .info-panel { top: auto; bottom: calc(83px + env(safe-area-inset-bottom)); left: 12px; right: 12px; width: auto; max-height: 44dvh; padding: 20px; }
    .info-panel h2 { font-size: 25px; margin: 6px 0 12px; }
    .info-content { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
    .info-row { display: block; padding: 7px 0; }
    .info-row .label, .info-row .value { display: block; text-align: left; }
    #flat-price { font-size: 20px; }
    .status-badge { width: fit-content; margin-top: 3px; }
    body:has(.info-panel:not([hidden])) .orbit-hint, body:has(.review-panel:not([hidden])) .orbit-hint { visibility: hidden; }
}
@media (max-height: 500px) and (min-width: 601px) { .info-panel { top: 20px; bottom: 115px; max-height: none; } .review-panel { max-height: 50dvh; overflow-y: auto; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .spinner { animation-duration: 3s; } }

#view-export { margin: auto; max-width: 94vw; border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: var(--paper); color: var(--ink); }
#view-export-image { display: block; max-width: 85vw; max-height: 70dvh; margin-bottom: 12px; border-radius: 8px; }
#view-export-close { float: right; }

/* Language stays available during loading and in the compact mobile header. */
.display-controls { position: absolute; top: max(28px, env(safe-area-inset-top)); right: max(32px, env(safe-area-inset-right)); z-index: 110; display: flex; align-items: center; gap: 5px; padding: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.language-switch { display: flex; gap: 2px; border-left: 1px solid var(--line); padding-left: 5px; }
.language-switch button { min-width: 44px; padding: 8px 10px; font-size: 11px; letter-spacing: .5px; }
@media (max-width: 600px) {
    .display-controls { top: max(14px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); gap: 3px; padding: 3px; }
    #theme-label { display: none; }
    .display-controls .theme-toggle { min-width: 44px; padding: 8px; }
    .display-controls #theme-icon { margin: 0; }
    .header { right: 170px; }
    .header h1 { font-size: 25px; }
    .header h1 span { display: block; }
    .header .eyebrow { font-size: 7px; letter-spacing: 1px; }
    .legend { top: 119px; }
}
.loading { text-align: center; padding: 24px; }

.theme-toggle { min-height: 44px; min-width: 95px; font-size: 12px; padding: 8px 12px; }
#theme-icon { font-size: 18px; vertical-align: -1px; margin-right: 6px; }
:root[data-theme="night"] { color-scheme: dark; --paper: #18232f; --ink: #ece9df; --muted: #abb9c6; --line: #354454; --gold: #c4a779; }
[data-theme="night"] button:hover { background: #344657; }
[data-theme="night"] button[aria-pressed="true"], [data-theme="night"] button.active { color: #f8ebd6; background: #45586a; }
[data-theme="night"] .main-controls, [data-theme="night"] .review-panel, [data-theme="night"] .info-panel, [data-theme="night"] .legend { background: #18232ff2; border-color: #394652; box-shadow: 0 8px 40px #0003; }
[data-theme="night"] #availability-toggle[aria-pressed="true"] { background: #e2cba6; color: #17212c; box-shadow: inset 0 0 0 2px #fff2d3; }
[data-theme="night"] #views-toggle[aria-expanded="true"], [data-theme="night"] .view-controls button { background: #273747; }
[data-theme="night"] .view-controls button.active { background: #526577; }
[data-theme="night"] .status-available { background: #26473e; color: #b3e2cb; }
[data-theme="night"] .status-reserved { background: #51432d; color: #f1d498; }
[data-theme="night"] .status-sold { background: #4b3337; color: #e7b9b2; }
