:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #e9ebf4;
  --text: #191b26;
  --muted: #606478;
  --line: #dcdfeb;
  --accent: #d63c31;
  --accent-ink: #ffffff;
  --accent-soft: #fbe4e2;
  --blue: #2f6bd8;
  --blue-soft: #e2ebfb;
  --green: #1f8a53;
  --red: #c2372b;
  --warn-soft: #fff3d6;
  --warn-ink: #6b4b00;
  --gold: #c99400;
  --gold-soft: #fff1c2;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .06);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151c;
    --surface: #1d1f29;
    --surface-2: #272a37;
    --text: #e9eaf2;
    --muted: #9ea2b6;
    --line: #333748;
    --accent: #ff6b5e;
    --accent-ink: #2a0805;
    --accent-soft: #3d1f1c;
    --blue: #6e9cf0;
    --blue-soft: #1f2a42;
    --green: #4cc488;
    --red: #f07366;
    --warn-soft: #3a3016;
    --warn-ink: #f5d68a;
    --gold: #f2c443;
    --gold-soft: #3b3112;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.klein { font-size: .85rem; }
[hidden] { display: none !important; }

/* ---------- Kopf ---------- */
.top {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand img { border-radius: 7px; }
.brand h1 { font-size: 1.25rem; margin: 0; white-space: nowrap; }
.sync { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync[data-state="live"] .dot { background: #2fb36d; }
.sync[data-state="off"] .dot { background: var(--red); }
.sync[data-state="demo"] .dot { background: #e0a423; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 12px; background: transparent; font-size: 1.4rem;
}
.icon-btn svg { fill: currentColor; }
.icon-btn:active { background: var(--surface-2); }

main, .login { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }

.banner { max-width: 608px; margin: 4px auto 12px; padding: 10px 14px; border-radius: 12px; font-size: .92rem; }
.banner.demo { background: var(--warn-soft); color: var(--warn-ink); margin: 4px 16px 12px; }
@media (min-width: 640px) { .banner.demo { margin: 4px auto 12px; } }
.banner.warn { background: var(--warn-soft); color: var(--warn-ink); }

/* ---------- Reiter ---------- */
.tabs {
  display: flex; gap: 4px; padding: 4px; margin: 0 0 12px; border-radius: 14px; background: var(--surface-2);
}
.tabs button {
  flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 11px; font-weight: 600; color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.zaehler:not(:empty) {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; font-weight: 800;
}

.statuszeile { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin: 0 2px 8px; }
.ortzeile { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 2px 12px; font-size: .88rem; color: var(--muted); }
.ortzeile button { border: 0; background: var(--blue-soft); color: var(--blue); padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: .85rem; }

/* ---------- Treffer ---------- */
.fund {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 4px 12px; align-items: center;
  padding: 12px 14px 12px 10px; margin-bottom: 10px; border-left: 5px solid var(--line);
}
.fund.iv-100 { border-left-color: var(--gold); }
.fund.iv-90 { border-left-color: var(--green); }
.fund.bald { opacity: .75; }
.fund.markiert { animation: blink 1.6s ease 2; }
@keyframes blink { 50% { box-shadow: 0 0 0 4px var(--accent); } }
.bild { width: 64px; height: 64px; position: relative; display: grid; place-items: center; }
.bild img { width: 72px; height: 72px; image-rendering: pixelated; margin: -4px; }
.bild .nr { position: absolute; inset: auto 0 0; text-align: center; font-size: .7rem; color: var(--muted); }
.bild.ohne { background: var(--surface-2); border-radius: 50%; font-weight: 800; color: var(--muted); }
.fund-kopf { min-width: 0; }
.fund-name { font-weight: 800; font-size: 1.08rem; line-height: 1.2; }
.fund-name .g { font-weight: 600; color: var(--muted); font-size: .9rem; }
.fund-werte { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 3px; font-size: .84rem; color: var(--muted); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-weight: 800; font-size: .82rem; background: var(--surface-2); color: var(--text); }
.badge.iv-100 { background: var(--gold-soft); color: var(--gold); }
.badge.iv-90 { background: color-mix(in srgb, var(--green) 16%, var(--surface)); color: var(--green); }
.badge.pvp { background: var(--blue-soft); color: var(--blue); }
.badge.grund { background: var(--accent-soft); color: var(--accent); }
.fund-rechts { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.km { font-size: 1.3rem; font-weight: 800; white-space: nowrap; }
.km small { font-size: .8rem; font-weight: 600; color: var(--muted); display: block; }
.rest { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.rest.knapp { color: var(--red); }
.fund-knoepfe { grid-column: 2 / -1; display: flex; gap: 8px; margin-top: 6px; }
.fund-knoepfe a { flex: 1; text-align: center; text-decoration: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; color: var(--text);
}
.btn.klein { padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.route { background: var(--blue); color: #fff; border-color: transparent; padding: 8px 12px; }
.btn.gefahr { color: var(--red); }
.btn:disabled { opacity: .5; }
.leer { text-align: center; padding: 28px 16px; }
.leer .gross { font-size: 2.2rem; display: block; margin-bottom: 4px; }

/* ---------- Verlauf ---------- */
.tag-titel { font-size: .95rem; margin: 18px 4px 8px; color: var(--muted); }
.vzeile { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.vzeile:last-child { border-bottom: 0; }
.vzeile img { width: 40px; height: 40px; image-rendering: pixelated; flex: none; margin: -4px; }
.vzeile .vtext { flex: 1; min-width: 0; }
.vzeile .vname { font-weight: 700; }
.vzeile .vzeit { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; width: 44px; flex: none; }
.vzeile.weg .vname { color: var(--muted); }
.vliste { padding: 2px 0; }

/* ---------- Suche ---------- */
.block { background: var(--surface); margin: 0 0 12px; padding: 14px; border-radius: 14px; }
.sheet .block { margin: 0 12px 12px; }
.block h3 { margin: 0 0 8px; font-size: 1rem; }
.block p { margin: 4px 0 8px; }
label { display: grid; gap: 4px; text-align: left; font-size: .9rem; color: var(--muted); }
input[type=email], input[type=password], input[type=text], input[type=search], input[type=number], input[type=time], select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.suchfeld { position: relative; }
.vorschlaege {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 1200; max-height: 300px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.vorschlaege button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; border: 0; background: transparent; text-align: left;
}
.vorschlaege button:hover, .vorschlaege button.aktiv { background: var(--surface-2); }
.vorschlaege img { width: 40px; height: 40px; image-rendering: pixelated; margin: -4px; }
.vorschlaege .nr { color: var(--muted); font-size: .8rem; margin-left: auto; }
.vorschlaege .schon { color: var(--green); font-size: .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 2px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--bg); font-size: .9rem; font-weight: 600;
}
.chip img { width: 30px; height: 30px; image-rendering: pixelated; margin: -2px 0; }
.chip .x { border: 0; background: transparent; color: var(--muted); font-size: 1rem; padding: 0 6px; line-height: 1; }
.ideen .chip { cursor: pointer; border-style: dashed; padding-right: 10px; }
.ideen .chip.dabei { opacity: .45; }
.wahl { display: grid; gap: 8px; margin-bottom: 10px; }
.wahl label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text); font-size: .98rem; }
.wahl input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.wahl input[type=number] { width: 70px; padding: 6px 8px; }
.schalter { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .98rem; }
.schalter input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.schalter.gross { font-weight: 700; font-size: 1.05rem; }
.regler { display: flex; align-items: center; gap: 12px; }
.regler input { flex: 1; accent-color: var(--accent); }
.regler output { font-weight: 800; min-width: 64px; text-align: right; }
.karte { position: relative; isolation: isolate; height: 260px; border-radius: 12px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; z-index: 0; }
.karte.leaflet-container { display: block; }
.zeile { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.zeile input[type=time] { flex: 1; min-width: 96px; }
.knoepfe { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.mehr summary { cursor: pointer; color: var(--blue); font-weight: 600; margin-top: 10px; }
.status { font-weight: 600; }
.ok-text { color: var(--green); font-weight: 600; }
.fehler-text { color: var(--red); font-weight: 600; }

/* ---------- Anmeldung ---------- */
.login { padding-top: 6vh; }
.login form { padding: 24px; display: grid; gap: 12px; text-align: center; }
.login form img { margin: 0 auto; border-radius: 14px; }
.login h2, .login p { margin: 0; }
.error { color: var(--red); font-size: .9rem; }

/* ---------- Einstellungen ---------- */
.sheet {
  width: min(560px, 100%); max-height: min(92vh, 900px); margin: auto auto 0; padding: 0 0 calc(20px + env(safe-area-inset-bottom));
  border: 0; border-radius: 20px 20px 0 0; background: var(--bg); color: var(--text); overflow-y: auto;
}
@media (min-width: 600px) { .sheet { margin: auto; border-radius: 20px; } }
.sheet::backdrop { background: rgb(0 0 0 / .4); }
.sheet-kopf { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 18px; background: var(--bg); }
.sheet-kopf h2 { margin: 0; font-size: 1.2rem; }

.fuss { text-align: center; margin: 24px 0 0; }

/* ---------- Meldung ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 2000;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: .92rem;
}
.toast button { border: 0; background: transparent; color: var(--accent-soft); font-weight: 700; padding: 0; }
