:root {
  --bg: #070a10;
  --bg-2: #0c1018;
  --surface: rgba(22, 27, 36, 0.62);
  --surface-solid: #161b24;
  --surface-2: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f5f8;
  --text-dim: #b9c0c9;
  --muted: #8990a0;
  --accent: #2563eb;
  --accent-2: #60a5fa;
  --accent-grad: linear-gradient(135deg, #1d4ed8 0%, #60a5fa 100%);
  --accent-soft: rgba(37, 99, 235, 0.16);
  --danger: #ff453a;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-glass:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 24px 60px -24px rgba(0, 0, 0, 0.55);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  padding:
    max(env(safe-area-inset-top), 18px)
    max(env(safe-area-inset-right), 18px)
    max(env(safe-area-inset-bottom), 22px)
    max(env(safe-area-inset-left), 18px);
  position: relative;
  overflow-x: hidden;
}

/* Aurora-Blobs entfernt — clean dunkler Hintergrund. .aurora-Container im
   Markup bleibt (kostet nichts), wird hier zu no-op. */
.aurora { display: none; }

.page {
  position: relative;
  z-index: 1;
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fadeUp 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.page.center {
  min-height: calc(100dvh - 40px);
  justify-content: center;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent-grad);
  color: #ffffff;
  box-shadow: 0 8px 24px -8px rgba(37, 99, 235, 0.55);
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.brand-accent {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.logo-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}
.logo-hero .brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
}
.logo-hero .brand-mark svg { width: 36px; height: 36px; }
.logo-hero h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(180deg, #fff 0%, #cdd3dd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-glass);
}

.glass {
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
}

.row { display: flex; flex-direction: column; gap: 10px; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

input, select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 17px;            /* prevents iOS zoom on focus */
  font-weight: 500;
  font-feature-settings: 'tnum' 1, 'kern' 1;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input::placeholder { color: var(--muted); }

input:focus, select:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 16px center, right 11px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

button, a.primary {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  padding: 14px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  letter-spacing: -0.005em;
  transition: transform 110ms ease, opacity 140ms ease, box-shadow 200ms ease, filter 140ms ease;
  user-select: none;
}

button:active, a.primary:active { transform: scale(0.985); }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.with-icon { gap: 10px; }

.primary {
  background: var(--accent-grad);
  color: #ffffff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 12px 28px -10px rgba(37, 99, 235, 0.55);
}
.primary:hover { filter: brightness(1.04); }
.primary.big {
  padding: 16px 18px;
  font-size: 17px;
  font-weight: 700;
}
.primary:disabled {
  opacity: 0.42;
  filter: grayscale(0.3);
  cursor: not-allowed;
  box-shadow: none;
}

.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.secondary:hover { background: rgba(255, 255, 255, 0.08); }

.ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
}
.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.muted { color: var(--muted); }
.small { font-size: 13px; margin: 0; }
.status { min-height: 1.2em; }

.error {
  margin: 0;
  color: #ffb4ad;
  font-size: 14px;
  padding: 12px 14px;
  background: rgba(255, 69, 58, 0.10);
  border: 1px solid rgba(255, 69, 58, 0.28);
  border-radius: var(--radius-sm);
}

.hidden { display: none !important; }

/* Result section */
.result {
  animation: slideUp 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 14px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1px solid transparent;
  background: var(--accent-grad) border-box;
  -webkit-mask:
    linear-gradient(#000 0 0) padding-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}
.stat.highlight::after { opacity: 0.55; }

.stat .label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat .value {
  display: block;
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.02em;
  font-feature-settings: 'tnum' 1;
}
.stat .value .unit {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  margin-left: 4px;
}

.retry {
  align-self: stretch;
}

.launch {
  position: relative;
}
.launch::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: var(--accent-grad);
  filter: blur(12px);
  opacity: 0.4;
  z-index: -1;
}

.launch-secondary {
  align-self: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 12px;
  margin-top: -6px;
  background: transparent;
  box-shadow: none;
}
.launch-secondary:hover { color: var(--text-dim); }

/* Map */
.map-wrap {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-2);
}
.map {
  height: 280px;
  width: 100%;
  background: var(--bg-2);
}
.map-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(7, 10, 16, 0.6);
  backdrop-filter: blur(4px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}
.map-overlay.show { opacity: 1; }

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Leaflet overrides */
.leaflet-container { background: var(--bg-2) !important; outline: none; }
.leaflet-control-attribution {
  background: rgba(7, 10, 16, 0.6) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
  padding: 2px 6px !important;
  backdrop-filter: blur(6px);
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }
.leaflet-control-zoom { border: 0 !important; box-shadow: 0 6px 16px rgba(0,0,0,0.4) !important; overflow: hidden; }
.leaflet-control-zoom a {
  background: rgba(22, 27, 36, 0.85) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  backdrop-filter: blur(8px);
}
.leaflet-control-zoom a:hover { background: rgba(40, 48, 60, 0.95) !important; }

.route-line {
  stroke-linecap: round;
  stroke-linejoin: round;
}
.route-line.draw {
  transition: stroke-dashoffset 1.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.origin-marker {
  position: relative;
  width: 20px;
  height: 20px;
}
.origin-marker .pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(29, 78, 216, 0.35);
  animation: pulse 2s ease-out infinite;
}
.origin-marker .dot {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #1d4ed8;
  box-shadow: 0 0 0 3px #ffffff;
}

/* Live-Position des Users im Walking-Mode (anders als Origin-Marker) */
.user-marker {
  position: relative;
  width: 26px;
  height: 26px;
}
.user-marker .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(29, 78, 216, 0.25);
  animation: pulse 1.6s ease-out infinite;
}
.user-marker .dot {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #1d4ed8;
  box-shadow:
    0 0 0 3px #ffffff,
    0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   Walking-Fullscreen — sub-page-feel, kein scroll, Karte dominant
   ============================================================ */
.walk-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.walk-row.sub {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.walk-label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.walk-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.walk-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-top: 8px;
}
.walk-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1d4ed8 0%, #60a5fa 100%);
  transition: width 600ms cubic-bezier(0.2, 0.7, 0.2, 1);
  border-radius: inherit;
}

/* Body-Lock: kein Scroll, kein Bounce solange Fullscreen aktiv */
body.walking-fullscreen {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.walk-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.walk-fullscreen.hidden { display: none; }

.walk-back {
  position: absolute;
  top: max(env(safe-area-inset-top), 16px);
  left: max(env(safe-area-inset-left), 14px);
  z-index: 110;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 9px 14px 9px 10px;
  background: rgba(22, 27, 36, 0.88);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.5);
}
.walk-back svg { width: 18px; height: 18px; }
.walk-back:active { transform: scale(0.97); }

.walk-map-host {
  flex: 1;
  position: relative;
  min-height: 0;
}
.walk-map-host .map {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.walk-fab {
  position: absolute;
  right: max(env(safe-area-inset-right), 16px);
  bottom: 0;  /* JS positioniert das je nach Card-Höhe; default fallback */
  z-index: 105;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  background: rgba(22, 27, 36, 0.95);
  color: var(--text);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 28px -8px rgba(0, 0, 0, 0.6);
  transition: transform 100ms ease, background 140ms ease;
}
.walk-fab svg { width: 22px; height: 22px; }
.walk-fab:active { transform: scale(0.93); }

.walk-fullscreen-card {
  position: relative;
  z-index: 101;
  background: rgba(12, 16, 24, 0.96);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  padding:
    16px
    max(env(safe-area-inset-right), 18px)
    max(env(safe-area-inset-bottom), 18px)
    max(env(safe-area-inset-left), 18px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.walk-fullscreen-card .walk-stop {
  margin-top: 10px;
}
.walk-stop {
  background: linear-gradient(135deg, #1d4ed8 0%, #60a5fa 100%);
  color: #ffffff;
}
@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0.7; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Login page */
.login-hero { margin-bottom: 4px; }

.login-card {
  width: 100%;
  max-width: 420px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f4f7;
    --bg-2: #e7e9ee;
    --surface: rgba(255, 255, 255, 0.72);
    --surface-solid: #ffffff;
    --surface-2: rgba(0, 0, 0, 0.04);
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.14);
    --text: #16181d;
    --text-dim: #4f535c;
    --muted: #6b7079;
    --shadow-glass:
      0 1px 0 rgba(255, 255, 255, 0.6) inset,
      0 0 0 1px rgba(0, 0, 0, 0.04) inset,
      0 18px 50px -22px rgba(20, 22, 30, 0.25);
  }
  body {
    background: var(--bg);
  }
  .primary { color: #ffffff; }
  .logo-hero h1 {
    background: linear-gradient(180deg, #16181d 0%, #4f535c 100%);
    -webkit-background-clip: text;
    background-clip: text;
  }
  .leaflet-container { background: var(--bg-2) !important; }
  .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.85) !important;
    color: #4f535c !important;
  }
  .leaflet-control-zoom a {
    background: rgba(255, 255, 255, 0.9) !important;
    color: var(--text) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page, .result { animation: none !important; }
  .route-line.draw { transition: none !important; }
}
