/* training-history Web-UI – Smartphone zuerst, hell/dunkel nach System */
:root {
  --bg: #f3f4f1; --card: #ffffff; --ink: #1c2321; --muted: #66706c; --line: #dfe3df;
  --accent: #b4500f; --hr: #2f6db5; --ref: #8a8f8c; --ok: #2e7d4f; --warn: #b7791f; --alert: #c0392b;
  --z1: #b9c0bc; --z2: #6fa8dc; --z3: #4caf7d; --z4: #e3b341; --z5: #e8833a; --z6: #d6453d; --z7: #8e3b8f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615; --card: #1b2120; --ink: #e6ebe8; --muted: #9aa5a0; --line: #2c3533;
    --accent: #f08a3c; --hr: #6ea8ec; --ref: #7d8783; --ok: #5fbf86; --warn: #e0b04a; --alert: #ef6b5e;
    --z1: #59605d; --z2: #4f86bd; --z3: #3f9a6b; --z4: #c99b2e; --z5: #d27330; --z6: #c43c35; --z7: #9a4e9b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px calc(76px + env(safe-area-inset-bottom, 0px));
  font-variant-numeric: tabular-nums;
}
main { max-width: 760px; margin: 0 auto; display: grid; gap: 12px; }
.top { max-width: 760px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top, 0px)) 0 10px;
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.top h1 { font-size: 1.35rem; margin: 0; }
.back { text-decoration: none; color: var(--muted); margin-right: 4px; }
h2 { font-size: 1rem; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; justify-content: space-between; }
h3 { font-size: .85rem; margin: 12px 0 6px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
a { color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: var(--alert); }
.count { background: var(--alert); color: #fff; border-radius: 999px; padding: 0 8px; font-size: .8rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 14px; margin-top: 8px; }
.kpis div { display: flex; flex-direction: column; }
.kpis .k { font-size: 1.3rem; font-weight: 650; }
.kpis .k small { font-size: .75rem; font-weight: 500; color: var(--muted); }
.kpis .l { font-size: .8rem; color: var(--muted); }
.flag { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start;
  padding: 10px 0 10px 10px; border-left: 3px solid var(--line); margin-bottom: 8px; }
.flag.sev-alert { border-color: var(--alert); } .flag.sev-warn { border-color: var(--warn); } .flag.sev-info { border-color: var(--hr); }
.sev { font-weight: 650; font-size: .85rem; }
button { font: inherit; border: 0; border-radius: 8px; padding: 10px 14px; background: var(--accent); color: #fff; min-height: 44px; cursor: pointer; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); min-width: 44px; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn { display: inline-block; background: var(--accent); color: #fff; padding: 12px 18px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.login { text-align: center; padding: 28px 16px; }
.logout { text-align: center; }
.srow { display: grid; grid-template-columns: 74px 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none; align-items: center; }
.srow:last-of-type { border-bottom: 0; }
.sdate { color: var(--muted); font-size: .85rem; grid-row: span 2; }
.sname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smeta { grid-column: 2 / 4; font-size: .85rem; color: var(--muted); }
.chip { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chip.t-grundlage, .chip.t-erholung { color: var(--ok); border-color: var(--ok); }
.chip.t-tempo, .chip.t-gemischt { color: var(--warn); border-color: var(--warn); }
.chip.t-schwelle, .chip.t-intervalle, .chip.warn { color: var(--alert); border-color: var(--alert); }
.pill { display: inline-block; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; margin: 0 4px 6px 0; font-size: .9rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-weight: 600; }
.tbl.zt td { text-align: right; }
details > summary { cursor: pointer; padding: 6px 0; font-weight: 600; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; align-items: end; margin-top: 8px; }
.fgrid.compact { margin-top: 0; }
.fgrid label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 4px; }
select, input { font: inherit; padding: 9px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-height: 44px; }
.pager { display: flex; justify-content: space-between; padding: 4px 2px 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: .8rem; font-weight: 500; }
.seg a { padding: 6px 10px; text-decoration: none; color: var(--muted); }
.seg a[aria-current] { background: var(--accent); color: #fff; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .tick.p { fill: var(--accent); } .chart .tick.s { fill: var(--hr); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .line.p { stroke: var(--accent); } .chart .line.s { stroke: var(--hr); stroke-width: 1.5; opacity: .85; }
.chart .ref { stroke: var(--ref); stroke-dasharray: 5 4; stroke-width: 1.2; } .chart .ref-t { fill: var(--ref); }
.chart .hit { fill: transparent; } .chart .hit:hover, .chart .hit.on { fill: var(--accent); }
.chart .col { fill: var(--z2); } .chart .col.last { fill: var(--accent); }
.zonebar { width: 100%; height: 18px; display: block; border-radius: 4px; }
.z1 { fill: var(--z1); background: var(--z1); } .z2 { fill: var(--z2); background: var(--z2); } .z3 { fill: var(--z3); background: var(--z3); }
.z4 { fill: var(--z4); background: var(--z4); } .z5 { fill: var(--z5); background: var(--z5); } .z6 { fill: var(--z6); background: var(--z6); }
.z7 { fill: var(--z7); background: var(--z7); }
.zd { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.legend { font-size: .8rem; color: var(--muted); margin: 6px 0 0; }
.lg { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin: 0 4px 0 10px; }
.lg.p { background: var(--accent); } .lg.s { background: var(--hr); } .lg.r { background: var(--ref); }
.tip { position: fixed; z-index: 10; background: var(--ink); color: var(--bg); font-size: .8rem; padding: 4px 8px; border-radius: 6px; pointer-events: none; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; font-size: .75rem; color: var(--muted); text-decoration: none; min-height: 56px; }
.tabs a[aria-current] { color: var(--accent); font-weight: 600; }
.tabs .ic { font-size: 1rem; line-height: 1.2; }
@media (min-width: 900px) { body { padding-bottom: 24px; } .tabs { position: static; max-width: 760px; margin: 0 auto 12px; border: 1px solid var(--line); border-radius: 10px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Trainer */
.btn.small { padding: 8px 12px; font-size: .9rem; }
.convbar { display: flex; flex-direction: column; gap: 8px; }
.convlink { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; font-size: .9rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convlink.on { color: var(--accent); font-weight: 600; }
.chat { display: grid; gap: 10px; }
.msg { border-radius: 12px; padding: 10px 12px; max-width: 100%; min-width: 0; overflow-wrap: anywhere; }
.msg.user { background: var(--accent); color: #fff; justify-self: end; max-width: 88%; }
.msg.user p { margin: 0; white-space: pre-wrap; }
.msg.assistant { background: var(--card); border: 1px solid var(--line); }
.md p { margin: 0 0 8px; } .md ul, .md ol { margin: 0 0 8px; padding-left: 20px; } .md h4 { margin: 10px 0 6px; font-size: .95rem; }
.md pre { background: var(--bg); padding: 8px; border-radius: 6px; overflow-x: auto; font-size: .8rem; }
.md code { font-size: .85em; } .tblwrap { overflow-x: auto; }
.tools { margin: 4px 0 0; }
.typing { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.proposal { border: 1px dashed var(--accent); border-radius: 8px; padding: 10px; margin-top: 8px; }
.proposal p { margin: 0 0 8px; }
.proposal.ps-confirmed { border-style: solid; border-color: var(--ok); }
.proposal.ps-rejected { opacity: .6; }
.pbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.askbar { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); background: var(--bg); padding: 8px 0;
  display: grid; gap: 6px; max-width: 760px; margin: 0 auto; width: 100%; }
.askbar textarea { font: inherit; width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); resize: vertical; min-height: 56px; }
.askrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.intro ul { padding-left: 20px; }
@media (min-width: 900px) { .askbar { bottom: 0; } }
@media (prefers-reduced-motion: reduce) { .typing { animation: none; } }
.askrow label { display: inline-flex; align-items: center; gap: 8px; }
input[type="checkbox"] { min-height: 0; width: 20px; height: 20px; padding: 0; accent-color: var(--accent); }
