:root {
  color-scheme: dark;
  --ink: #18140f;
  --ink-soft: rgb(24 20 15 / 78%);
  --paper: #f8f3e9;
  --muted: #c7bfae;
  --gold: #d7bb7a;
  --gold-bright: #f2dca4;
  --line: rgb(255 255 255 / 14%);
  --glass: rgb(22 18 13 / 74%);
  --shadow: 0 1.25rem 4rem rgb(0 0 0 / 36%);
}

* { box-sizing: border-box; }

html,
body,
.app-shell,
.viewer-shell,
#panorama { width: 100%; height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }
button:focus-visible,
[tabindex="0"]:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; }

.app-shell { position: relative; isolation: isolate; }
.viewer-shell { position: relative; overflow: hidden; }

.viewer-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgb(0 0 0 / 34%) 0, transparent 22%, transparent 70%, rgb(0 0 0 / 30%) 100%);
  z-index: 1;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: max(1rem, env(safe-area-inset-top));
  left: max(1rem, env(safe-area-inset-left));
  right: max(1rem, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 0.8rem;
  pointer-events: none;
}

.topbar > * { pointer-events: auto; }
.icon-button,
.control-button {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--glass);
  color: var(--paper);
  box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 18%);
  cursor: pointer;
  backdrop-filter: blur(18px) saturate(1.2);
}
.icon-button:hover,
.control-button:hover { background: rgb(64 53 38 / 86%); border-color: rgb(215 187 122 / 52%); }

.menu-glyph,
.menu-glyph::before,
.menu-glyph::after { width: 1.1rem; height: 1px; background: currentColor; }
.menu-glyph { position: relative; }
.menu-glyph::before,
.menu-glyph::after { content: ""; position: absolute; left: 0; }
.menu-glyph::before { top: -0.35rem; }
.menu-glyph::after { top: 0.35rem; }

.brand { display: flex; align-items: center; gap: 0.7rem; text-shadow: 0 2px 14px rgb(0 0 0 / 50%); }
.brand__mark { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 1px solid rgb(215 187 122 / 58%); color: var(--gold-bright); font-family: Georgia, serif; font-size: 1.45rem; }
.brand__copy { display: grid; line-height: 1.05; }
.brand__copy strong { font-family: Georgia, serif; font-weight: 500; font-size: 1.05rem; letter-spacing: 0.02em; }
.brand__copy small { margin-top: 0.28rem; color: var(--muted); font-size: 0.64rem; letter-spacing: 0.16em; text-transform: uppercase; }
.current-scene { justify-self: end; max-width: min(32rem, 44vw); margin: 0; padding: 0.72rem 1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--glass); box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 18%); color: var(--paper); font-size: 0.84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; backdrop-filter: blur(18px); }

.scene-drawer {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  width: min(25rem, 92vw);
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1.25rem, env(safe-area-inset-bottom));
  background: linear-gradient(150deg, #211b14, #100e0b 72%);
  box-shadow: var(--shadow);
  transform: translateX(-105%);
  transition: transform 360ms cubic-bezier(.22, 1, .36, 1);
  overflow: hidden;
}
.drawer-open .scene-drawer { transform: translateX(0); }
.scene-drawer__header { display: flex; align-items: center; justify-content: space-between; padding: 0.25rem 0 1.15rem; }
.eyebrow { margin: 0 0 0.28rem; color: var(--gold); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.19em; text-transform: uppercase; }
h2 { margin: 0; font-family: Georgia, serif; font-size: 1.8rem; font-weight: 500; }
.scene-drawer__header .icon-button,
.media-dialog__header .icon-button { box-shadow: none; font-size: 1.6rem; }
.scene-list { height: calc(100% - 5rem); padding-right: 0.35rem; display: grid; gap: 0.65rem; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--gold) transparent; }
.scene-card { position: relative; display: grid; grid-template-columns: 5.75rem auto 1fr; min-height: 4.5rem; padding: 0.45rem; align-items: center; gap: 0.75rem; border: 1px solid transparent; border-radius: 0.85rem; background: transparent; color: var(--paper); text-align: left; cursor: pointer; overflow: hidden; }
.scene-card:hover { background: rgb(255 255 255 / 6%); }
.scene-card.is-active { border-color: rgb(215 187 122 / 42%); background: rgb(215 187 122 / 11%); }
.scene-card img { width: 5.75rem; height: 3.7rem; border-radius: 0.55rem; object-fit: cover; filter: saturate(.82); }
.scene-card img:not([src]) { background: rgb(255 255 255 / 6%); }
.scene-card__number { color: var(--gold); font: 0.72rem/1 Georgia, serif; }
.scene-card__copy { min-width: 0; display: grid; justify-items: start; gap: 0.3rem; }
.scene-card__title { font-size: 0.86rem; line-height: 1.25; }
.scene-card__motion { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--gold-bright); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.scene-card__motion::before { width: 0.42rem; height: 0.42rem; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0.2rem rgb(215 187 122 / 12%); content: ""; }
.drawer-backdrop { position: fixed; z-index: 35; inset: 0; border: 0; background: rgb(0 0 0 / 48%); opacity: 0; visibility: hidden; transition: opacity 250ms ease, visibility 250ms; backdrop-filter: blur(2px); }
.drawer-open .drawer-backdrop { opacity: 1; visibility: visible; }

.viewer-controls { position: fixed; z-index: 10; left: 50%; bottom: max(1.25rem, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 0.45rem; padding: 0.42rem; border: 1px solid var(--line); border-radius: 999px; background: var(--glass); box-shadow: var(--shadow); transform: translateX(-50%); backdrop-filter: blur(20px) saturate(1.2); }
.viewer-controls .control-button { width: 2.75rem; height: 2.75rem; min-width: 2.75rem; min-height: 2.75rem; background: transparent; border-color: transparent; box-shadow: none; font-size: 1.3rem; }
.viewer-controls .control-button[aria-pressed="true"] { background: var(--gold); color: var(--ink); }
.control-separator { width: 1px; height: 1.6rem; margin-inline: 0.1rem; background: var(--line); }

.status { position: absolute; z-index: 12; inset: 50% auto auto 50%; display: flex; align-items: center; gap: 0.8rem; max-width: min(30rem, calc(100vw - 2rem)); padding: 0.9rem 1.15rem; border: 1px solid var(--line); border-radius: 999px; background: var(--glass); box-shadow: var(--shadow); transform: translate(-50%, -50%); backdrop-filter: blur(18px); }
.status[hidden] { display: none; }
.status[data-state="error"] { flex-wrap: wrap; justify-content: center; border-color: rgb(255 154 130 / 50%); border-radius: 1rem; color: #ffd7cd; }
.status__spinner { width: 1rem; height: 1rem; border: 2px solid rgb(255 255 255 / 24%); border-top-color: var(--gold-bright); border-radius: 50%; animation: spin 800ms linear infinite; }
.status[data-state="error"] .status__spinner { display: none; }
.status__retry { min-height: 2.75rem; padding: 0.55rem 0.9rem; border: 1px solid currentColor; border-radius: 999px; background: transparent; color: inherit; cursor: pointer; }
@keyframes spin { to { transform: rotate(360deg); } }

.gesture-hint { position: absolute; z-index: 10; left: 50%; bottom: 6.2rem; margin: 0; padding: 0.55rem 0.9rem; border-radius: 999px; background: rgb(0 0 0 / 54%); color: var(--paper); font-size: 0.75rem; transform: translateX(-50%); transition: opacity 450ms ease; pointer-events: none; }
.gesture-hint.is-hidden { opacity: 0; }

.tour-hotspot { display: grid !important; place-items: center; width: 2.8rem; height: 2.8rem; margin: -1.4rem 0 0 -1.4rem; border: 1px solid rgb(255 255 255 / 72%); border-radius: 50%; background: rgb(22 18 13 / 75%); box-shadow: 0 0.45rem 1.35rem rgb(0 0 0 / 38%); cursor: pointer; backdrop-filter: blur(8px); }
.tour-hotspot::before { color: white; font-size: 1.3rem; line-height: 1; }
.tour-hotspot--scene::before { content: "→"; }
.tour-hotspot--picture::before { content: "□"; }
.tour-hotspot--video::before { content: "▶"; font-size: 1rem; }
.control-button[hidden], .water-status[hidden] { display: none; }
.water-status { position: absolute; z-index: 5; bottom: 92px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 10px 16px; border-radius: 12px; background: #18140feb; color: #fffaf1; font-size: 0.8rem; text-align: center; pointer-events: none; }
@media (max-width: 360px) {
  .viewer-controls { gap: 0.25rem; padding: 0.25rem; }
  .viewer-controls .control-separator { margin-inline: 0; }
}
.tour-hotspot--gallery::before { content: "▦"; }
.tour-hotspot--media { border-color: var(--gold-bright); background: rgb(118 88 37 / 82%); }
.tour-hotspot__label { position: absolute; left: 50%; bottom: calc(100% + .55rem); width: max-content; max-width: 14rem; padding: 0.45rem 0.65rem; border-radius: 0.35rem; background: rgb(17 14 10 / 92%); color: white; font-size: 0.72rem; line-height: 1.2; opacity: 0; transform: translate(-50%, .25rem); transition: opacity 160ms ease, transform 160ms ease; pointer-events: none; }
.tour-hotspot:hover .tour-hotspot__label,
.tour-hotspot:focus .tour-hotspot__label { opacity: 1; transform: translate(-50%, 0); }

.media-dialog { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: clamp(1rem, 4vw, 3rem); border: 0; background: rgb(5 4 3 / 76%); color: var(--paper); backdrop-filter: blur(16px); }
.media-dialog::backdrop { background: transparent; }
.media-dialog__panel { width: min(70rem, 100%); height: 100%; margin: auto; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; border: 1px solid var(--line); border-radius: 1.25rem; background: #17130f; box-shadow: var(--shadow); }
.media-dialog__header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); }
.media-dialog__header h2 { font-size: 1.25rem; }
.media-dialog__content { min-height: 0; display: grid; place-items: center; padding: 1rem; overflow: auto; }
.media-dialog__content picture {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.media-dialog__content picture img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.media-dialog__content img,
.media-dialog__content video { display: block; width: auto; max-width: 100%; height: auto; max-height: 100%; border-radius: 0.75rem; box-shadow: 0 1rem 3rem rgb(0 0 0 / 38%); }
.gallery-controls { display: flex; justify-content: center; align-items: center; gap: 1rem; padding: 0.9rem; border-top: 1px solid var(--line); }
.gallery-controls[hidden] { display: none; }
.gallery-controls button { min-height: 2.75rem; padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--paper); cursor: pointer; }
.gallery-controls span { min-width: 4rem; color: var(--muted); text-align: center; }

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

@media (max-width: 640px) {
  .topbar { top: max(0.65rem, env(safe-area-inset-top)); left: 0.65rem; right: 0.65rem; grid-template-columns: auto 1fr; }
  .brand__mark { display: none; }
  .brand__copy strong { font-size: 0.95rem; }
  .brand__copy small { font-size: 0.56rem; }
  .current-scene { grid-column: 1 / -1; justify-self: start; max-width: calc(100vw - 1.3rem); padding: 0.55rem 0.75rem; font-size: 0.75rem; }
  .viewer-controls { bottom: max(0.75rem, env(safe-area-inset-bottom)); }
  .viewer-controls .control-button { width: 2.75rem; height: 2.75rem; }
  .gesture-hint { bottom: 5.4rem; white-space: nowrap; }
  .media-dialog { padding: 0; }
  .media-dialog__panel { border: 0; border-radius: 0; }
}

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