:root {
  color-scheme: dark;
  --ink: #1b211f;
  --panel: #19241fee;
  --cream: #f1ece1;
  --gold: #d8bf86;
  --muted: #b7c1b7;
  --line: #d9cfb32b;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--ink); color: var(--cream); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; color: inherit; transition: background .18s ease, border-color .18s ease; }
button, select, a { touch-action: manipulation; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
#viewport { position: fixed; inset: 0; background: #c8dce2; }
#viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }

header { position: fixed; z-index: 3; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 22px 26px 28px; background: linear-gradient(#101b17da, transparent); pointer-events: none; }
header > * { pointer-events: auto; }
.brand { color: var(--cream); text-decoration: none; display: block; }
.brand b { display: block; font-size: 19px; line-height: 1.2; letter-spacing: 3.2px; font-weight: 600; }
.brand b span { display: block; }
.brand small { display: block; margin-top: 7px; color: #d8c9a6; font-size: 8px; letter-spacing: 1.9px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.floor-badge { display: flex; gap: 5px; align-items: center; padding-right: 14px; margin-right: 5px; border-right: 1px solid var(--line); color: var(--gold); }
.floor-number { font: 36px Georgia, serif; line-height: 1; }
.floor-badge > span:last-child { font-size: 10px; letter-spacing: 1px; }
.floor-badge small { display: block; font-size: 6px; color: var(--muted); letter-spacing: 1px; margin-top: 5px; }
.type-pill { display: none; }
.icon-btn { border: 1px solid var(--line); width: 44px; min-width: 44px; height: 44px; background: #17251edd; border-radius: 9px; font-size: 21px; }
.icon-btn:hover { background: #2c392edd; }
.eyebrow { display: block; color: var(--gold); font-size: 9px; font-weight: 600; letter-spacing: 1.5px; }

.room-panel { position: fixed; z-index: 3; top: 115px; left: 26px; width: 254px; max-height: calc(100dvh - 235px); overflow: auto; scrollbar-width: thin; scrollbar-color: #667263 transparent; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); backdrop-filter: blur(14px); box-shadow: 0 10px 35px #07120b21; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 9px; }
.panel-heading .icon-btn { background: transparent; border-color: transparent; font-size: 25px; }
.panel-kicker { display: block; color: var(--muted); font-size: 8px; letter-spacing: 1px; margin: 2px 0 7px; }
.panel-heading .eyebrow { font-size: 9px; letter-spacing: 1.1px; }
#unit-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 0 0 9px; }
.unit-btn { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; min-height: 48px; border: 1px solid var(--line); border-radius: 7px; background: #ffffff04; padding: 7px 6px; font-size: 10px; line-height: 1.25; text-align: left; }
.unit-btn b { color: var(--muted); font-size: 10px; letter-spacing: .2px; }
.unit-btn:hover { background: #ffffff10; }
.unit-btn.selected { border-color: #d8bf868c; background: #d8bf861b; color: var(--gold); }
.unit-btn.selected b { color: #ead7ac; }
.panel-actions { display: flex; gap: 5px; margin: 0 0 10px; }
.common-btn, .outline-btn { display: flex; align-items: center; justify-content: space-between; gap: 6px; border: 1px solid var(--line); background: transparent; border-radius: 7px; padding: 8px; min-height: 40px; text-align: left; font-size: 10px; }
.common-btn { flex: 1; }
.outline-btn { color: var(--gold); }
.common-btn.selected { color: var(--gold); border-color: #d8bf868c; background: #d8bf8612; }
#room-list { border-top: 1px solid var(--line); padding-top: 8px; }
.room-btn { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 40px; border: 0; border-radius: 6px; background: transparent; margin: 1px 0; padding: 9px 8px; color: #dce3d9; text-align: left; font-size: 13px; }
.room-btn span { color: #afbdac; font-size: 10px; }
.room-btn .arrow { font-size: 14px; }
.room-btn > span:first-child { font-size: inherit; color: inherit; }
.room-btn:hover { background: #ffffff08; }
.room-btn.selected { color: var(--gold); background: #d8bf861b; }
.palette-picker { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 10px; }
.palette-picker > span { color: var(--muted); font-size: 8px; letter-spacing: 1px; line-height: 1.6; }
.palette-picker select { min-height: 42px; max-width: 155px; border: 1px solid var(--line); border-radius: 6px; padding: 7px; background: #26352b; color: var(--cream); font: inherit; font-size: 12px; }
#palette-cards { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.palette-btn { display: flex; align-items: center; gap: 9px; min-height: 43px; border: 1px solid var(--line); border-radius: 6px; background: #ffffff03; padding: 7px 9px; text-align: left; }
.palette-btn b { font-size: 12px; font-weight: 400; }
.palette-btn.selected { border-color: #d8bf8690; background: #d8bf8619; color: var(--gold); }
.swatches { display: flex; gap: 3px; flex-shrink: 0; }
.swatches i { width: 16px; height: 18px; border-radius: 3px; }
#palette-caption { font-size: 8px; color: var(--muted); letter-spacing: 1px; margin: 9px 0 1px; }
.room-panel.collapsed #room-list, .room-panel.collapsed .palette-picker, .room-panel.collapsed #palette-cards, .room-panel.collapsed #palette-caption { display: none; }
.room-panel.collapsed .panel-actions { margin-bottom: 0; }

.view-card { position: fixed; z-index: 2; right: 26px; top: 115px; max-width: 250px; background: #18251edc; border-left: 2px solid var(--gold); border-radius: 0 9px 9px 0; backdrop-filter: blur(8px); padding: 12px 16px; pointer-events: none; }
h1 { font: 28px Georgia, serif; margin: 8px 0 5px; }
#room-size { color: #d2dacd; font-size: 12px; margin: 0; line-height: 1.5; }
#hint { display: block; color: var(--muted); font-size: 10px; line-height: 1.5; margin-top: 10px; }
.toolbar { position: fixed; z-index: 4; left: 50%; bottom: calc(35px + var(--safe-bottom)); transform: translateX(-50%); display: flex; gap: 4px; align-items: center; max-width: calc(100vw - 28px); overflow-x: auto; scrollbar-width: none; white-space: nowrap; border: 1px solid var(--line); border-radius: 12px; background: #17231eef; box-shadow: 0 6px 28px #0003; padding: 7px; }
.toolbar::-webkit-scrollbar, #unit-list::-webkit-scrollbar, #room-list::-webkit-scrollbar, .reference-tabs::-webkit-scrollbar { display: none; }
.toolbar > * { flex-shrink: 0; }
.primary-btn, .tool-btn { min-height: 46px; border: 0; border-radius: 7px; padding: 12px 14px; font-size: 12px; background: transparent; }
.primary-btn { background: var(--gold); color: #19251d; font-weight: 700; min-width: 126px; }
.primary-btn:hover { background: #e5cf9e; }
.play-icon { margin-right: 8px; font-size: 10px; }
.tool-btn { color: #e0e5da; }
.tool-btn:hover, .tool-btn.active { background: #ffffff0b; }
.tool-btn.active { color: var(--gold); }
.courtyard-btn { border: 1px solid #d8bf8663; color: var(--gold); padding: 11px 13px; }
.courtyard-btn span { display: inline-block; margin-left: 7px; }
#vr-slot:empty { display: none; }
#vr-slot button { position: static !important; bottom: auto !important; left: auto !important; width: auto !important; min-height: 46px; border: 1px solid var(--gold) !important; background: #d8bf8614 !important; opacity: 1 !important; border-radius: 7px !important; padding: 12px !important; font: 12px Arial, sans-serif !important; }
#tour-progress { display: none; position: fixed; z-index: 4; bottom: calc(26px + var(--safe-bottom)); left: calc(50% - 180px); width: 360px; height: 3px; overflow: hidden; background: #16231fa6; border-radius: 3px; }
#tour-fill { height: 100%; width: 0; background: var(--gold); }
body.touring #tour-progress { display: block; }
body.touring #walk-pad, body.overview #walk-pad, body.overview .map-card, body.rail-view #walk-pad { display: none; }
#walk-pad { position: fixed; z-index: 4; bottom: 120px; left: 304px; display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 44px); gap: 5px; }
#walk-pad button { min-width: 44px; min-height: 44px; border: 1px solid #d9cfb347; border-radius: 10px; background: #18261edb; font-size: 25px; touch-action: none; user-select: none; -webkit-user-select: none; }
#walk-pad button:active { background: #d8bf8677; }
#walk-pad button:first-child { grid-column: 2; }
#walk-pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
#walk-pad button:nth-child(3) { grid-column: 2; grid-row: 2; }
#walk-pad button:nth-child(4) { grid-column: 3; grid-row: 2; }
.map-card { position: fixed; z-index: 3; right: 26px; bottom: 120px; width: 148px; border: 1px solid var(--line); border-radius: 11px; background: #18251ee3; padding: 11px; }
.map-card .eyebrow { font-size: 8px; letter-spacing: 1px; }
#minimap { display: block; width: 100%; height: auto; aspect-ratio: 188 / 168; margin: 8px 0 4px; }
#minimap rect { stroke: #aebcac; stroke-width: .23; fill: #c8ccba1c; }
#minimap rect:hover { fill: #d8bf8666; cursor: pointer; }
#minimap rect.active { fill: #d8bf8688; stroke: var(--gold); }
#minimap #map-dot { fill: #ffe3a4; stroke: #16271c; stroke-width: .4; }
#minimap #map-direction { fill: #ffe3a4; opacity: .7; }
.map-caption { font-size: 8px; color: var(--muted); }
footer { position: fixed; z-index: 2; bottom: calc(7px + var(--safe-bottom)); left: 8px; right: 8px; margin: auto; max-width: calc(100% - 16px); width: fit-content; padding: 4px 9px; border-radius: 15px; background: #15251bc2; color: #d9dfd4; font-size: 9px; text-align: center; pointer-events: none; }

dialog { max-width: 780px; width: calc(100% - 28px); max-height: 91dvh; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: #1a2820; color: var(--cream); scrollbar-width: thin; }
dialog::backdrop { background: #08130bcd; backdrop-filter: blur(5px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; margin-bottom: 13px; border-bottom: 1px solid var(--line); }
h2 { font: 25px Georgia, serif; margin: 7px 0 0; }
.close-btn { border: 0; background: transparent; font-size: 30px; width: 44px; min-width: 44px; height: 44px; border-radius: 7px; }
.close-btn:hover { background: #ffffff0a; }
.reference-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 0 14px; padding: 1px 1px 3px; }
.reference-tabs button { border: 1px solid var(--line); border-radius: 7px; padding: 10px 13px; min-height: 44px; flex-shrink: 0; background: transparent; font-size: 12px; }
.reference-tabs button[aria-pressed="true"] { border-color: #d8bf86a0; background: #d8bf861a; color: var(--gold); }
dialog img { display: block; width: 100%; height: auto; border-radius: 3px; background: #f0efe8; }
dialog ul { margin: 0; padding-left: 20px; }
dialog li { margin: 13px 0; line-height: 1.7; font-size: 13px; }
dialog li b { color: #e6d8b8; }
.note { border-top: 1px solid var(--line); padding-top: 13px; margin: 15px 0 0; color: var(--muted); line-height: 1.7; font-size: 11px; }
#toast { position: fixed; z-index: 30; top: 100px; left: 50%; max-width: calc(100vw - 28px); padding: 12px 18px; background: #18271ef4; color: var(--cream); border: 1px solid #d8bf8663; border-radius: 9px; font-size: 12px; line-height: 1.5; text-align: center; transform: translate(-50%, -8px); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#loading { position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: #1b2520; transition: opacity .45s ease; }
.loading-rule { display: block; width: 43px; height: 1px; background: var(--gold); margin-bottom: 25px; }
#loading .eyebrow { margin: 0 0 13px; font-size: 9px; letter-spacing: 3px; }
#loading h2 { margin: 0; color: #ede7d9; font: 36px / 1.35 Georgia, serif; letter-spacing: 5px; }
#loading p:not(.eyebrow) { margin: 25px 18px 0; color: var(--muted); font-size: 12px; letter-spacing: .4px; }
.loading-progress { width: 110px; height: 2px; margin-top: 22px; background: #d8bf8622; overflow: hidden; }
.loading-progress::after { content: ''; display: block; height: 100%; width: 40%; background: var(--gold); animation: loading-slide 1.25s infinite ease-in-out; }
@keyframes loading-slide { from { transform: translateX(-100%); } to { transform: translateX(350%); } }
#loading.done { opacity: 0; pointer-events: none; }
#arrival-veil { position: fixed; inset: 0; z-index: 1; background: #d5cbb8; opacity: 0; pointer-events: none; }
#arrival-veil.reveal { animation: arrival-reveal .48s ease-out; }
@keyframes arrival-reveal { from { opacity: .72; } to { opacity: 0; } }
.error-state { position: fixed; z-index: 30; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #1a2820; padding: 8vh 7vw; text-align: center; }
.error-state h1 { font-size: 27px; }
.error-state p { font-size: 14px; line-height: 1.7; max-width: 450px; }
.error-state img { display: block; max-width: 90vw; width: auto; height: 46vh; object-fit: contain; margin: 15px 0; }
.error-state a { color: var(--gold); }

body.showroom .room-panel, body.showroom .map-card, body.showroom .view-card, body.showroom #walk-pad, body.showroom #help-btn, body.showroom #walk-btn, body.showroom #overview-btn, body.showroom #light-btn { display: none; }
body.showroom .toolbar { background: #18251cbd; }
body.showroom header { background: linear-gradient(#101b1799, transparent); }
body.vr header, body.vr .room-panel, body.vr .view-card, body.vr .map-card, body.vr #walk-pad, body.vr footer { display: none; }
body.vr .toolbar > button { display: none; }

@media (max-width: 1000px) and (min-width: 701px) {
  header { padding: 18px 20px 24px; }
  .room-panel { left: 20px; width: 226px; top: 106px; }
  .view-card { right: 20px; max-width: 230px; }
  .map-card { right: 20px; width: 122px; }
  #walk-pad { left: 266px; }
  .primary-btn, .tool-btn { padding-left: 11px; padding-right: 11px; }
}
@media (max-width: 700px) {
  header { padding: calc(13px + env(safe-area-inset-top, 0px)) 13px 22px; align-items: flex-start; }
  .brand b { font-size: 15px; letter-spacing: 2.4px; }
  .brand small { font-size: 6px; letter-spacing: 1.15px; margin-top: 5px; }
  .header-right { gap: 5px; }
  .floor-badge { padding-right: 8px; margin-right: 1px; gap: 2px; min-height: 41px; }
  .floor-number { font-size: 30px; }
  .floor-badge > span:last-child { font-size: 7px; letter-spacing: .5px; }
  .floor-badge small { display: none; }
  .icon-btn { width: 43px; min-width: 43px; height: 43px; border-radius: 8px; font-size: 21px; }
  .room-panel { top: auto; bottom: calc(88px + var(--safe-bottom)); left: 10px; right: 10px; width: auto; padding: 7px 10px 9px; max-height: min(59dvh, 500px); border-radius: 13px; background: #18251ff2; }
  .panel-heading { margin-bottom: 2px; min-height: 43px; }
  .panel-heading .icon-btn { height: 43px; min-height: 43px; }
  .panel-kicker { display: none; }
  .panel-heading .eyebrow { font-size: 8px; letter-spacing: 1.3px; }
  #unit-list { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; margin: 0 0 6px; padding-bottom: 1px; }
  .unit-btn { flex: 0 0 auto; min-width: 86px; min-height: 44px; padding: 6px 9px; gap: 3px; font-size: 9px; }
  .unit-btn b { font-size: 10px; }
  .panel-actions { margin-bottom: 6px; }
  .common-btn, .outline-btn { min-height: 43px; padding: 7px 9px; font-size: 11px; }
  .common-btn { justify-content: flex-start; }
  .common-btn span { margin-left: auto; }
  .outline-btn { min-width: 76px; }
  #room-list { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; padding-top: 7px; padding-bottom: 2px; }
  .room-btn { flex: 0 0 auto; width: auto; min-height: 43px; padding: 9px 12px; background: #ffffff06; font-size: 12px; white-space: nowrap; }
  .room-btn .arrow { display: none; }
  .palette-picker { padding-top: 8px; margin-top: 5px; border-top: 0; }
  .palette-picker select { max-width: none; min-width: 160px; font-size: 12px; min-height: 43px; }
  .palette-picker > span { font-size: 8px; }
  #palette-cards { flex-direction: row; overflow-x: auto; scrollbar-width: none; margin-top: 6px; }
  .palette-btn { min-width: 138px; padding: 7px; gap: 6px; }
  .palette-btn b { font-size: 11px; }
  .swatches i { width: 13px; height: 17px; }
  #palette-caption { font-size: 7px; margin: 7px 0 0; }
  .room-panel.collapsed { max-height: 160px; overflow: hidden; }
  .toolbar { left: 10px; right: 10px; bottom: calc(21px + var(--safe-bottom)); max-width: none; transform: none; border-radius: 11px; gap: 4px; padding: 6px; }
  .primary-btn, .tool-btn { min-height: 45px; font-size: 11px; padding: 11px 12px; }
  .primary-btn { min-width: 110px; }
  .courtyard-btn { padding: 10px 11px; }
  #vr-slot button { min-height: 45px; font-size: 11px !important; }
  .view-card { left: 12px; right: auto; top: calc(83px + env(safe-area-inset-top, 0px)); bottom: auto; max-width: calc(100% - 152px); padding: 10px 12px; background: #17251bd4; }
  .view-card .eyebrow { font-size: 7px; letter-spacing: .85px; }
  h1 { font-size: 20px; line-height: 1.15; margin: 6px 0 5px; }
  #room-size { font-size: 10px; line-height: 1.5; }
  #hint { font-size: 8px; margin-top: 7px; }
  #walk-pad { left: auto; right: 12px; bottom: calc(265px + var(--safe-bottom)); grid-template-columns: repeat(3, 43px); grid-template-rows: repeat(2, 43px); gap: 4px; }
  #walk-pad button { min-width: 43px; min-height: 43px; font-size: 24px; border-radius: 9px; }
  .map-card { right: 12px; top: calc(83px + env(safe-area-inset-top, 0px)); bottom: auto; width: 104px; padding: 8px; border-radius: 9px; background: #18251ed6; }
  .map-card .eyebrow { font-size: 6px; letter-spacing: .6px; }
  #minimap { margin: 5px 0 2px; }
  .map-caption { display: none; }
  footer { bottom: calc(4px + var(--safe-bottom)); padding: 2px 6px; font-size: 7px; }
  #tour-progress { bottom: calc(15px + var(--safe-bottom)); left: 18px; right: 18px; width: auto; }
  body.touring .view-card, body.overview .view-card { max-width: calc(100% - 24px); }
  #toast { top: calc(86px + env(safe-area-inset-top, 0px)); max-width: calc(100% - 28px); width: max-content; font-size: 11px; padding: 10px 14px; }
  dialog { padding: 15px; width: calc(100% - 20px); max-height: 92dvh; }
  h2 { font-size: 22px; }
  .dialog-head { padding-bottom: 10px; margin-bottom: 10px; }
  .reference-tabs { gap: 5px; margin-bottom: 10px; }
  .reference-tabs button { padding: 10px 12px; font-size: 11px; }
  dialog li { font-size: 12px; margin: 11px 0; }
  .note { font-size: 10px; }
  body:has(.room-panel:not(.collapsed)) .view-card, body:has(.room-panel:not(.collapsed)) #walk-pad { display: none; }
}
@media (max-width: 370px) {
  .brand b { font-size: 13px; letter-spacing: 1.8px; }
  .brand small { font-size: 5px; letter-spacing: .9px; }
  .floor-number { font-size: 26px; }
  .floor-badge { padding-right: 5px; }
  .floor-badge > span:last-child { font-size: 6px; }
  .header-right { gap: 3px; }
  .view-card { max-width: calc(100% - 165px); }
  h1 { font-size: 18px; }
  #hint { display: none; }
}
@media (max-height: 540px) {
  header { padding-top: 10px; padding-bottom: 20px; }
  .brand b { font-size: 13px; }
  .brand small { display: none; }
  .floor-number { font-size: 27px; }
  .room-panel { top: 74px; bottom: auto; left: 12px; right: auto; width: 225px; max-height: calc(100dvh - 166px); }
  .room-panel.collapsed { max-height: 160px; }
  #unit-list { display: flex; overflow-x: auto; }
  .unit-btn { flex: 0 0 auto; min-width: 75px; min-height: 44px; }
  .view-card, .map-card { display: none; }
  #walk-pad { left: auto; right: 12px; bottom: calc(91px + var(--safe-bottom)); }
  .toolbar { left: 12px; right: 12px; bottom: calc(20px + var(--safe-bottom)); max-width: none; transform: none; }
  #toast { top: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 700px) and (min-height: 541px) { .room-panel.collapsed .panel-actions { display: none; } }
