/* Trainingslog – iPhone-orientiertes Layout, dunkel wie hell. */

:root {
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-2: #f2f2f7;
  --text: #14141a;
  --text-2: #6b6b76;
  --line: rgba(0, 0, 0, .1);
  --accent: #e8492a;
  --accent-soft: rgba(232, 73, 42, .12);
  --ok: #1f9d55;
  --warn: #b26a00;
  --danger: #d1342b;
  --bar: rgba(0, 0, 0, .06);
  --blur: saturate(180%) blur(20px);
  --radius: 16px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0f;
    --bg-elev: #16161c;
    --card: #16161c;
    --card-2: #1e1e26;
    --text: #f4f4f7;
    --text-2: #9a9aa6;
    --line: rgba(255, 255, 255, .1);
    --accent: #ff5c39;
    --accent-soft: rgba(255, 92, 57, .16);
    --ok: #32d74b;
    --warn: #ff9f0a;
    --danger: #ff453a;
    --bar: rgba(255, 255, 255, .08);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }
p { margin: 0 0 8px; }
.hidden { display: none !important; }

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

#topbar {
  position: sticky; top: 0; z-index: 40;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 6px 12px;
}

#title {
  font-size: 20px; font-weight: 700; letter-spacing: -.02em;
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

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

.icon-btn {
  width: var(--tap); height: 36px; min-width: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--text-2);
  font-size: 24px; line-height: 1; border-radius: 10px;
}
.icon-btn:active { background: var(--bar); }
.icon-btn.small { width: 32px; height: 32px; font-size: 20px; }
#backBtn { font-size: 30px; color: var(--accent); width: 32px; }

/* ---------- Hauptbereich ---------- */

#view {
  padding: 14px 14px calc(96px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
  outline: none;
}
body.rest-active #view { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }

.hero { padding: 6px 2px 14px; }
.hero-line { color: var(--text-2); font-size: 14px; }
.hero-title { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-top: 2px; }

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

.card-label {
  font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-2); margin-bottom: 10px;
}

.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 4px 6px; font-size: 14px; font-weight: 700;
}
.muted { color: var(--text-2); font-weight: 400; }
.warn { color: var(--warn); font-weight: 500; }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 12px 4px; }
.pad-top { margin-top: 14px; }

/* ---------- Kennzahlen ---------- */

.stat-row { display: flex; gap: 8px; }
.stat { flex: 1; min-width: 0; }
.stat-value { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.stat-label { font-size: 12px; color: var(--text-2); }
.stat-sub { font-size: 11px; color: var(--text-2); opacity: .85; }

.progress {
  height: 6px; background: var(--bar); border-radius: 3px;
  margin-top: 12px; overflow: hidden;
}
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border: 0; border-radius: 12px;
  padding: 0 16px; min-height: var(--tap);
  font-weight: 600; font-size: 16px;
  background: var(--card-2); color: var(--text);
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.975); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--card); border: 1px solid var(--line); }
.btn-ghost { background: none; color: var(--text-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-text { color: var(--danger); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-big { width: 100%; margin-bottom: 12px; min-height: 50px; font-size: 17px; }

/* ---------- Zeilen ---------- */

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; min-height: var(--tap);
  border-top: 1px solid var(--line);
  text-align: left; width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0;
}
.card > .row:first-of-type, .card > .card-label + .row { border-top: 0; }
.row-btn:active { background: var(--bar); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Untertitel brechen um, statt zu kuerzen. Vorher stand hier nowrap mit Ellipse:
   das sah in dichten Listen aufgeraeumt aus und hat dabei Anweisungen halbiert -
   Mahlzeitenbestandteile, Messvorschriften. Was nicht lesbar ist, ist nicht da.
   Wo eine Zeile bewusst einzeilig bleiben soll, gibt es .row-sub.kurz. */
.row-sub { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.row-sub.kurz { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-chev { color: var(--text-2); font-size: 22px; line-height: 1; }
.row-trail { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.row-trail.up { color: var(--ok); }
.row-trail.down { color: var(--text-2); }
.row-add .row-title { color: var(--accent); }

.row-date {
  width: 38px; text-align: center; flex: 0 0 38px;
  display: flex; flex-direction: column; line-height: 1.1;
}
.row-day { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row-wd { font-size: 11px; color: var(--text-2); }

/* ---------- Leerzustand ---------- */

.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty-icon { font-size: 40px; margin-bottom: 8px; }
.empty h3 { color: var(--text); font-size: 18px; margin-bottom: 6px; }
.empty p { font-size: 14px; }

/* ---------- Aktives Training ---------- */

.session-head { padding: 2px 2px 12px; }
.session-name {
  width: 100%; background: none; border: 0; padding: 0;
  font-size: 24px; font-weight: 800; letter-spacing: -.03em;
}
.session-name:focus { outline: none; }
.session-meta { display: flex; gap: 8px; color: var(--text-2); font-size: 14px; margin-top: 2px; }
.elapsed { font-variant-numeric: tabular-nums; }

.entry-head { display: flex; align-items: flex-start; gap: 8px; }
.entry-title-wrap { flex: 1; min-width: 0; }
.entry-title {
  background: none; border: 0; padding: 0; text-align: left;
  font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--text);
}
.entry-sub { font-size: 12px; color: var(--text-2); }
.entry-actions { display: flex; gap: 8px; margin-top: 10px; }
.entry-note {
  margin-top: 10px; padding: 8px 10px; border-radius: 10px;
  background: var(--card-2); font-size: 13px; color: var(--text-2);
}

.last-line { font-size: 13px; color: var(--text-2); margin-top: 6px; }

.hint {
  margin-top: 8px; padding: 8px 10px; border-radius: 10px;
  font-size: 13px; background: var(--card-2); color: var(--text-2);
  border-left: 3px solid var(--text-2);
}
.hint-up { border-color: var(--ok); color: var(--text); }
.hint-reps { border-color: var(--accent); }
.hint-hold { border-color: var(--warn); }
.hint-deload, .hint-warn { border-color: var(--danger); }

/* ---------- Satztabelle ---------- */

.sets { margin-top: 10px; }
.set-row {
  display: grid;
  grid-template-columns: 34px 1fr 1fr 46px 44px;
  gap: 6px; align-items: center;
  padding: 4px 0;
}
.set-row.cardio { grid-template-columns: 34px 1fr 1fr 44px; }
.set-head {
  font-size: 11px; color: var(--text-2); text-transform: uppercase;
  letter-spacing: .05em; padding-bottom: 2px;
}
.set-head span { text-align: center; }
.set-head .set-idx { background: none; height: auto; font-weight: 600; }

.set-idx {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--card-2); border: 0; color: var(--text-2);
  font-size: 13px; font-weight: 700; text-align: center;
}
.set-row.warmup .set-idx { color: var(--warn); }
.set-row.done .set-idx { background: var(--accent-soft); color: var(--accent); }

.set-input {
  text-align: center; padding: 0 4px; min-height: 40px;
  font-variant-numeric: tabular-nums; font-weight: 600;
}
.set-rpe { font-weight: 400; color: var(--text-2); }

.set-check {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card-2);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.set-check svg { width: 20px; height: 20px; fill: none; stroke: var(--text-2); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.set-check.on { background: var(--accent); border-color: var(--accent); }
.set-check.on svg { stroke: #fff; }
.set-row.done .set-input { color: var(--text-2); }

.set-static { grid-template-columns: 34px 1fr auto; }
.set-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.set-e1rm { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- Formularelemente ---------- */

.input {
  width: 100%; min-height: var(--tap);
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 12px; font-size: 16px; /* 16px verhindert das Zoomen in Safari */
  -webkit-appearance: none; appearance: none;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea.input { min-height: 70px; resize: vertical; line-height: 1.4; }
select.input { background-image: none; }
.input-narrow { width: 84px; text-align: center; }
.title-input { font-size: 20px; font-weight: 700; }

.field { display: block; margin-bottom: 10px; }
.field-label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-inline { flex: 1; margin-bottom: 0; }
.plan-fields { display: flex; gap: 8px; margin-top: 10px; }
.plan-fields .input { text-align: center; padding: 8px 4px; }
.hidden-file { display: none; }

.toggle {
  width: 50px; height: 30px; border-radius: 15px; border: 0;
  background: var(--bar); position: relative; transition: background .2s ease; padding: 0;
}
.toggle .knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.toggle.on { background: var(--ok); }
.toggle.on .knob { transform: translateX(20px); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line);
  font-size: 14px; color: var(--text-2); white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.segmented {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 14px;
  background: var(--card-2); border-radius: 12px;
}
.seg {
  flex: 1; min-height: 34px; border: 0; border-radius: 9px;
  background: none; color: var(--text-2); font-size: 15px; font-weight: 600;
}
.seg.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* ---------- Diagramme ---------- */

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart-block { margin-top: 14px; }
.chart-block:first-child { margin-top: 4px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: var(--accent-soft); stroke: none; }
.chart .dot { fill: var(--accent); }
.chart .dot-last { fill: var(--accent); stroke: var(--card); stroke-width: 2.5; }
.chart .axis { fill: var(--text-2); font-size: 9px; font-family: inherit; }
.chart .bar { fill: var(--accent); opacity: .75; }
.chart .bar-ok { fill: var(--ok); opacity: .85; }

/* ---------- Statistik ---------- */

.mbar { margin-bottom: 12px; }
.mbar-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.mbar-num { color: var(--text-2); font-size: 13px; }
.mbar-track { height: 8px; background: var(--bar); border-radius: 4px; overflow: hidden; }
.mbar-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.mbar-fill.tone-low { background: var(--warn); }
.mbar-fill.tone-ok { background: var(--ok); }
.mbar-fill.tone-high { background: var(--danger); }

.tip { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; padding: 6px 0; }
.tip-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: 0 0 8px; background: var(--text-2); }
.tip-ok { background: var(--ok); }
.tip-info { background: var(--accent); }
.tip-warn { background: var(--warn); }

.suggestion { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }

.pr-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; font-size: 14px; }
.pr-badge { color: var(--warn); font-size: 18px; }

.steps { margin: 0; padding-left: 20px; font-size: 14px; color: var(--text-2); }
.steps li { margin-bottom: 6px; }

/* ---------- Pausen-Timer ---------- */

.rest-bar {
  position: fixed; left: 0; right: 0;
  bottom: calc(60px + env(safe-area-inset-bottom));
  z-index: 45;
  background: var(--card-2);
  border-top: 1px solid var(--line);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.rest-bar-inner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; max-width: 640px; margin: 0 auto;
}
.rest-main { flex: 1; text-align: center; }
.rest-time { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.rest-label { font-size: 11px; color: var(--text-2); }
.rest-adj {
  min-width: 52px; min-height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text-2);
  font-size: 14px; font-weight: 600;
}
.rest-stop {
  min-height: 38px; padding: 0 14px; border-radius: 10px; border: 0;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 14px;
}
.rest-progress { height: 3px; background: var(--bar); }
.rest-progress > span { display: block; height: 100%; background: var(--accent); width: 100%; }
.rest-bar.done { background: var(--accent-soft); }
.rest-bar.done .rest-time { color: var(--accent); }

/* ---------- Tableiste ---------- */

#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; border: 0; background: none; color: var(--text-2);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0 5px; font-size: 10px; font-weight: 600;
  min-height: 54px; position: relative;
}
.tab svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.tab.active { color: var(--accent); }
.tab.running::after {
  content: ''; position: absolute; top: 6px; right: 50%;
  transform: translateX(16px);
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
}

/* ---------- Sheet ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .25s ease;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 640px;
  background: var(--bg-elev);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .25s cubic-bezier(.32, .72, 0, 1);
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: var(--bar); margin: 4px auto 8px; }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sheet-head h2 { flex: 1; font-size: 18px; font-weight: 700; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-text { font-size: 14px; color: var(--text-2); margin-bottom: 12px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.sheet-actions .btn { width: 100%; }

.menu { display: flex; flex-direction: column; }
.menu-item {
  text-align: left; background: none; border: 0;
  padding: 14px 4px; min-height: var(--tap);
  border-bottom: 1px solid var(--line); font-size: 16px;
}
.menu-item:last-child { border-bottom: 0; }
.menu-item.danger { color: var(--danger); }

.picker-search { margin-bottom: 4px; }
.picker-list { max-height: 52vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.picker-list .row:first-child { border-top: 0; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; transform: translate(-50%, 20px);
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 70; max-width: 90vw;
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 500; text-align: center;
  opacity: 0; transition: opacity .2s ease, transform .2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ---------- Bewegungszeichnungen (U-01, U-02) ---------- */

.zeichnung-halter { margin: 4px 0 2px; }

.zeichnung {
  width: 100%;
  height: auto;
  display: block;
}

/* Ruhig = was sich nicht bewegen darf. Aktiv = was arbeitet. Der Unterschied ist der
   ganze Zweck des Bildes, also traegt er den staerksten Kontrast. */
.zg-ruhig      { stroke: var(--text-2); stroke-width: 2; stroke-linecap: round; fill: none; }
/* --line ist bewusst fast durchsichtig - als Geraeteumriss war es unsichtbar. */
.zg-geraet     { stroke: var(--text-2); stroke-width: 3; stroke-linecap: round; opacity: .4; }
.zg-aktiv      { stroke: var(--accent); stroke-width: 3.2; stroke-linecap: round; }
.zg-aktiv-blass{ stroke: var(--accent); stroke-width: 3.2; stroke-linecap: round; opacity: .45; }
.zg-bahn       { stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 3 3; opacity: .85; }
.zg-spitzeform { fill: var(--accent); }
.zg-schrift    { fill: var(--text-2); font-size: 8px; font-family: inherit; }
.zg-unterschrift { text-align: center; margin-top: 0; }

/* ---------- Übungsanleitung ---------- */

.anleitung-blatt .card-label { margin-top: 16px; }
.anleitung { margin: 6px 0 0; padding-left: 20px; }
.anleitung li { margin-bottom: 8px; line-height: 1.45; }

/* Standardmaessig kuerzen Zeilenuntertitel mit Ellipse. Erklaerungen duerfen umbrechen. */
/* Fuer Elemente, die von woanders eine Kuerzung erben. */
.wrap {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.45;
  margin-top: 3px;
}

.row.gesperrt { opacity: .6; }
