:root {
  --bg: #f6f3ec;
  --card: #ffffff;
  --text: #2a2a2a;
  --muted: #6f6a60;
  --accent: #2f4f45;
  --accent-light: #e3ebe7;
  --orange: #c27c3e;
  --border: #e4ded2;
  --danger: #a23b2a;
  --success: #2f7a4a;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Kopfzeile & Navigation ---------- */
.topbar {
  background: var(--accent);
  color: #fff;
  padding: 14px 20px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { color: #fff; text-decoration: none; font-weight: 600; font-size: 1.15rem; }
.userbox { display: flex; gap: 12px; align-items: center; font-size: .9rem; }
.link-btn {
  background: none; border: 1px solid rgba(255,255,255,.5); color: #fff;
  padding: 5px 10px; border-radius: 8px; cursor: pointer; font-size: .85rem;
}

.mainnav {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.mainnav a {
  flex: 1; text-align: center; padding: 12px 6px;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: .95rem;
  border-bottom: 3px solid transparent;
}
.mainnav a.active { color: var(--accent); border-bottom-color: var(--accent); }

.container { width: 100%; max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; flex: 1; }

h1 { font-size: 1.5rem; margin: 8px 0 6px; color: var(--accent); }
h2 { font-size: 1.1rem; margin: 22px 0 8px; color: var(--accent); }

/* ---------- Karten ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
}
a.card { display: block; color: inherit; text-decoration: none; transition: transform .1s, box-shadow .1s; }
a.card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.card-title { font-weight: 600; font-size: 1.05rem; }
.card-sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }

.meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tag { background: var(--accent-light); color: var(--accent); font-size: .78rem; padding: 3px 9px; border-radius: 20px; }

.back { display: inline-block; margin-bottom: 8px; color: var(--accent); text-decoration: none; font-size: .95rem; }

ol.steps { padding-left: 0; list-style: none; counter-reset: step; margin: 0; }
ol.steps li { counter-increment: step; position: relative; padding: 10px 0 10px 44px; border-bottom: 1px solid var(--border); }
ol.steps li:last-child { border-bottom: none; }
ol.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 9px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 600;
}

ul.plain { margin: 0; padding-left: 20px; }
ul.plain li { margin: 4px 0; }

ol.plain-list { margin: 0; padding-left: 22px; }
ol.plain-list li { padding: 5px 0; border-bottom: 1px solid var(--border); }
ol.plain-list li:last-child { border-bottom: none; }
ol.plain-list li span:first-child { margin-right: 8px; }
ol.plain-list li span.muted { float: right; font-variant-numeric: tabular-nums; }

.box-goal { background: var(--accent-light); border: none; }
.box-warn { border-left: 4px solid #d9a441; }
.hint { font-size: .8rem; color: var(--muted); text-align: center; margin: 8px 0 0; }

.nav-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.nav-row a {
  flex: 1; text-align: center; padding: 12px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--accent); text-decoration: none; font-size: .9rem;
}

/* ---------- Formulare & Buttons ---------- */
.auth { max-width: 400px; margin: 30px auto; }
label { display: block; font-size: .9rem; margin: 12px 0 4px; color: var(--muted); }
input, select {
  width: 100%; padding: 12px; font-size: 1rem;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
label.check { display: flex; gap: 10px; align-items: center; color: var(--text); margin: 6px 0; cursor: pointer; }
label.check input { width: 20px; height: 20px; }

.btn {
  display: block; width: 100%; margin-top: 14px; padding: 13px;
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  font-size: 1rem; font-weight: 600; cursor: pointer; text-align: center; text-decoration: none;
}
.btn:disabled { opacity: .6; }
.btn-link { margin-bottom: 4px; }
.btn-outline { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }

.btn-small {
  display: inline-block; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--accent);
  font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-small.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-small.danger { color: var(--danger); border-color: var(--danger); }

.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--accent); cursor: pointer; font-size: 1rem; flex-shrink: 0;
}
.icon-btn:disabled { opacity: .35; }
.icon-btn.danger { color: var(--danger); }
.icon-btn.armed { width: auto; padding: 0 10px; background: var(--danger); color: #fff; }

.error { color: var(--danger); font-size: .9rem; margin-top: 10px; min-height: 1.2em; }
.error.success { color: var(--success); }
.switch { text-align: center; margin-top: 16px; font-size: .9rem; }
.switch a { color: var(--accent); }

/* ---------- Figur ---------- */
.figure-box { text-align: center; }
.figure-holder { width: 100%; max-width: 380px; margin: 0 auto; min-height: 120px; }
.figure-canvas { width: 100%; display: block; border-radius: 10px; touch-action: none; cursor: grab; }
.view-buttons { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.view-btn {
  padding: 5px 11px; border-radius: 16px; border: 1px solid var(--border);
  background: #fff; color: var(--muted); font-size: .8rem; cursor: pointer;
}
.view-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.figure-legend { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.figure-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-left: 6px; }
.figure-legend .dot.l { background: var(--accent); }
.figure-legend .dot.r { background: var(--orange); }
.figure-controls { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.figure-controls .speed { display: flex; align-items: center; gap: 8px; margin: 0; }
.figure-controls select { width: auto; padding: 7px 10px; font-size: .9rem; }

/* ---------- Pläne ---------- */
.plan-card { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.plan-info { flex: 1; min-width: 0; }
.plan-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; text-align: center; }

.item-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.item-row:last-child { border-bottom: none; }
.item-title { font-weight: 500; flex: 1; min-width: 160px; }
.item-ctrl { display: flex; align-items: center; gap: 6px; }
.sec-input { width: 78px; padding: 7px 8px; font-size: .95rem; }
.quick-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }

/* ---------- Geführtes Training ---------- */
.player-top { margin-bottom: 6px; }
.progress { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }
.player-title { margin-top: 12px; }
.timer {
  font-size: 3.2rem; font-weight: 300; text-align: center; color: var(--accent);
  font-variant-numeric: tabular-nums; margin: 6px 0 12px;
}
.step-card { min-height: 130px; }
.player .figure-holder { max-width: 250px; }
.player .timer { font-size: 2.6rem; margin: 2px 0 8px; }
.step-text { font-size: 1.15rem; margin: 6px 0 10px; }
.breath { border-top: 1px solid var(--border); padding-top: 8px; }
.player-controls { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 14px; }
.ctrl {
  width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--border);
  background: #fff; color: var(--accent); font-size: 1.3rem; cursor: pointer;
}
.ctrl.big { width: 74px; height: 74px; background: var(--accent); color: #fff; border: none; font-size: 1.6rem; }
.ctrl:disabled { opacity: .35; }

.done-card { text-align: center; padding: 28px 18px; }
.done-icon { font-size: 3rem; color: var(--accent); }

/* ---------- Fortschritt ---------- */
.stats { display: flex; gap: 12px; justify-content: center; margin: 16px 0; }
.stats.grid4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px; }
@media (min-width: 600px) { .stats.grid4 { grid-template-columns: repeat(4, 1fr); } }
.stats.grid4 .card { margin: 0; }
.stat { text-align: center; padding: 14px 8px; }
.stat-num { font-size: 1.7rem; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-label { font-size: .8rem; color: var(--muted); }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 100%; max-width: 26px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-val { font-size: .68rem; color: var(--muted); height: 16px; }
.bar-label { font-size: .7rem; color: var(--muted); margin-top: 4px; }

.session-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.session-row:last-child { border-bottom: none; }
.ok { color: var(--success); }

.footer {
  text-align: center; font-size: .78rem; color: var(--muted);
  padding: 16px 20px 24px; padding-bottom: max(24px, env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto;
}
