:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --text: #e9ecf1;
  --muted: #8b93a1;
  --accent: #4cc9f0;
  --accent-2: #ffd60a;
  --danger: #e5383b;
  --border: #2b303b;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, sans-serif; }
a { color: var(--accent); }
input, select, button { font: inherit; color: inherit; }
input, select {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2);
}
input[type=range] { padding: 0; }
input[type=checkbox] { width: auto; }
label { display: block; margin: 8px 0; color: var(--muted); font-size: 13px; }
label > input, label > select { margin-top: 4px; color: var(--text); font-size: 15px; }
label.inline { display: inline; margin-left: 8px; }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 15px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.error { color: #ff8a8a; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row label { margin: 4px 0; }

.btn {
  display: inline-block; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); text-decoration: none; color: var(--text); cursor: pointer; text-align: center;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #062029; border-color: transparent; font-weight: 600; }
.btn-danger { color: #ff8a8a; }
.btn-ghost { background: transparent; }
.btn-small { padding: 6px 10px; font-size: 13px; }

/* ---------- home ---------- */
.home { max-width: 560px; margin: 0 auto; padding: 48px 16px; }
.home-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0; }
.home-notes { color: var(--muted); padding-left: 18px; }
.home-notes li { margin: 6px 0; }

/* ---------- place ---------- */
.page-place { display: flex; height: 100dvh; overflow: hidden; }
#map { flex: 1; min-width: 0; background: #222; }
.panel { width: 360px; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--border); padding: 12px 16px 24px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 18px; }
.hint { color: var(--muted); font-size: 12px; }
.object-list { list-style: none; margin: 0; padding: 0; }
.object-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; }
.object-list li:hover, .object-list li.active { background: var(--panel-2); }
.editor { border-top: 1px solid var(--border); margin-top: 12px; }
.gps-box { margin: 8px 0; }
.gps-box .btn { width: 100%; }
#gps-status { margin-top: 6px; color: var(--muted); min-height: 1em; }
.actions { display: flex; gap: 8px; margin: 14px 0 8px; }
.actions .btn-danger { margin-left: auto; }
#open-ar { width: 100%; }

.pin { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: rgba(229, 56, 59, .35); display: grid; place-items: center; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.pin-selected { border-color: var(--accent-2); background: rgba(255, 214, 10, .3); }
.pin-dot { width: 4px; height: 4px; border-radius: 50%; background: #fff; }
.heading-handle { width: 18px; height: 18px; border-radius: 50%; background: var(--accent-2); border: 2px solid #000; cursor: grab; }

@media (max-width: 720px) {
  .page-place { flex-direction: column; }
  #map { flex: 1 1 55%; }
  .panel { width: 100%; flex: 1 1 45%; border-left: 0; border-top: 1px solid var(--border); }
}

/* ---------- view ---------- */
.page-view { overflow: hidden; background: #000; }
#camera, #scene { position: fixed; inset: 0; width: 100vw; height: 100dvh; }
#camera { object-fit: cover; }
#scene { display: block; }
#overlay { position: fixed; inset: 0; pointer-events: none; }
#overlay > * { pointer-events: auto; }
#overlay:xr-overlay { background: transparent; }
.start {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px;
}
.start .btn-primary { width: 100%; margin-top: 8px; padding: 12px; }
.mode-label { color: var(--accent); }

.hud {
  position: absolute; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
  /* No backdrop-filter: blurring the live camera behind the DOM overlay costs a full-screen pass per frame. */
  background: rgba(15, 17, 21, .86);
  border: 1px solid var(--border); border-radius: 14px; padding: 10px; max-width: 520px; margin: 0 auto;
}
.hud-top { display: flex; gap: 8px; align-items: flex-start; }
.hud-status { flex: 1; white-space: pre-wrap; color: #cfd6e0; }
.hud-target { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; margin: 8px 0; }
.hud-target select { padding: 6px 8px; }
.arrow-wrap { grid-row: span 2; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); display: grid; place-items: center; }
.arrow { color: var(--accent-2); font-size: 22px; transition: transform .2s linear; }
.hud-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.hud-actions label { display: flex; align-items: center; gap: 6px; margin: 0; flex: 1; }
.nudge { display: flex; gap: 12px; align-items: center; margin: 8px 0; }
.nudge-grid { display: grid; grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 36px); gap: 4px; }
.nudge button { border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); min-width: 40px; min-height: 36px; }
.nudge-side { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nudge-side > div:first-child { display: flex; gap: 6px; }
.nudge-side label { margin: 0; }
.nudge-side select { padding: 4px 6px; font-size: 13px; }
.log { display: flex; gap: 8px; }
.log input { flex: 1; padding: 6px 8px; }
#toast { min-height: 1em; margin-top: 6px; color: var(--accent); }

/* ---------- camera placement ---------- */
.camera-place { display: block; margin: 12px 0 4px; }
.place-open { width: 100%; margin: 8px 0 4px; }
.place-panel { margin-top: 8px; }
.place-panel .row { gap: 8px; }
.place-panel .hud-actions .btn-primary { margin-left: auto; }
.crosshair {
  position: absolute; left: 50%; top: 50%; width: 36px; height: 36px; transform: translate(-50%, -50%);
  pointer-events: none !important;
}
.crosshair::before, .crosshair::after {
  content: ''; position: absolute; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.6);
}
.crosshair::before { left: 17px; top: 0; width: 2px; height: 36px; }
.crosshair::after { top: 17px; left: 0; height: 2px; width: 36px; }
#place-info { white-space: pre-wrap; margin: 4px 0; color: #cfd6e0; }
.gps-pre { color: var(--muted); } .gps-pre.error { color: #ff8a8a; }

/* ---------- capture ---------- */
.login-form { max-width: 320px; }
.page-capture { padding: 0 16px 32px; max-width: 720px; margin: 0 auto; }
.cap-head { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0; }
.cap-session .row { align-items: end; }
.new-session { display: flex; gap: 8px; align-items: end; }
.new-session label { flex: 1; }
.cap-camera { position: relative; margin: 12px 0; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 60dvh; width: 100%; }
.cap-camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cap-overlay { position: absolute; left: 8px; top: 8px; right: 8px; background: rgba(0,0,0,.55); padding: 6px 8px; border-radius: 8px; white-space: pre-wrap; }
.cap-level { position: absolute; left: 50%; top: 50%; width: 60%; height: 0; transform: translate(-50%, -50%); pointer-events: none; }
.cap-level-line { height: 3px; background: #2ecc71; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.cap-level-line.bad { background: #e5383b; }
.cap-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .15s; }
.cap-flash.on { opacity: .35; transition: none; }
.cap-start { width: 100%; padding: 14px; font-size: 17px; margin: 8px 0; }
.cap-start.recording { background: var(--danger); color: #fff; }
.cap-stats { white-space: pre-wrap; color: #cfd6e0; min-height: 2.6em; }
.cap-thumbs { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0; }
.cap-thumbs img { height: 64px; border-radius: 6px; flex: 0 0 auto; }
.cap-thumbs img.pending { opacity: .45; }
.cap-thumbs img.failed { outline: 2px solid var(--danger); }
.inline-check { display: flex; gap: 6px; align-items: center; }
.cap-tips { margin-top: 16px; color: var(--muted); }
.cap-tips li { margin: 6px 0; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }
.anon .needs-login { display: none !important; }
.landing-list { list-style: none; padding: 0; } .landing-list li { margin: 0.6rem 0; display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
