:root {
  color-scheme: dark;
  --ink: #f7f7f3;
  --muted: rgba(247, 247, 243, 0.68);
  --glass: rgba(18, 20, 19, 0.72);
  --glass-strong: rgba(18, 20, 19, 0.94);
  --line: rgba(255, 255, 255, 0.16);
  --accent: #d8c3a5;
  --accent-ink: #24201b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html,
body,
.app,
.viewer-shell,
.viewer {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body { background: #171918; color: var(--ink); }
button { font: inherit; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.app { position: relative; min-height: 100svh; }
.viewer-shell { position: relative; background: #252826; }
.viewer { position: absolute; inset: 0; }
.viewer::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.44), transparent 24%, transparent 72%, rgba(0,0,0,.24));
}

.topbar {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: max(18px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 16px max(20px, env(safe-area-inset-left));
  pointer-events: none;
}

.topbar > * { pointer-events: auto; }
.topbar-actions { display: flex; gap: 10px; }
.title-block { min-width: 0; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.55rem, 3vw, 2.35rem); font-weight: 400; line-height: 1; }

.icon-button,
.control-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--glass);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  transition: background .2s ease, transform .2s ease, border-color .2s ease;
}

.icon-button:hover,
.control-button:hover { background: rgba(45, 48, 46, .9); border-color: rgba(255,255,255,.32); transform: translateY(-1px); }
.icon-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fullscreen-exit { display: none; }
.is-fullscreen .fullscreen-enter { display: none; }
.is-fullscreen .fullscreen-exit { display: block; }

.viewer-controls {
  position: absolute;
  z-index: 5;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-button { font-size: 1.55rem; font-weight: 300; }
.help {
  position: absolute;
  z-index: 4;
  bottom: max(30px, env(safe-area-inset-bottom));
  left: 50%;
  margin: 0;
  padding: 9px 14px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  background: var(--glass);
  font-size: .76rem;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}
.help-touch { display: none; }

.status-layer {
  position: absolute;
  z-index: 7;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(255,255,255,.84);
  background: #232624;
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s ease, visibility .35s ease;
}
.status-layer.is-visible { opacity: 1; visibility: visible; }
.spinner { width: 22px; height: 22px; border: 2px solid rgba(255,255,255,.22); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-panel {
  position: absolute;
  z-index: 9;
  top: 50%;
  left: 50%;
  width: min(420px, calc(100% - 40px));
  padding: 32px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  text-align: center;
}
.error-panel[hidden] { display: none; }
.error-panel h2 { margin: 14px 0 8px; font-family: Georgia, serif; font-weight: 400; }
.error-panel p { color: var(--muted); line-height: 1.55; }
.error-icon { display: grid; place-items: center; width: 42px; height: 42px; margin: auto; border: 1px solid #e0a59e; border-radius: 50%; color: #f0c1bb; font-weight: 700; }
.primary-button { padding: 11px 18px; border: 0; border-radius: 99px; color: var(--accent-ink); background: var(--accent); font-weight: 750; cursor: pointer; }

.sidebar {
  position: fixed;
  z-index: 11;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: min(380px, 88vw);
  height: 100%;
  padding: max(26px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  transform: translateX(-102%);
  color: var(--ink);
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform .32s cubic-bezier(.22,.8,.25,1);
}
.sidebar.is-open { transform: translateX(0); }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.sidebar-header h2 { margin: 0; font-family: Georgia, serif; font-size: 1.8rem; font-weight: 400; }
.close-button { width: 42px; height: 42px; box-shadow: none; }
.sidebar nav { min-height: 0; overflow-y: auto; margin: 18px -8px 0; padding: 0 8px; }
.room-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.room-button { display: grid; grid-template-columns: 36px 1fr; align-items: center; width: 100%; padding: 14px 12px; border: 0; border-radius: 10px; color: rgba(255,255,255,.72); background: transparent; text-align: left; cursor: pointer; transition: color .2s ease, background .2s ease; }
.room-button:hover { color: var(--ink); background: rgba(255,255,255,.07); }
.room-button.is-active { color: var(--ink); background: rgba(216,195,165,.14); }
.room-number { color: var(--accent); font-size: .67rem; letter-spacing: .1em; }
.sidebar-footer { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 22px; color: var(--muted); font-size: .74rem; }
.sidebar-footer p { margin: 0; }
.orientation-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); font-size: .7rem; font-weight: 750; }
.backdrop { position: fixed; z-index: 10; inset: 0; opacity: 0; background: rgba(0,0,0,.45); transition: opacity .25s ease; }
.backdrop.is-visible { opacity: 1; }

.floorplan-overlay {
  position: fixed;
  z-index: 14;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 10, 9, .74);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.floorplan-overlay[hidden] { display: none; }
.floorplan-dialog {
  width: min(860px, 100%);
  max-height: calc(100svh - 48px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  background: var(--glass-strong);
  box-shadow: var(--shadow);
}
.floorplan-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.floorplan-header h2 { margin: 0; font-family: Georgia, serif; font-size: 1.8rem; font-weight: 400; }
.floorplan-stage { position: relative; overflow: hidden; border-radius: 14px; background: #f4f0e9; }
.floorplan-stage img { display: block; width: 100%; height: auto; }
.floorplan-markers { position: absolute; inset: 0; }
.floorplan-marker {
  position: absolute;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 3px solid white;
  border-radius: 50%;
  color: white;
  background: rgba(28, 31, 29, .9);
  box-shadow: 0 5px 16px rgba(0,0,0,.34);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.floorplan-marker::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.floorplan-marker::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  max-width: 180px;
  padding: 6px 9px;
  transform: translateX(-50%) translateY(4px);
  border-radius: 6px;
  color: white;
  background: rgba(20,22,21,.92);
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.floorplan-marker:hover,
.floorplan-marker:focus-visible { z-index: 2; transform: translate(-50%, -50%) scale(1.1); }
.floorplan-marker:hover::after,
.floorplan-marker:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }
.floorplan-marker.is-active { color: var(--accent-ink); background: var(--accent); box-shadow: 0 0 0 6px rgba(216,195,165,.24), 0 5px 16px rgba(0,0,0,.34); }
.floorplan-marker.is-active::after { opacity: 1; transform: translateX(-50%) translateY(0); }
.floorplan-hint { margin: 14px 2px 0; color: var(--muted); font-size: .78rem; text-align: center; }

.hotspot { position: relative; display: flex; align-items: center; gap: 8px; padding: 0; border: 0; color: white; background: transparent; cursor: pointer; filter: drop-shadow(0 3px 10px rgba(0,0,0,.45)); }
.hotspot-marker { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border: 2px solid white; border-radius: 50%; background: rgba(20,22,21,.62); transition: transform .2s ease, background .2s ease; }
.hotspot-marker svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hotspot-label { max-width: 180px; padding: 8px 11px; border: 1px solid rgba(255,255,255,.3); border-radius: 7px; background: rgba(20,22,21,.75); font-size: .76rem; font-weight: 700; white-space: nowrap; backdrop-filter: blur(8px); }
.hotspot:hover .hotspot-marker, .hotspot:focus-visible .hotspot-marker { transform: scale(1.1); background: var(--accent-ink); }

noscript { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 30px; color: white; background: #171918; text-align: center; }

@media (hover: none), (pointer: coarse) {
  .help-desktop { display: none; }
  .help-touch { display: inline; }
}

@media (max-width: 640px) {
  .topbar { grid-template-columns: 44px 1fr auto; gap: 11px; padding-left: 14px; padding-right: 14px; }
  .topbar-actions { gap: 6px; }
  .icon-button { width: 44px; height: 44px; }
  .eyebrow { font-size: .59rem; }
  h1 { font-size: 1.38rem; }
  .viewer-controls { right: 14px; bottom: max(18px, env(safe-area-inset-bottom)); }
  .help { bottom: max(20px, env(safe-area-inset-bottom)); max-width: calc(100% - 142px); overflow: hidden; text-overflow: ellipsis; }
  .help-desktop { display: none; }
  .help-touch { display: inline; }
  .hotspot-label { display: none; }
  .hotspot-marker { width: 48px; height: 48px; }
  .floorplan-overlay { padding: 8px; }
  .floorplan-dialog { max-height: calc(100svh - 16px); padding: 14px; border-radius: 16px; }
  .floorplan-header { margin-bottom: 12px; }
  .floorplan-header h2 { font-size: 1.45rem; }
  .floorplan-marker { width: 32px; height: 32px; border-width: 2px; }
  .floorplan-marker::before { width: 8px; height: 8px; }
  .floorplan-marker::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
