:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a2027;
  --muted: #5c6672;
  --line: #e3e6ea;
  --accent: #4c8dff;
  --green: #2f9e44;
  --yellow: #e8a013;
  --red: #d64545;
  --radius: 12px;
  --gap: 12px;
  --pad: 16px;

  --fs-label: 13px;
  --fs-body: 15px;
  --fs-tile-title: 17px;
  --fs-kennzahl: 22px;
  --fs-hero: 28px;

  --zone-e: #4c8dff;
  --zone-m: #2f9e44;
  --zone-t: #e8a013;
  --zone-i: #e0662e;
  --zone-r: #d64545;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1318;
    --surface: #171d24;
    --text: #e6e9ed;
    --muted: #8b94a1;
    --line: #232b34;
  }
}

* {
  box-sizing: border-box;
}

[x-cloak] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--fs-body);
}

a {
  color: inherit;
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--pad);
  padding-bottom: 84px;
}

.top-nav {
  display: none;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 20;
}

.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  text-decoration: none;
  font-size: var(--fs-label);
  color: var(--muted);
}

.bottom-nav a.active {
  color: var(--accent);
  font-weight: 600;
}

@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }

  .top-nav {
    display: flex;
    gap: var(--gap);
    max-width: 960px;
    margin: 0 auto;
    padding: var(--pad) var(--pad) 0;
  }

  .top-nav a {
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius);
    color: var(--muted);
    font-weight: 600;
  }

  .top-nav a.active {
    color: var(--accent);
    background: var(--surface);
  }

  .tiles-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap);
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: var(--gap);
}

.card-title {
  font-size: var(--fs-tile-title);
  font-weight: 600;
  margin: 0 0 8px;
}

.label {
  font-size: var(--fs-label);
  color: var(--muted);
}

.hero-number {
  font-size: var(--fs-hero);
  font-weight: 700;
}

.kennzahl {
  font-size: var(--fs-kennzahl);
  font-weight: 600;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--gap);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: var(--fs-label);
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.chip-green {
  background: color-mix(in srgb, var(--green) 15%, var(--surface));
  color: var(--green);
  border-color: var(--green);
}

.chip-yellow {
  background: color-mix(in srgb, var(--yellow) 15%, var(--surface));
  color: var(--yellow);
  border-color: var(--yellow);
}

.chip-red {
  background: color-mix(in srgb, var(--red) 15%, var(--surface));
  color: var(--red);
  border-color: var(--red);
}

.muted {
  color: var(--muted);
}

.banner {
  border-radius: var(--radius);
  padding: 10px var(--pad);
  margin-bottom: var(--gap);
  font-size: var(--fs-label);
}

.banner-stale {
  background: color-mix(in srgb, var(--yellow) 18%, var(--surface));
  border: 1px solid var(--yellow);
  color: var(--text);
}

.banner-error {
  background: color-mix(in srgb, var(--red) 15%, var(--surface));
  border: 1px solid var(--red);
  color: var(--text);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.week-day {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  min-height: 90px;
  background: var(--surface);
}

.week-day.today {
  border-color: var(--accent);
  border-width: 2px;
}

.day-label {
  font-size: var(--fs-label);
  color: var(--muted);
  margin-bottom: 4px;
}

.tile-workout {
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 12px;
  margin-bottom: 4px;
}

.tile-workout.origin-intervals {
  border-style: dashed;
}

.tile-activity {
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 12px;
  margin-bottom: 4px;
}

.tile-activity.commute {
  background: var(--muted);
  font-size: 11px;
  opacity: 0.8;
}

.empty-day {
  color: var(--muted);
  font-size: 12px;
}

.progress-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}

.progress-bar > div {
  height: 100%;
  background: var(--accent);
}

button,
.btn {
  font-family: inherit;
  font-size: var(--fs-body);
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

input[type="password"],
input[type="text"] {
  font-family: inherit;
  font-size: var(--fs-body);
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-body);
}

table th,
table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

tr.current-week {
  border-left: 3px solid var(--accent);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}

.sheet {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: var(--pad);
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

@media (min-width: 768px) {
  .sheet-backdrop {
    align-items: center;
    justify-content: center;
  }

  .sheet {
    border-radius: var(--radius);
    max-width: 480px;
  }
}
