/* Lagenetz – Weboberfläche der Zentrale. Hell/Dunkel, Desktop und Tablet/Handy. Keine externen Schriften. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #17202a;
  --muted: #5f6b77;
  --border: #d5dbe1;
  --accent: #1565c0;
  --accent-text: #ffffff;
  --ok: #2e7d32;
  --warn: #b26a00;
  --bad: #c62828;
  --sos: #d50000;
  --top: #1b2a3a;
  --top-text: #f1f5f9;
  --shadow: 0 2px 10px rgba(0, 0, 0, .15);
  --grid: rgba(60, 80, 100, .12);
  --map-bg: #e9ecef;
  --msg-own: #d7e9fb;
  --msg-other: #ffffff;
  --radius: 10px;
  --side-w: 420px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1418; --surface: #182027; --surface-2: #212b34; --text: #e6edf3; --muted: #9aa7b3; --border: #2e3a45;
    --accent: #64b5f6; --accent-text: #0b1620; --ok: #66bb6a; --warn: #ffb74d; --bad: #ef5350; --top: #0b1117;
    --grid: rgba(160, 190, 220, .10); --map-bg: #161c22; --msg-own: #1d3a57; --msg-other: #212b34; --shadow: 0 2px 12px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1418; --surface: #182027; --surface-2: #212b34; --text: #e6edf3; --muted: #9aa7b3; --border: #2e3a45;
  --accent: #64b5f6; --accent-text: #0b1620; --ok: #66bb6a; --warn: #ffb74d; --bad: #ef5350; --top: #0b1117;
  --grid: rgba(160, 190, 220, .10); --map-bg: #161c22; --msg-own: #1d3a57; --msg-other: #212b34; --shadow: 0 2px 12px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: .4em 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85em; }
.warn { color: var(--warn); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; gap: .5rem; align-items: center; }
.row > .field { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.empty { color: var(--muted); padding: 1rem .5rem; text-align: center; list-style: none; }
.error-box { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); padding: .6rem .8rem; border-radius: 8px; margin: .5rem 0; }
.info-box { background: var(--surface-2); padding: .5rem .7rem; border-radius: 8px; margin: .5rem 0; }

/* ---------- Bedienelemente ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 40px; padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; touch-action: manipulation;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); font-weight: 600; }
.btn.small { min-height: 32px; padding: .25rem .6rem; font-size: .88rem; }
.btn.wide { width: 100%; }
.icon-btn { background: none; border: 0; cursor: pointer; font-size: 1.15rem; min-width: 38px; min-height: 38px; border-radius: 8px; color: inherit; }
.icon-btn:hover { background: var(--surface-2); }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-size: inherit; }
input[type=text], input[type=password], input[type=number], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.form { display: flex; flex-direction: column; gap: .75rem; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field-label { font-weight: 600; font-size: .9rem; }
.field-hint { color: var(--muted); font-size: .8rem; }
.check, .radio { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; }
.check input, .radio input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.indent { margin-left: 1.9rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; display: flex; flex-direction: column; gap: .6rem; }
legend { font-weight: 600; padding: 0 .3rem; }
progress { width: 100%; height: 10px; accent-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: .72rem; font-weight: 700; line-height: 18px; text-align: center; }
.status-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; border: 2px solid rgba(255, 255, 255, .8); box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.status-dot.big { width: 18px; height: 18px; }

/* ---------- Einrichtung / Anmeldung ---------- */
.screen { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, var(--top), var(--bg) 60%); }
.card { width: 100%; max-width: 460px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 1.5rem; }
.brand-big { display: flex; gap: .8rem; align-items: center; margin-bottom: 1rem; }
.brand-big h1 { margin: 0; font-size: 1.5rem; }
.steps { display: flex; gap: .4rem; margin: .5rem 0 1rem; }
.step { flex: 1; height: 5px; border-radius: 3px; background: var(--border); }
.step.done { background: var(--ok); }
.step.active { background: var(--accent); }
.wizard-buttons { display: flex; justify-content: space-between; gap: .5rem; margin-top: 1.2rem; }
.wizard-buttons .btn.primary { margin-left: auto; }

/* ---------- Grundlayout ---------- */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
#topbar {
  display: flex; align-items: center; gap: .75rem; padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top));
  background: var(--top); color: var(--top-text); flex: none; min-height: 52px;
}
.brand { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 700; }
.team-name { font-size: .8rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.conn { display: flex; gap: .3rem; flex-wrap: wrap; margin-left: auto; }
.conn-chip { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: rgba(255, 255, 255, .12); display: inline-flex; align-items: center; gap: 4px; }
.conn-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.conn-chip.ok { color: #81c784; }
.conn-chip.warn { color: #ffd54f; }
.conn-chip.bad { color: #ef9a9a; }
.top-actions { display: flex; align-items: center; gap: .4rem; }
.status-select select {
  min-height: 36px; width: auto; padding: .2rem 1.6rem .2rem .6rem; background: rgba(255, 255, 255, .1); color: var(--top-text);
  border: 2px solid var(--st, #43a047); border-radius: 18px; font-weight: 600;
}
.status-select select option { color: var(--text); background: var(--surface); }
.sos-btn {
  min-height: 38px; min-width: 64px; padding: 0 .9rem; border-radius: 19px; border: 2px solid #fff; background: var(--sos); color: #fff;
  font-weight: 800; letter-spacing: .05em; cursor: pointer;
}
.sos-btn.active { animation: pulse 1s infinite; }
.menu-btn { color: var(--top-text); }
.menu-btn:hover { background: rgba(255, 255, 255, .1); }

#main {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-w);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "map tabs" "map side";
}
#map-wrap { grid-area: map; position: relative; min-height: 0; background-color: var(--map-bg); }
#map { position: absolute; inset: 0; }
#tabs { grid-area: tabs; display: flex; background: var(--surface); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
#sidebar { grid-area: side; background: var(--surface); border-left: 1px solid var(--border); min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
#panels { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 4px; min-width: 58px;
  border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer; color: var(--muted); position: relative;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-icon { font-size: 1.15rem; line-height: 1.2; }
.tab-label { font-size: .72rem; font-weight: 600; white-space: nowrap; }
.tab .badge { position: absolute; top: 2px; right: 6px; }
.tab.mobile-only { display: none; }
.collapse-btn { flex: 0 0 40px; min-width: 40px; }

body.sidebar-collapsed #main { grid-template-columns: minmax(0, 1fr) 64px; grid-template-areas: "map tabs" "map tabs"; }
body.sidebar-collapsed #sidebar { display: none; }
body.sidebar-collapsed #tabs { flex-direction: column; overflow-y: auto; border-bottom: 0; }
body.sidebar-collapsed .tab { flex: 0 0 auto; border-bottom: 0; border-left: 3px solid transparent; padding: 10px 2px; }
body.sidebar-collapsed .tab.active { border-left-color: transparent; color: var(--muted); }
body.sidebar-collapsed .collapse-btn .tab-icon { display: inline-block; transform: scaleX(-1); }

/* ---------- Handy / schmales Tablet ---------- */
@media (max-width: 820px) {
  #main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "map" "tabs"; }
  body.sidebar-collapsed #main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "map" "tabs"; }
  body.sidebar-collapsed #sidebar { display: flex; }
  body.sidebar-collapsed #tabs { flex-direction: row; }
  #sidebar { grid-area: map; z-index: 5; border-left: 0; }
  body[data-tab="map"] #sidebar { display: none; }
  #tabs { border-left: 0; border-top: 1px solid var(--border); border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
  .tab { border-bottom: 0; border-top: 3px solid transparent; padding: 6px 2px; min-width: 52px; }
  .tab.active { border-top-color: var(--accent); }
  .tab.mobile-only { display: flex; }
  .collapse-btn { display: none !important; }
  .brand-text .brand-name { display: none; }
  .team-name { font-size: .9rem; font-weight: 600; opacity: 1; max-width: 26vw; }
  #topbar { gap: .4rem; padding-left: 8px; padding-right: 8px; }
  .conn-chip { padding: 2px 6px; font-size: .7rem; }
  .status-select select { max-width: 120px; }
}
@media (max-width: 480px) {
  .conn { display: none; }
  .tab-label { font-size: .64rem; }
  .brand img { width: 24px; height: 24px; }
}

/* ---------- SOS ---------- */
.sos-banner { background: var(--sos); color: #fff; flex: none; animation: sosbg 1.2s infinite alternate; z-index: 20; }
.sos-item { display: flex; align-items: center; gap: .7rem; padding: .5rem 12px; flex-wrap: wrap; }
.sos-item + .sos-item { border-top: 1px solid rgba(255, 255, 255, .35); }
.sos-item.own { background: #8e0000; }
.sos-icon { font-size: 1.6rem; }
.sos-text { flex: 1; min-width: 180px; }
.sos-text b { font-size: 1.1rem; }
.sos-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.sos-actions .btn { background: #fff; color: #b71c1c; border-color: #fff; font-weight: 700; }
.sos-actions .btn.primary { background: #ffeb3b; color: #000; border-color: #ffeb3b; }
@keyframes sosbg { from { background: #d50000; } to { background: #9b0000; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .8); } 50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); } }
@media (prefers-reduced-motion: reduce) { .sos-banner, .sos-btn.active, .map-member.sos .dot { animation: none !important; } }

/* ---------- Karte ---------- */
body.map-nodata #map-wrap, .map-error {
  background-color: var(--map-bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
}
.map-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 2rem; text-align: center; }
.map-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 3; max-width: min(560px, calc(100% - 120px));
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: .45rem .7rem;
  box-shadow: var(--shadow); font-size: .85rem; display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; opacity: .95;
}
.mode-bar {
  position: absolute; left: 50%; bottom: 36px; transform: translateX(-50%); z-index: 4; width: max-content; max-width: calc(100% - 24px);
  background: var(--surface); border: 2px solid var(--accent); border-radius: 12px; padding: .5rem .7rem; box-shadow: var(--shadow);
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: center;
}
.mode-text { font-weight: 600; font-size: .9rem; }
.mode-buttons { display: flex; gap: .4rem; }
.map-tools { position: absolute; left: 10px; top: 10px; z-index: 3; display: flex; flex-direction: column; gap: 4px; }
.map-tool {
  width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-size: 1.1rem; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; color: var(--text);
}
.map-tool:hover { border-color: var(--accent); }
body.map-mode .map-tools { opacity: .5; pointer-events: none; }
.layer-menu { position: absolute; left: 48px; bottom: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .5rem .7rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .4rem; min-width: 170px; }
@media (max-height: 520px) { .map-tools { flex-direction: row; flex-wrap: wrap; max-width: 60%; } .layer-menu { left: 0; top: 48px; bottom: auto; } }

.maplibregl-ctrl-group { background: var(--surface); }
.maplibregl-ctrl-group button + button { border-top-color: var(--border); }
[data-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted); }
[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1); }
.maplibregl-ctrl-attrib a { color: var(--muted); }
.maplibregl-ctrl-scale { background: color-mix(in srgb, var(--surface) 75%, transparent); color: var(--text); border-color: var(--text); }
.maplibregl-popup-content { background: var(--surface); color: var(--text); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; padding: 0 6px; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--surface); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left .maplibregl-popup-tip, .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface); }
.popup { display: flex; flex-direction: column; gap: 3px; min-width: 180px; }
.popup-title { font-weight: 700; font-size: 1rem; display: flex; gap: .4rem; align-items: center; padding-right: 16px; }
.popup-note { white-space: pre-wrap; background: var(--surface-2); padding: 4px 6px; border-radius: 6px; font-size: .88rem; }
.popup-actions { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: 6px; }
.ctx-popup .maplibregl-popup-content { padding: 6px; }
.ctx-menu { display: flex; flex-direction: column; min-width: 200px; }
.ctx-menu .muted { padding: 2px 8px 4px; }
.menu-item { text-align: left; background: none; border: 0; padding: .55rem .6rem; border-radius: 6px; cursor: pointer; color: var(--text); }
.menu-item:hover { background: var(--surface-2); }

/* Kartenobjekte (HTML-Marker) */
.map-member { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.map-member .dot { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .5); display: flex; align-items: center; justify-content: center; font-size: 10px; flex: none; }
.map-member.self .dot { outline: 3px solid var(--accent); }
.map-member .lbl, .map-pin .lbl, .map-task .lbl, .map-shape-label {
  position: absolute; left: 24px; white-space: nowrap; font-size: 12px; background: rgba(255, 255, 255, .92); color: #111;
  padding: 0 5px; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); pointer-events: none;
}
.map-member .lbl small { color: #555; }
.map-member.stale { opacity: .55; }
.map-member.sos .dot { animation: sosdot .8s infinite alternate; }
.map-member.sos .lbl { background: #d50000; color: #fff; font-weight: 700; }
.map-member.sos .lbl small { color: #fff; }
.map-member .heading { position: absolute; left: 4px; top: -9px; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 9px solid #1e88e5; transform-origin: 6px 19px; }
@keyframes sosdot { from { box-shadow: 0 0 0 0 rgba(213, 0, 0, .9); } to { box-shadow: 0 0 0 14px rgba(213, 0, 0, 0); } }
.map-pin { cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.map-pin .pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--c); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5); display: flex; align-items: center; justify-content: center;
}
.map-pin .pin-icon { transform: rotate(45deg); font-size: 17px; line-height: 1; }
.map-pin .lbl { left: 30px; top: 4px; }
.map-task { cursor: pointer; display: flex; align-items: center; }
.map-task .ico { width: 28px; height: 28px; border-radius: 6px; background: #fff; border: 2px solid #757575; display: flex; align-items: center; justify-content: center; font-size: 15px; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.map-task.prio-1 .ico { border-color: #fb8c00; }
.map-task.prio-2 .ico { border-color: #e53935; }
.map-task.state-1 .ico { background: #fff3e0; }
.map-task .lbl { left: 32px; }
.map-photo { cursor: pointer; width: 28px; height: 28px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0, 0, 0, .45); font-size: 15px; }
.map-shape-label { position: static; display: inline-block; width: max-content; max-width: 220px; overflow: hidden; text-overflow: ellipsis; border-left: 4px solid #1e88e5; pointer-events: auto; cursor: pointer; font-weight: 600; }

/* ---------- Seitenleiste allgemein ---------- */
.panel-toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .3rem 0 .6rem; }
.panel-toolbar h3 { margin: 0; flex: 1; }
.panel-toolbar select { width: auto; flex: 1; min-width: 140px; }
.subtabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin: -4px -4px 10px; padding: 0 4px; overflow-x: auto; }
.subtab { background: none; border: 0; border-bottom: 3px solid transparent; padding: .5rem .6rem; cursor: pointer; color: var(--muted); font-weight: 600; white-space: nowrap; }
.subtab.active { color: var(--accent); border-bottom-color: var(--accent); }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; white-space: nowrap; min-height: 34px; color: var(--text);
}
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ---------- Chat ---------- */
#panel-chat { display: flex; flex-direction: column; padding: 0; }
#panel-chat[hidden] { display: none; }
.chat-peers { display: flex; gap: .35rem; padding: 8px; overflow-x: auto; border-bottom: 1px solid var(--border); flex: none; scrollbar-width: thin; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.chat-date { align-self: center; font-size: .75rem; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 1px 10px; margin: 6px 0; }
.load-older { align-self: center; }
.msg { max-width: 85%; align-self: flex-start; background: var(--msg-other); border: 1px solid var(--border); border-radius: 12px 12px 12px 3px; padding: 5px 9px; position: relative; }
.msg.own { align-self: flex-end; background: var(--msg-own); border-radius: 12px 12px 3px 12px; }
.msg-from { font-size: .78rem; font-weight: 700; color: var(--accent); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-quote { font-size: .8rem; border-left: 3px solid var(--accent); padding-left: 6px; margin-bottom: 3px; color: var(--muted); }
.msg-meta { font-size: .7rem; color: var(--muted); text-align: right; display: flex; gap: .3rem; justify-content: flex-end; align-items: center; }
.delivery.d-read { color: var(--accent); font-weight: 700; }
.delivery.d-delivered { font-weight: 700; }
.msg-reply { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 0 2px; opacity: 0; font-size: .9rem; }
.msg:hover .msg-reply, .msg-reply:focus { opacity: 1; }
@media (hover: none) { .msg-reply { opacity: .7; } }
.chat-reply { display: flex; gap: .4rem; align-items: center; padding: 4px 10px; background: var(--surface-2); font-size: .85rem; border-top: 1px solid var(--border); }
.chat-reply span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-compose { padding: 8px; border-top: 1px solid var(--border); flex: none; background: var(--surface); }
.chat-compose-row { display: flex; gap: .4rem; align-items: flex-end; }
.chat-input { min-height: 42px; max-height: 140px; resize: none; }
.send-btn { min-width: 46px; min-height: 42px; font-size: 1.1rem; }
.chat-counter { font-size: .75rem; color: var(--warn); }
.chat-counter:empty { display: none; }

/* ---------- Aufgaben ---------- */
.board { display: flex; flex-direction: column; gap: 10px; }
.board-col { background: var(--surface-2); border-radius: 10px; padding: 8px; min-height: 60px; }
.board-col.drop { outline: 2px dashed var(--accent); }
.board-col h3 { display: flex; justify-content: space-between; font-size: .9rem; margin: 0 0 6px; }
.board-col .count { color: var(--muted); font-weight: 400; }
@media (min-width: 1400px) { :root { --side-w: 520px; } }
.task-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid #9e9e9e; border-radius: 8px; padding: 7px 9px; margin-bottom: 6px; cursor: pointer; }
.task-card.prio-1 { border-left-color: #fb8c00; }
.task-card.prio-2 { border-left-color: #e53935; }
.task-card:hover { border-color: var(--accent); }
.task-title { font-weight: 600; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.task-note { font-size: .85rem; color: var(--muted); white-space: pre-wrap; max-height: 3.6em; overflow: hidden; }
.task-meta { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: 3px; }
.task-actions { display: flex; gap: .3rem; justify-content: flex-end; margin-top: 5px; flex-wrap: wrap; }
.prio-badge { font-size: .68rem; padding: 0 6px; border-radius: 8px; color: #fff; font-weight: 700; }
.prio-badge.p1 { background: #fb8c00; }
.prio-badge.p2 { background: #e53935; }

/* ---------- Tagebuch ---------- */
.log-add { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .4rem; }
.log-add select { width: auto; flex: 1; }
.log-list { display: flex; flex-direction: column; gap: 4px; }
.log-list .chat-date { align-self: flex-start; }
.log-entry { border-left: 4px solid #9e9e9e; background: var(--surface-2); border-radius: 6px; padding: 5px 8px; }
.log-entry.cat-1 { border-left-color: #1e88e5; }
.log-entry.cat-2 { border-left-color: #8e24aa; }
.log-entry.cat-3 { border-left-color: #43a047; }
.log-entry.cat-4 { border-left-color: #fb8c00; }
.log-head { display: flex; gap: .5rem; font-size: .78rem; color: var(--muted); }
.log-time { font-weight: 700; color: var(--text); }
.log-cat { font-weight: 600; }
.log-by { margin-left: auto; }
.log-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Fotos ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.thumb { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-wait { display: flex; height: 100%; align-items: center; justify-content: center; font-size: .8rem; color: var(--muted); }
.thumb-cap { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); color: #fff; font-size: .7rem; padding: 10px 5px 3px; text-align: left; }
.thumb-pin { position: absolute; right: 4px; top: 4px; font-size: .8rem; }
.photo-view img { max-width: 100%; max-height: 65vh; display: block; margin: 0 auto; border-radius: 8px; }
.photo-caption { font-weight: 600; }
.upload-previews { display: flex; gap: 4px; }
.upload-previews img { width: 70px; height: 70px; object-fit: cover; border-radius: 6px; }
.upload-progress { display: flex; flex-direction: column; gap: 4px; background: var(--surface-2); border-radius: 8px; padding: 8px; margin-bottom: 8px; }
.file-list { padding-left: 1.2rem; }

/* ---------- Team / Listen ---------- */
.team-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.team-title { font-weight: 700; font-size: 1.15rem; }
.member-list, .map-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.member, .map-list > li { display: flex; align-items: center; gap: .6rem; padding: 7px 8px; border-radius: 8px; background: var(--surface-2); }
.member.sos { background: color-mix(in srgb, var(--sos) 20%, var(--surface-2)); border: 1px solid var(--sos); }
.member-main, .map-item-main { flex: 1; min-width: 0; }
.member-name { font-weight: 600; display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.member-actions { display: flex; gap: 2px; }
.role-badge { font-size: .68rem; padding: 0 6px; border-radius: 8px; background: var(--border); color: var(--text); font-weight: 600; }
.via { display: flex; gap: 3px; margin-top: 2px; }
.via-chip { font-size: .66rem; padding: 0 5px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); }
.via-lora { border-color: #8e24aa; }
.via-lan { border-color: #1e88e5; }
.via-nearby { border-color: #43a047; }
.qr-big { background: #fff; padding: 12px; border-radius: 10px; margin: .6rem auto; width: min(420px, 100%); aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.qr-big svg { width: 100%; height: 100%; display: block; }
.invite input { font-size: .8rem; }

/* ---------- Verwaltung ---------- */
.transport-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: .8rem; }
.transport { display: flex; gap: .6rem; align-items: center; padding: 6px 8px; background: var(--surface-2); border-radius: 8px; }
.tstate { font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 8px; color: #fff; background: var(--muted); white-space: nowrap; }
.tstate.ok { background: var(--ok); }
.tstate.warn { background: var(--warn); }
.tstate.bad { background: var(--bad); }
.job { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; display: flex; flex-direction: column; gap: 3px; }
.job.failed { border: 1px solid var(--bad); }
.admin-body h3 { margin-top: .6rem; }
details summary { cursor: pointer; }

/* ---------- Dialoge ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal { background: var(--surface); color: var(--text); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 480px; max-height: calc(100dvh - 24px); display: flex; flex-direction: column; }
.modal-wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 0 16px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 10px 16px; overflow-y: auto; }
.modal-buttons { display: flex; gap: .5rem; justify-content: flex-end; padding: 10px 16px 14px; flex-wrap: wrap; }
.modal-buttons .btn.danger:first-child { margin-right: auto; }
@media (max-width: 520px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 14px 14px 0 0; max-height: 92dvh; }
  .modal-buttons { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; box-shadow: 0 0 0 1px var(--border); }
.swatch[aria-checked="true"] { border-color: var(--surface); box-shadow: 0 0 0 3px var(--accent); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 4px; }
.icon-choice { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px; border: 2px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; color: var(--text); }
.icon-choice[aria-checked="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.icon-emoji { font-size: 1.4rem; line-height: 1.2; }
.icon-name { font-size: .64rem; text-align: center; line-height: 1.1; }

/* ---------- Meldungen ---------- */
#toasts { position: fixed; right: 12px; bottom: 12px; z-index: 200; display: flex; flex-direction: column; gap: 6px; max-width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: var(--surface); color: var(--text); border-left: 5px solid var(--accent); border-radius: 8px; padding: .55rem .8rem; box-shadow: var(--shadow); transition: opacity .4s, transform .4s; pointer-events: auto; }
.toast-ok { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--bad); }
.toast.out { opacity: 0; transform: translateY(8px); }
@media (max-width: 820px) { #toasts { bottom: 76px; left: 12px; right: 12px; max-width: none; } }

/* Netz (direkte Verbindungen, Hops) */
.net-h { font-size: .9rem; margin: .9rem 0 .4rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.net-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.net-transport { padding: 7px 8px; border-radius: 8px; background: var(--surface-2); }
.net-row { display: flex; align-items: center; gap: .6rem; }
.net-icon { font-size: 1.2rem; width: 1.6rem; text-align: center; }
.net-state { font-size: .7rem; font-weight: 700; padding: 0 6px; border-radius: 6px; color: #fff; background: var(--muted); }
.net-state.st-connected { background: var(--ok); }
.net-state.st-connecting { background: var(--warn); }
.net-state.st-error { background: var(--bad); }
.net-links { list-style: none; margin: 6px 0 0 2.2rem; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.net-links li { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .85rem; }
.fresh-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--muted); }
.fresh-dot.small { width: 9px; height: 9px; }
.fresh-dot.fr-fresh { background: var(--ok); }
.fresh-dot.fr-recent { background: var(--warn); }
.fresh-dot.fr-stale { background: var(--muted); opacity: .6; }
.fresh-dot.fr-never { background: transparent; border: 2px solid var(--muted); }
.net-graph { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: .88rem; }
.net-node.self { font-weight: 700; }
.net-tree, .net-tree ul { list-style: none; margin: 0; padding-left: 1.1rem; border-left: 1px solid var(--border); }
.net-tree li { padding: 2px 0; }

/* HTTPS / Team-Zertifikat */
.team-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.cert-info details { margin: .4rem 0; }
.cert-info summary { cursor: pointer; font-weight: 600; }
.cert-info ol { margin: .3rem 0 .3rem 1.2rem; padding: 0; }
.fingerprint { word-break: break-all; user-select: all; padding: .3rem .4rem; border-radius: 4px; background: rgba(127,127,127,.12); }
.linklike { background: none; border: none; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }
.center { text-align: center; }
a.btn { text-decoration: none; display: inline-block; }

/* Funk (Audio) */
.audio-live { margin-bottom: .8rem; display: flex; flex-direction: column; gap: 6px; }
.audio-meter { display: flex; align-items: center; gap: .5rem; }
.audio-meter-label { width: 6.5em; font-size: .85rem; color: var(--muted); }
.audio-meter-bar { flex: 1; height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.audio-meter-fill { height: 100%; transition: width .15s linear; }
.audio-meter-val { width: 5.5em; text-align: right; font-size: .85rem; }
.audio-stats td { padding: 1px 8px 1px 0; vertical-align: top; }
.msg-plain { color: var(--warn); font-weight: 600; }
