:root {
  --bg: #0b0f14; --panel: rgba(11, 15, 20, .78); --line: rgba(255, 255, 255, .14);
  --fg: #f2f5f7; --mut: #9aa7b2; --acc: #ffdc00; --ok: #2ecc40; --bad: #ff4136; --warn: #ff9f1a;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: rgba(255, 255, 255, .08); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; cursor: pointer; }
button:active { transform: scale(.97); }
[hidden] { display: none !important; }

#cam { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#map { position: fixed; inset: 0; display: none; background: #1b2128; }
body[data-mode=map] #map { display: block; }
body[data-mode=map] #cam, body[data-mode=map] #view { display: none; }

#top { position: fixed; top: 0; left: 0; right: 0; z-index: 500; display: flex; gap: 8px; align-items: center;
  padding: calc(var(--st) + 8px) 10px 8px 14px; background: linear-gradient(var(--panel), rgba(11, 15, 20, .55)); }
#top .tt { flex: 1; min-width: 0; }
#tName { font-weight: 650; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tSub { color: var(--mut); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bList, #bRoute, #bNight, #bTalk { font-size: 22px; padding: 4px 9px; position: relative; }
#bNight.on { background: #8b0000; border-color: #c00; }
#bRoute.on { background: #3d8bff; border-color: #3d8bff; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; border: 1px solid rgba(0,0,0,.5); }

#view { position: fixed; inset: 0; pointer-events: none; z-index: 400; }
#cross { position: absolute; left: 50%; top: 50%; width: 120px; height: 120px; transform: translate(-50%, -50%);
  fill: none; stroke: rgba(255, 255, 255, .85); stroke-width: 1.4; filter: drop-shadow(0 0 2px #000); transition: stroke .2s; }
#cross .c { fill: rgba(255, 255, 255, .9); stroke: none; }
#cross.lock { stroke: var(--ok); }
#cross.lock .c { fill: var(--ok); }
#marker { position: absolute; left: 0; top: 0; will-change: transform; }
#marker .ring { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); border-radius: 50%;
  border: 3px solid var(--acc); box-shadow: 0 0 0 2px rgba(0,0,0,.6), inset 0 0 0 2px rgba(0,0,0,.4); }
#mLabel { position: absolute; left: 0; top: 0; transform: translate(-50%, 0); margin-top: 10px; padding: 2px 12px;
  border-radius: 10px; background: rgba(0,0,0,.7); color: var(--acc); font-size: 28px; font-weight: 800; line-height: 1.15;
  white-space: nowrap; text-shadow: 0 1px 2px #000; }
#edge { position: absolute; left: 0; top: 0; will-change: transform; }
#edge .arr { position: absolute; width: 44px; height: 44px; transform: translate(-50%, -50%); fill: var(--acc);
  stroke: rgba(0,0,0,.7); stroke-width: 2; filter: drop-shadow(0 0 3px #000); }
#near { position: absolute; left: 12px; right: 12px; top: calc(50% + 74px); text-align: center; padding: 8px 10px;
  border-radius: 12px; background: rgba(46, 204, 64, .85); color: #021; font-weight: 650; }

#bFollow { position: fixed; right: 12px; bottom: calc(var(--sb) + 150px); z-index: 600; background: var(--panel); }
body[data-mode=cam] #bFollow { display: none; }

#info { position: fixed; left: 0; right: 0; bottom: calc(var(--sb) + 64px); z-index: 500; display: flex; gap: 12px;
  align-items: center; padding: 8px 14px; background: linear-gradient(rgba(11, 15, 20, .3), var(--panel)); }
#compass { width: 58px; height: 58px; flex: none; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; background: rgba(0,0,0,.35); }
#needle { width: 34px; height: 34px; fill: var(--acc); }
.iv { min-width: 0; }
#dist { font-size: 32px; font-weight: 750; letter-spacing: -.5px; }
#acc { color: var(--mut); }
#dir { font-size: 15px; }
#rinfo { font-size: 13px; color: #8fc1ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#rinfo:empty { display: none; }
#status { color: var(--mut); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 550; display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; padding: 6px 6px calc(var(--sb) + 6px); background: var(--bg); border-top: 1px solid var(--line); }
#bar button { padding: 4px 0; font-size: 20px; line-height: 1.1; display: flex; flex-direction: column; align-items: center; border-radius: 10px; }
#bar small { font-size: 10.5px; color: var(--mut); margin-top: 2px; }
#bar button.on { background: var(--acc); color: #000; }
#bar button.on small { color: #000; }

#start { position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; background: rgba(11, 15, 20, .94); padding: 20px; }
#start .box { max-width: 340px; text-align: center; }
#start h1 { margin: 0 0 10px; font-size: 30px; }
#bStart { margin-top: 16px; font-size: 19px; padding: 12px 28px; background: var(--acc); color: #000; border: 0; font-weight: 700; }

#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 800; max-height: 78vh; display: flex; flex-direction: column;
  background: #121820; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.6); }
.sh { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 16px; border-bottom: 1px solid var(--line); }
.sh b { flex: 1; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sheetBody { overflow: auto; padding: 10px 14px calc(var(--sb) + 18px); -webkit-overflow-scrolling: touch; }
#sheetBody h4 { margin: 16px 0 6px; color: var(--mut); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.sub { color: var(--mut); font-size: 13px; margin: 4px 0 8px; }
.coord { font-family: ui-monospace, Menlo, Consolas, monospace; user-select: all; }
.warn { color: var(--warn); }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tools button { font-size: 14px; padding: 7px 10px; }
input[type=search], input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%; font: inherit; color: var(--fg); background: #0b0f14; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
textarea { resize: vertical; }
.list, .logs { list-style: none; margin: 8px 0; padding: 0; }
.row { display: flex; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row .grow { flex: 1; min-width: 0; }
.row b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row small { color: var(--mut); }
.row .dd { text-align: right; font-size: 13px; color: var(--acc); white-space: nowrap; }
.row.found { opacity: .55; }
.empty { color: var(--mut); padding: 14px 4px; }
.hint { white-space: pre-wrap; padding: 10px; border-radius: 10px; background: #0b0f14; border: 1px solid var(--line); transition: filter .2s; }
.hint.blur { filter: blur(7px); user-select: none; }
.log { padding: 9px 4px 9px 10px; border-bottom: 1px solid var(--line); border-left: 4px solid #555; margin-bottom: 2px; }
.log.found { border-left-color: var(--ok); } .log.dnf { border-left-color: var(--bad); }
.log.maint { border-left-color: var(--warn); } .log.note { border-left-color: #3d8bff; } .log.admin { border-left-color: #b10dc9; }
.lh { color: var(--mut); font-size: 13px; margin-bottom: 3px; }
.lt { color: var(--fg); font-weight: 650; }
.lx { white-space: pre-wrap; word-break: break-word; }
.ki { font-size: 16px; }
.ai { padding: 9px 4px; border-bottom: 1px solid var(--line); }
.ai q { display: block; color: var(--mut); font-style: italic; margin: 4px 0; cursor: pointer; }
.ai q small { font-style: normal; }
.ai .full { margin: 4px 0 2px; padding: 8px; border-radius: 8px; background: #0b0f14; border-left: 3px solid #3d8bff; }
.ai .kat { display: block; font-size: 12px; color: var(--mut); text-transform: uppercase; letter-spacing: .4px; }
.warnli b { color: var(--warn); }
.zst { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 8px; font-size: 14px; }
.badge { padding: 3px 10px; border-radius: 999px; color: #021; font-weight: 750; }
.ai button { margin-top: 6px; font-size: 14px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.seg label { display: flex; gap: 6px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.th { position: relative; flex: none; }
.th img { width: 86px; height: 86px; object-fit: cover; border-radius: 8px; display: block; }
.th input { position: absolute; left: 4px; top: 4px; width: 20px; height: 20px; }
.f { display: block; margin: 10px 0; }
.f span { display: block; color: var(--mut); font-size: 13px; margin-bottom: 4px; }
.f.c { display: flex; gap: 10px; align-items: center; }
.f.c span { margin: 0; color: var(--fg); font-size: 15px; }
.f.c input { width: 22px; height: 22px; }
.diag li { padding: 6px 2px; border-bottom: 1px solid var(--line); }

#flash { position: fixed; inset: 0; z-index: 950; background: #fff; opacity: 0; pointer-events: none; transition: opacity .12s; }
#flash.on { opacity: .7; }
#toast { position: fixed; left: 50%; top: 38%; z-index: 960; transform: translate(-50%, -20px); opacity: 0;
  max-width: 90vw; padding: 9px 14px; border-radius: 12px; background: rgba(0,0,0,.85); border: 1px solid var(--line);
  transition: all .2s; pointer-events: none; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Karte */
.leaflet-container { background: #1b2128; font: inherit; }
.me { background: none; border: 0; }
.meArrow { width: 34px; height: 34px; position: relative; transition: transform .2s linear; }
.meArrow::before { content: ""; position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; border-radius: 50%;
  background: #39cccc; border: 3px solid #fff; box-shadow: 0 0 4px #000; }
.meArrow::after { content: ""; position: absolute; left: 11px; top: -2px; border: 6px solid transparent; border-bottom: 11px solid #39cccc; }
.pbtn { margin-top: 6px; color: #000; background: var(--acc); border: 0; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #121820; color: var(--fg); }
.leaflet-control-attribution { margin-bottom: calc(var(--sb) + 150px) !important; }

/* Multi: Kärtchen nächste Station */
#stage { position: fixed; left: 8px; right: 8px; top: calc(var(--st) + 62px); z-index: 520; max-height: 34vh; overflow: auto;
  padding: 8px 10px; border-radius: 12px; background: rgba(11, 15, 20, .86); border: 1px solid var(--line); }
#stage .st-h { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; cursor: pointer; }
#stage .st-h span { color: var(--acc); font-weight: 700; white-space: nowrap; }
#stage .st-t { margin-top: 4px; white-space: pre-wrap; font-size: 14px; }
#stage .st-v { margin-top: 4px; color: #8fc1ff; font-size: 14px; }
#stage .tools { margin: 6px 0 0; }
#stage.min .st-t, #stage.min .st-v, #stage.min .tools { display: none; }
.stn { padding: 10px 4px; border-bottom: 1px solid var(--line); }
.stn.cur { background: rgba(61, 139, 255, .08); border-left: 3px solid #3d8bff; padding-left: 8px; }
.stn.done { opacity: .7; }
.stn .aufg { white-space: pre-wrap; margin: 6px 0; }
.stn.final { border: 1px solid var(--acc); border-radius: 10px; padding: 10px; margin-top: 10px; }
.coord.big { font-size: 20px; font-weight: 700; margin: 6px 0; }
.var { display: grid; grid-template-columns: 30px 84px 40px 1fr; gap: 6px; align-items: center; margin: 6px 0; }
.var button { padding: 5px 0; }
.var b { font-size: 18px; color: var(--acc); }
.var input { padding: 6px 8px; font-size: 18px; text-align: center; }
.var small { color: var(--mut); }
.foto { margin: 6px 0; padding: 8px; border-radius: 8px; background: #0b0f14; border-left: 3px solid var(--ok); }
.fw { margin-top: 4px; }
.fw button { padding: 3px 8px; font-size: 13px; margin-left: 4px; }
.answer { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.answer img { width: 110px; height: 110px; object-fit: cover; border-radius: 10px; }
.answer .big { font-size: 44px; font-weight: 800; color: var(--acc); line-height: 1; }

/* Karte dunkel: Kacheln umfärben (Wasser bleibt bläulich, Straßen hell), Markierungen und Route bleiben farbig */
body.mapdark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9) saturate(.55); }
body.mapdark .leaflet-container { background: #0e1216; }

/* Nachtmodus: alles rot und gedimmt (schont die Dunkeladaption), darüber liegt nichts */
#nightveil { position: fixed; inset: 0; z-index: 10000; pointer-events: none; display: none; background: #ff2200; mix-blend-mode: multiply; }
body.night #nightveil { display: block; }
body.night { filter: brightness(.75); }
/* Reflektor-Ringe über dem roten Schleier: in echter Farbe sichtbar */
#spots { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 10001; pointer-events: none; }
body[data-mode=map] #spots { display: none; }
#spotInfo { position: absolute; left: 50%; top: calc(50% + 70px); transform: translateX(-50%); padding: 4px 12px; border-radius: 10px;
  background: rgba(0,0,0,.6); color: var(--acc); font-weight: 700; }
#peilbar { position: fixed; left: 8px; right: 8px; bottom: calc(var(--sb) + 150px); z-index: 560; padding: 8px 10px; border-radius: 12px;
  background: rgba(11, 15, 20, .9); border: 1px solid var(--acc); }
#peilbar #pbVal { color: var(--acc); font-weight: 750; font-size: 18px; }
#peilbar small { display: block; color: var(--mut); margin-top: 2px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 9px; border-radius: 999px; background: rgba(255,255,255,.07); border: 1px solid var(--line); font-size: 13px; }
.chip.neg { opacity: .6; text-decoration: line-through; }
.gear { padding: 6px 2px; border-bottom: 1px solid var(--line); }
.gear.miss b { color: var(--bad); }
.gear.ok small { color: var(--ok); }

.tourNr { background: #b10dc9; color: #fff; border-radius: 50%; font: bold 12px/20px system-ui; text-align: center; border: 1px solid #fff; }
.tourNr.done { opacity: .45; }
.tnr { width: 24px; height: 24px; flex: none; border-radius: 50%; background: #b10dc9; color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.gear.soft small { color: var(--warn); }

#bTalk.badge::after { content: attr(data-n); position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.tlist { list-style: none; margin: 6px 0; padding: 0; max-height: 42vh; overflow: auto; }
.tmsg { padding: 7px 9px; margin: 5px 0; border-radius: 10px; background: rgba(255,255,255,.06); max-width: 88%; }
.tmsg.me { margin-left: auto; background: rgba(61,139,255,.18); }
.tmsg .th small { color: var(--mut); }
.tmsg .tt { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.tmsg button { margin-top: 5px; font-size: 13px; padding: 4px 8px; }
.tsend { display: flex; gap: 6px; }
.tsend input { flex: 1; }
.talkPos { background: rgba(11,15,20,.85); color: #8fc1ff; border: 1px solid #3d8bff; border-radius: 8px; padding: 1px 6px; font-size: 12px; white-space: nowrap; }
.tmsg .chan { font-size: 12px; color: var(--mut); }

.ptt { width: 100%; padding: 16px; margin: 8px 0; font-size: 18px; font-weight: 700; border-radius: 14px; touch-action: none; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none; background: rgba(46,204,64,.15); border-color: var(--ok);
  box-shadow: inset 0 0 0 calc(var(--pegel, 0) * 8px) rgba(46,204,64,.5); }
.ptt.on { background: var(--bad); color: #fff; border-color: var(--bad); }

/* schwebender Sprechknopf (b:con talk an + Kanal vorhanden) */
#fPtt { position: fixed; left: 12px; bottom: calc(var(--sb) + 160px); z-index: 600; width: 74px; height: 74px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  background: rgba(11, 15, 20, .82); border: 2px solid var(--ok); box-shadow: 0 2px 10px rgba(0,0,0,.5), inset 0 0 0 calc(var(--pegel, 0) * 10px) rgba(46,204,64,.55); }
#fPtt[hidden] { display: none; }
#fPtt .fi { font-size: 30px; line-height: 1; }
#fPtt small { position: absolute; bottom: 9px; left: 0; right: 0; text-align: center; font-size: 11px; font-weight: 700; }
#fPtt b { position: absolute; top: -4px; right: -4px; font-size: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 50%; width: 24px; height: 24px; display: grid; place-items: center; }
#fPtt.on { background: var(--bad); border-color: #fff; transform: scale(1.12); }
#fPtt.on .fi { font-size: 26px; margin-top: -10px; }
#fPtt.rx { animation: rxpuls 1s ease-in-out infinite; border-color: #3d8bff; }
@keyframes rxpuls { 50% { box-shadow: 0 0 0 10px rgba(61,139,255,.35); } }
#peilbar:not([hidden]) ~ #fPtt { bottom: calc(var(--sb) + 230px); }
body:has(#sheet:not([hidden])) #fPtt, body:has(#start:not([hidden])) #fPtt { display: none; }

/* KI-Anbieter in den Einstellungen */
.kiA { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.kiH { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.kiH a { margin-left: auto; font-size: 13px; color: #8fc1ff; }
.kiP { font-size: 13px; padding: 5px 9px; }
.kiS { color: var(--mut); }
