:root {
  --primary: #1d4ed8;
  --primary-dark: #173a9c;
  --primary-soft: #e8eefc;

  --success: #0d7a6d;
  --success-soft: #e2f5f2;

  --warning: #e8a417;
  --warning-soft: #fff6dc;

  --danger: #c92a2a;
  --danger-soft: #ffe8e8;

  --background: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;

  --text: #172033;
  --text-muted: #64748b;

  --border: #dbe2ea;
  --shadow: 0 8px 24px rgba(23, 32, 51, .08);

  --radius: 14px;
  --radius-small: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 14px 40px;
}

.app-header {
  margin-bottom: 18px;
  text-align: center;
}

.app-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 850;
  letter-spacing: -.02em;
}

.app-subtitle {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: .9rem;
}

.card {
  padding: 16px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 800;
}

/* Suche */

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

#search {
  flex: 1 1 auto;
  min-width: 0;
  padding: 13px 14px;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

#search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.chip {
  padding: 8px 13px;
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.chip:hover {
  color: var(--primary-dark);
  border-color: #b9c6e6;
}

.chip.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

/* Status und Ergebnisse */

.status {
  min-height: 20px;
  margin: 12px 0 4px;
  color: var(--text-muted);
  font-size: .88rem;
}

.status-error {
  color: var(--danger);
  font-weight: 700;
}

.empty-state {
  padding: 22px 16px;
  color: var(--text-muted);
  text-align: center;
  background: var(--surface-soft);
  border: 1px dashed var(--border);
  border-radius: var(--radius-small);
}

.result {
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.result-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.result-title {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.3;
}

.result-subtitle {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: .82rem;
}

.competition-entries {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

/* Einzelwettkämpfe und Läufe */

.event-block {
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.event-title {
  margin-bottom: 10px;
  font-size: .95rem;
  font-weight: 750;
  color: var(--primary-dark);
}

.heat-block {
  padding: 10px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.heat-block:last-child {
  margin-bottom: 0;
}

.heat-title {
  margin-bottom: 8px;
  font-size: .82rem;
  font-weight: 750;
  color: var(--text-muted);
}

.heat-entries {
  display: grid;
  gap: 8px;
}

/* Startzeile */

.entry-row {
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.entry-main {
  --favorite-star-size: 30px;
  --favorite-star-gap: 8px;

  width: 100%;
}

.entry-first-line {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--favorite-star-gap);
}

.favorite-star {
  flex: 0 0 auto;
  width: var(--favorite-star-size);
  height: var(--favorite-star-size);
  display: grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
  color: #9aa7b2;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, transform .12s ease;
}

.favorite-star:hover,
.favorite-star.active {
  color: var(--warning);
  background: var(--warning-soft);
}

.favorite-star:active {
  transform: scale(.92);
}

.entry-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: .95rem;
  font-weight: 750;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.lane-chip {
  flex: 0 0 auto;
  margin-left: auto;
  display: inline-block;
  padding: 4px 9px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--success);
  background: var(--success-soft);
  border-radius: 999px;
}

.time-chip {
  flex: 0 0 auto;
  display: inline-block;
  padding: 4px 9px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 999px;
}

.entry-meta {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: .8rem;
}

.entry-subtitle {
  margin-left: calc(
    var(--favorite-star-size) + var(--favorite-star-gap)
  );

  color: var(--text-muted);
  font-size: .8rem;
}

/* Favoriten */

.favorite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.favorite-item:last-child {
  margin-bottom: 0;
}

.favorite-button {
  padding: 8px 12px;
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.favorite-button:hover {
  color: var(--primary-dark);
  border-color: #b9c6e6;
}

.favorite-button.active {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: #f0d08a;
}

/* Wettkampfverwaltung */

.competition-item {
  position: relative;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.competition-item:last-child {
  margin-bottom: 0;
}

.competition-title {
  font-size: .98rem;
  font-weight: 750;
  line-height: 1.3;
}

.competition-meta {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: .82rem;
}

.badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 9px;
  font-size: .72rem;
  font-weight: 800;
  border-radius: 999px;
}

.badge.ready {
  color: var(--success);
  background: var(--success-soft);
}

.badge.processing {
  color: var(--warning);
  background: var(--warning-soft);
}

.badge.failed {
  color: var(--danger);
  background: var(--danger-soft);
}

.competition-item .favorite-button {
  margin-top: 10px;
}

/* Upload */

.upload-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

input[type="file"] {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px;
  font-size: .9rem;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

button[type="submit"] {
  padding: 12px 16px;
  font-size: .92rem;
  font-weight: 800;
  color: #fff;
  background: var(--primary);
  border: 0;
  border-radius: var(--radius-small);
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}

button[type="submit"]:hover {
  background: var(--primary-dark);
}

button[type="submit"]:active {
  transform: scale(.98);
}

.upload-status {
  min-height: 20px;
  margin-top: 10px;
  color: var(--text-muted);
  font-size: .88rem;
}

.upload-status.status-error {
  color: var(--danger);
  font-weight: 700;
}

/* Mobil */

@media (max-width: 480px) {
  .app {
    padding: 14px 8px 30px;
  }

  .app-header h1 {
    font-size: 1.35rem;
  }

  .card {
    padding: 12px;
  }

  .result {
    padding: 10px;
  }

  .result-top {
    flex-direction: column;
  }

  .competition-entries {
    gap: 8px;
    margin-top: 10px;
  }

  .event-block {
    padding: 8px;
  }

  .heat-block {
    padding: 6px;
    margin-bottom: 6px;
  }

  .heat-entries {
    gap: 6px;
  }

  .entry-row {
    padding: 6px 8px;
  }

  .entry-main {
    --favorite-star-size: 26px;
    --favorite-star-gap: 5px;
  }

  .entry-first-line {
    gap: 5px;
  }

  .favorite-star {
    font-size: .95rem;
  }

  .entry-name {
    font-size: .88rem;
  }

  .lane-chip,
  .time-chip {
    padding: 3px 7px;
    font-size: .7rem;
    white-space: nowrap;
  }

  .entry-subtitle {
    font-size: .76rem;
  }
}

.app {
  width: 100%;
  max-width: 760px;
  margin: 0;
  padding: 18px 14px 40px;
}

/* Header */

.app-header h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 850;
  letter-spacing: -.02em;
}

.app-header p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: .9rem;
}

/* Kartenkopf */

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.card-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 50%;
}

/* Suche */

.search-wrap {
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 13px 14px;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.results {
  margin-top: 8px;
}

/* Wettkämpfe und Upload */

.competition-list {
  margin-bottom: 16px;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.field-label {
  margin-top: 4px;
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.upload-form input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  outline: none;
}

.upload-form input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}

.upload-form input[type="file"] {
  width: 100%;
}

.primary-button {
  align-self: flex-start;
  margin-top: 8px;
}

/* Favoriten */

.favorites {
  display: grid;
  gap: 8px;
}

.favorites .favorite-item {
  margin-bottom: 0;
}