:root {
  --ink: #1d1c1a;
  --paper: #f6f3ee;
  --glass: rgba(246, 243, 238, 0.82);
  --glass-solid: rgba(246, 243, 238, 0.93); /* always-visible HUD over the live canvas: no backdrop blur (per-frame GPU cost) */
  --line: rgba(29, 28, 26, 0.12);
  --accent: #8a6a43;
  --muted: #6d6a64;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #d9d4cb; color: var(--ink);
  font: 14px/1.4 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif; }
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
/* touch: no page scroll / pull-to-refresh / pinch / double-tap zoom / text selection / callout; panels scroll themselves */
html, body { touch-action: none; overscroll-behavior: none; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body.touch-mode, body.touch-mode .hud, body.touch-mode #app canvas { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button, select, input { touch-action: manipulation; }
.hud { position: fixed; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top { position: absolute; top: 12px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.brand { background: var(--glass-solid); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-weight: 600; letter-spacing: .01em; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 10px; height: 10px; border-radius: 2px; background: var(--accent); display: inline-block; }
.brand .sep { color: var(--muted); }
#hud-room { font-weight: 500; }
.hud-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pill, .seg button { font: inherit; border: 1px solid var(--line); background: var(--glass-solid); color: var(--ink); border-radius: 999px; padding: 7px 13px; cursor: pointer; }
.pill:hover, .seg button:hover { background: #fff; }
.seg { display: flex; background: var(--glass-solid); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; }
.seg button.on { background: var(--ink); color: var(--paper); }
.seg button:disabled { opacity: .35; cursor: default; background: transparent; }
.panel { position: absolute; top: 60px; right: 16px; width: min(300px, calc(100vw - 32px)); max-height: calc(100vh - 140px); overflow: auto; background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.panel h3 { margin: 8px 6px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.panel button.room { display: flex; justify-content: space-between; width: 100%; border: 0; background: transparent; font: inherit; text-align: left; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--ink); }
.panel button.room:hover { background: rgba(255,255,255,.8); }
.panel button.room span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.panel label { display: grid; gap: 4px; margin: 8px 6px; }
.panel label.row { display: flex; gap: 8px; align-items: center; }
.panel output { color: var(--muted); font-variant-numeric: tabular-nums; }
.panel select { font: inherit; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.perf { position: absolute; left: 16px; top: 58px; background: rgba(20, 19, 18, 0.78); color: #f3efe8; border-radius: 10px; padding: 7px 10px;
  font: 12px/1.45 ui-monospace, "SF Mono", Consolas, monospace; font-variant-numeric: tabular-nums; pointer-events: none; max-width: calc(100vw - 32px); }
.perf b { font-size: 15px; }
.perf .dim { color: #b9b3a8; }
.hidden { display: none !important; }
#minimap { position: absolute; left: 16px; bottom: 54px; width: 260px; height: 260px; border-radius: 14px; background: var(--paper); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.12); }
.hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--glass-solid); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 13px; color: var(--muted); white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
.hint b { color: var(--ink); font-weight: 600; }
.start { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(1200px 800px at 50% 40%, rgba(246,243,238,.55), rgba(217,212,203,.9)); backdrop-filter: blur(6px); z-index: 10; padding: 16px; }
.start-card { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 28px 30px; width: min(420px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.start-card h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.01em; }
.start-card p { margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 13px; }
.bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 10px 0 8px; }
#load-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.cta { width: 100%; margin-top: 8px; font: inherit; font-weight: 600; padding: 11px 14px; border-radius: 12px; border: 0; background: var(--ink); color: var(--paper); cursor: pointer; }
.cta:disabled { opacity: .35; cursor: default; }
.hud-menu { display: contents; }
.menu-btn { display: none; }
/* walking stick: the container is only a positioning frame (pointer-events none), so the rest of the screen keeps drag-look */
.touch { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.stick { position: absolute; left: calc(env(safe-area-inset-left, 0px) + 22px); bottom: calc(env(safe-area-inset-bottom, 0px) + 26px); width: 124px; height: 124px; border-radius: 50%;
  background: rgba(246,243,238,.32); border: 1.5px solid rgba(255,255,255,.7); box-shadow: 0 2px 14px rgba(0,0,0,.18); pointer-events: auto; touch-action: none; }
.stick::before { content: ""; position: absolute; inset: -26px; border-radius: 50%; } /* generous hit area around the ring */
.stick .knob { position: absolute; left: 36px; top: 36px; width: 52px; height: 52px; border-radius: 50%; background: rgba(246,243,238,.92); box-shadow: 0 1px 6px rgba(0,0,0,.28); pointer-events: none; will-change: transform; }
.stick.active { background: rgba(246,243,238,.45); }
body.touring .touch { display: none !important; }
.tap-ripple { position: fixed; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; border: 3px solid rgba(255,255,255,.95); box-shadow: 0 0 0 1px rgba(29,28,26,.35), inset 0 0 0 1px rgba(29,28,26,.25);
  pointer-events: none !important; z-index: 6; animation: tap-ripple .65s ease-out forwards; }
.tap-ripple.miss { border-color: rgba(255,255,255,.5); animation-duration: .35s; }
@keyframes tap-ripple { from { transform: scale(.35); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
.touch-hint { position: fixed; left: 50%; top: 36%; transform: translateX(-50%); z-index: 8; width: min(360px, calc(100vw - 32px)); background: var(--glass-solid); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; box-shadow: 0 10px 40px rgba(0,0,0,.2); text-align: center; }
.touch-hint p { margin: 0 0 10px; font-size: 15px; line-height: 1.5; }
.touch-hint b { font-weight: 600; }
.touch-hint .pill { min-height: 44px; padding: 0 22px; font-weight: 600; background: var(--ink); color: var(--paper); border-color: var(--ink); }
body.capture .hud, body.capture .start, body.capture .touch, body.capture .touch-hint { display: none !important; }
@media (max-width: 560px) { .hint { display: none; } #minimap { width: 180px; height: 180px; } }

.cta.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); margin-top: 8px; }
.plan-labels { position: fixed; inset: 0; pointer-events: none; z-index: 3; transition: opacity .3s; }
.plan-label { position: absolute; left: 0; top: 0; text-align: center; font: 600 12px/1.2 "Inter", "Segoe UI", system-ui, sans-serif; color: #1b1a18; white-space: nowrap; letter-spacing: .02em; }
.plan-label span { display: block; font-weight: 400; color: #55524c; font-variant-numeric: tabular-nums; }
.tour-caption { position: fixed; left: 24px; bottom: 74px; z-index: 4; background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; max-width: min(420px, calc(100vw - 48px)); }
.tour-caption b { display: block; font-size: 18px; letter-spacing: -.01em; }
.tour-caption span { color: var(--muted); }
.tour-ui { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 4; display: flex; gap: 10px; align-items: center; background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 999px; padding: 5px 6px 5px 14px; color: var(--muted); font-size: 13px; max-width: calc(100vw - 32px); }
.tour-ui b { color: var(--ink); }
body.touring .hud .hint, body.touring #minimap { display: none !important; }
body.capture .plan-labels, body.capture .tour-caption, body.capture .tour-ui { display: none !important; }

/* ================================================================ compact HUD (phones, tablets, narrow windows)
   body.compact is set by src/ui/touch.js: touch device OR window <= 640 px wide. Layout: small room pill top left, floor
   buttons (44 px) as a column under it on the left, "Menü" top right opening Räume / Plan / Licht; stick bottom left,
   map bottom right. Safe-area insets (notch, home bar) everywhere. */
#hud-room { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.compact .hud-top { top: calc(env(safe-area-inset-top, 0px) + 8px); left: calc(env(safe-area-inset-left, 0px) + 10px); right: calc(env(safe-area-inset-right, 0px) + 10px); flex-wrap: nowrap; align-items: flex-start; }
body.compact .brand { min-height: 36px; padding: 5px 11px; font-size: 13px; gap: 6px; min-width: 0; max-width: calc(100vw - 150px); }
body.compact .brand-mark { flex: none; width: 8px; height: 8px; }
body.compact .hud-actions { display: contents; }
body.compact .menu-btn { display: block; min-width: 76px; min-height: 44px; padding: 0 16px; font-weight: 600; }
body.compact .hud.menu-open .menu-btn { background: var(--ink); color: var(--paper); }
body.compact .seg { position: fixed; z-index: 4; left: calc(env(safe-area-inset-left, 0px) + 10px); top: calc(env(safe-area-inset-top, 0px) + 54px);
  flex-direction: column-reverse; gap: 4px; padding: 4px; border-radius: 26px; pointer-events: auto; }
body.compact .seg button { width: 46px; height: 46px; min-width: 44px; min-height: 44px; padding: 0; border-radius: 50%; font-weight: 600; font-size: 14px; }
body.compact .hud-menu { display: none; position: fixed; z-index: 6; top: calc(env(safe-area-inset-top, 0px) + 58px); right: calc(env(safe-area-inset-right, 0px) + 10px); gap: 8px; pointer-events: auto; }
body.compact .hud.menu-open .hud-menu { display: flex; }
body.compact .hud-menu .pill { min-height: 44px; min-width: 64px; padding: 0 16px; }
body.compact .panel { position: fixed; z-index: 6; top: calc(env(safe-area-inset-top, 0px) + 112px); right: calc(env(safe-area-inset-right, 0px) + 10px); left: auto;
  width: min(340px, calc(100vw - 20px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 112px - env(safe-area-inset-bottom, 0px) - 12px);
  backdrop-filter: none; background: var(--glass-solid); touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
body.compact .panel button.room { min-height: 44px; align-items: center; font-size: 15px; padding: 8px 10px; }
body.compact .panel label { font-size: 15px; margin: 12px 6px; }
body.compact .panel label.row { min-height: 36px; }
body.compact .panel input[type=checkbox] { width: 24px; height: 24px; flex: none; }
body.compact .panel input[type=range] { width: 100%; height: 36px; margin: 0; }
body.compact .panel select { min-height: 44px; font-size: 16px; }
body.compact .panel .muted { display: none; } /* "(Taste P)" means nothing without a keyboard */
body.compact .hint { display: none; }
body.compact #minimap { left: auto; right: calc(env(safe-area-inset-right, 0px) + 10px); bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); width: 150px; height: 150px; }
body.compact .perf { left: calc(env(safe-area-inset-left, 0px) + 68px); top: calc(env(safe-area-inset-top, 0px) + 54px); font-size: 11px; }
body.compact .tour-caption { left: calc(env(safe-area-inset-left, 0px) + 10px); bottom: calc(env(safe-area-inset-bottom, 0px) + 66px); max-width: calc(100vw - 20px); }
body.compact .tour-ui { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
body.compact .tour-ui .pill { min-height: 44px; }
body.compact .start-card { padding: 22px 20px; }
/* portrait phones: the open panel stays above the stick (bottom-left 180 px) and the map */
@media (orientation: portrait) {
  body.compact .panel { left: calc(env(safe-area-inset-left, 0px) + 68px); width: auto; /* right of the floor column */
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 112px - env(safe-area-inset-bottom, 0px) - 200px); }
}
/* landscape phones: the panel lives on the right half, the stick on the left */
@media (orientation: landscape) and (max-height: 500px) {
  body.compact .panel { width: min(340px, 46vw); top: calc(env(safe-area-inset-top, 0px) + 112px); }
  body.compact .touch-hint { top: 30%; }
  body.compact #minimap { width: 120px; height: 120px; }
}
/* load: slow-device hint (main.js: "Leichter darstellen") and the storey-loading toast */
.lighter-hint, .busy-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 58px; z-index: 5; display: flex; gap: 8px; align-items: center; max-width: calc(100vw - 32px);
  background: var(--glass-solid); border: 1px solid var(--line); border-radius: 999px; padding: 5px 6px 5px 14px; font-size: 13px; color: var(--ink); box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.lighter-hint .pill { padding: 5px 12px; background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; white-space: nowrap; }
.lighter-hint .x { border: 0; background: transparent; font: inherit; font-size: 18px; line-height: 1; color: var(--muted); padding: 2px 8px; cursor: pointer; }
.busy-toast { padding: 7px 14px; color: var(--muted); pointer-events: none; }
.lighter-hint > span { white-space: nowrap; }
@media (max-width: 420px) { .lighter-hint > span { display: none; } } /* phone: the button alone says it */
.hidden.lighter-hint, .hidden.busy-toast { display: none; }
body.compact .lighter-hint, body.compact .busy-toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 196px); }
body.compact .lighter-hint .pill { min-height: 40px; }
body.capture .lighter-hint, body.capture .busy-toast { display: none; }
