* { box-sizing: border-box; }
html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #172820;
  color: var(--visit-ink);
  font-family: "IBM Plex Sans Arabic", Arial, sans-serif;
}
canvas { display: block; touch-action: none; }
button, summary { font: inherit; touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
body {
  --edge: clamp(10px, 1.4vw, 20px);
  --edge-top: max(var(--edge), env(safe-area-inset-top));
  --edge-right: max(var(--edge), env(safe-area-inset-right));
  --edge-bottom: max(var(--edge), env(safe-area-inset-bottom));
  --edge-left: max(var(--edge), env(safe-area-inset-left));
  --movement-height: 110px;
  --surface-control: #fcfbf5f2;
}

.visitor-system {
  position: fixed;
  z-index: 8;
  top: var(--edge-top);
  left: var(--edge-left);
  display: flex;
  gap: 5px;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-control);
}
.visitor-system button, .visitor-menu-toggle {
  height: 44px;
  min-width: 44px;
  padding: 5px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--visit-ink);
  font-size: 13px;
  font-weight: 600;
}
.visitor-system button { display: grid; place-items: center; padding: 0; }
.visitor-system svg { width: 20px; height: 20px; }
.visitor-system button:hover,
.touch button:hover,
.visitor-elevation button:hover { background: var(--visit-hover); }

.visitor-menu-toggle {
  position: fixed;
  top: calc(var(--edge-top) + 3px);
  right: var(--edge-right);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--visit-forest);
  color: var(--visit-paper);
  font-size: 14px;
}
.visitor-menu-toggle::before {
  content: "";
  width: 13px;
  height: 9px;
  flex: none;
  border-block: 1px solid currentColor;
  background: linear-gradient(currentColor,currentColor) center / 100% 1px no-repeat;
}
.visitor-menu-toggle:hover { background: #285342; }
.visitor-menu-toggle[aria-expanded=true] { background: var(--visit-paper); color: var(--visit-forest); }

.visitor-menu {
  position: fixed;
  z-index: 9;
  top: calc(var(--edge-top) + 57px);
  right: var(--edge-right);
  display: grid;
  align-content: start;
  gap: 8px;
  width: 254px;
  max-width: calc(100vw - var(--edge-left) - var(--edge-right));
  max-height: calc(100dvh - var(--edge-top) - 57px - var(--edge-bottom) - var(--movement-height));
  padding: 10px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #829788 transparent;
  background: var(--surface-control);
  border-radius: 13px;
  box-shadow: 0 12px 28px #172c2329;
}
.visitor-showing .visitor-menu { --movement-height: 54px; }
.visitor-menu:dir(ltr) { text-align: left; }
.visitor-menu :focus-visible { outline-offset: -2px; }
.visitor-menu-header {
  display: grid;
  grid-template-columns: minmax(0,1fr) 44px;
  align-items: center;
  gap: 5px;
}
.visitor-room-select, .visitor-menu-close {
  min-height: 44px;
  min-width: 0;
  padding: 5px 9px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  color: var(--visit-ink);
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
.visitor-menu-close { display: grid; place-items: center; color: var(--visit-muted); }
.visitor-menu-close svg { width: 18px; height: 18px; }
.visitor-room-select:hover, .visitor-menu-close:hover { background: var(--visit-hover); }
.visitor-room-select option { background: var(--visit-paper); color: var(--visit-ink); }

.visitor-explore {
  min-height: 49px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--visit-forest);
  color: var(--visit-paper);
  line-height: 1.4;
  font-size: 15px;
  font-weight: 600;
}
.visitor-explore:hover { background: #285342; }
.visitor-menu-title {
  margin: 3px 0 0;
  padding-inline: 9px;
  color: var(--visit-muted);
  font-size: 12px;
  font-weight: 600;
}
.visitor-category, .visitor-group summary, .visitor-home-link, .visitor-menu-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  width: 100%;
  min-height: 44px;
  padding: 6px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--visit-ink);
  text-align: start;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.visitor-category::after {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border: solid currentColor;
  border-width: 0 0 1px 1px;
  transform: rotate(45deg);
  opacity: .7;
}
.visitor-category:dir(ltr)::after { transform: rotate(225deg); }
.visitor-category:hover, .visitor-category[aria-pressed=true],
.visitor-group summary:hover, .visitor-home-link:hover, .visitor-menu-action:hover {
  background: var(--visit-hover);
}
.visitor-category[aria-pressed=true] { color: var(--visit-forest); font-weight: 600; }
.visitor-group { border-top: 1px solid var(--visit-line); }
.visitor-group summary { cursor: pointer; font-weight: 600; color: var(--visit-forest); list-style: none; }
.visitor-group summary::-webkit-details-marker { display: none; }
.visitor-group summary::after {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
}
.visitor-group[open] summary::after { transform: rotate(225deg); }
.visitor-group .visitor-category { padding-inline-start: 16px; }
.visitor-menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  border-top: 1px solid var(--visit-line);
  padding-top: 4px;
}
.visitor-home-link, .visitor-menu-action { justify-content: center; text-align: center; font-weight: 600; }
.visitor-home-link { text-decoration: none; color: var(--visit-forest); }
.visitor-menu-action { color: var(--visit-muted); }
.visitor-status { margin: 0; padding-inline: 9px; color: #823d29; font-size: 13px; line-height: 1.5; }
.visitor-status:empty { display: none; }

.visitor-transport {
  position: fixed;
  bottom: var(--edge-bottom);
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  gap: 4px;
  max-width: calc(100vw - 24px);
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-control);
}
.visitor-transport button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--visit-ink);
  background: transparent;
}
.visitor-transport .visitor-replay { background: var(--visit-forest); color: var(--visit-paper); }
.visitor-return:hover { background: var(--visit-hover); }
.visitor-transport .visitor-replay:hover { background: #285342; }

.touch, .visitor-elevation {
  position: fixed;
  bottom: var(--edge-bottom);
  z-index: 6;
  display: grid;
  gap: 4px;
}
.touch {
  left: var(--edge-left);
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  direction: ltr;
}
.visitor-elevation { right: var(--edge-right); }
.touch button, .visitor-elevation button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: var(--surface-control);
  color: var(--visit-forest);
  touch-action: none;
}
.touch svg, .visitor-elevation svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.touch button:nth-child(1) { grid-area: 1/2; }
.touch button:nth-child(2) { grid-area: 2/1; }
.touch button:nth-child(3) { grid-area: 3/2; }
.touch button:nth-child(4) { grid-area: 2/3; }
.visitor-elevation button {
  width: 50px;
  height: 49px;
  grid-template-rows: 23px auto;
  align-content: center;
  font-size: 11px;
  line-height: 1.25;
}
.visitor-walk-actions, .visitor-showing :is(.touch,.visitor-elevation,.visitor-hint) { display: none; }
.visitor-menu-open .visitor-hint { visibility: hidden; }
.visitor-hint, .visitor-toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 13px;
  color: var(--visit-paper);
  background: var(--visit-forest);
}
.visitor-hint { top: calc(50% + 25px); pointer-events: none; }
.visitor-toast { bottom: 110px; max-width: calc(100vw - 28px); z-index: 11; }

.camera-shot-labels { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.camera-shot-label {
  position: absolute;
  max-width: min(190px,40vw);
  padding: 5px 9px;
  border-radius: 6px;
  background: #fbf1e0;
  color: #50402c;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
}
.camera-shot-label-line { position: absolute; height: 1px; background: #7f694a; transform-origin: 0 50%; }

@media (max-width: 720px), (pointer: coarse) and (max-height: 500px) {
  .visitor-menu { width: 232px; }
  .camera-shot-label { font-size: 12px; }
}
@media (max-height: 490px) {
  body { --edge: 8px; --movement-height: 102px; }
  .visitor-menu { width: 254px; }
  .visitor-elevation button { width: 46px; height: 45px; }
}
@media (prefers-contrast: more) {
  body { --surface-control: var(--visit-paper); }
  .visitor-menu { border: 1px solid var(--visit-line); box-shadow: none; }
}
