/* =====================================================================
   RUN Dashboard – Styles
   Farben als Tokens; Dark ist eigenständig abgestimmt, kein Auto-Invert.
   ===================================================================== */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c0e;
  --bg-glow: rgba(255, 90, 54, .10);
  --surface: #141619;
  --surface-2: #1b1e22;
  --surface-3: #23272c;
  --line: #2a2e34;
  --grid: #23262b;
  --text: #f5f4f0;
  --text-2: #b9b8b0;
  --muted: #84837c;
  --accent: #ff5a36;
  --accent-2: #ff2e63;
  --accent-ink: #ffffff;
  --accent-soft: rgba(255, 90, 54, .14);
  --good: #2bd4a4;
  --bad: #ff6b6b;
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 20px 40px -24px rgba(0,0,0,.6);
  --glass: rgba(20, 22, 25, .72);

  /* Laufarten (kategorisch, für Dark gestuft) */
  --t-easy: #3987e5;
  --t-tempo: #d95926;
  --t-recovery: #199e70;
  --t-race: #c98500;
  --t-trail: #008300;
  --t-long: #9085e9;
  --t-interval: #e66767;

  /* Heatmap – eine Farbe, hell → kräftig */
  --heat-0: #1f2226;
  --heat-1: #4a2a22;
  --heat-2: #8a3a24;
  --heat-3: #d24a28;
  --heat-4: #ff7a52;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f2ee;
  --bg-glow: rgba(255, 90, 54, .10);
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --surface-3: #efeee9;
  --line: #e5e3dd;
  --grid: #eeece7;
  --text: #121212;
  --text-2: #52514e;
  --muted: #7d7c76;
  --accent: #e2471c;
  --accent-2: #e01e57;
  --accent-ink: #ffffff;
  --accent-soft: rgba(226, 71, 28, .10);
  --good: #0f9e72;
  --bad: #d83a3a;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 32px -20px rgba(0,0,0,.18);
  --glass: rgba(255, 255, 255, .78);

  --t-easy: #2a78d6;
  --t-tempo: #eb6834;
  --t-recovery: #1baf7a;
  --t-race: #eda100;
  --t-trail: #008300;
  --t-long: #4a3aa7;
  --t-interval: #e34948;

  --heat-0: #ebe9e4;
  --heat-1: #fbd3c3;
  --heat-2: #f6a283;
  --heat-3: #ec6b41;
  --heat-4: #c23d14;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--bg-glow), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
svg { display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .04em; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
[hidden] { display: none !important; }

/* ---------- Brand ---------- */
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: .14em; font-size: 18px; text-decoration: none;
}
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px var(--accent);
}
.brand-xl { font-size: 44px; letter-spacing: .18em; }
.brand-xl .brand-dot { width: 26px; height: 26px; }

/* ---------- Buttons & Inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn-primary {
  border: 0; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px -10px var(--accent);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-danger { color: var(--bad); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; height: 48px; font-size: 15px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; fill: var(--text-2); }
.icon-btn:hover svg { fill: var(--text); }
[data-theme="dark"] .i-moon, [data-theme="light"] .i-sun { display: none; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--muted); font-size: 12px; }
input, select, textarea {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 80px; padding: 10px 14px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[type="color"] { padding: 4px; }
input::placeholder { color: var(--muted); }

.seg {
  display: inline-flex; padding: 4px; gap: 2px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.seg a, .seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; text-decoration: none;
}
.seg .active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2); }

.alert {
  padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px;
  background: color-mix(in oklab, var(--bad) 14%, transparent); color: var(--text);
  border: 1px solid color-mix(in oklab, var(--bad) 40%, transparent);
}

/* ---------- Auth ---------- */
.auth-body { background: var(--bg); }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { position: relative; overflow: hidden; background: #0b0c0e; color: #fff; }
.auth-hero-glow {
  position: absolute; inset: -20%;
  background:
    radial-gradient(40% 40% at 30% 30%, rgba(255, 90, 54, .55), transparent 70%),
    radial-gradient(35% 35% at 75% 70%, rgba(255, 46, 99, .45), transparent 70%);
  filter: blur(40px); animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate(4%, -3%) scale(1.08); } }
.auth-track { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-track path {
  fill: none; stroke: rgba(255,255,255,.22); stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 1200; stroke-dashoffset: 1200; animation: draw 3.5s ease forwards;
}
.auth-track path:nth-child(2) { animation-delay: .4s; stroke: rgba(255,255,255,.14); }
.auth-track path:nth-child(3) { animation-delay: .8s; stroke: rgba(255,255,255,.08); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.auth-hero-text { position: absolute; left: 8%; bottom: 12%; right: 8%; }
.auth-claim { font-size: 30px; font-weight: 700; line-height: 1.2; margin: 18px 0 0; letter-spacing: -.01em; }
.auth-claim span { color: rgba(255,255,255,.6); font-weight: 500; font-size: 20px; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 30px; margin: 0 0 4px; letter-spacing: -.02em; }
.auth-card > .muted { margin: 0 0 22px; }
.auth-card .seg { width: 100%; margin-bottom: 22px; }
.auth-card .seg a { flex: 1; text-align: center; padding: 9px; }
.ghost-link { display: block; margin: 18px auto 0; background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; }
.ghost-link:hover { color: var(--text); }
.only-mobile { display: none; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .only-mobile { display: inline-flex; margin-bottom: 28px; }
}

/* ---------- App-Rahmen ---------- */
.app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 24px;
  padding: 12px max(20px, env(safe-area-inset-left));
  background: var(--glass); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px;
  text-decoration: none; color: var(--text-2); font-weight: 600; font-size: 14px;
}
.nav a svg { width: 18px; height: 18px; fill: currentColor; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--text); background: var(--surface-3); }
.topbar-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.viewer {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 6px 0 12px;
  border-radius: 12px; background: var(--accent-soft); border: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
  font-size: 13px; font-weight: 600;
}
.viewer button { border: 0; background: var(--surface); border-radius: 8px; height: 28px; padding: 0 10px; cursor: pointer; font-size: 12px; font-weight: 600; }

.view { max-width: 1320px; margin: 0 auto; padding: 28px 20px 120px; outline: none; }
.loading { display: grid; place-items: center; min-height: 50vh; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  /* backdrop-filter würde die fixierte Bottom-Nav im Header einsperren */
  .topbar { gap: 12px; padding: 10px 14px; backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    justify-content: space-around; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
  }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 10px; }
  .nav a svg { width: 22px; height: 22px; }
  .nav a.active { background: transparent; color: var(--accent); }
  .btn-add span { display: none; }
  .btn-add { width: 40px; padding: 0; }
  .viewer { font-size: 12px; }
  .view { padding: 18px 14px 110px; }
}

/* ---------- Seitenkopf ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 30px; letter-spacing: -.025em; line-height: 1.15; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }

/* ---------- Karten & Grid ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
@media (max-width: 1100px) {
  .span-8, .span-7, .span-5, .span-4 { grid-column: span 12; }
  .span-3 { grid-column: span 6; }
  .span-6 { grid-column: span 12; }
}
/* Mobile-Feinschliff: siehe Ende der Datei */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 20px; box-shadow: var(--shadow); min-width: 0;
  animation: rise .45s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.005em; }
.card-head .sub { font-size: 13px; color: var(--muted); }
.card-title-group { display: grid; gap: 2px; }

/* Hero */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 55%),
    var(--surface);
}
.hero-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hero-value { font-size: clamp(56px, 8vw, 88px); font-weight: 800; letter-spacing: -.045em; line-height: 1; margin: 10px 0 6px; }
.hero-value small { font-size: .32em; font-weight: 700; letter-spacing: 0; color: var(--text-2); margin-left: 6px; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.delta.up { color: var(--good); background: color-mix(in oklab, var(--good) 14%, transparent); }
.delta.down { color: var(--text-2); background: var(--surface-3); }
.hero-stats { display: flex; gap: 28px; margin-top: 22px; flex-wrap: wrap; }
.hero-stats div { display: grid; }
.hero-stats b { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.hero-stats span { font-size: 12px; color: var(--muted); font-weight: 600; }
.hero-track { position: absolute; right: -10px; bottom: -10px; width: 55%; height: 70%; opacity: .5; pointer-events: none; }
.hero-track path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; opacity: .35; }

/* Ziel-Ringe */
.rings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.ring { position: relative; display: grid; justify-items: center; gap: 8px; }
.ring svg { width: 100%; max-width: 128px; height: auto; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-3); }
.ring-fill { fill: none; stroke: url(#ringGrad); stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(.2,.8,.2,1); }
.ring-center { position: absolute; top: 0; left: 0; right: 0; aspect-ratio: 1; max-width: 128px; margin: 0 auto; display: grid; place-content: center; }
.ring-center b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.ring-label { font-size: 13px; font-weight: 700; }
.ring-sub { font-size: 12px; color: var(--muted); margin-top: -6px; }
.pace-hint { margin-top: 16px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 13px; color: var(--text-2); }
.pace-hint b { color: var(--text); }

/* Stat-Kacheln */
.tile { display: grid; gap: 4px; }
.tile-label { font-size: 13px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tile-label .ic { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); font-size: 15px; }
.tile-value { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-top: 8px; }
.tile-value small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.tile-foot { font-size: 12px; color: var(--muted); }

/* Diagramme */
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--line); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .bar { transition: opacity .15s; }
.chart .bar-group:hover .bar { opacity: .85; }
.chart .goal-line { stroke: var(--text-2); stroke-width: 1; opacity: .7; }
.chart .goal-text { fill: var(--text-2); font-weight: 600; }
.chart .val-text { fill: var(--text); font-weight: 700; font-size: 12px; }
.chart .dot { stroke: var(--surface); stroke-width: 2; transition: r .15s; }
.chart .dot-hit:hover + .dot, .chart .dot:hover { r: 6; }
.empty-chart { height: 160px; display: grid; place-items: center; color: var(--muted); font-size: 14px; text-align: center; }
.chart-foot { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.key i.line { height: 2px; width: 16px; border-radius: 2px; }

/* Horizontale Balken */
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 96px 1fr 64px; align-items: center; gap: 10px; font-size: 13px; }
.hbar-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 10px; border-radius: 0 4px 4px 0; position: relative; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; transform-origin: left; animation: grow .8s cubic-bezier(.2,.8,.2,1) both; }
@keyframes grow { from { transform: scaleX(0); } }
.hbar-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar-val small { color: var(--muted); font-weight: 600; }

/* Heatmap */
.heat-scroll { overflow-x: auto; scrollbar-width: thin; padding-bottom: 4px; }
.heat-scroll svg { min-width: 680px; width: 100%; height: auto; }
.heat-cell { rx: 3; transition: opacity .15s; }
.heat-cell:hover { opacity: .75; }
.heat-legend { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.heat-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Bestzeiten */
.records { display: grid; gap: 2px; }
.record { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 2px 12px; }
.record:last-child { border-bottom: 0; }
.record-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.record-val { font-weight: 800; font-size: 17px; letter-spacing: -.01em; text-align: right; }
.record-meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.record.none .record-val { color: var(--muted); font-weight: 600; font-size: 14px; }
.chip-new { font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 2px 6px; border-radius: 6px; color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

/* Badges */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.badge {
  position: relative; padding: 16px 12px 14px; border-radius: 16px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; justify-items: center; gap: 6px;
}
.badge-ic {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 28px;
  background: linear-gradient(145deg, color-mix(in oklab, var(--accent) 30%, var(--surface-3)), var(--surface-3));
  box-shadow: 0 8px 20px -10px var(--accent);
}
.badge b { font-size: 13px; line-height: 1.25; }
.badge span { font-size: 11px; color: var(--muted); line-height: 1.3; }
.badge.locked .badge-ic { filter: grayscale(1); opacity: .35; background: var(--surface-3); box-shadow: none; }
.badge.locked b { color: var(--text-2); }
.badge-progress { width: 80%; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 2px; }
.badge-progress i { display: block; height: 100%; background: var(--muted); border-radius: 4px; }

/* Laufliste */
.run-list { display: grid; gap: 2px; }
.month-head { display: flex; justify-content: space-between; align-items: baseline; padding: 18px 4px 8px; font-weight: 700; }
.month-head span { font-size: 13px; color: var(--muted); font-weight: 600; }
.run-row {
  display: grid; grid-template-columns: 56px minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)) 72px;
  align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
}
.run-row + .run-row { margin-top: 6px; }
.run-date { text-align: center; line-height: 1.1; }
.run-date b { display: block; font-size: 20px; font-weight: 800; }
.run-date span { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.run-main { min-width: 0; }
.run-main .title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.run-main .note { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-metric { display: grid; }
.run-metric b { font-weight: 700; font-variant-numeric: tabular-nums; }
.run-metric span { font-size: 11px; color: var(--muted); font-weight: 600; }
.run-actions { display: flex; gap: 4px; justify-content: flex-end; }
.run-actions button { width: 32px; height: 32px; border-radius: 9px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.run-actions button:hover { background: var(--surface-3); }
.run-actions svg { width: 16px; height: 16px; fill: var(--text-2); }
.run-metrics-wrap { display: contents; }
.type-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.type-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
@media (max-width: 760px) {
  .run-row { grid-template-columns: 48px 1fr auto; grid-template-areas: "d m a" "d x x"; row-gap: 8px; }
  .run-date { grid-area: d; }
  .run-main { grid-area: m; }
  .run-actions { grid-area: a; }
  .run-metrics-wrap { grid-area: x; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
}

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters select { width: auto; height: 38px; padding-right: 32px; }

/* Leere Zustände */
.empty {
  text-align: center; padding: 56px 20px; border: 1px dashed var(--line); border-radius: 20px;
  background: var(--surface);
}
.empty .big { font-size: 46px; }
.empty h2 { margin: 10px 0 6px; letter-spacing: -.02em; }
.empty p { color: var(--muted); margin: 0 auto 20px; max-width: 420px; }

/* Freunde */
.person { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; color: #fff;
}
.person-info { flex: 1; min-width: 0; }
.person-info b { display: block; font-size: 14px; }
.person-info span { font-size: 12px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-actions { display: flex; gap: 6px; }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }

.lb-row { display: grid; grid-template-columns: 28px 38px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 14px; }
.lb-row.me { background: var(--accent-soft); }
.lb-rank { font-weight: 800; font-size: 16px; text-align: center; color: var(--muted); }
.lb-row:nth-child(1) .lb-rank { color: var(--text); }
.lb-body { min-width: 0; }
.lb-name { font-weight: 700; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.lb-bar { height: 8px; border-radius: 0 4px 4px 0; margin-top: 6px; background: var(--surface-3); overflow: hidden; }
.lb-bar i { display: block; height: 100%; border-radius: 0 4px 4px 0; animation: grow .9s cubic-bezier(.2,.8,.2,1) both; transform-origin: left; }
.lb-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.lb-km { text-align: right; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.lb-km small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }

/* Profil */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.invite { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.invite:last-child { border-bottom: 0; }
.invite code { font-size: 15px; font-weight: 700; }
.invite .meta { font-size: 12px; color: var(--muted); grid-column: 1; }
.status-pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.status-pill.open { background: color-mix(in oklab, var(--good) 16%, transparent); color: var(--good); }

/* ---------- Modal ---------- */
.modal {
  width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: 24px;
  background: var(--surface); color: var(--text); box-shadow: 0 40px 80px -20px rgba(0,0,0,.5);
}
.modal::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .25s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px 0; }
.modal-head h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; justify-content: space-between; gap: 10px; padding: 16px 22px 22px; border-top: 1px solid var(--line); }
.modal-foot .right { display: flex; gap: 10px; margin-left: auto; }
@media (max-width: 560px) {
  .modal { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 24px 24px 0 0; }
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.dur-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dur-inputs label { position: relative; }
.dur-inputs input { padding-right: 30px; text-align: right; }
.dur-inputs label::after { content: attr(data-u); position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.live-pace {
  display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; margin-bottom: 16px;
  border-radius: 14px; background: var(--accent-soft);
}
.live-pace b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.live-pace span { font-size: 13px; color: var(--text-2); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2);
}
.chips button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.feel button { font-size: 20px; width: 46px; padding: 0; justify-content: center; }
details.more { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 14px; }
details.more summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 8px; }
details.more summary::before { content: '+'; width: 22px; height: 22px; border-radius: 7px; background: var(--surface-3); display: grid; place-items: center; }
details.more[open] summary::before { content: '–'; }
details.more[open] summary { margin-bottom: 14px; }

/* ---------- Tooltip & Toast ---------- */
.tip {
  position: fixed; z-index: 100; pointer-events: none; max-width: 260px;
  padding: 8px 11px; border-radius: 10px; font-size: 12px; line-height: 1.45;
  background: var(--text); color: var(--bg); box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.tip.show { opacity: 1; transform: none; }
.tip b { font-weight: 700; }
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; justify-items: center; width: max-content; max-width: calc(100vw - 24px); }
@media (max-width: 760px) { .toast-wrap { bottom: calc(84px + env(safe-area-inset-bottom)); } }
.toast {
  padding: 12px 18px; border-radius: 14px; background: var(--text); color: var(--bg);
  font-weight: 600; font-size: 14px; box-shadow: 0 16px 40px -14px rgba(0,0,0,.5);
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1);
}
.toast.err { background: var(--bad); color: #fff; }
.toast.party { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--r)); opacity: .9; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 560px) {
  .hero-track { display: none; }
  .grid { gap: 12px; }
  .card { padding: 16px; border-radius: 18px; }
  .tile-value { font-size: 24px; }
  .tile-label .ic { display: none; }
  .hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .hero-stats b { font-size: 16px; }
  .hero-stats span { font-size: 11px; }
  .page-head h1 { font-size: 26px; }
}
.modal-foot { position: sticky; bottom: 0; background: var(--surface); }
