/* ===== TRI-COACH Design-System ===== */
:root {
  --bg: #0d1220;
  --bg-card: #151c2e;
  --bg-card-2: #1b2438;
  --border: #263250;
  --text: #e8edf7;
  --text-muted: #8b97b0;
  --accent: #38bdf8;        /* Haupt-Akzent (Cyan) */
  --swim: #38bdf8;          /* Schwimmen */
  --bike: #fb923c;          /* Rad */
  --run: #4ade80;           /* Laufen */
  --warn: #facc15;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 14px;
  --nav-h: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  height: 100%;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ===== Kopfzeile ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(180deg, #121a2e, #0d1220);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand .logo { font-size: 1.4rem; letter-spacing: -4px; }
.topbar h1 { font-size: 1.05rem; letter-spacing: 2px; color: var(--accent); }

/* ===== Layout ===== */
.layout { display: flex; flex: 1; min-height: 0; }
.content {
  flex: 1;
  padding: 18px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: calc(var(--nav-h) + 24px);
}
.view { display: none; animation: fadeIn .25s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ===== Navigation ===== */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex; justify-content: space-around; align-items: stretch;
  background: #10172a;
  border-top: 1px solid var(--border);
  z-index: 60;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1;
  background: none; border: none; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .68rem; cursor: pointer; transition: color .15s;
}
.nav-btn .nav-ico { font-size: 1.25rem; }
.nav-btn.active { color: var(--accent); }
.nav-btn:hover { color: var(--text); }

/* Desktop: Sidebar statt Bottom-Nav */
@media (min-width: 900px) {
  .nav {
    position: sticky; top: 61px; bottom: auto;
    height: calc(100vh - 61px);
    width: 190px;
    flex-direction: column; justify-content: flex-start;
    border-top: none; border-right: 1px solid var(--border);
    padding: 14px 10px; gap: 4px;
  }
  .nav-btn {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 14px; border-radius: 10px; font-size: .9rem;
  }
  .nav-btn.active { background: rgba(56, 189, 248, .12); }
  .content { padding-bottom: 24px; }
}

/* ===== Karten & Grids ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { font-size: .95rem; margin-bottom: 10px; color: var(--text); display: flex; align-items: center; gap: 8px; }

/* Einrichtungs-Hinweis auf dem Dashboard */
.card.onboard {
  background: linear-gradient(135deg, rgba(56,189,248,.10), rgba(56,189,248,.03));
  border-color: rgba(56,189,248,.35);
}
.onboard-steps { display: flex; flex-direction: column; gap: 4px; }
.onboard-steps > span { display: flex; align-items: center; gap: 8px; }
.onboard-steps .done { color: var(--ok); }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #06202e;
  font-size: .7rem; font-weight: 700;
}
.onboard-steps .done .step-num { background: var(--ok); color: #06280f; }
.card h3 { font-size: .85rem; margin: 10px 0 6px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ===== Kennzahlen ===== */
.metric { background: var(--bg-card-2); border-radius: 10px; padding: 12px; text-align: center; }
.metric .val { font-size: 1.5rem; font-weight: 700; }
.metric .lbl { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.metric .sub { font-size: .72rem; color: var(--text-muted); }

/* Hinweisblock im Konto-Bereich */
.vault-note {
  margin-top: 14px; padding: 11px 13px;
  background: rgba(56,189,248,.06); border: 1px solid rgba(56,189,248,.22);
  border-radius: 10px; font-size: .78rem; line-height: 1.6; color: var(--text-muted);
}
.vault-note strong { color: var(--text); }

/* ===== Karte "Heute absolviert" ===== */
.done-activity { padding: 10px 0; border-bottom: 1px solid var(--border); }
.done-activity:last-of-type { border-bottom: none; }
.done-metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px;
}
.done-metric {
  background: var(--bg-card-2); border-radius: 8px; padding: 8px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center;
}
.done-metric .v { font-size: 1.02rem; font-weight: 700; }
.done-metric .l { font-size: .64rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.plan-compare {
  margin-top: 12px; padding: 10px 12px;
  background: rgba(56,189,248,.07); border: 1px solid rgba(56,189,248,.2);
  border-radius: 10px; font-size: .88rem;
}

/* Aktualisieren-Knopf in der Kopfzeile */
.icon-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-muted); cursor: pointer;
  width: 32px; height: 32px; font-size: .9rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn.spinning { animation: spin 1s linear infinite; pointer-events: none; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* Streckenlaengen des Zielwettkampfs */
.race-dist {
  display: flex; justify-content: space-around; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: .85rem; font-weight: 600;
}

/* ===== Ringe / Readiness ===== */
.readiness-wrap { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; width: 110px; height: 110px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-txt {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring .ring-txt .big { font-size: 1.6rem; font-weight: 700; }
.ring .ring-txt .small { font-size: .65rem; color: var(--text-muted); }

/* ===== Buttons & Formulare ===== */
.btn {
  background: var(--accent); color: #06202e; border: none;
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .88rem;
  cursor: pointer; transition: filter .15s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-danger { background: var(--danger); color: #2b0a0a; }

label.field { display: block; margin-bottom: 12px; font-size: .82rem; color: var(--text-muted); }
input, select, textarea {
  width: 100%; margin-top: 4px;
  background: var(--bg-card-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 11px; color: var(--text); font-size: .9rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 700px) { .field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; } }

/* Erklaertext unter einem Eingabefeld — standardmaessig ausgeblendet,
   damit das Formular kompakt bleibt. Schalter oben im Setup blendet ein. */
.field-help { display: none; }
.show-help .field-help {
  display: block;
  font-size: .78rem; color: var(--text-muted); line-height: 1.55;
  margin: -6px 0 14px; padding-left: 10px;
  border-left: 2px solid var(--border);
}
.field-help strong { color: var(--text); font-weight: 600; }

.toggle-help {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .8rem; color: var(--text-muted); cursor: pointer;
}
.toggle-help input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* Setup-Formulare lesen sich schmaler besser als ueber die volle Breite */
#view-settings { max-width: 820px; }

/* Aufklappbare Detailhilfe (Testprotokolle) */
.help-details {
  background: var(--bg-card-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 12px;
}
.help-details > summary {
  cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--accent);
  list-style: none;
}
.help-details > summary::-webkit-details-marker { display: none; }
.help-details > summary::before { content: "▸ "; }
.help-details[open] > summary::before { content: "▾ "; }
.help-details[open] > summary { margin-bottom: 8px; }
.help-details p { margin-bottom: 7px; line-height: 1.6; }
.help-details p:last-child { margin-bottom: 0; }

/* ===== Pills & Badges ===== */
.pill { padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.pill-ok { background: rgba(74, 222, 128, .15); color: var(--ok); }
.pill-off { background: rgba(248, 113, 113, .15); color: var(--danger); }
.pill-warn { background: rgba(250, 204, 21, .15); color: var(--warn); }
.pill-info { background: rgba(56, 189, 248, .15); color: var(--accent); }
.badge-sport { padding: 2px 8px; border-radius: 6px; font-size: .7rem; font-weight: 700; }
.badge-swim { background: rgba(56,189,248,.18); color: var(--swim); }
.badge-bike { background: rgba(251,146,60,.18); color: var(--bike); }
.badge-run { background: rgba(74,222,128,.18); color: var(--run); }
.badge-rest { background: rgba(139,151,176,.18); color: var(--text-muted); }
.badge-brick { background: rgba(250,204,21,.18); color: var(--warn); }

/* ===== Wochenplan ===== */
.week-day {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 6px; border-bottom: 1px solid var(--border);
}
.week-day:last-child { border-bottom: none; }
.week-day.today-row { background: rgba(56,189,248,.06); border-radius: 8px; }
.week-day .day-name { width: 42px; flex-shrink: 0; font-weight: 700; font-size: .8rem; padding-top: 2px; }
.week-day .day-body { flex: 1; }
.week-day .day-title { font-size: .88rem; font-weight: 600; }
.week-day .day-desc { font-size: .78rem; color: var(--text-muted); }

/* ===== Chat ===== */
.chat-box {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 300px; max-height: 55vh; overflow-y: auto;
  padding: 4px;
}
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.msg-user { align-self: flex-end; background: var(--accent); color: #06202e; border-bottom-right-radius: 4px; }
.msg-ai { align-self: flex-start; background: var(--bg-card-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-ai.thinking { color: var(--text-muted); font-style: italic; }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }
.chat-input-row textarea { resize: none; height: 48px; margin-top: 0; }

/* ===== Checklisten ===== */
.check-item { display: flex; align-items: center; gap: 10px; padding: 7px 4px; font-size: .88rem; cursor: pointer; }
.check-item input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.check-item.done span { text-decoration: line-through; color: var(--text-muted); }
.progressbar { height: 6px; background: var(--bg-card-2); border-radius: 3px; overflow: hidden; margin: 6px 0 10px; }
.progressbar > div { height: 100%; background: var(--ok); transition: width .3s; }

/* ===== Diverses ===== */
.muted { color: var(--text-muted); }
.small { font-size: .78rem; }
.hidden { display: none !important; }
.spacer { height: 8px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.ai-output {
  background: var(--bg-card-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; font-size: .88rem; white-space: pre-wrap; margin-top: 10px;
  max-height: 420px; overflow-y: auto;
}
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 14px; font-size: .72rem; color: var(--text-muted); margin-top: 6px; flex-wrap: wrap; }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }

.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.25); border-top-color: currentColor;
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--bg-card-2); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 10px; font-size: .85rem; z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  max-width: 90vw;
}
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ===== Wetter ===== */
.weather-row { display: flex; align-items: center; gap: 14px; }
.weather-temp { font-size: 2rem; font-weight: 700; }
.weather-detail { font-size: .78rem; color: var(--text-muted); }
