:root {
  /* Schwarz & Grautöne */
  --bg: #0a0a0a; --bg2: #121212; --card: #171717; --card2: #1f1f1f; --line: #2a2a2a; --line2: #3a3a3a;
  --text: #f2f2f2; --muted: #9a9a9a; --accent: #f2f2f2; --accent-ink: #0a0a0a;
  --danger: #e5484d; --ok: #8a8a8a; --radius: 14px;
  --tabbar-h: calc(62px + env(safe-area-inset-bottom));
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: -0.005em; -webkit-tap-highlight-color: transparent; }
a { color: var(--text); text-underline-offset: 3px; text-decoration-color: var(--line2); }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin-bottom: .6rem; }
code { background: var(--card2); padding: .15em .4em; border-radius: 6px; font-size: .95em; word-break: break-all; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }

/* Kopf und Tabbar */
.topbar { position: sticky; top: 0; z-index: 500; display: flex; align-items: center; gap: .6rem;
  padding: calc(env(safe-area-inset-top) + .7rem) 1rem .7rem; background: rgba(10,10,10,.82);
  -webkit-backdrop-filter: saturate(140%) blur(14px); backdrop-filter: saturate(140%) blur(14px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 1.15rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { font-size: 2rem; line-height: 1; text-decoration: none; color: var(--text); padding: 0 .3rem; }
.content { max-width: 900px; margin: 0 auto; padding: 1rem 1rem calc(var(--tabbar-h) + 1.2rem); display: flex; flex-direction: column; gap: 1rem; }
body.auth .content { padding-bottom: 2rem; }
body.auth .topbar { display: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; display: flex; background: rgba(10,10,10,.88);
  -webkit-backdrop-filter: saturate(140%) blur(14px); backdrop-filter: saturate(140%) blur(14px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); height: var(--tabbar-h); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .7rem; }
.tabbar svg { width: 24px; height: 24px; fill: currentColor; }
.tabbar svg .hole { fill: var(--bg); }
.tabbar a.on { color: var(--text); }
.tabbar a.on span { font-weight: 600; }

/* Bausteine */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: .7rem .8rem; transition: border-color .15s; min-height: 46px; width: 100%; }
input:focus, select:focus { outline: none; border-color: var(--muted); box-shadow: 0 0 0 3px rgba(255,255,255,.08); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600;
  min-height: 46px; padding: .6rem 1.1rem; border-radius: 10px; border: 1px solid var(--line2); background: var(--card2);
  color: var(--text); text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:hover { background: #262626; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #d4d4d4; }
.btn.danger { background: transparent; color: #ff8a8d; border-color: rgba(229,72,77,.6); }
.btn.small { min-height: 38px; padding: .4rem .8rem; font-size: .9rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.icon-btn { font: inherit; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 10px;
  min-height: 38px; padding: .3rem .7rem; cursor: pointer; }
.icon-btn[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); }
.inline-form { display: flex; gap: .5rem; }
.inline-form input { flex: 1; }
.flash { padding: .8rem 1rem; border-radius: 10px; border: 1px solid var(--line2); background: var(--card2); }
.flash-ok { border-left: 3px solid var(--text); } .flash-error { border-left: 3px solid var(--danger); }
.copy { font: inherit; font-size: .8rem; background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: .15rem .5rem; cursor: pointer; }
.secret:not(.shown) { filter: blur(5px); user-select: none; }
.creds { display: grid; grid-template-columns: auto 1fr; gap: .5rem .8rem; margin: 0 0 1rem; align-items: center; }
.creds dt { color: var(--muted); font-size: .9rem; } .creds dd { margin: 0; }
@media (max-width: 420px) { .creds { grid-template-columns: 1fr; } .creds dt { margin-top: .3rem; } }

/* Schalter */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line2); border-radius: 30px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff;
  border-radius: 50%; transition: .2s; }
.switch input:checked + span::before { background: var(--accent-ink); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); }

/* Anmeldung */
.auth-box { max-width: 380px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 1rem; text-align: center; }
.auth-box form { text-align: left; }
.auth-logo { margin: 0 auto; border-radius: 22px; box-shadow: 0 10px 40px rgba(255,255,255,.06); }

/* Kameras */
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .7rem; }
.cam-tile { position: relative; display: block; aspect-ratio: 4/3; border-radius: var(--radius); overflow: hidden;
  background: var(--card); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.cam-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-tile .ph, .ph { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: .85rem; }
.cam-meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 1.4rem .6rem .5rem;
  background: linear-gradient(transparent, rgba(0,0,0,.8)); display: flex; flex-direction: column; }
.cam-meta span { font-size: .75rem; color: #c8c8c8; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.list a { display: flex; align-items: center; gap: .8rem; padding: .6rem; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); text-decoration: none; }
.list img, .ph.sm { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--card2); flex: none; }
.list div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.list small { color: var(--muted); }
.chev { font-size: 1.6rem; color: var(--muted); }

/* Wind */
.wind-head { display: flex; justify-content: space-between; align-items: baseline; }
.wind-body { display: flex; align-items: center; gap: 1rem; }
.wind-rose { width: 92px; height: 92px; flex: none; }
.wind-rose .ring { fill: none; stroke: var(--line); stroke-width: 2; }
.wind-rose text { fill: var(--muted); font-size: 11px; text-anchor: middle; dominant-baseline: middle; }
.wind-rose .arrow { fill: var(--accent); transition: transform .6s; }
.wind-main { display: flex; flex-direction: column; }
.wind-main .big { font-size: 1.6rem; font-weight: 700; }
.wind-hours { display: flex; gap: .4rem; overflow-x: auto; margin-top: .8rem; padding-bottom: .2rem; }
.wind-hours div { flex: none; text-align: center; font-size: .75rem; background: var(--card2); border-radius: 8px; padding: .3rem .45rem; min-width: 48px; }
.wind-hours svg { width: 18px; height: 18px; fill: var(--accent); display: block; margin: .15rem auto; }

/* Galerie */
.filters { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; align-items: end; }
.filters select { grid-column: 1 / -1; }
.filters .date { flex-direction: row; align-items: center; gap: .3rem; }
.filters .date span { font-size: .8rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 4px; }
.grid .day { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); padding: .6rem 0 .2rem; }
.tile { position: relative; aspect-ratio: 4/3; background: var(--card2); border: 0; padding: 0; cursor: pointer; overflow: hidden; border-radius: 4px; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .t { position: absolute; right: 4px; bottom: 3px; font-size: .7rem; background: rgba(0,0,0,.6); color: #fff; border-radius: 4px; padding: 0 .3rem; }
.tile .chk { position: absolute; left: 5px; top: 5px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff;
  background: rgba(0,0,0,.35); display: none; }
.selecting .tile .chk { display: block; }
.tile.sel .chk { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--accent-ink); }
.tile.sel img { opacity: .6; }
.selbar { position: fixed; left: 0; right: 0; bottom: var(--tabbar-h); z-index: 950; display: flex; justify-content: space-between;
  align-items: center; padding: .6rem 1rem; background: var(--bg2); border-top: 1px solid var(--line); }

/* Vollbild-Viewer */
.viewer { position: fixed; inset: 0; z-index: 2000; background: #000; display: flex; flex-direction: column; touch-action: none; }
.viewer[hidden] { display: none; }
.v-top { display: flex; align-items: center; gap: .5rem; padding: calc(env(safe-area-inset-top) + .4rem) .5rem .4rem;
  background: rgba(0,0,0,.6); position: absolute; top: 0; left: 0; right: 0; z-index: 3; }
.v-info { flex: 1; display: flex; flex-direction: column; font-size: .85rem; min-width: 0; }
.v-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-btn { background: none; border: 0; color: #fff; font-size: 1.4rem; width: 44px; height: 44px; display: flex;
  align-items: center; justify-content: center; text-decoration: none; cursor: pointer; border-radius: 50%; }
.v-stage { flex: 1; overflow: hidden; position: relative; }
.v-track { display: flex; height: 100%; will-change: transform; }
.v-slide { flex: 0 0 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.v-slide img, .v-slide video { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; user-select: none; -webkit-user-drag: none; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; background: rgba(0,0,0,.4); color: #fff; border: 0;
  width: 46px; height: 64px; font-size: 2rem; cursor: pointer; }
.v-nav.prev { left: 0; border-radius: 0 10px 10px 0; } .v-nav.next { right: 0; border-radius: 10px 0 0 10px; }
@media (hover: none) { .v-nav { display: none; } }

/* Karte */
body.mapmode .content { max-width: none; padding: 0; }
#map { position: fixed; top: calc(env(safe-area-inset-top) + 52px); left: 0; right: 0; bottom: var(--tabbar-h); z-index: 1; background: var(--bg); }
.map-panel { position: fixed; left: .6rem; right: .6rem; bottom: calc(var(--tabbar-h) + .6rem); z-index: 600;
  background: rgba(18,18,18,.9); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem; display: flex; flex-direction: column; gap: .5rem; }
.map-hint { font-size: .8rem; color: var(--muted); }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .1rem; }
.chip { flex: none; font: inherit; font-size: .85rem; border: 1px solid var(--line2); background: var(--card2); color: var(--text);
  border-radius: 999px; padding: .35rem .8rem; cursor: pointer; }
.chip.unplaced { border-style: dashed; color: var(--muted); }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.map-wind { position: fixed; top: calc(env(safe-area-inset-top) + 64px); right: .6rem; z-index: 600; background: rgba(18,18,18,.9); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem .6rem; display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.map-wind svg { width: 36px; height: 36px; }
.map-wind .arrow { fill: var(--accent); }
.cam-marker { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; background: #0a0a0a; border: 2px solid #fff;
  transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.cam-marker::after { content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%; background: #fff; left: 8px; top: 8px; }
.revier-marker { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #0a0a0a; background: #fff; box-shadow: 0 0 0 5px rgba(255,255,255,.35); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--text); }
.leaflet-popup-content img { width: 180px; border-radius: 8px; display: block; margin-top: .4rem; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-attribution { font-size: 10px; }

/* Kartenumschalter */
.leaflet-control-layers { background: rgba(18,18,18,.92); color: var(--text); border: 1px solid var(--line) !important; border-radius: 10px !important; }
.leaflet-control-layers-toggle { filter: invert(1); }
.leaflet-control-layers-expanded { padding: .5rem .7rem; font-size: .9rem; }
.leaflet-control-layers label { flex-direction: row; color: var(--text); font-size: .9rem; padding: .2rem 0; }
.leaflet-bar a { background: rgba(18,18,18,.92); color: var(--text); border-bottom-color: var(--line); }
.leaflet-bar a:hover { background: #262626; color: var(--text); }
.leaflet-control-attribution { background: rgba(10,10,10,.7) !important; color: #bbb; }
.leaflet-control-attribution a { color: #ddd; }
