:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #191919;
  --text-2: #666666;
  --line: #e3e3e8;
  --grid: #ececf0;
  --accent: #257de0;
  --accent-soft: #e4effc;
  --danger: #d93025;
  --good: #0a8a1f;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #191919;
    --text: #efefef;
    --text-2: #9c9c9c;
    --line: #2c2c2e;
    --grid: #2a2a2a;
    --accent: #338ced;
    --accent-soft: #1b2d44;
    --danger: #ff5a4f;
    --good: #2fc24a;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select { font-size: 16px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  padding: calc(env(safe-area-inset-top) + 10px) 18px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar h1 { margin: 0; font-size: 30px; font-weight: 700; }

main { padding: 6px 14px calc(env(safe-area-inset-bottom) + 90px); max-width: 520px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; background: none; border: 0; padding: 4px 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--text-2);
}
.tabbar button .ico { font-size: 22px; filter: grayscale(1); opacity: .7; }
.tabbar button.active { color: var(--accent); }
.tabbar button.active .ico { filter: none; opacity: 1; }

.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
}
.card h3 { margin: 0 0 10px; font-size: 17px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.btn {
  border: 0; border-radius: 12px; padding: 12px 16px;
  background: var(--accent); color: #fff; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.block { width: 100%; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.small { padding: 8px 12px; font-size: 14px; }
.link { background: none; border: 0; color: var(--accent); padding: 6px 0; font-size: 16px; }
.icon-btn { background: none; border: 0; font-size: 22px; padding: 6px 10px; color: var(--accent); }

.seg { display: flex; background: var(--line); border-radius: 10px; padding: 2px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* Kalender */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head strong { font-size: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 12px; color: var(--text-2); padding-bottom: 4px; }
.cal-day {
  aspect-ratio: 1 / 1.15; border: 0; border-radius: 10px; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 5px 0 3px; gap: 1px; position: relative; min-width: 0;
}
.cal-day .num { font-size: 15px; font-weight: 500; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; }
.cal-day .w { font-size: 10.5px; color: var(--text-2); white-space: nowrap; }
.cal-day.has { background: var(--accent-soft); }
.cal-day.has .w { color: var(--accent); font-weight: 600; }
.cal-day.today .num { background: var(--accent); color: #fff; }
.cal-day.other { visibility: hidden; }
.cal-day.future { opacity: .45; }
.cal-day .cam { position: absolute; top: 3px; right: 4px; font-size: 9px; }

.entry-list .entry { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.entry-list .entry:first-child { border-top: 0; }
.entry .d { flex: 1; }
.entry .kg { font-weight: 600; font-variant-numeric: tabular-nums; }
.thumb-sm { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--line); }

/* Tages-Editor */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); background: var(--bg);
  border-radius: 10px; padding: 12px;
}
.field textarea { min-height: 90px; resize: vertical; }
.weight-input { display: flex; align-items: center; gap: 8px; }
.weight-input input { font-size: 28px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.weight-input .unit { font-size: 20px; color: var(--text-2); }
.stepper { width: 48px; height: 48px; flex: none; border-radius: 50%; border: 0; background: var(--accent-soft); color: var(--accent); font-size: 24px; font-weight: 600; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid .ph { position: relative; aspect-ratio: 3/4; border-radius: 10px; overflow: hidden; background: var(--line); }
.photo-grid .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .ph .del {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 26px; padding: 0;
}
.photo-grid .add {
  aspect-ratio: 3/4; border-radius: 10px; border: 2px dashed var(--line); background: transparent;
  color: var(--accent); font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.photo-grid .add span { font-size: 28px; }

/* Vergleich */
.cmp-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cmp-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cmp-side .img-wrap { aspect-ratio: 3/4; border-radius: 12px; overflow: hidden; background: var(--line); }
.cmp-side img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cmp-side .cap { text-align: center; margin-top: 6px; font-size: 13px; }
.cmp-side .cap b { display: block; font-size: 16px; }
.cmp-strip { display: flex; gap: 6px; overflow-x: auto; margin-top: 6px; }
.cmp-strip img { width: 38px; height: 50px; object-fit: cover; border-radius: 6px; opacity: .55; border: 2px solid transparent; }
.cmp-strip img.sel { opacity: 1; border-color: var(--accent); }
.slider-wrap { position: relative; aspect-ratio: 3/4; width: min(100%, calc(60vh * 3 / 4)); margin: 0 auto; border-radius: 12px; overflow: hidden; background: var(--line); touch-action: none; user-select: none; -webkit-user-select: none; }
.slider-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.slider-wrap .top { clip-path: inset(0 50% 0 0); }
.slider-wrap .bar { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 4px rgba(0,0,0,.5); pointer-events: none; }
.slider-wrap .knob { position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; color: #333; font-size: 14px; pointer-events: none; }
.slider-wrap .tag { position: absolute; bottom: 10px; padding: 4px 8px; border-radius: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; pointer-events: none; }
.slider-wrap .tag.l { left: 10px; } .slider-wrap .tag.r { right: 10px; }
.diff-box { text-align: center; padding: 6px 0 2px; font-size: 15px; }
.diff-box b { font-size: 22px; font-variant-numeric: tabular-nums; }
.down { color: var(--good); }

/* Verlauf */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.stat .lbl { font-size: 12px; color: var(--text-2); }
.stat .val { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .val small { font-size: 14px; font-weight: 500; color: var(--text-2); }
.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; touch-action: pan-y; }
.chart-box .axis text { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-box .grid line { stroke: var(--grid); stroke-width: 1; }
.chart-box .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-box .area { fill: var(--accent); opacity: .08; }
.chart-box .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart-box .goal { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-box .goal-lbl { fill: var(--text-2); font-size: 11px; }
.chart-box .xhair { stroke: var(--text-2); stroke-width: 1; }
.chart-box .hover-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--surface);
  padding: 6px 9px; border-radius: 8px; font-size: 13px; white-space: nowrap; transform: translateX(-50%);
}
.tooltip b { font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 30px 10px; color: var(--text-2); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* Pläne */
.plan-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.plan { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.plan:first-child { border-top: 0; }
.plan .pi { width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 22px; flex: none; overflow: hidden; }
.plan .pi img { width: 100%; height: 100%; object-fit: cover; }
.plan .pt { flex: 1; min-width: 0; }
.plan .pt b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-text { white-space: pre-wrap; line-height: 1.5; }
.plan-img { width: 100%; border-radius: 10px; display: block; }
.pdf-frame { width: 100%; height: 70vh; border: 0; border-radius: 10px; background: #fff; }

/* Mehr */
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); gap: 10px; }
.list-row:first-of-type { border-top: 0; }
.list-row input { width: 110px; text-align: right; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 8px; }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet.hidden { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; top: calc(env(safe-area-inset-top) + 24px);
  background: var(--bg); border-radius: 16px 16px 0 0; display: flex; flex-direction: column;
  max-width: 520px; margin: 0 auto; animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 17px; flex: 2; text-align: center; }
.sheet-head > * { flex: 1; }
.sheet-head .link { text-align: left; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 24px); -webkit-overflow-scrolling: touch; }
.viewer-img { width: 100%; border-radius: 10px; display: block; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%);
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 20px; font-size: 14px; z-index: 60;
}
.toast.hidden { display: none; }
.hint { background: var(--accent-soft); color: var(--text); border-radius: var(--radius); padding: 12px 14px; font-size: 14px; margin-bottom: 14px; line-height: 1.4; }

/* Dialog */
.dlg-ov { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; padding: 24px; }
.dlg { background: var(--surface); border-radius: 16px; padding: 18px; width: 100%; max-width: 340px; }
.dlg p { margin: 0 0 14px; line-height: 1.4; }
.dlg-in { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px; margin-bottom: 14px; }
.dlg-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn.red { background: var(--danger); color: #fff; }


.topbar + .hint { max-width: 492px; margin-inline: auto !important; }

/* Coach-App */
.hidden { display: none !important; }
.topbar-in { max-width: 492px; margin: 0 auto; }
.topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { font-size: 17px; padding: 0 0 2px; }
.login-logo { text-align: center; margin: 10px 0 18px; }
.login-logo img { width: 84px; height: 84px; border-radius: 20px; }
.check { display: flex; gap: 10px; align-items: flex-start; line-height: 1.4; font-size: 15px; }
.check input { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.btn:disabled { opacity: .45; }
.card p { line-height: 1.5; }
a { color: var(--accent); }
.client { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.client:first-child { border-top: 0; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center; flex: none; }
.ct { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ct b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw { text-align: right; display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { display: inline-block; align-self: flex-start; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--line); color: var(--text-2); margin-top: 2px; }
.badge.warn { background: #fff3d6; color: #7a5200; }
.badge.off { background: #fde4e2; color: #a3231a; }
@media (prefers-color-scheme: dark) {
  .badge.warn { background: #3d2f0d; color: #fbd27a; }
  .badge.off { background: #451a17; color: #ff9b93; }
}
.small-seg button { font-size: 13px; padding: 8px 2px; }
.cursor, .entry[data-date], .plan[data-id] { cursor: pointer; }

/* ===== DS Coaching: Gold auf Schwarz ===== */
:root {
  --bg: #0a0a0a; --surface: #161512; --text: #f4ecd8; --text-2: #a69d89;
  --line: #2c2922; --grid: #25221c; --accent: #e0b04a; --accent-soft: #2b2416;
  --gold: linear-gradient(135deg, #f7d77a 0%, #e0b04a 45%, #b9842a 100%);
  --danger: #ff6b5e; --good: #6fd47f; color-scheme: dark;
}
body { background: var(--bg); }
.btn { background: var(--gold); color: #1a1205; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.red { background: var(--danger); color: #fff; }
.cal-day.today .num { background: var(--gold); color: #1a1205; }
.seg button.active { background: #2e2a21; color: var(--accent); box-shadow: none; }
.tooltip { background: #f4ecd8; color: #111; }
.toast { background: #f4ecd8; color: #111; }
.stepper { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: #3d2f0d; color: #fbd27a; }
.badge.off { background: #451a17; color: #ff9b93; }
.topbar h1 { color: var(--text); letter-spacing: .2px; }
.brand { display: block; height: 34px; margin-bottom: 4px; }
.login-logo img { width: min(320px, 82%); height: auto; border-radius: 0; }
.avatar { background: var(--gold); color: #1a1205; }
.dlg { border: 1px solid var(--line); }
.chart-box .area { fill: var(--accent); opacity: .12; }
.tabbar .ico { filter: grayscale(1) brightness(1.3); }

/* ===== Breite Coach-Ansicht (PC) ===== */
body.wide main { max-width: 1200px; }
body.wide .topbar-in { max-width: 1172px; }
body.wide .tabbar { position: fixed; left: 0; top: 0; bottom: 0; right: auto; width: 92px; flex-direction: column; justify-content: flex-start; gap: 10px; padding-top: 90px; border-top: 0; border-right: 1px solid var(--line); }
body.wide .tabbar button { flex: none; }
body.wide main, body.wide .topbar { padding-left: 110px; }
body.wide main { padding-bottom: 30px; }
.split { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
.split aside { position: sticky; top: 90px; max-height: calc(100vh - 110px); overflow-y: auto; }
.split .client.sel { background: var(--accent-soft); border-radius: 12px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
.split .detail-empty { text-align: center; color: var(--text-2); padding: 80px 20px; }
.split .detail-title { font-size: 26px; font-weight: 700; margin: 0 0 12px; }
body.wide .sheet-panel { max-width: 640px; top: 40px; bottom: 40px; border-radius: 16px; }
body.wide .stats { grid-template-columns: repeat(4, 1fr); }
.tb-logo { display: none; }
body.wide .tb-logo { display: block; width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 12px; position: absolute; top: 18px; left: 16px; }
body.wide .cmp-side .img-wrap { aspect-ratio: auto; height: min(56vh, 520px); }
body.wide .slider-wrap { width: min(100%, calc(56vh * 3 / 4)); }
