:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #13202f;
  --muted: #5d6b7a;
  --line: #dde3ea;
  --brand: #14324f;
  --accent: #1e88e5;
  --ok: #2e7d32;
  --no: #8d6e63;
  --tabbar-h: 58px;
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1722; --panel: #172231; --ink: #e6edf5; --muted: #9fb0c2; --line: #2a3a4e; --brand: #0b1f33;
  }
}
:root[data-theme="dark"] { --bg: #0f1722; --panel: #172231; --ink: #e6edf5; --muted: #9fb0c2; --line: #2a3a4e; --brand: #0b1f33; }

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Rubik", sans-serif;
  overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  padding: calc(var(--safe-t) + 6px) 12px 6px;
  min-height: calc(var(--top-h) + var(--safe-t));
  display: flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff;
}
.top-lines { flex: 1; min-width: 0; }
.obs-line { font-size: 12.5px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heading-line { font-size: 15px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.icon-btn { background: rgba(255,255,255,.12); border: 0; border-radius: 12px; width: 42px; height: 42px; font-size: 20px; color: #fff; }
.mini { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid currentColor; background: transparent; }
.topbar .mini { color: #fff; }

main {
  position: fixed; left: 0; right: 0;
  top: calc(var(--top-h) + var(--safe-t)); bottom: calc(var(--tabbar-h) + var(--safe-b));
}
.tab-panel { position: absolute; inset: 0; }

.welcome { max-width: 460px; margin: 0 auto; padding: 28px 16px; text-align: center; overflow-y: auto; height: 100%; }
.welcome-art { font-size: 54px; }
.welcome h1 { margin: 6px 0 10px; font-size: 26px; }
.welcome p { color: var(--muted); line-height: 1.55; }
.primary, .secondary { display: block; width: 100%; border-radius: 14px; padding: 14px; margin: 10px 0; border: 0; font-weight: 600; }
.primary { background: var(--accent); color: #fff; font-size: 18px; }
.secondary { background: var(--panel); border: 1px solid var(--line); }
.fine { font-size: 11.5px; color: var(--muted); }

.pano-wrap { position: absolute; inset: 0 0 24px 0; }
.pano-canvas { display: block; }
.pano-help, .map-help {
  position: absolute; bottom: 0; left: 0; right: 0; height: 24px; line-height: 24px;
  text-align: center; font-size: 11.5px; color: var(--muted); background: var(--panel);
}
.map { position: absolute; inset: 0 0 24px 0; }
.pick-menu { display: flex; flex-direction: column; gap: 6px; direction: rtl; }
.pick-menu button { border: 1px solid #cfd8dc; background: #fff; color: #13202f; border-radius: 10px; padding: 8px 12px; font-size: 14px; text-align: right; }

.list-body { height: 100%; overflow-y: auto; padding: 10px 12px 90px; -webkit-overflow-scrolling: touch; }
.list-summary { font-size: 13px; color: var(--muted); margin: 2px 2px 10px; }
.band { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden; }
.band h3 { margin: 0; padding: 9px 12px; font-size: 15px; background: rgba(30,136,229,.08); display: flex; justify-content: space-between; }
.count { font-size: 12px; color: var(--muted); font-weight: 500; }
.type-group { padding: 4px 0; border-top: 1px solid var(--line); }
.type-title { font-size: 12.5px; font-weight: 700; padding: 4px 12px; }
.item {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 12px; background: none; border: 0; text-align: right; border-top: 1px solid transparent;
}
.item:active { background: rgba(0,0,0,.05); }
.item-main { display: flex; flex-direction: column; min-width: 0; }
.item-name { font-weight: 600; }
.item-sub { font-size: 12px; color: var(--muted); }
.item-meta { font-size: 12.5px; color: var(--muted); text-align: left; white-space: nowrap; }
.item-meta small { font-size: 11px; }
.item.is-hidden .item-name { color: var(--muted); font-weight: 500; }
.hidden-group { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px 0; }
.hidden-group summary { padding: 4px 12px; font-weight: 600; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.note { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 16px; }

.ar-wrap { position: absolute; inset: 0; background: #000; overflow: hidden; }
.ar-wrap video, .ar-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.ar-wrap video { object-fit: cover; }
.ar-help {
  position: absolute; bottom: 52px; left: 10px; right: 10px; color: #fff; font-size: 12px; text-align: center;
  background: rgba(0,0,0,.45); border-radius: 10px; padding: 6px 8px; pointer-events: auto;
}
.ar-help .mini { color: #fff; margin-inline-start: 6px; }

.fab {
  position: fixed; z-index: 15; left: 12px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 34px);
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 9px 15px; font-size: 14px; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
body[data-tab="pano"] .fab { bottom: auto; top: calc(var(--top-h) + var(--safe-t) + 10px); }
.fab:disabled { opacity: .6; }
body[data-tab="welcome"] .fab, body[data-tab="camera"] .fab { display: none; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20; height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b); display: flex; background: var(--panel); border-top: 1px solid var(--line);
}
.tabbar button { flex: 1; border: 0; background: none; font-size: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); }
.tabbar button span { font-size: 11.5px; }
.tabbar button.active { color: var(--accent); font-weight: 700; }

.busy {
  position: fixed; z-index: 40; top: calc(var(--top-h) + var(--safe-t) + 10px); left: 50%; transform: translateX(-50%);
  background: rgba(20,32,47,.92); color: #fff; border-radius: 999px; padding: 8px 16px;
  display: flex; gap: 10px; align-items: center; font-size: 14px; white-space: nowrap;
}
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; z-index: 50; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 90px);
  background: #263238; color: #fff; padding: 11px 14px; border-radius: 12px; font-size: 14px; text-align: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
}

.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto;
  background: var(--panel); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
}
.sheet h2 { margin: 0 0 12px; font-size: 20px; padding-inline-end: 36px; }
.sheet h3 { margin: 16px 0 6px; font-size: 15px; }
.sheet-close { position: absolute; top: 12px; left: 12px; border: 0; background: var(--bg); border-radius: 50%; width: 34px; height: 34px; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sheet th { text-align: right; color: var(--muted); font-weight: 500; padding: 6px 0; width: 40%; vertical-align: top; }
.sheet td { padding: 6px 0; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; vertical-align: middle; color: #fff; }
.badge.ok { background: var(--ok); }
.badge.no { background: var(--no); }
.details-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.details-actions button, .details-actions a {
  flex: 1; min-width: 100px; text-align: center; padding: 10px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); text-decoration: none; font-size: 14px;
}
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.row select, .row input[type=number] { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); max-width: 48%; }
.row input[type=range] { width: 45%; }
.row-block { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font-size: 13.5px; display: inline-flex; gap: 4px; align-items: center; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 6px; }
