/* Eltern App — mobil zuerst, Vereinsblau, systemeigene Schrift, hell und dunkel. */

:root {
  --brand: #03519c;
  --brand-strong: #023b73;
  --brand-soft: #e5eef8;
  --topbar: #03519c;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #5b6678;
  --line: #e2e7ee;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --warning-soft: #fff6e0;
  --warning-line: #f0d48a;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 4px 16px rgb(15 23 42 / 5%);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #5aa2ea;
    --brand-strong: #8cc0f2;
    --brand-soft: #11263d;
    --topbar: #0a2d52;
    --bg: #0b1320;
    --surface: #131d2c;
    --text: #e8eef6;
    --muted: #9aa8bb;
    --line: #223149;
    --danger: #f87171;
    --danger-soft: #3a1717;
    --warning-soft: #33290f;
    --warning-line: #6b561b;
    --shadow: none;
  }
}

[hidden] {
  display: none !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(96px + var(--safe-bottom));
}

a {
  color: var(--brand);
}

button,
input,
select {
  font: inherit;
  font-size: 16px; /* verhindert das Hineinzoomen auf iOS */
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.icon--large {
  width: 44px;
  height: 44px;
  color: var(--muted);
}

/* ---------- Kopfzeile ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  /* Eigene Farbe: im dunklen Modus ist --brand hellblau — weiße Schrift wäre dort kaum lesbar. */
  background: var(--topbar);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* „Fehlt was?" mittig zwischen Titel und Knöpfen; „Neue Antwort" hervorgehoben */
.topbar-missing.has-reply {
  border-color: #ffc629;
  background: #ffc629;
  color: #0b2545;
}

.topbar-missing {
  flex: none;
  margin: 0 auto;
  padding: 6px 12px;
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  box-shadow: 0 0 0 1.5px rgb(255 255 255 / 55%);
}

.brand-title {
  font-weight: 700;
  font-size: 18px;
}

@media (max-width: 340px) {
  .brand-title {
    display: none;
  }
}

@media (max-width: 380px) {
  .brand-title {
    font-size: 16px;
  }

  .topbar-missing {
    padding: 5px 9px;
    font-size: 13px;
  }
}

.topbar-actions {
  display: flex;
  flex: none;
  gap: 2px;
}

.topbar .icon-button {
  color: #fff;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  background: rgb(127 127 127 / 14%);
}

.icon-button .icon {
  width: 24px;
  height: 24px;
}

/* ---------- Layout ---------- */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.page-title {
  margin: 8px 0 4px;
  font-size: 26px;
  line-height: 1.2;
}

.lead {
  margin: 0 0 20px;
  color: var(--muted);
}

.section-title {
  margin: 20px 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

@media (prefers-color-scheme: dark) {
  .button--primary,
  .filter--team[aria-pressed='true'] {
    color: #06121f;
  }
}

.button--small {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 15px;
}

.button--block {
  width: 100%;
}

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

.text-link {
  font-weight: 600;
}

/* ---------- Auswahl ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  --team-color: #64748b;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 96px;
  padding: 14px 14px 12px 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tile::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: var(--team-color);
}

.tile[aria-pressed='true'] {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.tile-check {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  border-radius: 50%;
  color: transparent;
}

.tile[aria-pressed='true'] .tile-check {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.tile-check .icon {
  width: 16px;
  height: 16px;
  stroke-width: 3;
}

.tile-name {
  padding-right: 30px;
  font-size: 17px;
  font-weight: 700;
}

.tile-subtitle {
  font-size: 14px;
  color: var(--muted);
}

.tile-source {
  margin-top: auto;
  padding-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.sticky-action {
  position: fixed;
  inset: auto 0 0;
  z-index: 5;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.sticky-action .button {
  max-width: 688px;
  margin: 0 auto;
  display: flex;
}

/* ---------- Filter & Status ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0;
}

.filter {
  flex: none;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.filter[aria-pressed='true'] {
  border-color: var(--text);
  background: var(--text);
  color: var(--surface);
}

.status-banner {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--warning-line);
  border-radius: 12px;
  background: var(--warning-soft);
  font-size: 14px;
}

.status-banner p {
  margin: 0;
}

/* ---------- Termine ---------- */

.next-when {
  margin-left: 6px;
  color: var(--brand);
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
}

.day-heading {
  position: sticky;
  top: calc(58px + var(--safe-top));
  z-index: 2;
  margin: 18px -16px 8px;
  padding: 6px 16px;
  background: var(--bg);
  font-size: 15px;
  font-weight: 700;
}

.event-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.event {
  --team-color: #64748b;
  position: relative;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.event::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--team-color);
}

.event--hero {
  border: 2px solid var(--brand);
}

.event-main {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 24px;
  gap: 10px;
  width: 100%;
  padding: 12px 12px 12px 16px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.event-time {
  display: flex;
  flex-direction: column;
}

.time-start {
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.time-start--small {
  font-size: 13px;
  font-weight: 700;
}

.time-meet {
  font-size: 12px;
  color: var(--muted);
}

.event-body {
  min-width: 0;
}

.event-title {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-weight: 700;
}

.event-title .icon {
  margin-top: 2px;
  color: var(--muted);
}

.event--game .event-title .icon {
  color: var(--brand);
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 2px;
  font-size: 14px;
  color: var(--muted);
}

.event-location {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.team-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.team-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--team-color);
}

.event-chevron {
  align-self: center;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.event-main[aria-expanded='true'] .event-chevron {
  transform: rotate(180deg);
}

.event--hero .event-chevron {
  visibility: hidden;
}

.event--cancelled .event-title span,
.event--cancelled .time-start {
  text-decoration: line-through;
  color: var(--muted);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

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

.badge--muted {
  background: var(--bg);
  color: var(--muted);
}

.badge--win {
  background: #dcfce7;
  color: #166534;
}

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

.badge--draw {
  background: var(--bg);
  color: var(--muted);
}

@media (prefers-color-scheme: dark) {
  .badge--win {
    background: #12341f;
    color: #86efac;
  }
}

.badge--outline {
  border: 1px solid var(--line);
  color: var(--muted);
}

.event-details {
  padding: 0 14px 14px 88px;
}

.detail-rows {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 15px;
}

.detail-rows li {
  display: flex;
  gap: 8px;
}

.detail-rows .icon {
  margin-top: 1px;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 420px) {
  .event-details {
    padding-left: 16px;
  }
}

/* ---------- Leere Zustände ---------- */

.empty-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 48px 16px;
  color: var(--muted);
  text-align: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
}

/* ---------- Hinweise, Toast, Version ---------- */

.banners {
  position: fixed;
  inset: auto 12px calc(12px + var(--safe-bottom));
  z-index: 20;
  max-width: 696px;
  margin: 0 auto;
}

/* Während der Teamauswahl liegt der „Weiter"-Knopf unten — Hinweise darüber. */
.is-onboarding .banners {
  bottom: calc(88px + var(--safe-bottom));
}

.is-onboarding {
  padding-bottom: calc(220px + var(--safe-bottom));
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 30px rgb(15 23 42 / 18%);
}

.banner p {
  flex: 1 1 200px;
  margin: 0;
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--surface);
  transform: translateX(-50%);
  font-size: 15px;
}

.version {
  position: fixed;
  right: 8px;
  bottom: calc(4px + var(--safe-bottom));
  z-index: 1;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
  pointer-events: none;
}

/* ---------- Dialog ---------- */

.dialog {
  width: min(560px, 100%);
  max-height: 92vh;
  margin: auto auto 0;
  padding: 0 16px calc(16px + var(--safe-bottom));
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  color: var(--text);
}

@media (min-width: 640px) {
  .dialog {
    margin: auto;
    border-radius: 20px;
  }
}

.dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

.dialog-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 8px;
  background: var(--surface);
}

.dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

.settings-section {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.settings-section h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.settings-section p {
  margin: 0 0 10px;
}

.hint {
  font-size: 14px;
  color: var(--muted);
}

.push-status {
  font-weight: 600;
}

.push-status.is-on {
  color: #15803d;
}

.select {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}

.version-inline {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Hilfe- und Textseiten ---------- */

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

.callout {
  padding: 12px 14px;
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  background: var(--brand-soft);
}

.platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.steps {
  margin: 0;
  padding-left: 22px;
}

.steps li {
  margin-bottom: 8px;
}

.checks {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.checks li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.check-yes {
  color: #15803d;
  font-weight: 700;
}

.check-no {
  color: var(--muted);
  font-weight: 700;
}

.prose p {
  margin: 0 0 12px;
}

/* ---------- Hinweis „nur Trainingszeiten" ---------- */

.info-banner {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--brand-soft);
  font-size: 14px;
}

.info-banner p {
  margin: 0;
}

.missing-hint {
  margin-top: 20px;
}

/* ---------- Mehrfachauswahl ---------- */

.filters + .filters {
  margin-top: 0;
}

.filter--team[aria-pressed='true'] {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.filter--action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: var(--brand);
  color: var(--brand);
}

.selection-panel {
  margin-bottom: 8px;
  padding: 12px 14px;
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  background: var(--surface);
}

.selection-title {
  margin: 0 0 4px;
  font-size: 17px;
}

.selection-panel .hint {
  margin: 0 0 10px;
}

.quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pick-box {
  align-self: center;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: transparent;
}

.pick-box .icon {
  width: 18px;
  height: 18px;
  stroke-width: 3;
}

.event--picked {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: var(--brand-soft);
}

.event--picked .pick-box {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.event-main:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.event-main:disabled .pick-box {
  visibility: hidden;
}

.selection-bar {
  position: fixed;
  inset: auto 0 0;
  z-index: 25;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 -6px 24px rgb(15 23 42 / 12%);
}

.selection-count {
  flex: 1 1 100%;
  font-weight: 700;
}

.selection-bar .button {
  flex: 1 1 0;
}

.is-selecting .banners,
.is-selecting .version {
  display: none;
}

/* ---------- Prüfansicht ---------- */

.review-summary {
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--brand);
}

.review-day {
  margin: 14px 0 6px;
  font-size: 14px;
  color: var(--muted);
}

.review-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-row {
  --team-color: #64748b;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  padding: 6px 4px 6px 12px;
  border-left: 4px solid var(--team-color);
  border-radius: 10px;
  background: var(--bg);
}

.review-time {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.review-text {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.review-text > span {
  min-width: 0;
}

.review-text .icon {
  flex: none;
  margin-top: 2px;
}

.review-text strong {
  display: block;
  overflow-wrap: anywhere;
}

.review-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-text small {
  color: var(--muted);
}

.dialog-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

/* ---------- Kalender-Abo je Gerät ---------- */

.calendar-option {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.calendar-option h4 {
  margin: 0 0 4px;
  font-size: 15px;
}

.hint--warning {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--warning-line);
  border-radius: 10px;
  background: var(--warning-soft);
  color: var(--text);
}

/* ---------- Termine hochladen ---------- */

.field {
  display: grid;
  gap: 4px;
  margin: 14px 0 0;
}

.field label {
  font-weight: 600;
}

.textarea,
.field input[type='file'] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.new-team {
  margin-top: 6px;
  padding: 4px 12px 12px;
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  background: var(--brand-soft);
}

.label-preview {
  margin: 12px 0 0;
  font-weight: 700;
  color: var(--brand);
}

#upload-form .button--block {
  margin-top: 18px;
}

.upload-success {
  display: grid;
  justify-items: start;
  gap: 6px;
}

.upload-success .icon--large {
  color: #15803d;
}

/* ---------- Chat „Fehlt was?" ---------- */

.chat-thread {
  display: grid;
  gap: 8px;
  max-height: 50vh;
  margin-bottom: 12px;
  overflow-y: auto;
}

.chat-message {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 14px;
}

.chat-message p {
  margin: 2px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-message--own {
  justify-self: end;
  background: var(--brand-soft);
}

.chat-message--admin {
  justify-self: start;
  background: var(--bg);
  border: 1px solid var(--line);
}

.chat-meta {
  font-size: 12px;
  color: var(--muted);
}

#chat-form .button--block {
  margin-top: 10px;
}
