:root {
  --bg: #0b0d10;
  --surface: #13171c;
  --surface-2: #1a1f26;
  --line: #262d36;
  --text: #f2f4f5;
  --muted: #8b95a1;
  --volt: #d7ff3a;
  --volt-ink: #0b0d10;
  --wish: #7c9cff;
  --done: #a7b0ba;
  --danger: #ff5c6c;
  --radius: 18px;
  --display: "Barlow Condensed", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }

.demo-banner {
  background: var(--volt); color: var(--volt-ink);
  font-size: 13px; font-weight: 600; text-align: center; padding: 8px 16px;
}
.demo-banner code { background: rgba(0,0,0,.1); padding: 1px 5px; border-radius: 4px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 56px 0 28px;
  background:
    radial-gradient(900px 380px at 85% -10%, rgba(215,255,58,.16), transparent 60%),
    radial-gradient(700px 300px at -10% 110%, rgba(124,156,255,.12), transparent 60%);
  border-bottom: 1px solid var(--line);
}
.hero-lanes {
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(-62deg, transparent 0 58px, rgba(255,255,255,.035) 58px 60px);
  mask-image: linear-gradient(to bottom, #000 30%, transparent);
}
.hero-inner { position: relative; }
.eyebrow {
  margin: 0 0 6px; color: var(--volt); font-weight: 600; font-size: 13px;
  letter-spacing: .08em; text-transform: uppercase;
}
.hero-title {
  margin: 0; font-family: var(--display); font-weight: 800; text-transform: uppercase;
  font-size: clamp(48px, 12vw, 96px); line-height: .88; letter-spacing: -.01em;
}
.hero-tagline { margin: 12px 0 0; color: var(--muted); font-size: 16px; max-width: 46ch; }

.next-race {
  margin-top: 28px; padding: 20px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--volt), #b6f000);
  color: var(--volt-ink); display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end;
  cursor: pointer; transition: transform .15s ease;
}
.next-race:hover { transform: translateY(-2px); }
.next-race .label { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: .7; }
.next-race .name { font-family: var(--display); font-weight: 800; font-size: clamp(26px, 6vw, 38px); line-height: 1; text-transform: uppercase; margin-top: 4px; }
.next-race .meta { font-size: 14px; font-weight: 500; margin-top: 6px; opacity: .8; }
.next-race .count { text-align: right; font-family: var(--display); line-height: .85; }
.next-race .count b { display: block; font-size: clamp(56px, 14vw, 84px); font-weight: 800; }
.next-race .count span { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat b { display: block; font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1; }
.stat span { font-size: 12px; color: var(--muted); }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Personal Bests ---------- */
.pbs {
  margin-top: 14px; padding: 16px; border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); position: relative; overflow: hidden;
}
.pbs::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(215,255,58,.14), transparent 70%); pointer-events: none;
}
.pbs-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.pbs-head h2 {
  margin: 0; font-family: var(--display); font-size: 20px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em;
}
.pbs-icon { color: var(--volt); }
.pb-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.pb {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 6px; text-align: center; min-width: 0;
}
.pb-dist { display: block; font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--volt); }
.pb-time {
  display: block; font-family: var(--display); font-weight: 800; line-height: 1.1;
  font-size: clamp(18px, 5vw, 30px); margin: 2px 0; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pb-note { display: block; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-pb .pb-time { color: var(--muted); }
@media (max-width: 560px) {
  .pb-grid { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .pb { grid-column: span 2; }
  .pb:nth-child(4), .pb:nth-child(5) { grid-column: span 3; }
  .pb-time { font-size: 24px; }
}

.pb-row { display: grid; grid-template-columns: 44px 1fr 1.4fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.pb-row-label { font-family: var(--display); font-weight: 800; font-size: 18px; color: var(--volt); }
.pb-row input { margin-top: 0 !important; }
@media (max-width: 460px) { .pb-row { grid-template-columns: 40px 1fr; } .pb-row input:last-child { grid-column: 2; } }

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 14px 0; background: rgba(11,13,16,.88); backdrop-filter: blur(12px);
}
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .view-toggle button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 8px 14px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.tabs button.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.view-toggle { display: flex; gap: 4px; flex-shrink: 0; }
.view-toggle button { padding: 8px 10px; display: grid; place-items: center; }
.view-toggle button.active { color: var(--volt); border-color: var(--volt); }
@media (max-width: 600px) {
  .toolbar { flex-wrap: wrap; }
  .tabs { order: 2; width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .tabs button { padding: 8px 2px; font-size: 13px; }
  .view-toggle { order: 1; margin-left: auto; }
  .toolbar::before {
    content: "Meine Events"; order: 0; font-family: var(--display); font-weight: 800;
    font-size: 22px; text-transform: uppercase;
  }
}

/* ---------- List ---------- */
.month { margin: 22px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.month h3 { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.month small { color: var(--muted); font-size: 13px; }

.card {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; cursor: pointer; position: relative; overflow: hidden;
  transition: border-color .15s, transform .15s;
  animation: rise .35s ease both;
}
.card:hover { border-color: #3a434f; transform: translateY(-1px); }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--volt)); }
.card.wishlist { --accent: var(--wish); }
.card.done { --accent: var(--done); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.date-block { text-align: center; background: var(--surface-2); border-radius: 12px; padding: 8px 4px; }
.date-block .d { font-family: var(--display); font-size: 30px; font-weight: 800; line-height: 1; }
.date-block .m { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent, var(--volt)); }
.date-block .w { font-size: 11px; color: var(--muted); }

.card-main { min-width: 0; }
.card-title { font-weight: 700; font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.chip {
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); white-space: nowrap;
}
.chip.status-registered { background: rgba(215,255,58,.12); color: var(--volt); border-color: rgba(215,255,58,.3); }
.chip.status-wishlist { background: rgba(124,156,255,.12); color: var(--wish); border-color: rgba(124,156,255,.3); }
.chip.status-done { color: var(--done); }
.place { font-size: 13px; color: var(--muted); }

.card-side { text-align: right; }
.countdown { font-family: var(--display); font-size: 26px; font-weight: 700; line-height: 1; }
.countdown small { display: block; font-family: var(--body); font-size: 11px; color: var(--muted); font-weight: 500; }
.result { font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--volt); }

.empty {
  text-align: center; padding: 56px 16px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius); margin-top: 18px;
}
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 12px; }
.cal-head h3 { margin: 0; font-family: var(--display); font-size: 28px; font-weight: 800; text-transform: uppercase; }
.cal-nav { display: flex; gap: 6px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  width: 38px; height: 38px; display: grid; place-items: center; font-size: 16px;
}
.icon-btn:hover { border-color: #3a434f; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; text-align: center; padding: 4px 0; }
.cal-day {
  min-height: 86px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; display: flex; flex-direction: column; gap: 3px; overflow: hidden;
}
.cal-day.out { opacity: .3; }
.cal-day.today { border-color: var(--volt); }
.cal-day .num { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-day.today .num { color: var(--volt); }
.pill {
  font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px; border: 0; text-align: left;
  background: var(--volt); color: var(--volt-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;
}
.pill.wishlist { background: var(--wish); color: #0b0d10; }
.pill.done { background: var(--done); color: #0b0d10; }
@media (max-width: 600px) {
  .cal-day { min-height: 54px; padding: 4px; }
  .pill { font-size: 0; height: 7px; padding: 0; border-radius: 4px; }
}
.cal-list { margin-top: 18px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; align-items: center; gap: 6px;
  background: var(--volt); color: var(--volt-ink); border: 0; border-radius: 999px;
  padding: 14px 20px; font-weight: 700; font-size: 15px;
  box-shadow: 0 10px 30px rgba(215,255,58,.25);
}
.fab svg { stroke-width: 2.6; }

/* ---------- Footer ---------- */
.footer {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--muted); font-size: 13px; padding-top: 40px; padding-bottom: 90px;
}
.footer-right { display: flex; align-items: center; gap: 8px; }
.link-btn { background: none; border: 0; color: var(--muted); padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.link-btn:hover { color: var(--text); }
.link-btn svg { width: 16px; height: 16px; }

/* ---------- Dialogs ---------- */
.sheet {
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: 22px; padding: 22px;
}
.sheet::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 800; text-transform: uppercase; }
.sheet label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.sheet input, .sheet select, .sheet textarea {
  display: block; width: 100%; margin-top: 5px; padding: 11px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; color: var(--text); font-size: 16px;
}
.sheet input:focus, .sheet select:focus, .sheet textarea:focus { outline: none; border-color: var(--volt); }
.sheet input[type="date"] { color-scheme: dark; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 460px) { .row { grid-template-columns: 1fr; gap: 0; } }

.seg { border: 0; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg legend { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; padding: 0; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 11px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-weight: 600; font-size: 14px;
}
.seg input:checked + span { border-color: var(--volt); background: rgba(215,255,58,.1); }
.seg input:focus-visible + span { outline: 2px solid var(--volt); }

.sheet-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.spacer { flex: 1; }
.btn { border-radius: 12px; padding: 11px 16px; font-weight: 700; border: 1px solid var(--line); background: var(--surface-2); }
.btn.primary { background: var(--volt); color: var(--volt-ink); border-color: var(--volt); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(255,92,108,.35); }
.btn:disabled { opacity: .5; cursor: progress; }

.detail-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.detail-date { color: var(--volt); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; }
.detail-name { font-family: var(--display); font-size: 36px; font-weight: 800; line-height: 1; text-transform: uppercase; margin: 6px 0 12px; overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0; }
.detail-grid div { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.detail-grid small { display: block; color: var(--muted); font-size: 12px; }
.detail-grid b { font-size: 16px; }
.detail-notes { color: var(--muted); white-space: pre-wrap; margin: 0 0 16px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-actions a.btn { text-decoration: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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