/* ============================================================
   Kashtu — design system
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

:root {
  --accent: #6366f1;
  --accent-strong: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --rpe: #f97316;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --maxw: 640px;
  --nav-h: 64px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 24px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

[data-theme="light"] {
  --bg: #eef0f4;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #e7eaf0;
  --border: #d2d7e0;
  --text: #14171c;
  --text-2: #4a5360;
  --text-3: #6b7585;
  --mm-fill: #d4dae4;
  --scrim: rgba(20, 24, 30, .45);
}
[data-theme="dark"] {
  --bg: #10151d;
  --bg-elev: #1b232f;
  --surface: #1b232f;
  --surface-2: #2c3644;
  --border: #3b4655;
  --text: #f2f6fb;
  --text-2: #b2bdca;
  --text-3: #828d9c;
  --mm-fill: #3c4757;
  --scrim: rgba(0, 0, 0, .6);
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.3);
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }
::-webkit-scrollbar { width: 0; height: 0; }

/* ── App shell ─────────────────────────────────────────────── */
#app { min-height: 100vh; }
.screen {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--nav-h) + 90px);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  max-width: var(--maxw);
  margin: 0 auto;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.topbar h1 { font-size: 1.5rem; letter-spacing: -.02em; }
.topbar .sub { color: var(--text-2); font-size: .85rem; font-weight: 500; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--text-2); font-weight: 600; font-size: .95rem; margin-bottom: 4px;
  background: none; border: none; padding: 4px 0;
}

/* ── Bottom navigation ─────────────────────────────────────── */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; align-items: stretch;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,.06);
}
.nav-btn {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: none; color: var(--text-3);
  font-size: .58rem; font-weight: 600; letter-spacing: -.01em; transition: color .15s;
}
.nav-btn > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-btn.active { color: var(--accent); }
.nav-btn .icon { transition: transform .15s; }
.nav-btn.active .icon { transform: translateY(-1px); }
.nav-start { position: relative; }
.nav-start .start-fab {
  width: 52px; height: 52px; margin-top: -22px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 4px solid var(--bg-elev);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px var(--accent-soft);
}
.nav-start.active .start-fab { background: var(--accent-strong); }
.nav-badge {
  position: absolute; top: -6px; right: -8px;
  min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  border-radius: 8px;
  background: var(--danger); color: #fff;
  border: 2px solid var(--bg-elev);
  font-size: 10px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* ── Active session bar ────────────────────────────────────── */
.active-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 10px);
  width: min(var(--maxw), calc(100% - 24px)); z-index: 29;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--accent); color: #fff;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease;
}
.active-bar .pulse { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
.active-bar .ab-name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.active-bar .ab-timer { font-variant-numeric: tabular-nums; font-weight: 700; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes slideUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  color: var(--text);
}
.card + .card { margin-top: 14px; }
.card-tap { transition: transform .12s, border-color .12s; }
.card-tap:active { transform: scale(.99); }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 22px 4px 10px; font-weight: 700; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-sm); padding: 12px 18px;
  font-size: .98rem; font-weight: 700; transition: transform .1s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 15px 22px; font-size: 1.05rem; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
.turnstile { display: flex; justify-content: center; min-height: 65px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: var(--surface-2); color: var(--text); transition: background .15s, transform .1s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.ghost { background: transparent; color: var(--text-2); }
.icon-btn.danger { color: var(--danger); }

/* ── Forms ─────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 14px; }
.field > label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 70px; }

/* ── Chips / badges ────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid transparent;
}
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge-pr { background: rgba(245,158,11,.16); color: var(--warn); }
.badge-muscle { background: var(--accent-soft); color: var(--accent); }
.badge-muscle.secondary { background: var(--surface-2); color: var(--text-2); }

/* ── Loading / empty ───────────────────────────────────────── */
.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 50px 0; color: var(--text-2); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--surface-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty-state .empty-icon { color: var(--text-3); margin-bottom: 8px; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }
.empty-state p { margin-bottom: 16px; }

/* ── Stats grid ────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); color: var(--text);
}
.stat .num { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; display: flex; align-items: baseline; gap: 5px; }
.stat .num small { font-size: .8rem; font-weight: 600; color: var(--text-3); }
.stat .lbl { font-size: .78rem; color: var(--text-2); font-weight: 600; margin-top: 2px; }
.stat .accent { color: var(--accent); }
.stat .flame { color: var(--rpe); }

/* ── Muscle map ────────────────────────────────────────────── */
.muscle-map { display: flex; justify-content: center; align-items: flex-start; gap: 6px; }
/* All four SVGs share a 0.5 (w:h) viewBox, so width-based sizing yields equal heights
   and the figures fill the container width. */
.muscle-map-side { flex: 1; min-width: 0; max-width: 240px; display: flex; }
.muscle-map svg { width: 100%; height: auto; display: block; }
/* Base body: every region painted neutral; muscle highlights override per group. */
.muscle-map .mm-region path { fill: var(--mm-fill); stroke: var(--text-3); stroke-width: 1; transition: fill .2s, opacity .2s; }
.muscle-map g.mm-secondary path { fill: var(--accent); opacity: .45; }
.muscle-map g.mm-indirect path { fill: var(--accent); opacity: .28; }
.muscle-map g.mm-primary path { fill: var(--accent); opacity: 1; }
.muscle-map g.mm-selected path { fill: var(--accent); opacity: 1; }
.muscle-map g.mm-recovery-0 path { fill: var(--danger); opacity: .9; }
.muscle-map g.mm-recovery-1 path { fill: var(--warn); opacity: .85; }
.muscle-map g.mm-recovery-2 path { fill: #eab308; opacity: .7; }
.muscle-map g.mm-recovery-3 path { fill: var(--success); opacity: .75; }
.muscle-map.mini { max-width: 130px; gap: 2px; }
.recovery-legend { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 10px; font-size: .74rem; color: var(--text-2); }
.recovery-legend span { display: inline-flex; align-items: center; gap: 5px; }
.recovery-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ── Exercise rows / library ───────────────────────────────── */
.ex-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.ex-row + .ex-row { margin-top: 8px; }
.ex-thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.ex-thumb.placeholder { display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.ex-info { flex: 1; min-width: 0; }
.ex-name { font-weight: 700; font-size: .96rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-meta { color: var(--text-2); font-size: .8rem; text-transform: capitalize; }
.ex-list { display: flex; flex-direction: column; }

/* ── Active session screen ─────────────────────────────────── */
.session-head {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg); padding: calc(var(--safe-top) + 10px) 16px 10px;
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border);
}
.session-head .s-timer { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.session-head .s-name { color: var(--text-2); font-size: .8rem; font-weight: 600; }
.session-head .grow { flex: 1; }

.ex-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 14px; }
.ex-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.ex-card-head .ex-name { flex: 1; }
.ex-card .last { font-size: .8rem; color: var(--text-2); margin-bottom: 10px; }
.ex-card .last b { color: var(--text); font-weight: 700; }

/* Superset / circuit grouping: a coloured left rail ties grouped exercises together,
   and an A1/A2 badge marks each member's order within the group. */
.ex-card.ss-member { border-left: 3px solid var(--accent); }
.ss-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 20px; padding: 0 6px; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: .72rem; font-weight: 800;
  letter-spacing: .02em; flex: none;
}
.ss-hint { font-size: .76rem; color: var(--accent); margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.ss-chain {
  display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2); cursor: pointer;
}
.ss-chain.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.set-grid { display: flex; flex-direction: column; gap: 7px; }
.set-row {
  display: grid; grid-template-columns: 34px 1fr 1fr 52px 44px; gap: 7px; align-items: center;
}
/* Metric-typed layouts: fewer columns for bodyweight/duration/distance exercises. */
.set-grid.m-bodyweight_reps .set-row,
.set-grid.m-duration .set-row { grid-template-columns: 34px 1fr 52px 44px; }
.set-grid.m-distance_duration .set-row { grid-template-columns: 34px 1fr 1fr 44px; }
.set-row.head { color: var(--text-3); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 0 2px; }
.set-row.head > div { text-align: center; }
.set-num { display: flex; align-items: center; justify-content: center; width: 30px; height: 34px; border-radius: 8px; background: var(--surface-2); font-weight: 700; font-size: .85rem; color: var(--text-2); }
.set-num.warmup { background: rgba(245,158,11,.16); color: var(--warn); }
.set-input { width: 100%; text-align: center; padding: 9px 4px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.set-input:focus { outline: none; border-color: var(--accent); }
.set-rpe { background: var(--surface-2); border: none; border-radius: 8px; padding: 9px 2px; color: var(--rpe); font-weight: 700; text-align: center; }
.set-check {
  width: 40px; height: 36px; border-radius: 8px; border: 2px solid var(--border);
  background: var(--bg-elev); color: var(--text-3); display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.set-row.done .set-check { background: var(--success); border-color: var(--success); color: #fff; }
.set-row.done .set-input { border-color: transparent; background: var(--surface-2); }
.set-add { margin-top: 9px; display: flex; gap: 8px; }
.set-add .btn { flex: 1; padding: 9px; font-size: .85rem; }
.set-swipe-del { color: var(--text-3); background: none; border: none; font-size: .75rem; }

/* ── Rest timer ────────────────────────────────────────────── */
.rest-timer {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 10px); z-index: 35;
  width: min(var(--maxw), calc(100% - 24px));
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  animation: slideUp .2s ease;
}
.rest-timer .rt-time { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); min-width: 64px; }
.rest-timer .rt-label { font-size: .75rem; color: var(--text-2); font-weight: 600; }
.rest-timer .grow { flex: 1; }
.rest-timer .rt-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); border-radius: 0 0 var(--radius) var(--radius); transition: width 1s linear; }

/* ── Progress bars ─────────────────────────────────────────── */
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

/* ── Chart ─────────────────────────────────────────────────── */
.chart { width: 100%; height: auto; }
.chart .c-line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart .c-area { fill: var(--accent-soft); }
.chart .c-dot { fill: var(--accent); }
.chart .c-bar { fill: var(--accent); }
.chart .c-axis { stroke: var(--border); stroke-width: 1; }
.chart .c-label { fill: var(--text-3); font-size: 10px; }
.chart .c-goal { stroke: var(--success); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: .75; }
.chart .c-goal-label { fill: var(--success); font-size: 10px; font-weight: 700; }

/* ── History timeline ──────────────────────────────────────── */
.history-item { display: flex; gap: 14px; }
.history-date { width: 54px; flex-shrink: 0; text-align: center; }
.history-date .d { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.history-date .m { font-size: .72rem; color: var(--text-3); text-transform: uppercase; font-weight: 700; }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.tabs button { flex: 1; min-width: 0; padding: 9px 6px; border: none; border-radius: 7px; background: none; color: var(--text-2); font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: all .15s; }
.tabs button.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow); }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .2s; backdrop-filter: blur(2px);
}
.modal-overlay.modal-open { opacity: 1; }
.modal {
  width: 100%; max-width: var(--maxw); max-height: 92vh; background: var(--bg-elev);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  padding-bottom: var(--safe-bottom);
}
.modal-open .modal { transform: translateY(0); }
.modal-fullscreen { max-height: 100vh; height: 100vh; border-radius: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 1.15rem; }
.modal-body { padding: 16px; overflow-y: auto; }
@media (min-width: 700px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius-lg); max-height: 86vh; }
}
.confirm-actions { display: flex; gap: 10px; margin-top: 18px; }
.confirm-actions .btn { flex: 1; }

/* ── Toast ─────────────────────────────────────────────────── */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-bottom) + 80px); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px;
  font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px); transition: all .25s; max-width: calc(100% - 32px);
}
.toast-show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-warn { background: var(--warn); color: #111; }

/* ── Auth ──────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; max-width: 420px; margin: 0 auto; padding: 24px; }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo .mark { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow-lg); }
.auth-logo h1 { margin-top: 14px; font-size: 1.6rem; letter-spacing: -.02em; }
.auth-logo p { color: var(--text-2); }
.auth-switch { text-align: center; margin-top: 18px; color: var(--text-2); }
.auth-switch button { background: none; border: none; color: var(--accent); font-weight: 700; }
.auth-agree { display: flex; align-items: flex-start; gap: 9px; margin: 2px 0 14px; font-size: .82rem; color: var(--text-2); line-height: 1.45; cursor: pointer; }
.auth-agree input { margin-top: 2px; width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.auth-agree a { color: var(--accent); }
/* One-time strictly-necessary storage notice */
.cookie-notice {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--surface-2); border-top: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.cookie-notice p { margin: 0; font-size: .82rem; color: var(--text-2); line-height: 1.45; max-width: 640px; }
.cookie-notice a { color: var(--accent); }
.cookie-notice button { flex: none; padding: 8px 18px; }
/* Legal pages + footer links */
.legal-links { text-align: center; font-size: .8rem; color: var(--text-2); }
.legal-links a { color: var(--text-2); text-decoration: none; }
.legal-links a:hover { text-decoration: underline; }
.legal .legal-top { margin-bottom: 10px; }
.prose { padding: 22px; line-height: 1.6; }
.prose h1 { font-size: 1.5rem; letter-spacing: -.02em; margin: 0 0 4px; }
.prose h2 { font-size: 1.05rem; margin: 22px 0 8px; }
.prose .legal-sec:first-of-type h2 { margin-top: 12px; }
.prose p { margin: 0 0 12px; color: var(--text); }
.prose ul { margin: 0 0 12px; padding-left: 20px; }
.prose li { margin: 5px 0; color: var(--text); }
.prose a { color: var(--accent); }
/* Invite codes (admin) */
.invite-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; font-weight: 700; letter-spacing: .04em; background: var(--surface-2); padding: 2px 8px; border-radius: 6px; }
/* First-run onboarding */
.onboard { max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; min-height: 100vh; padding-block: 24px; }
.onboard-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.btn-ghost-link { background: none; border: none; color: var(--text-2); font-weight: 600; font-size: .9rem; padding: 6px 4px; }
.onboard-dots { display: flex; gap: 7px; justify-content: center; margin-bottom: 14px; }
.onboard-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--surface-2); transition: background .2s, width .2s; }
.onboard-dot.on { width: 22px; background: var(--accent); }
.onboard-dot.done { background: var(--accent-soft); }
.onboard-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.onboard-pick { padding: 18px 12px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); text-align: center; transition: border-color .15s, background .15s; }
.onboard-pick.on { border-color: var(--accent); background: var(--accent-soft); }
.onboard-stepper { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.onboard-stepper .btn { font-size: 1.5rem; width: 56px; height: 56px; flex: 0 0 auto; padding: 0; }
.onboard-goal { text-align: center; }
.onboard-goal .num { font-size: 2.6rem; font-weight: 800; line-height: 1; color: var(--accent); }
.onboard-hero { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 2px auto 14px; }
.onboard-lead { font-weight: 800; font-size: 1.25rem; text-align: center; }
.onboard-card p.dim { text-align: center; }
.onboard-fineprint { font-size: .78rem; margin-top: 16px; }
.onboard-features { display: flex; flex-direction: column; gap: 14px; }
.onboard-feature { display: flex; gap: 12px; align-items: flex-start; text-align: left; }
.onboard-feature .fi-d, .onboard-action .fi-d { text-align: left; }
.fi-ic { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.fi-t { font-weight: 700; line-height: 1.2; }
.fi-d { font-size: .84rem; margin-top: 2px; }
.onboard-row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-top: 1px solid var(--border); text-align: left; }
.onboard-row .grow { flex: 1; }
.onboard-tips { text-align: left; margin: 14px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; font-size: .85rem; color: var(--text-2); }
.onboard-tips li { line-height: 1.35; }
.onboard-actions { display: flex; flex-direction: column; gap: 10px; }
.onboard-action { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: inherit; text-align: left; transition: border-color .15s, background .15s; }
.onboard-action:active { background: var(--surface-2); }
.onboard-action .grow { flex: 1; }

.oauth { margin-top: 18px; }
.oauth-divider { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: .82rem; margin-bottom: 14px; }
.oauth-divider::before, .oauth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.oauth-btn { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; }
.oauth-ico { display: inline-flex; }
.oauth-ico svg { display: block; }

/* ── Achievements ──────────────────────────────────────────── */
.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ach {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; text-align: center; box-shadow: var(--shadow); opacity: .6;
}
.ach-earned { opacity: 1; border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--surface)); }
.ach-icon { font-size: 2rem; filter: grayscale(1); }
.ach-earned .ach-icon { filter: none; }
.ach-title { font-weight: 700; font-size: .92rem; margin-top: 4px; }
.ach-desc { color: var(--text-2); font-size: .76rem; margin-top: 2px; }
.ach-progress { margin-top: 8px; }
.ach-check { margin-top: 8px; color: var(--success); font-weight: 700; font-size: .78rem; }
.ach-strip { display: flex; gap: 8px; font-size: 1.6rem; }
.ach-strip .locked { filter: grayscale(1); opacity: .4; }

/* ── Toggle switch ─────────────────────────────────────────── */
.switch {
  flex-shrink: 0; width: 48px; height: 28px; border-radius: 999px; border: none;
  background: var(--surface-2); position: relative; transition: background .18s; cursor: pointer;
}
.switch.on { background: var(--accent); }
.switch-knob {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .18s;
}
.switch.on .switch-knob { transform: translateX(20px); }

/* misc */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--text-2); }
.center { text-align: center; }
.mt { margin-top: 14px; } .mt-lg { margin-top: 22px; }
.hstack { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.dim { color: var(--text-3); font-size: .85rem; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 800; font-size: 1rem; }

/* ── Progress photos ─────────────────────────────────────── */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-cell { position: relative; padding: 0; border: none; background: var(--surface-2); border-radius: 10px; overflow: hidden; aspect-ratio: 3 / 4; cursor: pointer; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-date { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 6px 4px; font-size: .68rem; color: #fff; text-align: center; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.photo-view { text-align: center; }
.photo-view img { max-width: 100%; max-height: 70vh; object-fit: contain; border-radius: 10px; }
.photo-compare { display: flex; gap: 8px; }
.photo-compare-side { position: relative; flex: 1; min-width: 0; }
.photo-compare-side img { width: 100%; border-radius: 10px; display: block; }
.photo-compare-label { position: absolute; top: 8px; left: 8px; font-size: .72rem; font-weight: 700; color: #fff; background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 999px; }

/* ── Program start: day picker ───────────────────────────── */
.prog-day-opt { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 8px; color: var(--text); }
.prog-day-opt.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.prog-day-opt .pdo-idx { font-size: .72rem; font-weight: 800; min-width: 40px; color: var(--text-3); letter-spacing: .03em; text-transform: uppercase; }
.prog-day-opt.sel .pdo-idx { color: var(--accent); }
.prog-day-opt .pdo-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Plate calculator ────────────────────────────────────── */
.plate-stack { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; min-height: 40px; }
.plate-pill { min-width: 36px; padding: 9px 11px; border-radius: 8px; font-weight: 800; font-size: .9rem; text-align: center; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }

/* ── Training heatmap ────────────────────────────────────── */
.heatmap-wrap { display: flex; flex-direction: column; gap: 8px; }
.hm-grid { display: flex; gap: 3px; }
.hm-col { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.hm-cell { aspect-ratio: 1; border-radius: 3px; background: var(--mm-fill); }
.hm-cell.hm-future { background: transparent; }
.hm-off { background: var(--mm-fill); }
.hm-on { background: var(--accent); }
.hm-legend { display: flex; align-items: center; gap: 6px; justify-content: flex-end; font-size: .72rem; color: var(--text-3); }
.hm-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.hm-legend span { margin-right: 6px; }

/* ── Admin dashboard ─────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.admin-table th { text-align: left; font-weight: 600; color: var(--text-3); font-size: .7rem;
  text-transform: uppercase; letter-spacing: .04em; padding: 6px 10px; }
.admin-table td { padding: 8px 10px; border-top: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.admin-table .ta-right { text-align: right; }
.admin-table tbody tr:first-child td { border-top: none; }
.admin-table tbody tr.admin-row { cursor: pointer; }
.admin-table tbody tr.admin-row:active { background: var(--surface-2); }
.admin-table tbody tr.is-banned td { opacity: .55; }

/* ── Camera capture (fullscreen) ─────────────────────────── */
.cam-overlay { position: fixed; inset: 0; z-index: 150; background: #000; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.cam-top { display: flex; justify-content: space-between; padding: 10px 12px; }
.cam-icon-btn { width: 44px; height: 44px; border-radius: 50%; border: none; background: rgba(255,255,255,.14); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.cam-stage { position: relative; flex: 1; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #000; }
.cam-stage-msg { padding: 20px; }
.cam-video { width: 100%; height: 100%; object-fit: cover; }
.cam-video.mirror { transform: scaleX(-1); }
.cam-ghost { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.cam-grid { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cam-grid line { stroke: rgba(255,255,255,.4); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cam-preview { max-width: 100%; max-height: 100%; object-fit: contain; }
.cam-bottom { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.cam-ghost-ctrl { display: flex; align-items: center; gap: 10px; justify-content: center; }
.cam-ghost-ctrl input[type=range] { flex: 1; max-width: 200px; }
.cam-chip { border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff; font-size: .78rem; font-weight: 600; padding: 5px 12px; border-radius: 999px; }
.cam-chip.on { background: var(--accent); border-color: var(--accent); }
.cam-shutter-row { display: flex; align-items: center; justify-content: space-between; }
.cam-shutter { width: 68px; height: 68px; border-radius: 50%; background: #fff; border: 4px solid rgba(255,255,255,.4); box-shadow: 0 0 0 2px #000 inset; }
.cam-shutter:active { transform: scale(.94); }
.cam-upload { width: 64px; background: transparent; border: none; color: #fff; font-size: .82rem; font-weight: 600; }

/* ── Body measurements: tappable silhouette ──────────────── */
.ms-figure-wrap { padding: 14px 6px 10px; overflow: visible; }
.ms-body { position: relative; width: 150px; aspect-ratio: 724 / 1448; margin: 0 auto; }
.ms-svg-holder, .ms-svg-holder svg { width: 100%; height: 100%; display: block; }
.ms-body svg path { fill: var(--mm-fill); stroke: var(--text-3); stroke-width: 1; }
.ms-marker { position: absolute; cursor: pointer; z-index: 2; -webkit-tap-highlight-color: transparent; }
.ms-dot { position: absolute; top: 0; left: 0; width: 15px; height: 15px; border-radius: 50%;
  transform: translate(-50%, -50%); background: var(--text-3); border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.ms-marker.set .ms-dot { background: var(--accent); }
.ms-marker.done .ms-dot { background: var(--success); }
.ms-marker.empty .ms-dot { background: var(--surface-2); border-color: var(--accent); }
.ms-label { position: absolute; top: 0; transform: translateY(-50%); white-space: nowrap;
  font-size: .62rem; font-weight: 700; line-height: 1; padding: 3px 6px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.ms-label b { color: var(--text); }
.ms-marker.r .ms-label { left: 12px; }
.ms-marker.l .ms-label { right: 12px; }
.ms-marker:active .ms-label { border-color: var(--accent); }
.ms-plus { color: var(--accent); font-weight: 800; margin-left: 3px; }

/* per-site goal row + progress */
.btn-sm { padding: 6px 12px; font-size: .82rem; }

/* ── Patch notes / changelog ─────────────────────────────── */
.cl-entry { margin-bottom: 12px; }
.cl-head { display: flex; align-items: center; gap: 8px; }
.cl-version { font-weight: 800; font-size: .82rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.cl-current { background: var(--success); color: #fff; font-size: .64rem; }
.cl-title { font-weight: 700; font-size: 1.05rem; margin: 2px 0 6px; }
.cl-notes { margin: 0; padding-left: 18px; }
.cl-notes li { font-size: .88rem; color: var(--text-2); margin: 4px 0; line-height: 1.4; }
.ms-goal { cursor: pointer; margin-top: 8px; }
.ms-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.ms-bar-fill { height: 100%; border-radius: 999px; transition: width .3s; }
