:root {
  --bg: #f4f5f7;
  --ink: #16181c;
  --muted: #6b7280;
  --line: #e4e6ea;
  --accent: #2563eb;
  --stage: #616a75;
  --panel-w: 300px;
  --top-h: 60px;
  --foot-h: 34px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.4 var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- top bar */
.top { position: fixed; inset: 0 0 auto 0; height: var(--top-h); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 20px; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.brand b { color: var(--ink); letter-spacing: .04em; font-size: 13px; }
.brand span { color: var(--muted); font-size: 13px; }
.switch { display: flex; gap: 2px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.switch a { display: flex; gap: 7px; align-items: center; padding: 7px 12px; border-radius: 8px; color: #374151; font-size: 13px; }
.switch a.on { background: #eef3ff; color: var(--accent); font-weight: 600; }
.ico { opacity: .75; }
.download { justify-self: end; display: flex; gap: 8px; align-items: center; background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; }
.download:hover { background: #000; }

/* ---------- stage */
.stage { position: fixed; top: var(--top-h); left: 0; right: var(--panel-w); bottom: var(--foot-h); background: var(--stage); overflow: hidden; }
.stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.stage:fullscreen { inset: 0; right: 0; }

.card { position: absolute; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-radius: 12px; padding: 12px 16px; box-shadow: 0 6px 24px rgba(0,0,0,.14); }
.intro { top: 16px; left: 16px; max-width: 260px; }
.intro small, .panel small, .chip { font: 10px/1 var(--mono); letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.intro h1 { margin: 6px 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.intro p { margin: 0; color: var(--muted); font-size: 12px; }
.intro p i { margin: 0 8px; font-style: normal; opacity: .5; }

.loading { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 999px; padding: 9px 16px; font-size: 13px; box-shadow: 0 6px 24px rgba(0,0,0,.18); transition: opacity .4s; white-space: nowrap; }
.loading.done { opacity: 0; pointer-events: none; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; }

.corner { position: absolute; left: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.92); border-radius: 8px; padding: 9px 12px; color: var(--ink); }
.chip i { font-style: normal; color: var(--muted); border-left: 1px solid var(--line); padding-left: 8px; }
.hint { background: rgba(255,255,255,.92); border-radius: 8px; padding: 8px 12px; font-size: 11px; color: #4b5563; max-width: 190px; }

.modes { position: absolute; right: 16px; bottom: 60px; display: flex; gap: 2px; background: rgba(255,255,255,.92); border-radius: 10px; padding: 3px; }
.modes button { padding: 6px 10px; border-radius: 8px; font-size: 12px; color: #4b5563; }
.modes button.on { background: #eef3ff; color: var(--accent); font-weight: 600; }
.toolbar { position: absolute; right: 16px; bottom: 16px; display: flex; background: rgba(255,255,255,.92); border-radius: 10px; padding: 3px; }
.toolbar button { width: 30px; height: 30px; border-radius: 7px; font-size: 15px; color: #374151; display: grid; place-items: center; }
.toolbar button:hover, .modes button:hover { background: #f1f3f6; }

/* ---------- touch stick (walk mode on phones) */
.stick[hidden] { display: none; }
.stick { position: absolute; width: 110px; height: 110px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.5); background: rgba(255,255,255,.1); pointer-events: none; }
.knob { position: absolute; left: 32px; top: 32px; width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.85); }

/* ---------- walkthrough: full-bleed stage, floating room chips */
.walkmode .panel, .walkmode .foot { display: none; }
.walkmode .stage { right: 0; bottom: 0; }
.rooms { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 70vw; }
.rooms button { background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-radius: 999px; padding: 8px 14px; font-size: 13px; color: #374151; box-shadow: 0 4px 16px rgba(0,0,0,.14); }
.rooms button.on { background: #eef3ff; color: var(--accent); font-weight: 600; }
.walkmode .modes { bottom: 64px; }
@media (max-width: 860px) {
  .walkmode .stage { bottom: 0; }
  .rooms { bottom: 12px; max-width: 92vw; gap: 5px; }
  .rooms button { padding: 6px 10px; font-size: 12px; }
  .walkmode .minimap { bottom: auto; top: 12px; left: auto; right: 12px; }
  .walkmode .intro { max-width: 52vw; }
  .walkmode .modes { display: none; }     /* on a phone the walkthrough is walk-only; the header goes back to the model */
  .walkmode .toolbar { display: none; }
  .walkmode .intro { max-width: 50vw; padding: 8px 10px; }
  .walkmode .intro h1 { font-size: 15px; }
  .walkmode .corner { display: none; }
}

/* ---------- minimap */
.minimap { position: absolute; top: 16px; right: 16px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-radius: 12px; padding: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.14); cursor: crosshair; }
.minimap canvas { display: block; width: 204px; height: 96px; border-radius: 6px; }
.mapRoom { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; padding: 0 2px; font-size: 12px; font-weight: 600; }
.mapRoom i { font: 10px var(--mono); letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }

/* ---------- side panel */
.panel { position: fixed; top: var(--top-h); right: 0; bottom: var(--foot-h); width: var(--panel-w); padding: 18px 20px; overflow: auto; background: var(--bg); border-left: 1px solid var(--line); }
.grip { display: none; }
.panel h2 { margin: 6px 0 12px; font-size: 16px; font-weight: 600; }
.tabs { display: flex; background: #e9ebef; border-radius: 9px; padding: 3px; margin-bottom: 8px; }
.tabs button { flex: 1; padding: 6px; border-radius: 7px; font-size: 12px; color: #4b5563; }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.views { list-style: none; margin: 0 0 12px; padding: 0; }
.views button { width: 100%; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 9px 8px; border-radius: 8px; text-align: left; color: #4b5563; font-size: 13px; }
.views button small { font: 10px var(--mono); color: #9ca3af; }
.views button em { font-style: normal; color: #b0b5bd; font-size: 12px; }
.views button:hover { background: #eceef2; }
.views button.on { background: #e8efff; color: var(--accent); font-weight: 600; }
.views button.on em { color: var(--accent); }
.toggles { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.toggles label { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 4px 18px; font-size: 12.5px; color: #374151; cursor: pointer; }
.toggles label.lead { padding-left: 0; font-weight: 600; color: var(--ink); }
.toggles input { display: none; }
.toggles i { width: 30px; height: 17px; border-radius: 999px; background: #cfd3da; position: relative; transition: background .2s; }
.toggles i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: left .2s; }
.toggles input:checked + i { background: var(--accent); }
.toggles input:checked + i::after { left: 15px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 8px; }
.stats b { display: block; font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.stats small { display: block; font-size: 10px; color: var(--muted); }
.stats span { display: block; font-size: 11px; color: var(--muted); margin-top: 6px; }
.note { font-size: 11px; color: var(--muted); margin: 6px 0 14px; }
.note code { font: 10px var(--mono); background: #e9ebef; padding: 1px 4px; border-radius: 3px; }
.link { color: var(--accent); font-size: 13px; font-weight: 500; }
.gallery { display: grid; gap: 10px; margin-top: 6px; }
.gallery figure { margin: 0; cursor: zoom-in; }
.gallery img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 8px; background: #d5d9df; display: block; }
.gallery figcaption { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; }
.gallery figcaption small { font: 10px var(--mono); color: #9ca3af; }

/* ---------- footer */
.foot { position: fixed; inset: auto 0 0 0; height: var(--foot-h); display: flex; justify-content: space-between; align-items: center; padding: 0 20px; font: 10px var(--mono); letter-spacing: .12em; color: var(--muted); text-transform: uppercase; border-top: 1px solid var(--line); background: var(--bg); }
.foot a:hover { color: var(--ink); }

.lightbox[hidden] { display: none; }
.lightbox { position: fixed; inset: 0; z-index: 20; background: rgba(15,17,20,.92); display: grid; place-items: center; padding: 24px; }
.lightbox img { max-width: 100%; max-height: 88vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox button { position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; font-size: 16px; }
.lightbox .cap { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: #cbd0d8; font-size: 12px; }

/* ---------- phone: stage on top, panel as a bottom sheet; the canvas only covers the visible area */
@media (max-width: 860px) {
  :root { --panel-w: 0px; --top-h: 52px; --foot-h: 0px; --sheet: 42vh; }
  .top { padding: 0 12px; grid-template-columns: auto 1fr auto; gap: 8px; background: var(--bg); }
  .brand b, .brand span { display: none; }
  .switch { justify-self: center; }
  .switch a { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
  .download { padding: 8px 10px; font-size: 0; gap: 0; }
  .download .ico { font-size: 15px; opacity: 1; }
  .stage { bottom: var(--sheet); right: 0; }
  .intro { max-width: 62vw; padding: 8px 12px; left: 12px; top: 12px; }
  .intro h1 { font-size: 17px; margin: 4px 0 2px; }
  .intro p { font-size: 11px; }
  .minimap { top: auto; bottom: 12px; left: 12px; right: auto; padding: 5px; }
  .minimap canvas { width: 136px; height: 64px; }
  .mapRoom { font-size: 10px; margin-top: 3px; }
  .mapRoom i { display: none; }
  .corner { display: none; }
  .chip { padding: 7px 10px; }
  .chip i { display: none; }
  .hint { display: none; }
  .modes { bottom: 52px; right: 12px; }
  .modes button { padding: 5px 8px; font-size: 11px; }
  .toolbar { bottom: 12px; right: 12px; }
  .toolbar button { width: 26px; height: 26px; font-size: 13px; }
  .loading { bottom: 100px; }
  .panel { top: auto; bottom: 0; width: 100%; height: var(--sheet); border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; padding-top: 8px; transition: height .3s; box-shadow: 0 -8px 30px rgba(0,0,0,.18); z-index: 4; }
  .panel.tall { height: 82vh; }
  .grip { display: block; width: 36px; height: 4px; border-radius: 2px; background: #cbd0d8; margin: 0 auto 10px; }
  .panel h2 { font-size: 15px; margin: 4px 0 8px; }
  .views button { padding: 7px 8px; }
  .foot { display: none; }
}
