/* Walkabout: Popsicle (light) + Popsicle Dark (house-design §15). All color through tokens.
   Contrast (computed, not eyeballed):
     light: ink #241f33 on bg #f6f5fa = 14.6; muted #6f6885 on #ffffff = 5.0; white on accent #e2570e = 4.6
     dark:  ink #f2eef9 on bg #191625 = 15.4; muted #a69dba on #241f33 = 6.6; #2a1206 on accent #ff8a3d = 8.9
     badge: light #6f6885 on rgba(255,255,255,.85) over bg = 4.9; dark #a69dba on rgba(25,22,37,.85) = 6.3 */
:root {
  --bg: #f6f5fa; --surface: #ffffff; --surface2: #efedf8; --line: #e2def0;
  --ink: #241f33; --muted: #6f6885; --accent: #e2570e; --accent-ink: #ffffff;
  --teal: #0a9d90; --grape: #6b4de6; --danger: #d64545; --gold: #e0a400; --chip-ink: #14100c;
  --glass: rgba(255,255,255,.82); --shadow: 0 6px 20px rgba(36,31,51,.10); --radius: 15px;
  --stage-bg: #0b0a10;
}
:root[data-theme="dark"] {
  --bg: #191625; --surface: #241f33; --surface2: #2e2840; --line: #3b3352;
  --ink: #f2eef9; --muted: #a69dba; --accent: #ff8a3d; --accent-ink: #2a1206;
  --teal: #2fd4c4; --grape: #ab8dff; --danger: #ff6b78; --gold: #e0b24d; --chip-ink: #ffffff;
  --glass: rgba(25,22,37,.82); --shadow: 0 10px 26px rgba(0,0,0,.42);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Text", "Nunito", system-ui, sans-serif;
  font-size: 16px; line-height: 1.35; overflow: hidden; overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; }
h2 { font-size: 20px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
[hidden] { display: none !important; }

/* ---- version badge (§26) */
.vbadge { position: fixed; z-index: 100; top: calc(env(safe-area-inset-top, 0px) + 4px); left: calc(env(safe-area-inset-left, 0px) + 6px);
  font-size: 9px; line-height: 1; padding: 2px 5px; border-radius: 6px; background: var(--glass); color: var(--muted); pointer-events: none;
  font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* ---- PIN gate */
.gate { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.gate-inner { display: flex; flex-direction: column; align-items: center; gap: clamp(6px, 1.5vh, 12px); text-align: center; padding: 12px; }
.gate-logo { font-size: clamp(36px, 7vh, 56px); line-height: 1; }
.gate-title { font-size: clamp(22px, 4vh, 30px); }
.gate-sub { margin: 0; font-size: 15px; color: var(--muted); max-width: 32ch; }
.pin-gate { display: flex; flex-direction: column; align-items: center; gap: clamp(10px, 2.2vh, 20px); margin-top: 6px;
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.pin-dots { display: flex; gap: 10px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
.pin-dots span.on { background: var(--ink); }
.pin-gate.busy .pin-dots span.on { animation: pinpulse .9s ease-in-out infinite; }
@keyframes pinpulse { 50% { opacity: .35; } }
.pin-gate.bad .pin-dots { animation: pinshake .35s; }
@keyframes pinshake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }
.pin-msg { min-height: 1.3em; font-size: 16px; color: var(--muted); }
.pin-pad { display: grid; grid-template-columns: repeat(3, clamp(64px, 22vw, 84px)); gap: clamp(8px, 1.8vh, 16px); }
.pin-pad button { height: clamp(60px, 9vh, 84px); border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: clamp(26px, 4vh, 32px); line-height: 1; touch-action: manipulation; -webkit-tap-highlight-color: transparent; cursor: pointer; box-shadow: var(--shadow); }
.pin-pad button:active { background: var(--accent); color: var(--accent-ink); }
.pin-pad button:disabled { opacity: .5; }
.pin-pad .pin-del { border: none; background: transparent; font-size: 24px; box-shadow: none; }

/* ---- app frame: fixed chrome, content region fills, no page scroll */
.app { position: fixed; inset: 0; display: grid; grid-template-rows: 1fr auto; }
.view { position: relative; min-height: 0; display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.view-head { padding: max(calc(env(safe-area-inset-top, 0px) + 10px), 24px) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }
.view-body { min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left)); }
.view-body > * + * { margin-top: 10px; }
.tabbar { display: flex; justify-content: space-around; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px max(8px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom, 0px) + 6px) max(8px, env(safe-area-inset-left)); }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 0; border-radius: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tabbar button .ico { font-size: 20px; line-height: 1; }
.tabbar button.on { color: var(--accent); }

/* ---- buttons, cards, chips */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px; padding: 9px 14px; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.small { padding: 6px 10px; font-size: 14px; border-radius: 10px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: var(--surface2); color: var(--ink); width: 36px; height: 36px; border-radius: 50%; font-size: 16px; cursor: pointer; }
.pill { border: 0; background: var(--glass); color: var(--ink); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: 999px; padding: 9px 14px; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pill.on { background: var(--accent); color: var(--accent-ink); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.card h3 { font-size: 16px; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; color: var(--chip-ink); background: color-mix(in srgb, var(--hue, var(--teal)) 18%, var(--surface)); }
.chip.teal { --hue: var(--teal); } .chip.grape { --hue: var(--grape); } .chip.gold { --hue: var(--gold); } .chip.danger { --hue: var(--danger); } .chip.accent { --hue: var(--accent); }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; }
.item .thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface2); flex: none; }
.item .thumb.empty { display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search { width: 100%; font-size: 17px; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); outline: none; }
.search:focus { border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; color: var(--muted); padding: 5px 11px; font-weight: 700; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv b { font-weight: 600; color: var(--muted); }
details.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 14px; }
details.sec > summary { cursor: pointer; padding: 12px 0; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.sec > summary::after { content: "▸"; color: var(--muted); transition: transform .15s; }
details.sec[open] > summary::after { transform: rotate(90deg); }
details.sec > .sec-body { padding: 0 0 12px; }
details.sec > .sec-body > * + * { margin-top: 8px; }
.log { font-size: 13px; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; }
.log .when { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field input, .field select, .field textarea { font-size: 16px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
a { color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .big { font-size: 40px; }

/* ---- Walk view */
.view-walk { grid-template-rows: 1fr; background: var(--stage-bg); }
.stage { position: absolute; inset: 0; touch-action: none; }
.stage canvas { display: block; width: 100%; height: 100%; }
.walk-top { position: absolute; z-index: 5; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); top: calc(env(safe-area-inset-top, 0px) + 18px);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; pointer-events: none; }
.walk-top > * { pointer-events: auto; }
.walk-top-right { display: flex; gap: 8px; }
.pill-room { max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.walk-hint { position: absolute; z-index: 5; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 66px);
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); color: var(--ink); padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; max-width: 90vw; text-align: center; pointer-events: none; }
.walk-empty { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; padding: 16px; pointer-events: none; }
.walk-empty-card { background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: var(--radius); padding: 20px 22px; text-align: center; max-width: 36ch; color: var(--ink); }
.walk-empty-card .big { font-size: 44px; }
.walk-empty-card p { margin: 6px 0 0; color: var(--muted); }
.joy { position: absolute; z-index: 5; left: max(24px, env(safe-area-inset-left)); bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); touch-action: none; display: none; }
.joy .joy-nub { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255,255,255,.55); }
@media (pointer: coarse) { .joy { display: block; } }
.orient-bar { position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 96vw; }
.orient-bar button { border: 0; background: var(--glass); color: var(--ink); border-radius: 999px; padding: 8px 12px; font-weight: 600; font-size: 13px; cursor: pointer; }
.orient-bar button.accent { background: var(--accent); color: var(--accent-ink); }
.hot-label { position: absolute; z-index: 4; transform: translate(-50%, -140%); background: var(--glass); color: var(--ink); padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; pointer-events: none; white-space: nowrap; }

/* Container panel: a sheet over the viewer. On wide screens it docks right. */
.panel { position: absolute; z-index: 8; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); display: flex; flex-direction: column;
  left: 0; right: 0; bottom: 0; max-height: 70%; border-radius: var(--radius) var(--radius) 0 0; padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 900px) { .panel { left: auto; top: calc(env(safe-area-inset-top, 0px) + 70px); right: 16px; bottom: 16px; width: min(440px, 45vw); max-height: none; border-radius: var(--radius); } }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px 16px 8px; }
.panel-title { font-weight: 700; font-size: 18px; }
.panel-sub { font-size: 13px; }
.panel-body { min-height: 0; overflow-y: auto; padding: 0 16px 16px; }
.panel-body > * + * { margin-top: 10px; }
.photo-wrap { position: relative; border-radius: 12px; overflow: hidden; background: var(--surface2); }
.photo-wrap img { display: block; width: 100%; height: auto; }
.bbox { position: absolute; border: 2px solid var(--accent); border-radius: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,.4); pointer-events: none; }
.bbox.hl { border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 45%, transparent); }
.objs { display: flex; flex-wrap: wrap; gap: 6px; }
.obj { border: 1px solid var(--line); background: var(--surface2); color: var(--ink); border-radius: 999px; padding: 5px 10px; font-size: 14px; cursor: pointer; }
.obj.unverified { border-style: dashed; }
.obj.hl { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 18%, var(--surface)); }
.room-menu { position: absolute; z-index: 9; top: calc(env(safe-area-inset-top, 0px) + 64px); left: max(12px, env(safe-area-inset-left)); width: min(360px, calc(100vw - 24px)); max-height: 60%; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; }
.room-menu button { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 8px; border: 0; background: none; color: var(--ink); text-align: left; padding: 10px 10px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.room-menu button:hover, .room-menu button.on { background: var(--surface2); }
.room-menu .grp { font-size: 12px; color: var(--muted); padding: 8px 10px 2px; text-transform: uppercase; letter-spacing: .05em; }

/* toast */
.toast { position: fixed; z-index: 120; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 76px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); max-width: 92vw; text-align: center; }

/* progress and feedback (§16) */
.busy { opacity: .7; pointer-events: none; }
.prog { font-size: 13px; color: var(--muted); }
