:root {
  --bg: #f4f5f7; --surface: #ffffff; --border: #e3e6eb; --text: #14171c; --muted: #6b7280;
  --accent: #ff5a1f; --accent-soft: #fff0ea;
  --ctl: #2563eb; --atl: #db2777; --tsb: #f59e0b; --pos: #16a34a; --neg: #dc2626;
  --z1: #9ca3af; --z2: #3b82f6; --z3: #10b981; --z4: #eab308; --z5: #f97316; --z6: #ef4444; --z7: #8b5cf6;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014; --surface: #171a20; --border: #262a33; --text: #e8eaee; --muted: #9098a5;
    --accent-soft: #2a1a12; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1014; --surface: #171a20; --border: #262a33; --text: #e8eaee; --muted: #9098a5;
  --accent-soft: #2a1a12; --shadow: none; color-scheme: dark;
}

/* Thema-knop rechtsboven */
.theme-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 36px; height: 36px; border-radius: 50%;
  font-size: 17px; cursor: pointer; display: grid; place-items: center; flex: none; margin-left: auto; }
.theme-btn:hover { border-color: var(--muted); }
.user + .theme-btn { margin-left: 0; }
.sync { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.sync-info { font-size: 11px; color: var(--muted); }

/* Trainingsstatus */
.status-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 28px; padding: 24px; }
.status-main { border-right: 1px solid var(--border); padding-right: 28px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.status-label { font-size: 32px; font-weight: 700; line-height: 1.15; margin: 4px 0 6px; }
.status-label.small { font-size: 22px; }
.status-text { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.focus-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 120px; gap: 12px; align-items: center; margin: 12px 0; font-size: 14px; }
.focus-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.focus-name i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.focus-track { position: relative; height: 16px; border-radius: 8px; background: var(--bg); overflow: hidden; }
.focus-band { position: absolute; top: 0; bottom: 0; opacity: .22; }
.focus-band.neutral { background: var(--pos); opacity: .18; }
.focus-fill { position: absolute; left: 0; top: 3px; bottom: 3px; border-radius: 6px; }
.focus-val { text-align: right; font-size: 13px; }
.acute { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; margin-top: 8px; font-size: 14px; }
.acute-mark { position: absolute; top: 1px; width: 6px; height: 14px; border-radius: 3px; transform: translateX(-3px); }
.status-foot { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 14px; font-size: 13px; }
@media (max-width: 860px) {
  .status-card { grid-template-columns: 1fr; gap: 20px; }
  .status-main { border-right: 0; padding-right: 0; border-bottom: 1px solid var(--border); padding-bottom: 20px; }
  .focus-row { grid-template-columns: 110px minmax(0, 1fr); }
  .focus-val { grid-column: 2; text-align: left; margin-top: -6px; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 Inter, system-ui, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num, td.num { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.logo { color: var(--accent); font-size: 22px; }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 500; padding: 8px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
nav button:hover { color: var(--text); }
nav button.active { color: var(--accent); background: var(--accent-soft); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 10px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--neg); }
.btn.ghost { border-color: transparent; background: none; padding-left: 0; }

main { max-width: 1240px; margin: 0 auto; padding: 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); min-width: 0; }
.card.narrow { max-width: 560px; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart { position: relative; height: 240px; }
.chart.tall { height: 340px; }
.note { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.tile .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.tile .label i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tile .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 13px; color: var(--muted); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; padding: 5px 10px; border-radius: 8px; cursor: pointer; }
.seg button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th.num, td.num { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--accent-soft); }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); margin-left: 6px; }

.recent-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.recent-item:last-child { border-bottom: 0; }
.recent-item:hover .r-name { color: var(--accent); }
.r-name { font-weight: 500; }
.r-meta { font-size: 13px; color: var(--muted); }
.r-tss { font-weight: 600; text-align: right; }

.zone-row { display: grid; grid-template-columns: 110px 1fr 70px; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
.zone-bar { height: 14px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.zone-bar span { display: block; height: 100%; border-radius: 4px; }
.peak-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.peak { border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.peak b { display: block; font-size: 20px; }
.peak span { font-size: 12px; color: var(--muted); }

#detailHead h1 { margin: 6px 0 2px; font-size: 24px; }
#detailHead p { margin: 0 0 18px; color: var(--muted); }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.form input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.ok-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--pos); margin-right: 4px; }
code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
a { color: var(--accent); }
.btn:disabled { opacity: .55; cursor: progress; }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
body.logged-out nav, body.logged-out .topbar .btn, body.logged-out .topbar label.btn, body.logged-out .user, body.logged-out .sync { display: none !important; }
.auth { max-width: 420px; margin: 48px auto; padding: 32px; }
.auth h1 { font-size: 22px; margin: 18px 0 6px; }
.brand.big { font-size: 22px; }
.error { color: var(--neg); font-size: 14px; margin: 0; min-height: 1em; }
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
ul.plain { list-style: none; padding: 0; margin: 0 0 14px; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
li.invite { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
li.invite code { word-break: break-all; flex-basis: 100%; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

.empty { max-width: 620px; margin: 60px auto; text-align: center; background: var(--surface); border: 2px dashed var(--border); border-radius: 20px; padding: 40px 28px; }
.empty h1 { margin-top: 0; }
.hints { text-align: left; color: var(--muted); font-size: 14px; margin: 20px 0 24px; padding-left: 20px; }
.hints li { margin: 6px 0; }

.drop { position: fixed; inset: 0; background: rgba(255,90,31,.12); border: 3px dashed var(--accent); z-index: 20; display: grid; place-items: center; font-size: 22px; font-weight: 600; color: var(--accent); pointer-events: none; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 30; font-size: 14px; max-width: calc(100% - 32px); }

#settings:not(.hidden) { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 20px; align-items: start; }
#settings .card { margin-bottom: 0; max-width: none; }
@media (max-width: 1000px) {
  nav { order: 3; flex-basis: 100%; }
  .user { margin-left: auto; }
}
@media (max-width: 760px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .brand { order: 0; }
  .topbar .theme-btn { order: 1; margin-left: auto; }
  .sync { order: 2; flex-direction: row; align-items: center; gap: 8px; }
  .topbar > label.btn { order: 3; }
  .user { order: 4; margin-left: auto; }
  nav { order: 5; }
  .status-label { font-size: 26px; }
  .grid2 { grid-template-columns: 1fr; }
  .chart.tall { height: 280px; }
}
