:root {
  --bg: #f6f7f5; --card: #ffffff; --ink: #1c2321; --quiet: #5b6662; --line: #dfe4e1;
  --primary: #0f766e; --primary-ink: #ffffff; --primary-soft: #e3f2ef;
  --off: #c2410c; --off-soft: #fde8dc; --on: #15803d; --on-soft: #dcf2e3;
  --dysk: #7c3aed; --dysk-soft: #ede9fe; --trouble: #9f1239; --trouble-soft: #fbe1e7;
  --right: #2563eb; --left: #ea580c;
  --radius: 16px; --tap: 64px;
  font-size: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%; }
body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.iconbtn { width: 48px; height: 48px; border: none; background: transparent; font-size: 1.6rem; border-radius: 12px; }

main { padding: 16px; max-width: 640px; margin: 0 auto; }
h1 { font-size: 1.45rem; margin: 4px 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
p { line-height: 1.45; margin: 0 0 10px; }
.quiet { color: var(--quiet); }
.small { font-size: .85rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card.accent { border: 2px solid var(--primary); background: var(--primary-soft); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: var(--tap);
  border-radius: 14px; border: 2px solid var(--primary); background: var(--card); color: var(--primary);
  font-weight: 700; font-size: 1.05rem; padding: 10px 16px; cursor: pointer; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.big { min-height: 84px; font-size: 1.25rem; }
.btn.danger { border-color: var(--trouble); color: var(--trouble); }
.btn.slim { min-height: 52px; font-size: .95rem; }
.btn:disabled { opacity: .45; }
.btn + .btn { margin-top: 10px; }
.btnrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btnrow .btn + .btn { margin-top: 0; }

.tiles { display: grid; gap: 10px; }
.tile { min-height: var(--tap); border-radius: 14px; border: 2px solid var(--line); background: var(--card); padding: 12px 14px;
  text-align: left; font-weight: 600; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.tile .dot { width: 22px; height: 22px; border-radius: 50%; flex: none; }
.tile.sel { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 52px; padding: 8px 16px; border-radius: 26px; border: 2px solid var(--line); background: var(--card); font-weight: 600; }
.chip.sel { background: var(--ink); color: #fff; border-color: var(--ink); }

label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type=text], input[type=number], input[type=time], select, textarea {
  width: 100%; min-height: 56px; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; }
textarea { min-height: 90px; }
input[type=range] { width: 100%; height: 48px; accent-color: var(--primary); }
.rangeval { font-size: 2rem; font-weight: 800; text-align: center; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: none; }
.dose { display: grid; grid-template-columns: 1fr; gap: 8px; }
.dose .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dose .acts .btn { min-height: 56px; padding: 6px 10px; font-size: 1rem; margin: 0; }
.dose .acts .btn.slim:only-child { grid-column: 1 / -1; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: .8rem; font-weight: 700; }
.badge.ok { background: var(--on-soft); color: var(--on); }
.badge.skip { background: var(--off-soft); color: var(--off); }
.badge.sim { background: #ede9fe; color: #6d28d9; }

.banner { background: #fff7d6; border: 2px solid #e5b700; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; font-weight: 600; }

/* Messung */
.measure { text-align: center; padding-top: 8px; }
.measure .hand { font-size: 1.1rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.measure .hand.R { color: var(--right); } .measure .hand.L { color: var(--left); }
.measure .instr { font-size: 1.35rem; font-weight: 700; margin: 14px 0; line-height: 1.35; }
.counter { font-size: 6rem; font-weight: 800; line-height: 1; margin: 18px 0; font-variant-numeric: tabular-nums; }
.progress { height: 14px; background: var(--line); border-radius: 7px; overflow: hidden; margin: 10px 0 20px; }
.progress > div { height: 100%; background: var(--primary); transition: width .2s linear; }
.illu { font-size: 4rem; margin: 6px 0; }
.result { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result .card { margin: 0; }
.result h3 { margin: 0 0 6px; font-size: 1rem; }
.result .R h3 { color: var(--right); } .result .L h3 { color: var(--left); }
.kv { display: flex; justify-content: space-between; font-size: .9rem; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.big-index { font-size: 2.6rem; font-weight: 800; }

/* Diagramm */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .78rem; color: var(--quiet); margin-top: 6px; }
.legend i { display: inline-block; width: 16px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.legend i.box { height: 12px; width: 14px; }
table.sum { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.sum th, table.sum td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; }
table.sum th:first-child, table.sum td:first-child { text-align: left; }

.daynav { display: grid; grid-template-columns: 64px 1fr 64px; gap: 8px; align-items: center; text-align: center; margin-bottom: 10px; }
.daynav .btn { min-height: 52px; padding: 0; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { border: none; background: none; min-height: 68px; font-size: 1.4rem; color: var(--quiet); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tabbar button span { font-size: .72rem; font-weight: 600; }
.tabbar button.active { color: var(--primary); }
.tabbar.hidden { display: none; }

#print { display: none; }
@media print {
  body { padding: 0; background: #fff; font-size: 11pt; }
  .topbar, .tabbar, main { display: none !important; }
  #print { display: block; padding: 0 8mm; }
  #print .page-day { break-inside: avoid; margin-bottom: 8mm; }
  #print h1 { font-size: 16pt; } #print h2 { font-size: 12pt; margin: 4mm 0 2mm; }
}

/* v0.2: Schritte, Zurück, Rechtliches */
.back { display: inline-flex; align-items: center; min-height: 52px; padding: 0 4px; margin: -6px 0 6px; border: none; background: none;
  color: var(--primary); font-weight: 700; font-size: 1.05rem; cursor: pointer; }
.stephead { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 6px; }
.stephead h2 { margin: 2px 0 4px; }
.stepnum { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; }
.status { display: inline-block; font-size: .85rem; font-weight: 700; padding: 3px 10px; border-radius: 10px; }
.status.due { background: #fff1c2; color: #8a5a00; }
.status.done { background: var(--on-soft); color: var(--on); }
.step-of { color: var(--quiet); font-size: .9rem; margin-bottom: 4px; }
.toast { position: fixed; left: 50%; top: calc(70px + env(safe-area-inset-top)); transform: translate(-50%, -20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 24px; font-weight: 600; z-index: 20; transition: all .25s; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.legal-links { margin-top: 8px; }
.linkbtn { border: none; background: none; padding: 8px 0; color: var(--primary); font-weight: 600; text-decoration: underline; cursor: pointer; }
.consent { display: flex; gap: 12px; align-items: flex-start; font-weight: 500; margin: 6px 0 14px; line-height: 1.4; }
.consent input { width: 28px; height: 28px; flex: none; accent-color: var(--primary); margin-top: 2px; }
.legal h2 { font-size: 1.05rem; margin: 18px 0 6px; }
.legal p, .legal li { line-height: 1.5; }
.legal ul { padding-left: 20px; } .legal li { margin-bottom: 8px; }
.legal mark { background: #fff1c2; padding: 0 3px; }
.howto { padding-left: 22px; margin: 0 0 10px; } .howto li { margin-bottom: 10px; line-height: 1.45; }

/* v0.3 */
.greet { font-size: 1.15rem; font-weight: 700; color: var(--primary); margin: 4px 0 0; }
.stars { display: flex; gap: 6px; }
.star { width: 56px; height: 56px; border: none; background: none; font-size: 2.4rem; line-height: 1; color: #d4d8d6; cursor: pointer; padding: 0; }
.star.on { color: #eab308; }

/* v0.8 Befinden: drei große Kacheln */
.tile.big3 { min-height: 84px; align-items: center; }
.tile.big3 .dot { width: 28px; height: 28px; }
.tile .tl { display: block; font-size: 1.15rem; font-weight: 800; }
.tile .th { display: block; font-size: .85rem; font-weight: 500; color: var(--quiet); margin-top: 2px; }
