:root {
  --bg: #f3f4f6;
  --flaeche: #ffffff;
  --linie: #e3e5e9;
  --text: #15171c;
  --gedaempft: #6a7080;
  --akzent: #2f6fec;
  --akzent-weich: #e8f0fe;
  --weg: #dd8a1a;
  --weg-weich: #fdf2e2;
  --luecke: #a2a7b2;
  --gut: #1f9d55;
  --warn: #d68a00;
  --schlecht: #d93a3a;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --flaeche: #1a1d23;
    --linie: #2b2f37;
    --text: #e9ebef;
    --gedaempft: #9aa1ae;
    --akzent: #5b8ff9;
    --akzent-weich: #1d2a44;
    --weg: #f0a33c;
    --weg-weich: #3a2d17;
    --luecke: #6b717d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

button, input, select { font: inherit; color: inherit; }

button {
  border: 1px solid var(--linie);
  background: var(--flaeche);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--gedaempft); }
button:disabled { opacity: .4; cursor: default; }
button.icon { width: 32px; padding: 6px 0; font-size: 18px; line-height: 1; }
button.leise { background: transparent; }

input, select {
  border: 1px solid var(--linie);
  background: var(--flaeche);
  border-radius: 8px;
  padding: 5px 8px;
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--akzent);
  outline-offset: 1px;
}

/* ---------- Kopfzeile ---------- */

.kopf {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
  flex-wrap: wrap;
}
.marke { font-weight: 650; font-size: 15px; letter-spacing: -.01em; margin-right: 4px; }
.kopf select { min-width: 180px; font-weight: 550; }
.datumsnav { display: flex; align-items: center; gap: 6px; }

.steuerung { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.startstopp { font-weight: 550; }
.startstopp[data-modus="stoppen"] { color: var(--schlecht); }
.startstopp[data-modus="stoppen"]:hover:not(:disabled) { border-color: var(--schlecht); }
.startstopp[data-modus="starten"] { background: var(--gut); border-color: var(--gut); color: #fff; }

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gedaempft);
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg);
}
.status .punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--luecke); flex: none; }
.status[data-zustand="ok"] .punkt { background: var(--gut); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gut) 20%, transparent); }
.status[data-zustand="warnung"] .punkt { background: var(--warn); }
.status[data-zustand="fehler"] { color: var(--schlecht); }
.status[data-zustand="fehler"] .punkt { background: var(--schlecht); }
.status[data-zustand="pausiert"] { color: var(--text); }
.status[data-zustand="pausiert"] .punkt { background: var(--luecke); }

/* ---------- Layout ---------- */

.layout { flex: 1; display: flex; min-height: 0; }

.seite {
  width: 400px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--flaeche);
  border-right: 1px solid var(--linie);
  min-height: 0;
}

.karte { flex: 1; min-height: 300px; background: var(--bg); }

.tageskopf { padding: 18px 20px 12px; }
.tageskopf h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.kennzahlen { margin: 4px 0 0; color: var(--gedaempft); font-size: 13px; }

/* ---------- Zeitpunkt-Suche ---------- */

.suche {
  margin: 0 20px 8px;
  padding: 12px;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
}
.suche label { display: block; font-size: 12px; color: var(--gedaempft); margin-bottom: 6px; }
.suchzeile { display: flex; gap: 8px; }
.suchzeile input { flex: 1; }
.suchzeile button { background: var(--akzent); color: #fff; border-color: var(--akzent); }
.suchergebnis { margin-top: 10px; font-size: 13px; }
.suchergebnis strong { display: block; font-size: 14px; }
.suchergebnis .klein { color: var(--gedaempft); }

/* ---------- Zeitleiste ---------- */

.verlauf { flex: 1; overflow-y: auto; padding: 8px 20px 12px; min-height: 0; }
.verlauf h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gedaempft);
  font-weight: 600;
  margin: 8px 0 10px;
}

.zeitleiste { list-style: none; margin: 0; padding: 0; }

.eintrag {
  display: grid;
  grid-template-columns: 50px 18px 1fr;
  gap: 0 10px;
  padding: 0;
  cursor: default;
}
.eintrag .zeiten {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  text-align: right;
  padding-top: 8px;
}
.eintrag .zeiten .bis { display: block; color: var(--gedaempft); font-size: 12px; }

.eintrag .spur { position: relative; display: flex; justify-content: center; }
.eintrag .spur::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--linie);
}
.eintrag:first-child .spur::before { top: 14px; }
.eintrag:last-child .spur::before { bottom: calc(100% - 14px); }
.eintrag .knoten {
  position: relative;
  margin-top: 9px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--flaeche);
  border: 3px solid var(--akzent);
  z-index: 1;
}

.eintrag .inhalt {
  padding: 6px 10px 6px;
  margin: 2px 0 6px;
  border-radius: 8px;
}
.eintrag .titel { font-weight: 560; overflow-wrap: anywhere; }
.eintrag .meta { color: var(--gedaempft); font-size: 12px; }

.eintrag.aufenthalt { cursor: pointer; }
.eintrag.aufenthalt:hover .inhalt { background: var(--bg); }
.eintrag.aufenthalt.aktiv .inhalt { background: var(--akzent-weich); }
.eintrag .nummer {
  display: inline-grid;
  place-items: center;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  background: var(--akzent);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  margin-right: 6px;
  vertical-align: 1px;
}
.eintrag .ungenau { color: var(--warn); font-size: 12px; }

.eintrag.unterwegs .knoten { width: 10px; height: 10px; border-width: 2px; border-color: var(--weg); margin-top: 10px; }
.eintrag.unterwegs .titel { font-weight: 500; color: var(--weg); }
.eintrag.unterwegs { cursor: pointer; }
.eintrag.unterwegs:hover .inhalt { background: var(--weg-weich); }
.eintrag.unterwegs details summary { cursor: pointer; color: var(--gedaempft); font-size: 12px; }
.eintrag.unterwegs details ul { margin: 4px 0 0; padding-left: 16px; color: var(--gedaempft); font-size: 12px; }

.eintrag.luecke .spur::before { background: repeating-linear-gradient(to bottom, var(--luecke) 0 3px, transparent 3px 6px); }
.eintrag.luecke .knoten { width: 8px; height: 8px; border: 0; background: var(--luecke); margin-top: 12px; }
.eintrag.luecke .titel { font-weight: 450; font-style: italic; color: var(--gedaempft); }

.leer { color: var(--gedaempft); padding: 24px 0; text-align: center; }
.leer strong { display: block; color: var(--text); margin-bottom: 4px; }

.seitenfuss { padding: 12px 20px; border-top: 1px solid var(--linie); font-size: 13px; }
.seitenfuss a { color: var(--akzent); text-decoration: none; }
.seitenfuss a:hover { text-decoration: underline; }

/* ---------- Karte ---------- */

.marker-nr {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--akzent);
  color: #fff;
  font: 650 12px/1 -apple-system, system-ui, sans-serif;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.marker-nr.aktiv { background: #173f9c; transform: scale(1.15); }

.marker-jetzt {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--gut);
  border: 3px solid #fff;
  box-shadow: 0 0 0 0 rgba(31,157,85,.5);
  animation: puls 2s infinite;
}
@keyframes puls {
  0% { box-shadow: 0 0 0 0 rgba(31,157,85,.5); }
  70% { box-shadow: 0 0 0 14px rgba(31,157,85,0); }
  100% { box-shadow: 0 0 0 0 rgba(31,157,85,0); }
}
@media (prefers-reduced-motion: reduce) { .marker-jetzt { animation: none; } }

.leaflet-popup-content { font: 13px/1.4 -apple-system, system-ui, sans-serif; margin: 10px 14px; }
.leaflet-popup-content strong { display: block; font-size: 14px; margin-bottom: 2px; }

/* ---------- Anmeldung ---------- */

body.anmeldung { align-items: center; justify-content: center; padding: 20px; }
.anmeldebox {
  width: 100%;
  max-width: 340px;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 24px;
}
.anmeldebox h1 { margin: 0 0 16px; font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.anmeldebox label { display: block; font-size: 12px; color: var(--gedaempft); margin-bottom: 6px; }
.anmeldebox input { width: 100%; padding: 8px 10px; }
.anmeldebox button {
  width: 100%;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--akzent);
  border-color: var(--akzent);
  color: #fff;
  font-weight: 550;
}
.anmeldebox .meldung { margin: 0 0 14px; color: var(--schlecht); font-size: 13px; overflow-wrap: anywhere; }
.anmeldebox .hinweis { margin: 14px 0 0; color: var(--gedaempft); font-size: 12px; }

.abmelden { margin: 0; }

/* ---------- Schmale Fenster ---------- */

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .seite { flex: 1; width: auto; border-right: 0; border-top: 1px solid var(--linie); }
  .karte { order: -1; flex: none; height: 45vh; }
  .steuerung { margin-left: 0; }
}
