:root {
  --bg: #0d1117; --bg2: #161b22; --card: #1c2330; --line: #2d3646;
  --fg: #e6edf3; --muted: #8b98a9;
  --green: #22c55e; --amber: #f59e0b; --red: #ef4444; --accent: #3b82f6;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.ok { color: var(--green); font-size: 13px; }
.error { color: var(--red); font-size: 14px; margin-top: 8px; }

/* Login */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { text-align: center; width: 100%; max-width: 320px; }
.login-card h1 { margin: 12px 0 2px; font-size: 24px; }
.login-card form { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
input, textarea {
  width: 100%; background: var(--bg2); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 16px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* Layout */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; background: rgba(13,17,23,.92); backdrop-filter: blur(8px);
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.dot.gruen { background: var(--green); } .dot.gelb { background: var(--amber); } .dot.rot { background: var(--red); }

main { flex: 1; padding: 16px 16px 90px; max-width: 640px; width: 100%; margin: 0 auto; }
.view h2 { margin-bottom: 12px; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px;
}
.card h3 { font-size: 15px; margin-bottom: 6px; }
details.card summary { cursor: pointer; font-weight: 600; }
details.card > *:not(summary) { margin-top: 10px; }

/* Hero (MCI-Stil: große Begrüßung + Motivations-Kacheln) */
.hero { margin: 4px 0 16px; }
.hero-gruss { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.hero-cell {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 6px; text-align: center;
}
.hero-cell b { display: block; font-size: 20px; }
.hero-cell span { font-size: 10.5px; color: var(--muted); }
.hero-cell.fire b { color: var(--amber); }
.hero-cell .soll-ok { color: var(--green); }

/* Briefing */
.ampel-banner {
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px;
  font-weight: 600; display: flex; gap: 10px; align-items: flex-start;
}
.ampel-banner.gruen { background: rgba(34,197,94,.14); color: #7ee2a8; border: 1px solid rgba(34,197,94,.4); }
.ampel-banner.gelb { background: rgba(245,158,11,.13); color: #fbd38d; border: 1px solid rgba(245,158,11,.4); }
.ampel-banner.rot { background: rgba(239,68,68,.13); color: #fca5a5; border: 1px solid rgba(239,68,68,.4); }
.session-card { border-left: 4px solid var(--accent); }
.session-card .meta { color: var(--muted); font-size: 13px; margin: 4px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; color: var(--muted);
}
.warn-list { margin: 6px 0 0 18px; font-size: 13.5px; color: #fbd38d; }
.warn-list li { margin-bottom: 4px; }
.gate {
  background: rgba(59,130,246,.12); border: 1px solid rgba(59,130,246,.4);
  border-radius: 10px; padding: 8px 12px; font-size: 13.5px; margin-top: 10px;
}

/* Buttons */
.btn {
  background: var(--bg2); color: var(--fg); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 16px; font-size: 15px; cursor: pointer; width: 100%;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; margin-top: 8px; }
.btn.compact { padding: 9px 10px; font-size: 13.5px; color: var(--muted); }
.btn:disabled { opacity: .5; }
.actions { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }
.actions-row { display: flex; gap: 8px; margin: 2px 0 14px; }

/* Aufgeräumte Aufklapper (Progressive Disclosure) */
details.card summary {
  font-size: 14px; color: var(--muted); font-weight: 600;
  display: flex; align-items: center; gap: 6px; list-style: none;
}
details.card summary::before { content: '▸'; transition: transform .15s; font-size: 12px; }
details.card[open] summary::before { transform: rotate(90deg); }
details.card summary::-webkit-details-marker { display: none; }
details.card[open] summary { color: var(--fg); margin-bottom: 4px; }

.warn-inline {
  margin-top: 10px; padding: 8px 12px; border-radius: 10px; font-size: 13px;
  background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: #fbd38d;
}

/* Markdown-light */
.md h1, .md h2, .md h3 { font-size: 15px; margin: 10px 0 4px; color: var(--fg); }
.md p { margin-bottom: 6px; }
.md ul { margin: 4px 0 8px 18px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.md table { font-size: 12.5px; border-collapse: collapse; display: block; overflow-x: auto; }
.md td, .md th { border: 1px solid var(--line); padding: 4px 6px; text-align: left; }

/* Tabbar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: rgba(13,17,23,.95); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: 0; color: var(--muted);
  padding: 8px 0 10px; font-size: 11px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab span { font-size: 20px; }
.tab.active { color: var(--fg); }

textarea { resize: vertical; margin-top: 6px; }

/* Chat */
.chat-log { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; max-height: 260px; overflow-y: auto; }
.msg { padding: 8px 12px; border-radius: 12px; font-size: 14px; max-width: 88%; }
.msg .t { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.msg.martin { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.martin .t { color: rgba(255,255,255,.7); }
.msg.coach { align-self: flex-start; background: var(--bg2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { flex: 1; margin-top: 0; }
.chat-input .btn { width: 48px; margin-top: 0; }

/* Cardio */
.section-h { font-size: 14px; color: var(--muted); margin: 14px 0 8px; }
.state-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.state-cell { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; text-align: center; }
.state-cell b { display: block; font-size: 17px; }
.state-cell span { font-size: 10.5px; color: var(--muted); }
.week-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.week-row:last-child { border-bottom: 0; }
.week-row .bar { height: 6px; background: var(--accent); border-radius: 3px; margin-top: 4px; }
.act-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.act-row:last-child { border-bottom: 0; }
.act-icon { font-size: 20px; width: 28px; text-align: center; }
.act-main { flex: 1; min-width: 0; }
.act-main b { font-size: 14px; }
.act-main .sub { font-size: 12px; color: var(--muted); }
.act-load { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }

/* Kraft */
.routine-card { cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.routine-card:active { background: var(--bg2); }
.pill { font-size: 10px; font-weight: 700; letter-spacing: .5px; padding: 3px 8px; border-radius: 999px; }
.pill.upper { background: rgba(59,130,246,.18); color: #93c5fd; }
.pill.lower { background: rgba(168,85,247,.18); color: #d8b4fe; }
.pill.reha { background: rgba(34,197,94,.18); color: #86efac; }
.badge-heute { font-size: 10px; background: var(--green); color: #06270f; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
.ex-card { display: flex; gap: 12px; }
.ex-img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: #fff; flex-shrink: 0; }
.ex-body { flex: 1; min-width: 0; }
.ex-body h4 { font-size: 14.5px; }
.ex-body .soll { color: var(--accent); font-size: 13px; font-weight: 600; }
.ex-body .hint { color: var(--muted); font-size: 12px; }
.set-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.set-chip { background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.4); color: #86efac; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.set-form { display: flex; gap: 6px; margin-top: 6px; }
.set-form input { width: 74px; padding: 8px; text-align: center; margin: 0; }
.set-form .btn { width: auto; flex: 1; margin: 0; padding: 8px; }
.search-hit { padding: 8px 4px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.workout-head { margin: 10px 0 14px; }
.workout-head .prog { height: 6px; background: var(--bg2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.workout-head .prog > div { height: 100%; background: var(--green); transition: width .3s; }

/* Ernährung */
.macro-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.macro-cell { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; text-align: center; }
.macro-cell b { display: block; font-size: 16px; }
.macro-cell span { font-size: 10.5px; color: var(--muted); }
.ziel-bar { height: 6px; background: var(--bg2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.ziel-bar > div { height: 100%; background: var(--green); }
.ziel-bar > div.over { background: var(--amber); }
.food-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.food-row:last-child { border-bottom: 0; }
.food-row .muted { font-size: 12px; }
.menge-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.menge-row .btn { width: auto; flex: 1; min-width: 60px; padding: 9px 4px; margin: 0; font-size: 14px; }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.food-chip { background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }

/* Mobility */
.mob-ex { cursor: pointer; }
.mob-ex.done { opacity: .45; border-color: var(--green); }
.mob-ex.done b::before { content: '✓ '; color: var(--green); }

/* Scanner */
.scanner { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; align-items: center; justify-content: center; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; width: 78%; max-width: 340px; height: 150px; border: 3px solid rgba(34,197,94,.9); border-radius: 14px; box-shadow: 0 0 0 2000px rgba(0,0,0,.45); }
.scan-hint { position: absolute; bottom: 110px; color: #fff; font-size: 14px; text-shadow: 0 1px 4px #000; }
.scan-close { position: absolute; bottom: 40px; width: auto; padding: 12px 32px; }
