:root {
	--bg: var(--menu-bg, #0f1113);
	--panel: var(--menu-bg, rgba(18, 20, 23, 0.82));
	--panel-solid: var(--menu-bg, #16181b);
	--text: var(--menu-text, #f2f0ec);
	--muted: var(--menu-text, rgba(242, 240, 236, 0.62));
	--line: rgba(255, 255, 255, 0.15);
	--subtle-fill: rgba(255, 255, 255, 0.06);
	--hover-fill: rgba(255, 255, 255, 0.13);
	--accent: var(--menu-accent, #e8c79a);
	--accent-text: var(--menu-accent-text, #1a1611);
	--accent-label: var(--menu-accent-label, var(--accent));
	--radius: 14px;
	--font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--ui-top: max(14px, env(safe-area-inset-top));
	--ui-right: max(14px, env(safe-area-inset-right));
	--ui-bottom: max(14px, env(safe-area-inset-bottom));
	--ui-left: max(14px, env(safe-area-inset-left));
	--tools-width: 54px;
	--dock-space: 0px;
}

@supports (color: color-mix(in srgb, black, white)) {
	:root {
		--line: color-mix(in srgb, var(--text) 15%, transparent);
		--subtle-fill: color-mix(in srgb, var(--text) 6%, transparent);
		--hover-fill: color-mix(in srgb, var(--text) 13%, transparent);
	}
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	height: 100%;
	overflow: hidden;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 15px;
	-webkit-font-smoothing: antialiased;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

#viewport {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	outline: none;
	touch-action: none;
}

.hidden { display: none !important; }

/* ---------- overlays & panels ---------- */

.overlay {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
		max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
	background: rgba(8, 9, 10, 0.45);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	z-index: 20;
}

#loading { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }

.panel {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 28px 28px 24px;
	width: min(520px, 100%);
	max-height: calc(100% - 8px);
	overflow: auto;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}


h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; margin-bottom: 20px; }
h2 { font-size: 22px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
.muted { color: var(--muted); }
p { line-height: 1.5; margin: 10px 0 0; }

/* loading */
.loading-panel { background: transparent; border: none; box-shadow: none; text-align: left; width: min(420px, 100%); }
.bar { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
#loading-bar { height: 100%; width: 0%; background: var(--accent); transition: width 0.2s ease; }
#loading-text { font-size: 13px; font-variant-numeric: tabular-nums; }

/* buttons */
button { font: inherit; color: inherit; cursor: pointer; }

.primary {
	background: var(--accent);
	color: var(--accent-text);
	border: none;
	border-radius: 999px;
	padding: 10px 18px;
	font-weight: 600;
	white-space: nowrap;
}
.primary:hover { filter: brightness(1.06); }
.primary:focus-visible, .chip:focus-visible, .segmented button:focus-visible, .icon-btn:focus-visible, .linklike:focus-visible {
	outline: 2px solid var(--menu-accent-label, #fff);
	outline-offset: 2px;
}
body.playing #viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.primary.big { width: 100%; padding: 15px 20px; font-size: 17px; }

/* vervagen bij grote sprongen (150 ms) */
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 15; transition: opacity 150ms ease; }
#fade.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #fade { transition: none; } }

/* ingebed: pas na het starten touch-gebaren afvangen, ervoor scrolt de pagina eromheen gewoon */
#viewport { touch-action: manipulation; }
body.playing #viewport { touch-action: none; }
html, body { overscroll-behavior: auto; }
body.playing { overscroll-behavior: none; }

#stair-actions {
	position: fixed;
	left: var(--ui-left);
	right: var(--ui-right);
	bottom: max(68px, calc(env(safe-area-inset-bottom) + 44px));
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	z-index: 10;
	pointer-events: none;
}
#stair-actions .primary { min-height: 44px; pointer-events: auto; box-shadow: 0 2px 14px rgb(0 0 0 / 0.32); }
#stair-actions kbd { margin-left: 4px; border-color: currentColor; }

.start-hint { margin: -6px 0 16px; color: var(--muted); font-size: 14px; }
.linklike { display: block; margin: 12px auto 0; background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.linklike:hover { color: var(--text); }

#hud-room .hud-size { font-weight: 400; font-size: 15px; color: rgba(255, 255, 255, 0.85); }

body:not(.playing) #minimap { display: none; }
#minimap {
	--map-size: min(200px, 40vh, 38vw);
	position: fixed;
	left: var(--ui-left);
	bottom: calc(var(--ui-bottom) + var(--dock-space));
	width: var(--map-size);
	height: var(--map-size);
	border-radius: 12px;
	background: rgba(18, 20, 23, 0.62);
	border: 1px solid var(--line);
	z-index: 6;
	cursor: pointer;
	touch-action: manipulation;
}

#measure-layer { position: fixed; inset: 0; pointer-events: none; z-index: 7; }
.measure-label {
	position: absolute;
	left: 0;
	top: 0;
	margin: -14px 0 0 8px;
	padding: 3px 8px;
	border-radius: 6px;
	background: rgba(20, 18, 12, 0.82);
	color: #ffd166;
	font: 600 13px/1.3 var(--font);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
.measure-dist { font-size: 15px; color: #fff3cf; }
#crosshair { display: none; position: fixed; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; z-index: 7; pointer-events: none;
	background: linear-gradient(#ffd166, #ffd166) center/2px 14px no-repeat, linear-gradient(#ffd166, #ffd166) center/14px 2px no-repeat; }
body.measuring.locked #crosshair { display: block; }
body.measuring #viewport { cursor: crosshair; }
.icon-btn[aria-pressed="true"] {
	background: var(--accent);
	color: var(--accent-text);
	border-color: var(--menu-accent-label, transparent);
}
#viewer-tools {
	position: fixed;
	top: calc(var(--ui-top) - 4px);
	right: calc(var(--ui-right) - 4px);
	z-index: 10;
	display: grid;
	grid-auto-columns: 44px;
	grid-auto-rows: 44px;
	gap: 10px;
	max-height: calc(100% - var(--ui-top) - var(--ui-bottom) + 8px);
	padding: 4px;
	overscroll-behavior: contain;
	overflow: auto;
}
.icon-btn:focus-visible { scroll-margin: 4px; }
.icon-btn {
	flex: none;
	width: 44px;
	height: 44px;
	border-radius: 12px;
	border: 1px solid var(--line);
	background: var(--panel);
	display: grid;
	place-items: center;
}

/* legend */
.legend { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin-top: 22px; font-size: 14px; align-items: center; }
.menu-panel .legend { margin-top: 0; }
.legend .keys { white-space: nowrap; color: var(--muted); }
/* lage vensters (bv. ingebed in een makelaarssite): startpaneel zonder toetsenlijst, zodat het niet
   zelf gaat scrollen en het scrollwiel gewoon de pagina eromheen scrolt; de lijst staat ook in het menu */
@media (max-height: 760px) { .start-panel .legend { display: none; } }
kbd {
	display: inline-block;
	min-width: 22px;
	padding: 2px 6px;
	border: 1px solid var(--line);
	border-bottom-width: 2px;
	border-radius: 6px;
	font: 600 12px/1.3 var(--font);
	text-align: center;
	color: var(--text);
	background: var(--subtle-fill);
}

/* ---------- HUD ---------- */

#hud {
	position: fixed;
	top: max(16px, env(safe-area-inset-top));
	left: max(18px, env(safe-area-inset-left));
	max-width: calc(100% - var(--ui-left) - var(--ui-right) - var(--tools-width) - 8px);
	z-index: 5;
	pointer-events: none;
	color: #f2f0ec;
	text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
	transition: opacity 0.3s ease;
	overflow-wrap: anywhere;
}
#hud-room { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
#hud-floor { font-size: 13px; color: rgba(255, 255, 255, 0.78); margin-top: 2px; }

#fly-badge {
	position: fixed;
	top: max(18px, env(safe-area-inset-top));
	left: 50%;
	transform: translateX(-50%);
	padding: 5px 12px;
	border-radius: 999px;
	background: var(--accent);
	color: var(--accent-text);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	z-index: 5;
	pointer-events: none;
}

#toast {
	position: fixed;
	bottom: calc(max(24px, env(safe-area-inset-bottom)) + var(--dock-space));
	left: 50%;
	transform: translateX(-50%);
	padding: 9px 16px;
	border-radius: 999px;
	background: var(--panel);
	border: 1px solid var(--line);
	font-size: 14px;
	z-index: 30;
	pointer-events: none;
	max-width: calc(100% - 32px);
	text-align: center;
}

/* ---------- menu ---------- */

.menu-panel { display: flex; flex-direction: column; width: min(640px, 100%); padding: 22px 24px; overflow: hidden; }
.menu-head { display: flex; flex: none; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.menu-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 4px; margin: -4px; }
.menu-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.menu-actions .linklike { margin: 0; }
.menu-actions .primary { min-height: 44px; }
.menu-panel section { border-top: 1px solid var(--line); padding: 16px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip {
	border: 1px solid var(--line);
	background: var(--subtle-fill);
	border-radius: 999px;
	padding: 7px 13px;
	font-size: 14px;
}
.chip:hover { background: var(--hover-fill); }
.chip.current { border-color: var(--accent-label); color: var(--accent-label); }
.room-group { margin-bottom: 10px; }
.room-group-name { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; }
.row > span { display: flex; flex-direction: column; gap: 2px; }
.row small { color: var(--muted); font-size: 12px; }
.row small kbd { min-width: 18px; padding: 0 4px; font-size: 11px; }
.row .label { font-size: 15px; }
.row output { color: var(--accent-label); font-variant-numeric: tabular-nums; font-size: 13px; margin-left: 6px; }
.fov-controls { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.fov-controls .linklike { margin: 0; }
.fov-controls .linklike:disabled { opacity: 0.55; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.segmented button { border: none; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 14px; color: var(--muted); }
.segmented button[aria-checked="true"] { background: var(--text); color: var(--bg); }

input[type="range"] { width: 180px; accent-color: var(--accent); }

.switch {
	appearance: none;
	-webkit-appearance: none;
	width: 44px;
	height: 26px;
	border-radius: 999px;
	background: var(--line);
	position: relative;
	cursor: pointer;
	flex: none;
	transition: background 0.15s ease;
}
.switch::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: var(--text);
	transition: transform 0.15s ease;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { background: var(--accent-text); transform: translateX(18px); }

/* ---------- touch ---------- */

#joystick {
	position: fixed;
	width: 112px;
	height: 112px;
	margin: -56px 0 0 -56px;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.35);
	background: rgba(255, 255, 255, 0.06);
	z-index: 6;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.12s ease;
}
#joystick.visible { opacity: 1; }
#joystick-knob {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.55);
	transform: translate(-50%, -50%);
}

#touch-fly {
	position: fixed;
	right: max(16px, env(safe-area-inset-right));
	bottom: max(24px, env(safe-area-inset-bottom));
	display: flex;
	flex-direction: column;
	gap: 10px;
	z-index: 7;
}
#touch-fly button {
	width: 54px;
	height: 54px;
	border-radius: 50%;
	border: 1px solid var(--line);
	background: var(--panel);
	font-size: 18px;
}

/* comfortvignet: donkere randen tijdens bewegen (opacity via JS) */
#vignette {
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 4;
	opacity: 0;
	background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 52%, rgba(0, 0, 0, 0.55) 82%, rgba(0, 0, 0, 0.85) 100%);
}

/* ---------- debug ---------- */

#debug {
	position: fixed;
	right: max(12px, env(safe-area-inset-right));
	bottom: max(12px, env(safe-area-inset-bottom));
	padding: 6px 10px;
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.6);
	font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
	white-space: pre;
	z-index: 8;
	pointer-events: none;
}

.error-panel h2 { margin-bottom: 4px; }
.error-panel .primary { margin-top: 20px; }

@media (max-width: 520px) {
	#minimap { --map-size: min(140px, 40vh, 38vw); }
	.panel { padding: 22px 18px 18px; }
	h1 { font-size: 22px; }
	.menu-panel { padding: 18px 16px; }
	.menu-head { flex-direction: column; align-items: stretch; }
	.menu-actions .primary { flex: 1; }
	input[type="range"] { width: 130px; }
	#hud-room { font-size: 17px; }
}

@media (max-height: 420px) {
	:root { --tools-width: 106px; }

	#viewer-tools { grid-auto-flow: column; grid-template-rows: repeat(4, 44px); gap: 8px; }
	#stair-actions { right: calc(var(--ui-right) + var(--tools-width)); }
	#touch-fly { right: calc(var(--ui-right) + var(--tools-width)); flex-direction: row; }
	#touch-fly button { width: 44px; height: 44px; }

	.menu-panel { padding-block: 12px; }
	.menu-head { gap: 8px; margin-bottom: 10px; }
}

@media (max-height: 235px) {
	:root { --tools-width: 0px; --dock-space: 54px; }

	.overlay {
		padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
			max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
	}
	#viewer-tools {
		top: auto;
		bottom: calc(var(--ui-bottom) - 4px);
		left: calc(var(--ui-left) - 4px);
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		width: max-content;
		max-width: calc(100% - var(--ui-left) - var(--ui-right) + 8px);
		margin-inline: auto;
	}

	#stair-actions, #touch-fly { bottom: calc(var(--ui-bottom) + var(--dock-space)); }
	#minimap {
		--available-height: calc(100vh - var(--ui-top) - var(--ui-bottom) - var(--dock-space));
		max-width: var(--available-height);
		max-height: var(--available-height);
	}
	.start-panel { padding-block: 12px; }
	.start-panel h1 { margin-bottom: 12px; }
	.menu-panel { max-height: 100%; padding-block: 8px; }
	.menu-head { align-items: center; flex-direction: row; margin-bottom: 8px; }
	.menu-head > div:first-child { min-width: 0; }
	.menu-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-height: 235px) and (max-width: 383px) {
	:root { --dock-space: 106px; }

	.menu-actions { flex: none; align-items: flex-end; flex-direction: column; gap: 4px; }
}

@media (max-width: 360px) {
	.row { flex-wrap: wrap; gap: 8px; }
}

/* derde persoon: lengte boven het hoofd als maatstaf naast deuren en ramen */
.tp-tag {
	position: fixed; left: 0; top: 0; z-index: 4; pointer-events: none;
	padding: 3px 8px; border-radius: 999px;
	background: rgb(255 255 255 / 0.9); color: #14181f;
	font: 600 12px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums;
	box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
	transform: translate(-50%, -100%);
	white-space: nowrap;
}
.tp-tag.hidden { display: none; }

/* Keep the actual house visible behind its entry and use the viewer's theme for the UI. */
#start {
	justify-content: flex-start;
	align-items: flex-end;
	padding: max(28px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right))
		max(28px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
	background: linear-gradient(22deg, rgb(6 9 11 / 0.62), transparent 66%);
	backdrop-filter: none;
	-webkit-backdrop-filter: none;
}

.start-panel,
.error-panel {
	width: min(440px, 100%);
	padding: clamp(18px, 3vw, 30px);
	border-radius: 20px;
	background: var(--panel-solid);
	box-shadow: 0 14px 54px rgb(4 7 10 / 0.26);
}

.start-panel h1 {
	margin: 0;
	font: 500 clamp(29px, 5vw, 57px)/1.02 "Iowan Old Style", Georgia, serif;
	letter-spacing: -0.035em;
	overflow-wrap: anywhere;
}

.start-hint {
	margin: 12px 0 0;
	color: var(--muted);
	font-size: 14px;
}

.start-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-top: 20px;
}

.start-actions button,
.error-panel .primary {
	min-height: 44px;
	border-radius: 10px;
	padding: 0 14px;
}

.start-actions .primary,
.error-panel .primary {
	border: 1px solid var(--menu-accent-label, transparent);
}

#start-btn {
	display: inline-flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

#start-lock-btn {
	margin: 0;
	border: 1px solid var(--line);
	color: var(--text);
	text-decoration: none;
}

#start-lock-btn:hover { background: var(--hover-fill); }

#loading {
	background: var(--bg);
}

.loading-panel {
	width: min(360px, 100%);
	padding: 14px;
}

.loading-mark {
	width: 44px;
	height: 44px;
	display: grid;
	place-items: center;
	margin: 0 0 16px;
	background: var(--accent);
	color: var(--accent-text);
	border-radius: 12px;
}

.loading-panel h1 {
	margin: 0 0 16px;
	font-size: clamp(20px, 3vw, 27px);
	overflow-wrap: anywhere;
}

.loading-panel p { min-height: 1.5em; }
.loading-panel .bar { height: 3px; }

.error-panel h2 { font-size: clamp(19px, 4vw, 26px); }
.error-panel p { overflow-wrap: anywhere; }

@media (max-height: 360px), (max-width: 450px) {
	#start {
		padding: var(--ui-top) var(--ui-right) var(--ui-bottom) var(--ui-left);
	}

	.start-panel, .error-panel {
		max-height: 100%;
		padding: 15px;
		border-radius: 16px;
	}

	.start-panel h1 { font-size: clamp(23px, 6vw, 35px); }
	.start-hint { font-size: 13px; margin-top: 7px; }
	.start-actions { margin-top: 11px; }
}

@media (max-height: 205px) {
	.start-panel h1 {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
	.loading-mark { margin-bottom: 9px; }
	.loading-panel h1 { margin-bottom: 9px; }
}

/* In beeld tijdens het rondlopen */
:root {
	--walk-surface: var(--menu-bg, rgb(18 20 23 / 92%));
	--walk-shadow: 0 6px 20px rgb(0 0 0 / 22%);
	--walk-radius: 16px;
}

#hud {
	top: var(--ui-top);
	left: var(--ui-left);
	display: grid;
	gap: 4px;
	max-width: min(340px, calc(100% - var(--ui-left) - var(--ui-right)));
	padding: 10px 14px;
	border: 1px solid var(--line);
	border-radius: var(--walk-radius);
	background: var(--walk-surface);
	color: var(--text);
	box-shadow: var(--walk-shadow);
	text-shadow: none;
}

#hud:has(#hud-room:empty):has(#hud-floor:empty):has(#hud-property:empty),
#hud-property:empty, #hud-room:empty, #hud-floor:empty,
.hud-location:has(#hud-room:empty):has(#hud-floor:empty) { display: none; }

#hud-property {
	overflow: hidden;
	color: var(--muted);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.015em;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hud-location { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
#hud-room { font-size: 16px; line-height: 1.25; }
#hud-room .hud-size { color: var(--muted); font-size: 12px; }
#hud-floor {
	margin: 0;
	padding: 2px 7px;
	border-radius: 6px;
	background: var(--subtle-fill);
	color: var(--muted);
	font-size: 11px;
	font-weight: 600;
	line-height: 1.3;
}

#fly-badge {
	top: var(--ui-top);
	right: var(--ui-right);
	left: auto;
	transform: none;
}

#walk-controls {
	position: fixed;
	inset: auto var(--ui-right) var(--ui-bottom) var(--ui-left);
	z-index: 10;
	display: grid;
	grid-template:
		"map stairs fly" auto
		"map tools  fly" auto
		/ minmax(0, 1fr) auto minmax(0, 1fr);
	align-items: end;
	gap: 8px 12px;
	pointer-events: none;
}

body:not(.playing) #walk-controls { display: none; }

#viewer-tools {
	grid-area: tools;
	position: static;
	display: flex;
	flex-wrap: wrap;
	justify-self: center;
	justify-content: center;
	gap: 4px;
	width: max-content;
	max-width: 100%;
	max-height: calc(100vh - var(--ui-top) - var(--ui-bottom));
	margin: 0;
	padding: 5px;
	border: 1px solid var(--line);
	border-radius: 22px;
	background: var(--walk-surface);
	box-shadow: var(--walk-shadow);
	pointer-events: auto;
}

#viewer-tools .icon-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 4px;
	border-color: transparent;
	border-radius: var(--walk-radius);
	background: transparent;
	color: var(--text);
}

#viewer-tools .icon-btn:hover { background: var(--hover-fill); }
#viewer-tools .icon-btn:is([aria-pressed="true"], [aria-expanded="true"]) {
	border-color: var(--menu-accent-label, transparent);
	background: var(--accent);
	color: var(--accent-text);
}
.tool-label { display: none; }

#stair-actions {
	grid-area: stairs;
	position: static;
	justify-self: center;
	gap: 6px;
}

#stair-actions .primary {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding-inline: 13px;
	font-size: 14px;
	box-shadow: var(--walk-shadow);
}

#stair-actions kbd {
	margin: 0;
	border-color: currentColor;
	background: transparent;
	color: inherit;
	font-size: 11px;
}

#stair-actions .primary > span { font-size: 16px; line-height: 1; }

#minimap {
	grid-area: map;
	position: static;
	width: min(180px, 35vh, 100%);
	max-width: none;
	height: auto;
	max-height: none;
	aspect-ratio: 1;
	border-radius: var(--walk-radius);
	background: var(--walk-surface);
	box-shadow: var(--walk-shadow);
	pointer-events: auto;
}

#touch-fly {
	grid-area: fly;
	position: static;
	justify-self: end;
	flex-direction: column;
	gap: 4px;
	padding: 4px;
	border: 1px solid var(--line);
	border-radius: var(--walk-radius);
	background: var(--walk-surface);
	box-shadow: var(--walk-shadow);
	pointer-events: auto;
}

#touch-fly button {
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 12px;
	background: transparent;
	font-weight: 600;
	touch-action: none;
}

#touch-fly button:is(:hover, :active) { background: var(--hover-fill); }
#touch-fly button:focus-visible { outline: 2px solid var(--accent-label); outline-offset: -2px; }

#toast { bottom: calc(var(--ui-bottom) + 64px); border-radius: 12px; }
body:has(#stair-actions:not(.hidden)) #toast { bottom: calc(var(--ui-bottom) + 114px); }

@media (min-width: 720px) and (min-height: 355px) {
	#viewer-tools .icon-btn {
		flex-direction: column;
		gap: 3px;
		width: 90px;
		height: 54px;
	}

	.tool-label {
		display: block;
		font-size: 11px;
		font-weight: 600;
		line-height: 1;
		white-space: nowrap;
	}

	#toast { bottom: calc(var(--ui-bottom) + 74px); }
	body:has(#stair-actions:not(.hidden)) #toast { bottom: calc(var(--ui-bottom) + 124px); }
}

@media (max-width: 900px) {
	#walk-controls {
		grid-template:
			"map stairs fly" auto
			"tools tools tools" auto
			/ minmax(0, 1fr) minmax(0, min(55%, 258px)) minmax(0, 1fr);
		gap: 8px;
	}

	#minimap { width: min(145px, 32vh, 100%); }
	#touch-fly { flex-direction: row; }
}

@media (max-width: 383px) {
	#viewer-tools { border-radius: 20px; }
	#stair-actions .primary { padding-inline: 8px; }
	#stair-actions .primary > span, #stair-actions kbd { display: none; }
	#toast { bottom: calc(var(--ui-bottom) + 112px); }
	body:has(#stair-actions:not(.hidden)) #toast { bottom: calc(var(--ui-bottom) + 162px); }
}

@media (max-height: 235px) {
	#hud { padding: 6px 9px; }
	#hud-room { font-size: 14px; }
	#walk-controls { row-gap: 6px; }
	#minimap {
		width: min(90px, 32vh, 100%, max(26px, calc(100vh - var(--ui-top) - var(--ui-bottom) - 64px)));
	}
	#touch-fly { flex-direction: row; }
	#toast, body:has(#stair-actions:not(.hidden)) #toast {
		top: var(--ui-top);
		right: var(--ui-right);
		bottom: auto;
		left: auto;
		max-width: min(48%, 320px);
		transform: none;
		text-align: left;
	}

}

body:has(#fly-badge:not(.hidden)) #hud { max-width: min(340px, calc(100% - var(--ui-left) - var(--ui-right) - 96px)); }

@media (max-height: 235px) and (max-width: 383px) {
	#walk-controls {
		grid-template:
			"map stairs" auto
			"map tools" auto
			/ minmax(0, 1fr) minmax(0, 198px);
		row-gap: 4px;
	}
	#viewer-tools { justify-self: end; padding: 4px; gap: 2px; }
	#stair-actions { justify-self: end; }
	#touch-fly { grid-column: 2; grid-row: 1; }
	#hud:has(#hud-room:not(:empty)) #hud-property { display: none; }
	#hud-room, #hud-floor { overflow: hidden; max-width: 100%; text-overflow: ellipsis; white-space: nowrap; }
	body:has(#stair-actions:not(.hidden)) #hud {
		max-width: calc(100% - var(--ui-left) - var(--ui-right) - 150px);
	}
}

/* Tour navigation and settings. All colors inherit the company menu palette. */
#menu {
	--menu-inset: clamp(16px, 3vw, 28px);
	background: rgb(8 9 10 / 0.54);
}

#menu .menu-panel {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
	width: min(940px, 100%);
	max-height: min(850px, 100%);
	padding: 0;
	overflow: hidden;
	border-radius: 20px;
	background: var(--panel-solid);
}

#menu .menu-head {
	align-items: center;
	margin: 0;
	padding: 17px var(--menu-inset);
	border-bottom: 1px solid var(--line);
}

#menu-title {
	display: -webkit-box;
	min-width: 0;
	overflow: hidden;
	font-size: clamp(21px, 3vw, 30px);
	font-weight: 650;
	letter-spacing: -0.035em;
	line-height: 1.13;
	overflow-wrap: anywhere;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

#menu .menu-actions { flex: none; }

#menu #lock-mouse-btn {
	min-height: 44px;
	padding: 0 12px;
	border-radius: 9px;
	font-weight: 550;
	text-decoration: none;
}

#menu #lock-mouse-btn:hover { background: var(--hover-fill); }

#menu #resume-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 0 15px;
	border-radius: 10px;
}

#menu #resume-btn::after {
	content: "";
	width: 6px;
	height: 6px;
	margin-right: 3px;
	transform: rotate(-45deg);
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
}

#menu .menu-scroll {
	min-height: 0;
	overflow: auto;
	overscroll-behavior: contain;
	scrollbar-gutter: stable;
	scrollbar-color: var(--line) transparent;
	margin: 0;
	padding: var(--menu-inset);
}

#menu .menu-content {
	display: grid;
	grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
	grid-template-areas: "navigation settings" "controls settings";
	grid-template-rows: auto 1fr;
	column-gap: var(--menu-inset);
	row-gap: 24px;
	align-items: start;
}

#menu .menu-navigation { grid-area: navigation; min-width: 0; }

#menu .menu-controls { grid-area: controls; min-width: 0; }

#menu .menu-settings {
	grid-area: settings;
	min-width: 0;
	padding-left: var(--menu-inset);
	border-left: 1px solid var(--line);
}

#menu section { padding-block: 0; border-top: 0; }

#menu .menu-navigation section + section { margin-top: 24px; }

#menu h3 {
	margin: 0 0 12px;
	color: var(--text);
	font-size: 16px;
	font-weight: 650;
	letter-spacing: -0.015em;
	text-transform: none;
}

#menu .chips { gap: 6px; margin: 0; }

#menu .chip {
	min-height: 36px;
	max-width: 100%;
	padding: 6px 10px;
	border-radius: 8px;
	background: transparent;
	font-size: 13px;
	line-height: 1.3;
	text-align: left;
	overflow-wrap: anywhere;
}

#menu .chip:hover { background: var(--hover-fill); }

#menu .chip.current {
	border-color: var(--accent-label);
	color: var(--accent-label);
}

#menu-floors .chip { background: var(--subtle-fill); }

#menu .room-group { margin: 0 0 12px; }

#menu .room-group:last-child { margin-bottom: 0; }

#menu .room-group-name {
	margin: 0 0 7px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 550;
}

#menu .menu-search-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

#menu .menu-search { position: relative; margin-bottom: 13px; }

#menu .menu-search::before,
#menu .menu-search::after {
	position: absolute;
	content: "";
	z-index: 1;
	pointer-events: none;
}

#menu .menu-search::before {
	top: 12px;
	left: 11px;
	width: 10px;
	height: 10px;
	border: 1.5px solid currentColor;
	border-radius: 50%;
}

#menu .menu-search::after {
	top: 21px;
	left: 20px;
	width: 6px;
	height: 1.5px;
	background: currentColor;
	transform: rotate(45deg);
}

#menu-room-search {
	width: 100%;
	min-width: 0;
	min-height: 40px;
	padding: 0 9px 0 34px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--subtle-fill);
	color: var(--text);
	font: inherit;
	font-size: 14px;
	-webkit-user-select: text;
	user-select: text;
}

#menu-room-search::placeholder { color: var(--muted); }

#menu .menu-room-empty { margin: 0; color: var(--muted); font-size: 13px; }

#menu .menu-controls {
	padding-top: 15px;
	border-top: 1px solid var(--line);
}

#menu .legend {
	grid-template-columns: fit-content(52%) minmax(0, 1fr);
	gap: 6px 10px;
	font-size: 12px;
	line-height: 1.35;
}

#menu .legend .keys { white-space: normal; }

#menu .menu-settings h3 { margin-bottom: 10px; }

#menu .menu-setting-group { padding-top: 8px; }

#menu .menu-setting-group + .menu-setting-group {
	margin-top: 10px;
	padding-top: 14px;
	border-top: 1px solid var(--line);
}

#menu .menu-setting-group h4 {
	margin: 0 0 2px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 650;
}

#menu .row {
	gap: 10px 12px;
	min-height: 42px;
	padding: 5px 0;
}

#menu .row > :first-child { min-width: 0; }

#menu .row > span.label { display: block; }

#menu .row .label { font-size: 14px; }

#menu .row small { font-size: 12px; line-height: 1.22; }

#menu .row output { margin-left: 3px; white-space: nowrap; }

#menu .row input[type="range"] { min-width: 0; width: clamp(92px, 15vw, 134px); }

#menu .fov-controls { flex: none; gap: 0; }

#menu #opt-fov-reset { min-height: 30px; }

#menu .segmented {
	flex: none;
	padding: 2px;
	border-radius: 8px;
}

#menu .segmented button {
	min-height: 32px;
	padding: 3px 9px;
	border-radius: 6px;
	font-size: 12px;
}

#menu :is(button, input):focus-visible {
	outline: 2px solid var(--accent-label);
	outline-offset: 2px;
	scroll-margin-block: 6px;
}

@media (max-width: 700px) {
	#menu {
		--menu-inset: clamp(12px, 3.8vw, 18px);
		padding: max(8px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right))
			0 max(6px, env(safe-area-inset-left));
		align-items: flex-end;
	}

	#menu .menu-panel {
		max-height: 100%;
		border-radius: 18px 18px 0 0;
	}

	#menu .menu-head {
		flex-direction: row;
		gap: 8px;
		padding-block: 11px;
	}

	#menu .menu-actions { gap: 4px; flex-wrap: nowrap; }

	#menu .menu-actions .primary { flex: none; }

	#menu #lock-mouse-btn { padding: 0 6px; font-size: 12px; }

	#menu #resume-btn { padding: 0 10px; gap: 5px; font-size: 13px; }

	#menu .menu-scroll { padding-bottom: max(16px, env(safe-area-inset-bottom)); }

	#menu .menu-content {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas: "navigation" "settings" "controls";
		row-gap: 22px;
	}

	#menu .menu-settings {
		padding-left: 0;
		padding-top: 16px;
		border-left: 0;
		border-top: 1px solid var(--line);
	}

	#menu .chip, #menu .row { min-height: 44px; }

	#menu .row input[type="range"] { min-height: 30px; }

	#menu-room-search { min-height: 44px; font-size: 16px; }
}

@media (max-width: 370px) {
	#menu .menu-actions { flex: 0 1 auto; }
	#menu #lock-mouse-btn { max-width: 67px; line-height: 1.15; }
	#menu .row small { max-width: 24ch; }
}
