:root {
  --bg: #15171a;
  --board: #1f2227;
  --line: #33373d;
  --chalk: #f3efe6;
  --muted: #9aa0a8;
  --accent: #e8e2d4;
  --good: #76c47a;
  --bad: #e0655f;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--chalk);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 14px calc(90px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ---------- views / tabs ---------- */
.view { display: none; }
.view.active { display: block; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  max-width: 520px;
  margin: 0 auto;
  background: var(--board);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 8px;
  font-size: 11px;
  font-weight: 700;
}
.tab.active { color: var(--chalk); }
.tab svg { display: block; }

/* ---------- week chart (self-built) ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 150px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}
.bar-val { font-size: 11px; color: var(--muted); height: 14px; }
.bar-track {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.bar-fill {
  width: 70%;
  min-height: 3px;
  background: var(--line);
  border-radius: 5px 5px 0 0;
}
.bar-fill.now { background: var(--chalk); }
.bar-lbl { font-size: 11px; color: var(--muted); margin-top: 6px; }

.hint { color: var(--muted); font-size: 12px; padding: 2px 4px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 2px 12px;
  background: linear-gradient(var(--bg) 70%, rgba(21,23,26,0));
}
.logo {
  font-weight: 900;
  letter-spacing: 1px;
  font-size: 20px;
  line-height: 1;
  text-transform: uppercase;
}
.logo span { opacity: .55; }
.logo.small { font-size: 26px; line-height: 1.05; margin-bottom: 10px; }

.whoami {
  border: 1.5px solid var(--line);
  background: var(--board);
  color: var(--chalk);
  font-weight: 800;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 999px;
}

/* ---------- roast banner ---------- */
.roast {
  font-style: italic;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 4px 6px 14px;
  min-height: 20px;
}

/* ---------- cards ---------- */
.card {
  background: var(--board);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-head h2 {
  margin: 0;
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.date { color: var(--muted); font-size: 12px; }

/* ---------- exercise rows ---------- */
.ex {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.ex:first-child { border-top: none; }
.ex-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.ex-name { font-weight: 800; font-size: 16px; }
.goal {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 6px 0;
}
.step-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #15171a;
  color: var(--chalk);
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-btn:active { background: #0e0f11; }
.reps {
  flex: 1;
  text-align: center;
  font-size: 26px;
  font-weight: 900;
}
.reps small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
.reps.hit { color: var(--good); }

/* ---------- day done ---------- */
.daydone {
  width: 100%;
  margin-top: 14px;
  padding: 16px;
  border-radius: 14px;
  border: 2px solid var(--chalk);
  background: transparent;
  color: var(--chalk);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 1px;
}
.daydone.done {
  background: var(--good);
  border-color: var(--good);
  color: #0e2010;
}
.daydone.locked { opacity: .5; border-color: var(--line); color: var(--muted); }

/* ---------- leaderboard ---------- */
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.lb-row:first-child { border-top: none; }
.lb-rank { font-weight: 900; font-size: 18px; width: 26px; color: var(--muted); }
.lb-row.me .lb-name { color: var(--accent); }
.lb-name { flex: 1; font-weight: 800; font-size: 16px; }
.lb-streak { font-size: 13px; color: var(--muted); }
.lb-reps { font-weight: 900; font-size: 18px; }
.lb-reps small { font-size: 11px; font-weight: 600; color: var(--muted); }
.crown { filter: grayscale(0); }

/* ---------- group goals ---------- */
.gg-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.gg-row:first-child { border-top: none; }
.gg-name { flex: 1; font-weight: 800; font-size: 16px; }
.gg-goal { font-weight: 900; font-size: 20px; min-width: 28px; text-align: right; }

/* ---------- buttons ---------- */
.btn {
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #15171a;
  color: var(--chalk);
  font-weight: 800;
  font-size: 14px;
  padding: 10px 16px;
}
.btn:active { transform: scale(.98); }
.btn.small { padding: 8px 14px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.solid { background: var(--chalk); color: #15171a; border-color: var(--chalk); }

/* ---------- modal ---------- */
.modal {
  background: var(--board);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  width: 100%;
  max-width: 360px;
}
.modal-title { font-weight: 900; font-size: 20px; text-transform: uppercase; letter-spacing: .5px; }
.small { font-size: 12px; }
.stepper.big { justify-content: center; gap: 18px; margin: 18px 0 22px; }
.stepper.big .reps { flex: 0 0 auto; min-width: 70px; font-size: 40px; }
.modal-actions { display: flex; gap: 12px; }
.modal-actions .btn { flex: 1; padding: 14px; font-size: 15px; }
.pin-input {
  width: 100%;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #15171a;
  color: var(--chalk);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 6px;
}
.pin-input::placeholder { color: var(--muted); letter-spacing: normal; font-weight: 600; }
.pin-input:focus { outline: none; border-color: var(--chalk); }

/* ---------- picker overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,11,13,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}
.picker-card {
  background: var(--board);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  text-align: center;
  width: 100%;
  max-width: 360px;
}
.picker-names { display: grid; gap: 12px; margin-top: 10px; }
.picker-names button {
  padding: 16px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #15171a;
  color: var(--chalk);
  font-weight: 800;
  font-size: 18px;
}
.picker-names button:active { background: #0e0f11; }
.muted { color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--chalk);
  color: #15171a;
  font-weight: 800;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: 999px;
  z-index: 40;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  transition: opacity .25s, transform .25s;
  max-width: 88vw;
  text-align: center;
}
.toast.hidden { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  padding-top: 6px;
}

/* ---------- icons ---------- */
.ic { width: 22px; height: 22px; fill: currentColor; flex: 0 0 auto; vertical-align: middle; }
.ic.xs { width: 13px; height: 13px; vertical-align: -2px; }
.ic.sm { width: 15px; height: 15px; vertical-align: -2px; }

.ex-name { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 16px; }
.ex-ic { width: 22px; height: 22px; opacity: .9; }

.whoami { display: inline-flex; align-items: center; gap: 6px; }
.whoami .ic { width: 16px; height: 16px; }

.step-btn.icon { font-size: 0; padding: 0; }
.step-btn .ic { width: 30px; height: 30px; }

/* ---------- progress ring ---------- */
.ring { width: 78px; height: 78px; flex: 0 0 auto; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 3; }
.ring-fg { fill: none; stroke: var(--chalk); stroke-width: 3; stroke-linecap: round; transition: stroke-dasharray .35s ease; }
.ring.hit .ring-fg { stroke: var(--good); }
.ring-num { fill: var(--chalk); font-size: 11px; font-weight: 900; text-anchor: middle; dominant-baseline: central; }
.ring.hit .ring-num { fill: var(--good); }

/* ---------- daydone (icon + feedback) ---------- */
.daydone { display: flex; align-items: center; justify-content: center; gap: 10px; }
.daydone .ic { width: 22px; height: 22px; }
.daydone.pulse { animation: dd-pulse .6s ease; }
@keyframes dd-pulse { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }

/* ---------- goals row ---------- */
.gg-name { display: inline-flex; align-items: center; gap: 9px; flex: 1; font-weight: 800; font-size: 16px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #15171a; color: var(--chalk);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: scale(.96); }
.icon-btn .ic { width: 20px; height: 20px; }

/* ---------- leaderboard icons ---------- */
.lb-crown { width: 24px; height: 24px; fill: var(--chalk); flex: 0 0 auto; }
.lb-streak { display: inline-flex; align-items: center; gap: 4px; }
.lb-streak .ic { width: 14px; height: 14px; }

/* ---------- log: feed ---------- */
.empty { color: var(--muted); font-size: 14px; padding: 8px 2px; }
.feed-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.feed-row:first-child { border-top: none; }
.feed-ic { width: 20px; height: 20px; opacity: .85; flex: 0 0 auto; }
.feed-main { flex: 1; font-size: 14px; }
.feed-user { font-weight: 800; }
.feed-row.me .feed-user { color: var(--accent); }
.feed-when { text-align: right; font-size: 12px; color: var(--muted); line-height: 1.25; }
.feed-when small { display: block; font-size: 11px; }

/* ---------- log: comparison ---------- */
.cmp-day { padding: 12px 0; border-top: 1px solid var(--line); }
.cmp-day:first-child { border-top: none; }
.cmp-date { font-weight: 800; font-size: 13px; margin-bottom: 8px; }
table.cmp { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
table.cmp th, table.cmp td { padding: 6px 4px; text-align: center; }
table.cmp th.cmp-h, table.cmp td.cmp-name { text-align: left; }
table.cmp thead th { color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); }
.th-ic { width: 18px; height: 18px; opacity: .8; vertical-align: middle; }
.cmp-name { font-weight: 800; }
.cmp-sum { font-weight: 900; }
table.cmp tbody tr.me td { color: var(--accent); }

/* ---------- confetti ---------- */
.confetti { position: fixed; bottom: 90px; width: 8px; height: 8px; border-radius: 2px; pointer-events: none; z-index: 60; animation: cf 1s ease-out forwards; }
@keyframes cf { to { transform: translate(var(--dx), var(--dy)) rotate(420deg); opacity: 0; } }

.hidden { display: none !important; }

/* ---------- dashboard ex rows (read-only rings) ---------- */
.ex { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.ex:first-child { border-top: none; }
.ex-info { flex: 1; }
.ex-count { flex: 0 0 auto; font-size: 26px; font-weight: 900; }
.ex-count.hit { color: var(--good); }
.ex-goal { font-size: 14px; font-weight: 700; color: var(--muted); }
.ring-wrap { flex: 0 0 auto; }
.ring-goal { fill: var(--muted); font-size: 7.5px; text-anchor: middle; }

/* ---------- log triggers (bottom-bar + / desktop +) ---------- */
.tab-group { flex: 1; display: flex; }
.tab-group .tab { flex: 1; }
.tabadd { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; background: transparent; border: none; padding: 0 4px; }
.tabadd .ic { width: 24px; height: 24px; fill: #15171a; background: var(--chalk); border-radius: 50%; padding: 10px; box-sizing: content-box; }
.tabadd:active .ic { transform: scale(.94); }

.top-actions { display: flex; align-items: center; gap: 10px; }
.top-add { display: none; width: 38px; height: 38px; border-radius: 50%; border: none; background: var(--chalk); color: #15171a; align-items: center; justify-content: center; }
.top-add .ic { width: 22px; height: 22px; }
.top-add:active { transform: scale(.95); }

/* ---------- log modal ---------- */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.seg button { padding: 12px 4px; border-radius: 12px; border: 1.5px solid var(--line); background: #15171a; color: var(--chalk); font-weight: 800; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 5px; line-height: 1.1; }
.seg button .ic { width: 24px; height: 24px; }
.seg button.sel { border-color: var(--chalk); background: #23262b; }
.num-input { width: 100%; padding: 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #15171a; color: var(--chalk); font-size: 28px; font-weight: 900; text-align: center; margin-bottom: 12px; }
.num-input:focus { outline: none; border-color: var(--chalk); }
.num-input::placeholder { color: var(--muted); font-weight: 600; font-size: 18px; }
.quick { display: flex; gap: 8px; margin-bottom: 16px; }
.quick button { flex: 1; padding: 12px; border-radius: 12px; border: 1.5px solid var(--line); background: #15171a; color: var(--chalk); font-weight: 800; font-size: 15px; }
.quick button:active { background: #0e0f11; }
.quick .clear { flex: 0 0 44px; color: var(--muted); }

/* log modal extras */
.log-modal { max-height: 88vh; overflow-y: auto; }
.fld-label { display: block; text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; margin: 4px 2px 6px; }
.row2 { display: flex; gap: 12px; margin-bottom: 14px; }
.row2 .fld { flex: 1; }
.ministep { display: flex; align-items: center; justify-content: space-between; border: 1.5px solid var(--line); border-radius: 12px; padding: 6px 8px; }
.ministep span { font-size: 20px; font-weight: 900; }
.ms-btn { width: 38px; height: 38px; border-radius: 10px; border: none; background: #15171a; color: var(--chalk); font-size: 22px; font-weight: 800; }
.ms-btn:active { background: #0e0f11; }
.total-val { border: 1.5px dashed var(--line); border-radius: 12px; padding: 12px; font-size: 22px; font-weight: 900; text-align: center; }
.day-seg { display: flex; gap: 8px; margin-bottom: 12px; }
.day-seg button[data-day] { padding: 12px; border-radius: 12px; border: 1.5px solid var(--line); background: #15171a; color: var(--chalk); font-weight: 800; font-size: 13px; flex: 0 0 auto; }
.day-seg button[data-day].sel { border-color: var(--chalk); background: #23262b; }
.date-input { flex: 1; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: #15171a; color: var(--chalk); font-weight: 700; font-size: 13px; color-scheme: dark; }
.time-input { width: 100%; padding: 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #15171a; color: var(--chalk); font-size: 20px; font-weight: 900; text-align: center; letter-spacing: 2px; margin-bottom: 16px; }
.time-input:focus, .date-input:focus { outline: none; border-color: var(--chalk); }

/* ---------- feed delete ---------- */
.del { background: transparent; border: none; color: var(--muted); padding: 6px; margin-left: 2px; flex: 0 0 auto; }
.del .ic { width: 18px; height: 18px; }
.del:active { color: var(--bad); }

/* ---------- exercises tab + demos ---------- */
.ex-card { padding: 14px 0; border-top: 1px solid var(--line); }
.ex-card:first-child { border-top: none; }
.ex-card-head { display: flex; align-items: center; justify-content: space-between; }
.ex-card-head .ex-name { font-weight: 800; font-size: 16px; }
.ex-actions { display: flex; gap: 8px; }
.demo { margin: 10px auto 6px; text-align: center; }
.demo-vid { width: 100%; max-width: 200px; border-radius: 12px; display: block; margin: 0 auto; background: #0e0f11; }
.demo-fallback { display: none; }
.demo-fallback.show { display: block; }
.demo-svg { width: 128px; height: 128px; display: block; margin: 0 auto; }
.powered { text-align: center; color: var(--muted); font-size: 11px; margin-top: 12px; }
.demo-body { min-height: 120px; display: flex; align-items: center; justify-content: center; }
.demo-body .demo-vid { width: 100%; max-width: 100%; border-radius: 12px; background: #0e0f11; }
.demo-msg { color: var(--muted); font-size: 14px; text-align: center; padding: 24px 8px; }
.demo-photos { position: relative; width: 100%; max-width: 320px; margin: 0 auto; aspect-ratio: 850 / 567; }
.demo-photos img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border-radius: 12px; background: #fff; }
.demo-draw { text-align: center; }

/* ---------- doodle (Tag geschafft) ---------- */
.draw-canvas { width: 100%; max-width: 280px; height: auto; aspect-ratio: 1; background: #1f2227; border: 1.5px solid var(--line); border-radius: 14px; touch-action: none; display: block; margin: 0 auto 12px; cursor: crosshair; }
.doodles { display: flex; gap: 10px; }
.doodle { flex: 1; text-align: center; min-width: 0; }
.doodle-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: #1f2227; border: 1px solid var(--line); display: block; }
.doodle-done { display: flex; align-items: center; justify-content: center; color: var(--good); }
.doodle-done .ic { width: 34px; height: 34px; fill: var(--good); }
.doodle-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); border-style: dashed; }
.doodle-name { font-size: 12px; font-weight: 800; margin-top: 5px; }
.dstreak { color: var(--accent); white-space: nowrap; }
.doodle-name .ic { width: 11px; height: 11px; vertical-align: -1px; }

/* ---------- history (week navigator) ---------- */
.week-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.wk-btn { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: #15171a; color: var(--chalk); font-size: 22px; font-weight: 800; line-height: 1; }
.wk-btn:disabled { opacity: .35; }
.wk-btn:active { background: #0e0f11; }
.wk-label { font-weight: 800; font-size: 14px; }
table.wk td, table.wk th { text-align: center; }
table.wk .cmp-name { text-align: left; white-space: nowrap; }
.cell-done { color: var(--good); font-weight: 900; }
.wk-today .cmp-name { color: var(--accent); }
.wk-total td { border-top: 1px solid var(--line); font-weight: 900; }
.auth-go { width: 100%; margin-top: 12px; }
.d-bar, .d-l { stroke: var(--chalk); stroke-width: 5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.d-strap { stroke: var(--muted); stroke-width: 2.6; fill: none; stroke-linecap: round; }
.d-ring { stroke: var(--chalk); stroke-width: 2.6; fill: none; }
.d-h, .d-dot { fill: var(--chalk); }
.pose { animation-duration: 2.6s; animation-iteration-count: infinite; animation-timing-function: ease-in-out; transform-origin: center; }
.pose-a { animation-name: poseA; }
.pose-b { animation-name: poseB; }
@keyframes poseA { 0%, 40% { opacity: 1; } 50%, 90% { opacity: 0; } 100% { opacity: 1; } }
@keyframes poseB { 0%, 40% { opacity: 0; } 50%, 90% { opacity: 1; } 100% { opacity: 0; } }
.demo-none { color: var(--muted); font-size: 13px; text-align: center; padding: 38px 0; }
.cue { color: var(--muted); font-size: 13px; text-align: center; }
.add-ex { width: 100%; margin-top: 12px; }
.num-input.txt { font-size: 18px; font-weight: 700; text-align: left; letter-spacing: normal; }
@media (prefers-reduced-motion: reduce) { .pose { animation: none; } .pose-b { opacity: 0; } }

/* ---------- responsive: tablet / desktop dashboard ---------- */
@media (min-width: 760px) {
  body {
    max-width: 980px;
    padding: 0 24px 40px;
  }
  .topbar { padding-top: 20px; padding-bottom: 10px; }
  .tabbar { display: none; }
  .top-add { display: inline-flex; }
  #roast { text-align: center; padding: 8px 0 20px; }
  #app {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
  }
  .view { display: block !important; }
  .view .card { margin-bottom: 20px; }
  .view .card:last-child { margin-bottom: 0; }
}
