:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: rgba(17, 21, 25, 0.94);
  --text: #f5f7fa;
  --muted: #a9b3bd;
  --accent: #29d391;
  --abend: #f28a24;
  --warn: #ffb020;
  --danger: #ff5b66;
  --line: rgba(255, 255, 255, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
#map {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Lokaler Leaflet-Basis-Fallback, falls die CDN-CSS nicht geladen wird. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  top: 0;
  left: 0;
}

.leaflet-container {
  overflow: hidden;
  background: #d7d8d4;
  outline-offset: 1px;
  touch-action: none;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  border: 0;
  filter: inherit;
}

.leaflet-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control-zoom {
  margin: 12px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  background: #fff;
}

.leaflet-control-zoom a {
  display: block;
  width: 30px;
  height: 30px;
  background: #fff;
  color: #111;
  font: 700 20px/30px Arial, sans-serif;
  text-align: center;
  text-decoration: none;
}

.leaflet-control-attribution {
  margin: 0;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.8);
  color: #222;
}

.app-shell {
  position: relative;
}

#map {
  z-index: 1;
}

.running-brand,
.info-panel,
.status-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(14px);
}

.running-brand {
  position: absolute;
  z-index: 600;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  max-width: 760px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto;
  padding: 12px 14px;
}

.brand-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: var(--abend);
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
}

.brand-link strong {
  color: var(--text);
}

.brand-link em {
  color: var(--ok);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.running-brand div {
  min-width: 0;
  display: grid;
  gap: 2px;
  justify-items: end;
  text-align: right;
}

.running-brand span,
.label,
.metrics span,
.meeting-panel span {
  display: block;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.running-brand div strong {
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.2;
}

.info-panel {
  position: absolute;
  z-index: 550;
  top: calc(max(16px, env(safe-area-inset-top)) + 78px);
  left: max(16px, env(safe-area-inset-left));
  width: min(360px, calc(100% - 32px));
  padding: 14px;
  background: rgba(17, 21, 25, 0.88);
}

.info-panel h2 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.05;
}

.info-panel p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.status-panel {
  position: absolute;
  z-index: 500;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--accent);
  color: #08120d;
  font-size: 13px;
  font-weight: 800;
}

.badge-waiting {
  background: var(--warn);
  color: #211400;
}

.badge-offline {
  background: var(--danger);
  color: #fff;
}

.metrics,
.meeting-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.metrics > div,
.meeting-panel > div {
  min-width: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.metrics strong,
.meeting-panel strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.25;
}

.meeting-panel {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #07110c;
  font-weight: 800;
  cursor: pointer;
}

.offline-message {
  margin: 14px 0 0;
  color: #ffe9eb;
  font-weight: 800;
}

.is-hidden {
  display: none;
}

.leaflet-top.leaflet-left {
  top: 230px;
}

.leaflet-control-attribution {
  font-size: 10px;
}

@media (max-width: 900px), (pointer: coarse) {
  .running-brand {
    top: max(3px, env(safe-area-inset-top));
    right: max(3px, env(safe-area-inset-right));
    left: max(3px, env(safe-area-inset-left));
    width: auto;
    max-width: none;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    padding: 1px 3px;
    border-radius: 3px;
    background: rgba(17, 21, 25, 0.62);
    box-shadow: none;
  }

  .brand-link {
    font-size: 7px;
    gap: 1px;
  }

  .brand-link em {
    font-size: 4px;
  }

  .running-brand div {
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 4px;
    justify-items: start;
    text-align: left;
  }

  .running-brand div strong {
    overflow: hidden;
    font-size: 6px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .info-panel {
    display: flex;
    top: calc(max(3px, env(safe-area-inset-top)) + 14px);
    right: max(3px, env(safe-area-inset-right));
    left: max(3px, env(safe-area-inset-left));
    width: auto;
    align-items: baseline;
    gap: 4px;
    padding: 1px 3px;
    border-radius: 3px;
    background: rgba(17, 21, 25, 0.54);
    box-shadow: none;
  }

  .info-panel .label {
    display: none;
  }

  .info-panel h2 {
    flex: 0 0 auto;
    margin: 0;
    font-size: 6px;
    line-height: 1.1;
    white-space: nowrap;
  }

  .info-panel p:last-child {
    overflow: hidden;
    min-width: 0;
    font-size: 5px;
    line-height: 1.1;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .leaflet-top.leaflet-left {
    top: calc(max(3px, env(safe-area-inset-top)) + 29px);
    left: max(3px, env(safe-area-inset-left));
  }

  .leaflet-control-zoom {
    margin: 0;
  }

  .leaflet-control-zoom a {
    width: 16px;
    height: 16px;
    font: 700 11px/16px Arial, sans-serif;
  }

  .status-panel {
    right: max(3px, env(safe-area-inset-right));
    bottom: max(3px, env(safe-area-inset-bottom));
    left: max(3px, env(safe-area-inset-left));
    width: auto;
    max-width: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: 2px;
    padding: 3px 4px;
    border-radius: 3px;
    background: rgba(17, 21, 25, 0.64);
    box-shadow: none;
  }

  h1 {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    font-size: 16px;
    line-height: 1.05;
    white-space: normal;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .top-row {
    min-width: 0;
    align-items: center;
    gap: 5px;
  }

  .top-row > div {
    min-width: 0;
    flex: 1 1 auto;
  }

  .top-row .label {
    font-size: 5px;
  }

  .badge {
    flex: 0 0 auto;
    padding: 2px 4px;
    font-size: 7px;
    line-height: 1.05;
    white-space: nowrap;
  }

  .running-brand span,
  .label,
  .metrics span,
  .meeting-panel span {
    margin-bottom: 0;
    font-size: 4px;
    line-height: 1.05;
  }

  .metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    min-width: 0;
    margin-top: 1px;
  }

  .metrics > div,
  .meeting-panel > div {
    padding-top: 0;
    border-top: 0;
  }

  .metrics strong,
  .meeting-panel strong {
    overflow: hidden;
    font-size: 7px;
    line-height: 1.05;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .offline-message {
    display: block;
    overflow: hidden;
    margin: 0;
    font-size: 5.5px;
    line-height: 1.05;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .meeting-panel {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr auto;
    gap: 2px;
    margin-top: 1px;
  }

  .meeting-panel button {
    grid-column: 1 / -1;
  }

  .meeting-panel.is-hidden,
  .offline-message.is-hidden {
    display: none;
  }
}
