/* Feuerwehr Leader – optimiert für Tablets (Querformat), funktioniert auch im Hochformat und auf Smartphones. */

:root {
  --bg: #14171b;
  --panel: #1c2127;
  --panel-2: #272e36;
  --panel-3: #323a44;
  --line: #343c46;
  --text: #eef1f4;
  --muted: #9aa6b2;
  --accent: #e30613;
  --ok: #22c55e;
  --focus: #60a5fa;
  --danger: #f87171;

  --btn: 48px;
  --sb-w: 330px;
  --radius: 12px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);

  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.i {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- Werkzeugleiste ---------- */

.toolbar {
  position: relative;
  z-index: 1100;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: calc(6px + var(--safe-t)) calc(8px + var(--safe-r)) 6px calc(8px + var(--safe-l));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-tools, .tb-ap { padding: 0 6px; border-left: 1px solid var(--line); }
.tb-spacer { flex: 1; }

.tb-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--btn);
  height: var(--btn);
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
}
.tb-btn:not(:disabled):active { background: var(--panel-3); }
.tb-btn.active { background: var(--panel-2); box-shadow: inset 0 0 0 2px var(--focus); }
.tb-btn.small { width: 40px; height: 40px; }

.badge {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
}

.pen .swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .28);
  transition: transform .12s;
}
.pen.active { box-shadow: none; background: var(--panel-2); }
.pen.active .swatch {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px var(--panel-2), 0 0 0 5px #fff;
}

/* Absprachepunkte in der Leiste */
.ap-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 56px;
  height: var(--btn);
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  touch-action: none;
}
.ap-btn:active, .ap-btn.active { background: var(--panel-2); }
.ap-btn.active { box-shadow: inset 0 0 0 2px var(--focus); }
.ap-short { font-size: 11px; font-weight: 700; line-height: 1; white-space: nowrap; letter-spacing: .01em; }
.ap-btn .ap-badge {
  position: absolute;
  top: 1px;
  right: 6px;
  display: none;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--ok);
  color: #052e12;
}
.ap-btn .ap-badge .i { width: 12px; height: 12px; stroke-width: 3.5; }
.ap-btn.done .ap-badge { display: grid; }
.ap-btn.placed .ap-ico { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px rgba(255, 255, 255, .7); }
.ap-progress {
  min-width: 38px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

/* Signaturen nach FKS: farbige Umrisse auf weissem Grund */
.sig { display: block; flex: none; overflow: visible; }
.ap-ico {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #fff;
  color: var(--c);
  flex: none;
}
.ap-ico .sig { width: 24px; height: 24px; }

/* ---------- Hauptbereich ---------- */

.main { position: relative; flex: 1; display: flex; min-height: 0; }

.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: #e6eaee; }

/* ---------- Seitenleiste ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  flex: none;
  width: var(--sb-w);
  background: var(--panel);
  border-right: 1px solid var(--line);
  transition: margin-left .22s ease;
  z-index: 950;
}
body.sb-collapsed .sidebar { margin-left: calc(-1 * var(--sb-w) - 1px); }

.sb-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 12px 8px calc(12px + var(--safe-l));
}

/* ---------- Ereignis-Rubriken ---------- */

/* Farbe der gewählten Rubrik als Linie unter der Werkzeugleiste */
.toolbar { box-shadow: inset 0 -3px 0 var(--ev, transparent); }

.ev-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  margin-bottom: 10px;
  padding: 0 12px;
  border: 1px solid var(--ev, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--ev, var(--panel-2)) 18%, var(--panel-2));
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  text-align: left;
}
.ev-chip .i { width: 26px; height: 26px; color: var(--ev, var(--muted)); }
.ev-chip-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-chip-change { color: var(--muted); font-size: 13px; font-weight: 600; }

.ev-bar {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 800;
  display: flex;
  gap: 8px;
  max-width: calc(100% - 24px);
}
.ev-bar[hidden] { display: none; }
.ev-badge, .ev-tool {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 14px 0 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 23, 27, .92);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.ev-badge { box-shadow: inset 0 0 0 2px var(--ev), 0 2px 10px rgba(0, 0, 0, .35); }
.ev-badge .i { width: 22px; height: 22px; color: var(--ev); }
.ev-tool { background: var(--ev); color: #05202e; }
.ev-tool .i { width: 22px; height: 22px; }
.ev-badge:active, .ev-tool:active { filter: brightness(1.15); }

.ev-dialog { width: min(560px, calc(100vw - 24px)); }
.ev-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px 20px 20px; overflow-y: auto; }
.ev-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 132px;
  padding: 14px 8px;
  border: 2px solid color-mix(in srgb, var(--ev) 55%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--ev) 14%, var(--panel-2));
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}
/* Brandfall (häufigstes Ereignis) als grosse Kachel zuoberst, die übrigen darunter im Raster */
.ev-tile[data-id="brand"] { grid-column: 1 / -1; order: -1; flex-direction: row; gap: 18px; min-height: 150px; font-size: 26px; }
.ev-tile[data-id="brand"] .ev-icon { width: 84px; height: 84px; }
.ev-tile[data-id="brand"] .ev-icon .i { width: 50px; height: 50px; }
.ev-tile.current { border-color: var(--ev); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ev) 40%, transparent); }
.ev-tile:active { filter: brightness(1.15); }
.ev-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: var(--ev); color: #fff; }
.ev-icon .i { width: 34px; height: 34px; }
@media (max-width: 420px) {
  .ev-grid { gap: 10px; padding: 12px; }
  .ev-tile { min-height: 116px; font-size: 16px; }
  .ev-tile[data-id="brand"] { min-height: 128px; font-size: 22px; }
  .ev-tile[data-id="brand"] .ev-icon { width: 70px; height: 70px; }
}
@media (max-width: 380px) {
  .ev-tile { font-size: 14.5px; }
}
/* Handy quer: Brandfall oben, die übrigen vier in einer Reihe */
@media (max-height: 560px) and (min-width: 560px) {
  .dialog.ev-dialog { width: min(760px, calc(100vw - 24px)); }
  .ev-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 12px 16px 16px; }
  .ev-tile { min-height: 100px; gap: 6px; font-size: 15px; }
  .ev-icon { width: 46px; height: 46px; }
  .ev-icon .i { width: 28px; height: 28px; }
  .ev-tile[data-id="brand"] { min-height: 100px; font-size: 22px; }
  .ev-tile[data-id="brand"] .ev-icon { width: 64px; height: 64px; }
  .ev-tile[data-id="brand"] .ev-icon .i { width: 38px; height: 38px; }
}
/* Schmale Karte: Werkzeug-Hinweis unter die Ereignis-Leiste */
@media (max-width: 600px) {
  .mode-hint { top: 60px; }
}

.sb-mission input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 17px;
  font-weight: 600;
}
.sb-mission input::placeholder { color: var(--muted); font-weight: 400; }
.mission-times {
  display: flex;
  justify-content: space-between;
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 14px;
}
.mission-times b { color: var(--text); font-variant-numeric: tabular-nums; margin-left: 4px; }

.sb-section { margin-top: 18px; }
.sb-head { display: flex; align-items: center; gap: 8px; margin: 0 2px 8px; }
.sb-head h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.link-btn {
  margin-left: auto;
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--focus);
  font-size: 15px;
  font-weight: 600;
}
.sb-hint { margin: 8px 4px 0; color: var(--muted); font-size: 12.5px; }

.ap-list, .cl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.ap-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 4px 8px 4px 4px;
  border-radius: 10px;
  background: var(--panel-2);
}
.ap-row .ap-ico { width: 34px; height: 34px; border-radius: 8px; touch-action: none; cursor: grab; }
.ap-row .ap-ico .sig { width: 30px; height: 30px; }
.ap-name {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  background: none;
  text-align: left;
  font-weight: 600;
  line-height: 1.2;
}
.ap-name small { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.ap-row.done .ap-name small { color: #86efac; }

.chk {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border: 2px solid #6b7785;
  border-radius: 8px;
  background: transparent;
  color: transparent;
  padding: 0;
}
.chk .i { width: 20px; height: 20px; stroke-width: 3; }
button.chk { width: 44px; height: 44px; border: 0; position: relative; }
button.chk::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2px solid #6b7785;
  border-radius: 8px;
}
button.chk .i { position: relative; }
.done .chk { color: #052e12; }
.done span.chk { background: var(--ok); border-color: var(--ok); }
.done button.chk::before { background: var(--ok); border-color: var(--ok); }

.cl-row { border-radius: 10px; background: var(--panel-2); }
.cl-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 12px 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
}
.cl-text { flex: 1; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.cl-row.done .cl-text { color: var(--muted); }
.cl-row time { color: #86efac; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cl-row.editing { display: flex; align-items: center; gap: 2px; padding: 4px; }
.cl-row.editing input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.cl-empty { padding: 14px; color: var(--muted); text-align: center; font-size: 14px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
}
.icon-btn:active { background: var(--panel-3); }
.icon-btn.danger { color: var(--danger); }

.cl-add { display: flex; gap: 6px; margin-top: 8px; }
.cl-add input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px dashed #4b5562;
  border-radius: 10px;
  background: transparent;
}
.cl-add input::placeholder { color: var(--muted); }
.cl-add .tb-btn { width: 44px; height: 44px; background: var(--panel-2); }

.sb-footer {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-b)) calc(12px + var(--safe-l));
  border-top: 1px solid var(--line);
}
.sb-footer .btn { flex: 1; min-width: 0; padding: 0 8px; }

.backdrop { display: none; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--panel-2);
  font-weight: 600;
}
.btn .i { width: 20px; height: 20px; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-ok { background: var(--ok); color: #052e12; }
.btn-ghost { background: var(--panel-2); }
.btn-danger-outline { background: transparent; border-color: rgba(248, 113, 113, .55); color: var(--danger); }

/* ---------- Karte: Bedienelemente ---------- */

.map-ctrl {
  position: absolute;
  right: calc(12px + var(--safe-r));
  bottom: calc(30px + var(--safe-b));
  z-index: 800;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fab {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: rgba(28, 33, 39, .94);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.fab:active { background: var(--panel-3); }
.fab-group { display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.fab-group .fab { border-radius: 0; box-shadow: none; }
.fab-group .fab + .fab { border-top: 1px solid var(--line); }
#btn-locate.has-fix { color: #60a5fa; }

.mode-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  padding: 5px 5px 5px 14px;
  border-radius: 999px;
  background: rgba(20, 23, 27, .92);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .35);
  transform: translateX(-50%);
  user-select: none;
  -webkit-user-select: none;
}
.mode-hint[hidden] { display: none; }
.mode-hint.with-color::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .6);
}
.mode-hint-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint-btn {
  flex: none;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(248, 113, 113, .18);
  color: #fecaca;
  font-size: 13px;
  font-weight: 700;
}
.hint-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.hint-close .i { width: 20px; height: 20px; }

/* Suche */
.search-panel {
  position: absolute;
  top: 10px;
  right: calc(10px + var(--safe-r));
  z-index: 850;
  width: min(400px, calc(100% - 20px));
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
  overflow: hidden;
}
.search-panel[hidden] { display: none; }
.search-field { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; }
.search-field > .i { color: var(--muted); }
.search-field input {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 0;
  background: transparent;
  font-size: 17px;
  outline: none;
}
.search-results { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.search-results:not(:empty) { border-top: 1px solid var(--line); }
.search-hit {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 8px 12px;
  border: 0;
  background: none;
  text-align: left;
}
.search-hit:active { background: var(--panel-2); }
.search-hit .i { color: var(--accent); }
.search-hit small { display: block; color: var(--muted); font-size: 12.5px; }
.search-msg { padding: 14px; color: var(--muted); font-size: 14px; }

/* ---------- Karte: Leaflet-Anpassungen ---------- */

.leaflet-container { font: inherit; background: #e6eaee; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.leaflet-container.mode-draw { touch-action: none !important; cursor: crosshair; }
.leaflet-container[data-mode="eraser"] { cursor: cell; }
.leaflet-container[data-mode="place"] { cursor: copy; }
.leaflet-control-attribution { font-size: 11px; }
.leaflet-bottom.leaflet-left { margin-bottom: var(--safe-b); }
.leaflet-bottom.leaflet-right { margin-bottom: var(--safe-b); margin-right: var(--safe-r); }

.leaflet-popup-content-wrapper { border-radius: 14px; background: var(--panel); color: var(--text); }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 14px 16px; font-size: 15px; }
.leaflet-container a.leaflet-popup-close-button { width: 32px; height: 32px; font: 24px/32px sans-serif; color: var(--muted); }
.pp-title { font-weight: 700; font-size: 16px; padding-right: 18px; }
.pp-sub { margin-top: 2px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pp-actions { display: flex; gap: 8px; margin-top: 12px; }
.pp-actions .btn { flex: 1; padding: 0 10px; }

/* Absprache-Symbol auf der Karte */
.ap-marker { background: none; border: 0; }
.ap-pin { position: relative; width: 60px; height: 50px; }
.ap-pin-box {
  position: absolute;
  inset: 0 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid rgba(0, 0, 0, .25);
  border-radius: 8px;
  background: #fff;
  color: var(--c);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}
.ap-pin-box .sig { width: 26px; height: 26px; }
.ap-pin-box span { font-size: 9.5px; font-weight: 800; line-height: 1; white-space: nowrap; }
.ap-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  border-style: solid;
  border-width: 11px 8px 0;
  border-color: #fff transparent transparent;
  transform: translateX(-50%);
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .35));
}
.ap-pin-done {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--ok);
  color: #052e12;
}
.ap-pin-done .i { width: 13px; height: 13px; stroke-width: 3.5; }

.ap-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 3000;
  pointer-events: none;
  opacity: .75;
}
.ap-ghost .ap-pin { transform: translate(-50%, -100%) scale(1.1); transform-origin: 50% 100%; }
.ap-ghost.over-map { opacity: 1; }

/* Rettungsachse */
.axis-head { background: none; border: 0; }
.axis-head svg { width: 30px; height: 30px; fill: #00a651; stroke: #fff; stroke-width: 1.6; stroke-linejoin: round; overflow: visible; }
.axis-r {
  display: grid;
  place-items: center;
  border: 2px solid #00a651;
  border-radius: 50%;
  background: #fff;
  color: #00a651;
  font: 800 12px/1 Arial, Helvetica, sans-serif;
}

/* Eigener Standort */
.loc-dot { background: none; border: 0; }
.loc-dot span {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
  margin: 2px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 1px 5px rgba(0, 0, 0, .4);
}
.loc-dot span::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, .55);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  from { transform: scale(.6); opacity: 1; }
  to { transform: scale(1.6); opacity: 0; }
}

/* Suchergebnis */
.search-pin { background: none; border: 0; }
.search-pin span {
  display: block;
  width: 26px;
  height: 26px;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: var(--accent);
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}
.search-tip.leaflet-tooltip { font-weight: 600; }

/* ---------- Popover, Toast, Dialog ---------- */

.popover {
  position: fixed;
  z-index: 2500;
  min-width: 200px;
  max-width: calc(100vw - 16px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
.pop-title { margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.pop-list { display: flex; flex-direction: column; gap: 4px; }
.pop-item {
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--panel-2);
  text-align: left;
  font-weight: 600;
}
.pop-item.active { box-shadow: inset 0 0 0 2px var(--focus); }
.pop-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: 14px; color: var(--muted); }
.pop-row input[type="range"] { flex: 1; max-width: 150px; }

.swatch-grid { display: grid; grid-template-columns: repeat(5, 40px); gap: 8px; }
.swatch-grid.inline { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.swatch-grid.inline .swatch-btn { width: 32px; height: 32px; }
.swatch-btn.active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px #fff; }

input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  z-index: 4000;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(20, 23, 27, .95);
  color: #fff;
  font-size: 15px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.dialog {
  width: min(600px, calc(100vw - 24px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
}
.dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dlg-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 40px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-body { overflow-y: auto; padding: 4px 20px 20px; }
.dlg-section { padding-top: 16px; }
.dlg-section h3 { margin: 0 0 6px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.dlg-hint { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.set-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.set-label { width: 92px; font-weight: 600; }
.set-row input[type="range"] { flex: 1; min-width: 140px; }
.width-preview { width: 48px; height: var(--w); border-radius: 99px; background: var(--text); }
.ap-label-row input[type="text"] {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.ap-label-row input.short { flex: 0 0 96px; }

/* ---------- Hochformat / schmale Bildschirme ---------- */

@media (orientation: portrait), (max-width: 860px) {
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(var(--sb-w), 88vw);
    margin-left: 0 !important;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, .4);
    z-index: 1060; /* über den Leaflet-Bedienelementen */
  }
  body.sb-open .sidebar { transform: none; }
  .backdrop { position: absolute; inset: 0; z-index: 1050; background: rgba(0, 0, 0, .35); }
  body.sb-open .backdrop { display: block; }
}

/* Tablets quer (iPad 1024–1194 px): Leiste kompakter, damit sie einzeilig bleibt */
@media (min-width: 1011px) and (max-width: 1240px) {
  :root { --btn: 44px; }
  .toolbar { column-gap: 6px; }
  .ap-btn { width: 50px; }
  .ap-progress { display: none; }
}
@media (min-width: 1011px) and (max-width: 1100px) {
  :root { --btn: 42px; }
  .ap-btn { width: 46px; }
}

/* Absprachepunkte in eine zweite Zeile, wenn die Breite nicht reicht */
@media (max-width: 1010px) {
  .tb-ap {
    order: 10;
    flex-basis: 100%;
    justify-content: center;
    padding: 4px 0 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 520px) {
  :root { --btn: 42px; }
  .toolbar { gap: 4px; padding-left: calc(4px + var(--safe-l)); padding-right: calc(4px + var(--safe-r)); }
  .tb-group { gap: 2px; }
  .tb-tools { padding: 0 2px; }
  .tb-ap { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .tb-ap::-webkit-scrollbar { display: none; }
  .ap-btn { width: 52px; flex: none; touch-action: pan-x; }
  .pen .swatch { width: 26px; height: 26px; }
  .mode-hint { top: 8px; font-size: 13px; }
}

@media (max-width: 400px) {
  :root { --btn: 39px; }
  .ap-btn { width: 50px; }
}

/* ---------- Aufnahme (Sprachjournal) ---------- */

.tb-btn.rec { width: auto; min-width: var(--btn); padding: 0 12px; gap: 8px; display: flex; align-items: center; justify-content: center; }
.rec-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, .28);
}
.rec-time { display: none; font-weight: 800; font-variant-numeric: tabular-nums; }
.tb-btn.rec.recording { background: var(--accent); color: #fff; }
.tb-btn.rec.recording .rec-dot {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: #fff;
  box-shadow: none;
  animation: rec-blink 1.2s ease-in-out infinite;
}
.tb-btn.rec.recording .rec-time { display: inline; }
@keyframes rec-blink { 50% { opacity: .35; } }

.jr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.jr-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px 6px 6px;
  border-radius: 10px;
  background: var(--panel-2);
}
.jr-row.playing { box-shadow: inset 0 0 0 2px var(--focus); }
.jr-play {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--panel-3);
}
.jr-play .i { width: 20px; height: 20px; stroke: none; }
.jr-main { flex: 1; min-width: 0; }
.jr-meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.jr-meta b { color: var(--text); }
.jr-note {
  width: 100%;
  height: 32px;
  margin-top: 3px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: rgba(0, 0, 0, .18);
  font-size: 16px; /* < 16px würde iOS beim Antippen hineinzoomen */
}
.jr-note:focus { border-color: var(--line); }
.jr-note::placeholder { color: #6f7a86; }
#jr-export { display: inline-flex; align-items: center; gap: 4px; }
#jr-export .i { width: 18px; height: 18px; }

/* ---------- Offline-Karten ---------- */

.offline-frame {
  position: absolute;
  top: 64px;
  left: 8%;
  right: 8%;
  bottom: 40%;
  z-index: 700;
  border: 3px dashed #fff;
  border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(10, 14, 20, .42), inset 0 0 0 1px rgba(0, 0, 0, .35);
  pointer-events: none;
}
.offline-frame[hidden] { display: none; }

.offline-panel {
  position: absolute;
  left: 50%;
  bottom: calc(12px + var(--safe-b));
  z-index: 860;
  width: min(560px, calc(100% - 24px));
  max-height: 60%;
  overflow-y: auto;
  padding: 10px 14px 14px;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  transform: translateX(-50%);
}
.offline-panel[hidden] { display: none; }
body.offline-select .mode-hint { display: none; }
.off-head { display: flex; align-items: center; justify-content: space-between; }
.off-head h2 { margin: 0; font-size: 17px; }
.off-hint { margin: 4px 0 10px; color: var(--muted); font-size: 13.5px; }
.off-row { margin-bottom: 10px; }
.off-row input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  font-weight: 600;
}
.off-row.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}
.chip .i { width: 18px; height: 18px; stroke-width: 3; opacity: .2; }
.chip.on { background: rgba(37, 99, 235, .2); border-color: #2563eb; }
.chip.on .i { opacity: 1; }
.off-estimate { margin-bottom: 10px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.off-estimate.warn, small.warn { color: #fca5a5; }
.off-start { width: 100%; }
.off-progress { margin-bottom: 10px; }
.off-progress .bar { height: 10px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.off-progress .bar span { display: block; height: 100%; background: #22c55e; transition: width .25s; }
.off-progress-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 13px; }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 13px; }
.off-saved { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.off-saved summary { padding: 6px 0; font-weight: 700; cursor: pointer; }
.off-usage { color: var(--muted); font-weight: 400; font-size: 13px; }
.off-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.off-area { display: flex; align-items: center; gap: 4px; padding: 6px 4px 6px 10px; border-radius: 10px; background: var(--panel-2); }
.off-area-text { flex: 1; min-width: 0; }
.off-area-text b { display: block; }
.off-area-text small { display: block; color: var(--muted); font-size: 12.5px; }
.area-label.leaflet-tooltip { background: rgba(22, 163, 74, .9); color: #fff; border: 0; font-weight: 700; box-shadow: none; }
.area-label.leaflet-tooltip::before { display: none; }

.dl-pill, .net-pill {
  position: absolute;
  left: 12px;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 23, 27, .92);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.dl-pill { top: 100px; }
.dl-pill[hidden] { display: none; }
.dl-pill .i { width: 18px; height: 18px; color: #22c55e; }
.net-pill { top: 60px; display: none; background: #92400e; }
body.is-offline .net-pill { display: flex; }

/* ---------- Toolbar-Umbruch ---------- */
.tb-break { display: none; }

@media (max-width: 520px) {
  .tb-spacer { display: none; }
  .tb-break { display: block; order: 9; flex-basis: 100%; height: 0; }
  .tb-ap { order: 10; flex: 1 1 0; min-width: 0; border-top: 0; padding-top: 0; }
  .tb-right { order: 11; }
  .tb-btn.rec { padding: 0 8px; }
  .rec-dot { width: 20px; height: 20px; }
  .offline-panel { width: calc(100% - 16px); max-height: 55%; }
  body.offline-select .map-ctrl { display: none; }
}

@media (max-height: 520px) {
  .fab-group { display: none; }
  .fab { width: 46px; height: 46px; }
}

/* ---------- Notizblock ---------- */

.notes, .regs {
  position: absolute;
  inset: 0;
  z-index: 1010; /* über den Leaflet-Bedienelementen, unter Schublade und Leiste */
  display: flex;
  flex-direction: column;
  background: #dfe4ea;
}
.notes[hidden], .regs[hidden] { display: none; }
.notes-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.notes-head h2 { margin: 0; font-size: 16px; }
.notes-hint { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes-head .btn .i { width: 18px; height: 18px; }
.notes-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px calc(12px + var(--safe-b));
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.notes-scroll[data-tool="pen"], .notes-scroll[data-tool="eraser"] { touch-action: none; cursor: crosshair; }
.notes-scroll[data-tool="eraser"] { cursor: cell; }
.notes-paper {
  position: relative;
  max-width: 1000px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08), 0 4px 18px rgba(0, 0, 0, .12);
}
.notes-paper canvas { position: sticky; top: 0; display: block; }
body.notes-open .tb-ap, body.regs-open .tb-ap { opacity: .35; pointer-events: none; }

@media (max-width: 520px) {
  .notes-hint { display: none; }
  .notes-head h2 { flex: 1; }
}

/* ---------- Reglemente ---------- */

.regs { background: var(--bg); }
.regs-search {
  flex: 1;
  min-width: 80px;
  max-width: 320px;
  height: 38px;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}
.regs .btn .i { width: 18px; height: 18px; }
.regs-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 14px calc(16px + var(--safe-b)); }
.regs-status { max-width: 900px; margin: 0 auto 10px; color: var(--muted); font-size: 13.5px; }
.regs-source { max-width: 900px; margin: 16px auto 0; color: var(--muted); font-size: 12.5px; }
.regs-source a { color: var(--focus); }
.regs-list { list-style: none; max-width: 900px; margin: 0 auto; padding: 0; }
.reg-group h3 { margin: 16px 2px 6px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.reg-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.reg-row { display: flex; align-items: center; gap: 6px; min-height: 56px; padding: 4px 6px 4px 4px; border-radius: 10px; background: var(--panel); }
.reg-name { flex: 1; min-width: 0; padding: 8px 4px; border: 0; background: none; text-align: left; font-weight: 600; line-height: 1.25; }
.reg-name em { margin-left: 8px; padding: 1px 6px; border-radius: 6px; background: rgba(34, 197, 94, .18); color: #86efac; font-size: 11px; font-style: normal; font-weight: 700; vertical-align: 1px; }
.reg-name small { display: block; margin-top: 3px; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.reg-row.saved .reg-name small { color: #86efac; }
.reg-name .bar { display: block; height: 6px; margin-top: 6px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.reg-name .bar span { display: block; height: 100%; background: #22c55e; transition: width .25s; }
.reg-row.saved button.chk::before, .reg-row button.chk[aria-checked="true"]::before { background: var(--ok); border-color: var(--ok); }
.reg-row button.chk[aria-checked="true"] { color: #052e12; }

@media (max-width: 700px) {
  .regs .notes-head { flex-wrap: wrap; }
  .regs-search { order: 5; flex-basis: 100%; max-width: none; margin: 4px 0 2px; }
  #regs-check { margin-left: auto; }
}

/* ---------- PDF-Reader ---------- */

/* Ganzer Bildschirm: über Leiste und Seitenleiste, unter Popups und Meldungen */
.reader { position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column; background: #4b5058; }
.reader-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: calc(6px + var(--safe-t)) calc(10px + var(--safe-r)) 6px calc(10px + var(--safe-l));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.reader-head h2 { flex: 1 1 160px; min-width: 0; margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.reader-pages { display: inline-flex; align-items: center; gap: 4px; margin-right: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
.reader-pages input {
  width: 64px;
  height: 38px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  text-align: center;
  font-size: 16px;
}
.reader-find { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; }
.reader-find input {
  width: 190px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 16px;
}
#reader-find-info { min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; }
.reader-body { position: relative; flex: 1; min-height: 0; }
.reader-scroll { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; }
.reader-scroll .pdfViewer { padding: 10px 0 calc(16px + var(--safe-b)); }
.reader-scroll .pdfViewer .page { margin: 0 auto 10px; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.reader-msg {
  position: absolute;
  left: 50%;
  top: 36%;
  width: min(440px, calc(100% - 32px));
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(20, 23, 27, .94);
  color: #fff;
  transform: translate(-50%, -50%);
}
.reader-msg p { margin: 0; font-weight: 600; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere; }
.reader-bar { height: 6px; margin-top: 12px; overflow: hidden; border-radius: 3px; background: rgba(255, 255, 255, .15); }
.reader-bar span { display: block; height: 100%; background: #3b82f6; transition: width .3s; }
.reader-msg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.reader-msg-actions:empty { display: none; }
.reader-msg-actions .btn { flex: 1 1 auto; }
.toc { width: min(420px, calc(100vw - 32px)); }
.toc-list { display: flex; flex-direction: column; max-height: 60vh; overflow-y: auto; }
.toc-item { padding: 9px 10px; border: 0; border-radius: 8px; background: none; text-align: left; font-size: 14px; }
.toc-item:active { background: var(--panel-2); }

@media (max-width: 700px) {
  .reader-tools { width: 100%; }
  .reader-find { flex: 1; }
  .reader-find input { flex: 1; width: auto; min-width: 0; }
}

/* ---------- Fotojournal ---------- */

.ph-list { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; padding: 0; }
.ph-list .ph-empty { grid-column: 1 / -1; }
.ph-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: var(--panel-2);
}
.ph-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-time {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ph-note-mark { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(0, 0, 0, .65); color: #fff; }
.ph-note-mark .i { width: 13px; height: 13px; }

/* Kamera: ganzer Bildschirm */
.camera { position: fixed; inset: 0; z-index: 2100; background: #000; color: #fff; }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.camera video.mirror { transform: scaleX(-1); }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: cam-flash .35s ease-out; }
@keyframes cam-flash { from { opacity: .85; } to { opacity: 0; } }
.cam-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) 10px calc(12px + var(--safe-l));
  background: linear-gradient(rgba(0, 0, 0, .55), transparent);
}
.cam-count { font-weight: 700; font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px #000; }
.cam-round {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(30, 34, 40, .75);
  color: #fff;
}
.cam-round .i { width: 26px; height: 26px; }
.cam-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 16px calc(24px + var(--safe-r)) calc(22px + var(--safe-b)) calc(24px + var(--safe-l));
  background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}
.cam-bar .cam-round { justify-self: end; }
.cam-shutter {
  width: 78px;
  height: 78px;
  padding: 0;
  border: 5px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, .25);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35);
}
.cam-shutter:active { background: rgba(255, 255, 255, .7); transform: scale(.94); }
.cam-last {
  justify-self: start;
  width: 58px;
  height: 58px;
  padding: 0;
  overflow: hidden;
  border: 2px solid #fff;
  border-radius: 10px;
  background: #222;
}
.cam-last[hidden] { display: block; visibility: hidden; }
.cam-last img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-msg { top: 45%; }

/* Foto ansehen: ganzer Bildschirm */
.photo-view { position: fixed; inset: 0; z-index: 2200; display: flex; flex-direction: column; background: #0d0f12; }
.photo-view .reader-head h2 { font-size: 15px; }
.pv-body { position: relative; flex: 1; min-height: 0; }
.pv-body img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pv-foot { padding: 8px calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) calc(10px + var(--safe-l)); background: var(--panel); border-top: 1px solid var(--line); }
.pv-foot input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 16px;
}

/* ---------- Team (Lage teilen) ---------- */

.tm-chip { background: rgba(20, 23, 27, .92); color: #fff; }
.tm-chip[hidden] { display: none; }
.tm-chip b { padding: 2px 8px; border-radius: 999px; background: #fff; color: var(--danger); font-size: 12px; }
.tm-chip.alarm { background: #b91c1c; animation: tm-blink 1s steps(2) infinite; }
.tm-chip.offline .i { opacity: .45; }
@keyframes tm-blink { 50% { background: #7f1d1d; } }
#btn-team.alarm { background: #b91c1c; color: #fff; animation: tm-blink 1s steps(2) infinite; }

/* Team-Fenster: rechts über der Karte (Tablet quer: Karte bleibt links sichtbar), auf dem Handy ganze Breite */
.team-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1020; /* über Leaflet-Bedienelementen, unter der Schublade (Hochformat) */
  display: flex;
  flex-direction: column;
  width: min(400px, 100%);
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 30px rgba(0, 0, 0, .4);
}
.team-panel .notes-head { padding-right: calc(8px + var(--safe-r)); }
.team-panel .notes-head .i { color: var(--muted); }
.tp-space { flex: 1; }
.tp-tabs { display: flex; gap: 6px; padding: 10px calc(12px + var(--safe-r)) 0 12px; }
.tp-tabs button {
  flex: 1;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}
.tp-tabs button[aria-selected="true"] { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 2px var(--focus); }
.tp-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px calc(12px + var(--safe-r)) calc(16px + var(--safe-b)) 12px;
}
.tp-section + .tp-section { margin-top: 22px; }
.sb-head h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 600px) {
  .team-panel { width: 100%; border-left: 0; box-shadow: none; }
}

.tm-status { display: flex; align-items: center; gap: 8px; margin: 0 2px 8px; color: var(--muted); font-size: 13px; }
.tm-status > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-status .link-btn { margin-left: 0; font-size: 13px; }
.tm-conn { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #6b7280; }
.tm-conn.on { background: #22c55e; }
.tm-wide { width: 100%; margin-top: 8px; gap: 8px; }
.tm-mission {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
}
.tm-mission b, .tm-mission small { display: block; }
.tm-mission small { color: var(--muted); font-size: 12px; }
.tm-mission.current { border-left: 4px solid var(--ev, #2563eb); }

.tm-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; }
.tm-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 10px; border-radius: 10px; background: var(--panel-2); }
.tm-row.tm-alarm { box-shadow: inset 0 0 0 2px var(--danger); background: rgba(185, 28, 28, .18); }
.tm-row.tm-off { opacity: .55; }
.tm-light { flex: none; width: 16px; height: 16px; border-radius: 50%; background: #9ca3af; box-shadow: 0 0 0 3px rgba(255, 255, 255, .08); }
.tm-ok .tm-light { background: #22c55e; }
.tm-warn .tm-light { background: #eab308; }
.tm-alarm .tm-light { background: #ef4444; }
.tm-unknown .tm-light { background: transparent; box-shadow: inset 0 0 0 2px #9ca3af; }
.tm-main { flex: 1; min-width: 0; }
.tm-main b, .tm-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-main b em { color: var(--muted); font-style: normal; font-weight: 500; }
.tm-main small { color: var(--muted); font-size: 12px; }
.tm-alarm .tm-age { color: #fca5a5; font-weight: 700; }
.tm-warn .tm-age { color: #fde047; }
.tm-ack { margin-top: 6px; }
.tm-row .icon-btn { flex: none; }
a.icon-btn { color: var(--text); }
.tm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tm-actions .btn { flex: 1 1 auto; gap: 6px; }

/* Kartensymbol: Kreis mit Kürzel, Ring in der Ampelfarbe, Name darunter */
.tm-marker { background: none; border: 0; }
.tm-pin { position: relative; width: 36px; height: 36px; }
.tm-dot {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 4px solid #9ca3af;
  border-radius: 50%;
  background: #1f2937;
  color: #fff;
  font: 700 11px/1 system-ui, sans-serif;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}
.tm-ok .tm-dot { border-color: #22c55e; }
.tm-warn .tm-dot { border-color: #eab308; }
.tm-alarm .tm-dot { border-color: #ef4444; animation: tm-pulse 1.2s ease-in-out infinite; }
.tm-unknown .tm-dot { border-color: #9ca3af; border-style: dashed; opacity: .8; }
@keyframes tm-pulse { 50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, .35); } }
.tm-name {
  position: absolute;
  top: 38px;
  left: 50%;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(17, 24, 39, .85);
  color: #fff;
  font: 700 11px/1.4 system-ui, sans-serif;
  white-space: nowrap;
  transform: translateX(-50%);
}
.tm-st-alarm b { color: #dc2626; }
.tm-st-warn b { color: #ca8a04; }
.tm-call { display: flex; margin-top: 8px; color: #fff !important; text-decoration: none; }

/* Dialoge: Anmelden, Gerät, Verwaltung, QR */
.tm-dialog { width: min(520px, calc(100vw - 24px)); }
.tm-field { display: block; margin-bottom: 10px; }
.tm-field span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.tm-field input, .tm-inline input, .qr-link input, .tm-device select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 16px;
}
.tm-inline { display: flex; gap: 8px; }
.tm-devices { list-style: none; display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; }
.tm-device { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }
.tm-device.blocked { opacity: .6; }
.tm-device .tm-main { flex: 1 1 180px; }
.tm-device select { width: auto; height: 36px; font-size: 14px; }
.qr-dialog { width: min(440px, calc(100vw - 24px)); }
.qr-body { padding: 16px 20px 20px; text-align: center; }
.qr-svg { width: min(320px, 70vw); height: auto; border-radius: 8px; }
.qr-expiry { margin: 4px 0 12px; color: var(--muted); font-size: 13px; }
.qr-link { display: flex; gap: 8px; }
.qr-link input { font-size: 13px; }

/* QR-Scanner: ganzer Bildschirm */
.scanner { position: fixed; inset: 0; z-index: 2300; background: #000; color: #fff; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(64vw, 64vh, 320px);
  aspect-ratio: 1;
  border: 4px solid #fff;
  border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45);
  transform: translate(-50%, -55%);
}
.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px calc(16px + var(--safe-r)) calc(18px + var(--safe-b)) calc(16px + var(--safe-l)); text-align: center; }
.scan-msg { margin: 0 0 10px; font-weight: 700; text-shadow: 0 1px 3px #000; }
.scan-paste { display: flex; gap: 8px; max-width: 520px; margin: 0 auto; }
.scan-paste input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 0; border-radius: 10px; font-size: 16px; }
