:root {
  --bg: #0f1115;
  --card: #181b22;
  --line: #2a2f3a;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --danger: #ff5c5c;
  --ok: #3ecf8e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; color: inherit; }

.screen { display: none; }
.screen.active { display: block; }

/* ---------- Tela de cadastro ---------- */
#setup { max-width: 640px; margin: 0 auto; padding: 16px 16px 110px; }
.top h1 { margin: 8px 0 2px; font-size: 26px; }
.top p { margin: 0 0 16px; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label small { color: #6c7483; }
input, select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  background: #0f1218; border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
input[type=color] { padding: 2px; height: 42px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }

#map { height: 220px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 4px; }

button, .fileBtn {
  border: 1px solid var(--line); background: #222734; padding: 10px 14px; border-radius: 10px; cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost, .ghost { background: transparent; }
button.small, .small { padding: 6px 10px; font-size: 13px; }
button.big { width: 100%; padding: 16px; font-size: 17px; border-radius: 14px; }
.fileBtn { display: inline-block; margin: 0; color: var(--text); font-size: 13px; }

.sticky { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.sticky button { max-width: 608px; margin: 0 auto; display: block; }

#pointList { list-style: none; padding: 0; margin: 0; }
#pointList li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
#pointList li:last-child { border-bottom: none; }
#pointList .dot { width: 14px; height: 14px; border-radius: 4px; flex: none; }
#pointList .info { flex: 1; min-width: 0; }
#pointList .info b { display: block; }
#pointList .info span { font-size: 12px; color: var(--muted); }
#pointList .empty { color: var(--muted); font-size: 14px; }

/* ---------- Tela AR ---------- */
#ar { position: fixed; inset: 0; background: #000; overflow: hidden; touch-action: none; }
#ar.active { display: block; }
#video, #gl { position: absolute; inset: 0; width: 100%; height: 100%; }
#video { object-fit: cover; }
#gl { touch-action: none; }
#labels { position: absolute; inset: 0; pointer-events: none; }

.label {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap;
  background: rgba(15, 17, 21, .78); border: 1px solid rgba(255,255,255,.15);
  padding: 6px 10px; border-radius: 10px; font-size: 13px; text-align: center;
  backdrop-filter: blur(6px);
}
.label b { display: block; font-size: 14px; }
.label.far { opacity: .8; }

.hud { position: absolute; z-index: 5; }
.top-hud {
  top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 10px 10px;
  background: linear-gradient(rgba(0,0,0,.6), transparent);
}
#status { flex: 1; font-size: 12px; line-height: 1.35; text-shadow: 0 1px 2px #000; }
.hudBtn { width: 42px; height: 42px; padding: 0; border-radius: 50%; background: rgba(0,0,0,.5); border-color: rgba(255,255,255,.2); font-size: 18px; }

#compass {
  position: absolute; z-index: 5; right: 12px; top: calc(70px + env(safe-area-inset-top));
  width: 54px; height: 54px; border-radius: 50%; background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.2);
  display: grid; place-items: center;
}
#compassNeedle { position: absolute; inset: 0; display: flex; justify-content: center; font-size: 11px; font-weight: 700; color: var(--danger); padding-top: 3px; }
#headingTxt { font-size: 11px; margin-top: 10px; }

#guide {
  left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,.2); padding: 10px 16px; border-radius: 999px;
  font-size: 15px; white-space: nowrap; display: none;
}
#toast {
  position: absolute; z-index: 6; left: 50%; top: 30%; transform: translate(-50%, -20px); opacity: 0;
  background: var(--ok); color: #04140c; font-weight: 700; padding: 12px 18px; border-radius: 12px;
  transition: .3s; pointer-events: none; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#calPanel {
  left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom));
  background: rgba(15,17,21,.9); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
#calPanel p { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
#calPanel input { padding: 0; }
#calVal { flex: 1; }
