:root {
  --bg: #0a0c0a;
  --card: #141815;
  --line: #232a25;
  --fg: #e8f0ea;
  --muted: #7d8c82;
  --green: #00e05a;
  --green-dim: #0b8f3c;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: #000; color: var(--fg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

/* ---------- Einrichtung ---------- */
#setup {
  max-width: 620px; margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  background: var(--bg); min-height: 100vh;
}
header { padding: 12px 4px 18px; }
h1 { margin: 0; font-size: 27px; letter-spacing: -0.4px; }
h1::before { content: "▲"; color: var(--green); margin-right: 9px; font-size: 21px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; letter-spacing: 0.2px; }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }

.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text] {
  width: 100%; padding: 13px 14px; font-size: 16px;
  background: #0b0e0c; color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input[type=text]:focus { border-color: var(--green-dim); }
input[type=text].bad { border-color: #d8503c; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.hint.err { color: #ff7a63; }
.hint.ok { color: var(--green); }

button {
  font: inherit; font-size: 15px; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); background: #1b211d; color: var(--fg);
  padding: 12px 16px; transition: background .12s, opacity .12s;
}
button:active { background: #232b26; }
button.primary {
  width: 100%; background: var(--green); color: #04150a;
  border: none; font-weight: 700; font-size: 17px; padding: 17px;
  letter-spacing: 0.3px;
}
button.primary:disabled { background: #1d2620; color: #4d5a51; }
button.primary.small { width: auto; padding: 11px 20px; font-size: 15px; }
button.ghost { flex: 1; }
button.small { padding: 9px 13px; font-size: 14px; }
.row { display: flex; gap: 9px; margin-top: 11px; }

#map {
  height: 260px; border-radius: 11px; overflow: hidden;
  background: #10140f; border: 1px solid var(--line);
}
.leaflet-container { background: #10140f; font-family: inherit; }

/* Kartenkacheln abdunkeln, damit die Seite dunkel bleibt */
.leaflet-tile-pane { filter: brightness(.62) saturate(.65) contrast(1.06); }
.leaflet-control-attribution {
  background: rgba(0,0,0,.6) !important; color: #6f7d73 !important; font-size: 10px !important;
}
.leaflet-control-attribution a { color: #8b9a90 !important; }
.pin-target, .pin-me {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #04150a; box-shadow: 0 0 0 2px rgba(0,224,90,.35);
}
.pin-target { background: var(--green); }
.pin-me { background: #4aa3ff; box-shadow: 0 0 0 2px rgba(74,163,255,.35); }

.collapsible { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.chev { color: var(--muted); transition: transform .15s; }
.collapsible.open .chev { transform: rotate(180deg); }

.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 10px 6px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--green-dim); color: #eafff1; border-color: var(--green-dim); }

.slider label b { color: var(--fg); font-weight: 600; }
input[type=range] {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px; background: #2a332d; outline: none; margin: 8px 0 0;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--green); border: 3px solid var(--bg);
}
.check { display: flex; align-items: center; gap: 10px; color: var(--fg); font-size: 15px; margin: 16px 0; }
.check input { width: 21px; height: 21px; accent-color: var(--green); }

#savedList { list-style: none; margin: 0; padding: 0; }
#savedList li {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0; border-top: 1px solid var(--line);
}
#savedList li:first-child { border-top: none; }
#savedList .nm { flex: 1; min-width: 0; }
#savedList .nm b { display: block; font-weight: 600; font-size: 15px; }
#savedList .nm span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#savedList .del { padding: 8px 11px; color: var(--muted); font-size: 13px; }

.status {
  font-size: 13px; color: var(--muted); padding: 4px 4px 12px;
  min-height: 22px; white-space: pre-line;
}
.status b { color: var(--green); font-weight: 600; }
.status .warn { color: #ffb44d; }
.foot { color: var(--muted); font-size: 12px; text-align: center; margin: 14px 4px 0; }

/* ---------- VR ---------- */
#vr { position: fixed; inset: 0; background: #000; z-index: 50; }
#stage { position: absolute; inset: 0; }
/* Bild um 90 Grad kippen, wenn iOS wegen der Rotationssperre im Hochformat
   bleibt, das Geraet aber quer in der Halterung steckt. Reihenfolge beachten:
   ein nachgestelltes inset wuerde top/left wieder auf auto zuruecksetzen. */
#stage.rot-left, #stage.rot-right {
  top: 50%; left: 50%; right: auto; bottom: auto;
  width: 100vh; height: 100vw;
  margin-top: -50vw; margin-left: -50vh;
  transform-origin: center center;
}
#stage.rot-left  { transform: rotate(90deg); }
#stage.rot-right { transform: rotate(-90deg); }
#view { display: block; width: 100%; height: 100%; background: #000; }

.hud {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.72); opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
.hud.show { opacity: 1; pointer-events: auto; }
.hudbox {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; text-align: center; max-width: 88vw;
}
#hudInfo { font-size: 14px; color: var(--muted); margin-bottom: 14px; white-space: pre-line; line-height: 1.6; }
#hudInfo b { color: var(--green); }
