:root {
  --bg: #0f1714;
  --bg-elev: #17211c;
  --card: #1c2a24;
  --line: #2a3b33;
  --text: #eef6f1;
  --muted: #9bb0a6;
  --accent: #1f8a6e;
  --accent-2: #2bb58e;
  --warn: #d4a017;
  --danger: #d45a5a;
  --ok: #3cbc7a;
  --radius: 18px;
  --tap: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
}
body { padding: var(--safe-t) 0 var(--safe-b); }
button, textarea, input { font: inherit; color: inherit; }
.screen {
  min-height: 100dvh;
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(16px + var(--safe-b));
}
.screen.has-timer { padding-bottom: calc(110px + var(--safe-b)); }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.tiny { font-size: 12px; line-height: 1.4; }
.error { color: var(--danger); margin: 8px 0 0; font-size: 14px; }
.eyebrow {
  margin: 0; text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 11px; color: var(--muted); font-weight: 700;
}
.grow { flex: 1; min-width: 0; }
.h-sm { font-size: 20px !important; line-height: 1.2 !important; }

#screen-lock { display: flex; align-items: center; justify-content: center; }
.lock-card {
  width: 100%; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 24px; padding: 28px 20px 24px; text-align: center;
}
.brand-mark {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px;
  background: linear-gradient(145deg, var(--accent), #145c4a);
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
}
.lock-card h1 { margin: 0 0 6px; font-size: 24px; }
.pass-dots {
  display: flex; justify-content: center; gap: 12px;
  margin: 18px 0 8px; min-height: 16px;
}
.pass-dots span {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--muted); display: inline-block;
}
.pass-dots span.on { background: var(--accent-2); border-color: var(--accent-2); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 16px; }
.key {
  height: var(--tap); border-radius: 16px; border: 1px solid var(--line);
  background: var(--card); font-size: 22px; font-weight: 600;
}
.key:active { background: #24362e; }
.key-ghost { color: var(--muted); font-size: 18px; }

.btn {
  min-height: var(--tap); border-radius: 16px; border: 1px solid transparent;
  padding: 0 18px; font-weight: 700; font-size: 16px; background: var(--card);
}
.btn.wide { width: 100%; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: 0.4; }
.btn.secondary { background: var(--card); border-color: var(--line); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.timer-btn {
  min-height: 44px; min-width: 64px; padding: 0 12px; font-size: 14px;
  background: #24362e; border-color: var(--line);
}
.btn.timer-btn.accent { background: var(--accent); color: #fff; border-color: transparent; }
.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: 16px;
  border: 1px solid var(--line); background: var(--card); font-size: 22px; flex: 0 0 auto;
}

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.topbar h1 { margin: 4px 0 0; font-size: 26px; line-height: 1.15; }
.session-meta { display: grid; gap: 10px; margin-bottom: 16px; }
.meta-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.meta-card .label { font-size: 12px; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
.meta-card .value { margin: 0; font-size: 20px; font-weight: 750; }
.flag {
  display: inline-block; margin-top: 8px; padding: 6px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
}
.flag.warn { background: rgba(212, 160, 23, 0.18); color: var(--warn); }
.flag.ok { background: rgba(60, 188, 122, 0.16); color: var(--ok); }
.flag.rest { background: rgba(155, 176, 166, 0.16); color: var(--muted); }

.session-body { display: grid; gap: 12px; padding-bottom: 12px; }
.session-footer { position: sticky; bottom: 0; padding: 12px 0 4px; background: linear-gradient(transparent, var(--bg) 30%); }
.empty {
  background: var(--bg-elev); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 28px 18px; text-align: center;
}
.empty h2 { margin: 0 0 8px; font-size: 20px; }

.ex-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; text-align: left; width: 100%;
  color: inherit; cursor: pointer;
}
.ex-card.done { border-color: rgba(60, 188, 122, 0.45); }
.ex-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.ex-num {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 10px;
  background: #24362e; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: var(--accent-2);
}
.ex-title { margin: 0; font-size: 18px; line-height: 1.25; flex: 1; text-align: left; }
.ex-type {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
.ex-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 10px;
}
.stat { background: #15201b; border-radius: 12px; padding: 10px 12px; }
.stat .k { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.stat .v { font-weight: 750; font-size: 15px; }
.progress-pill {
  display: block; margin-top: 8px; font-size: 12px; font-weight: 700;
  color: var(--accent-2);
}
.cues, .swaps { margin: 10px 0 0; padding: 0; list-style: none; }
.cues li, .swaps li {
  position: relative; padding-left: 14px; margin: 4px 0;
  color: var(--muted); font-size: 14px; line-height: 1.35;
}
.cues li::before, .swaps li::before {
  content: ""; position: absolute; left: 0; top: 0.55em;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.swaps li::before { background: var(--warn); }
.section-label {
  margin: 12px 0 0; font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Logger */
.swap-bar {
  background: rgba(212, 160, 23, 0.15); border: 1px solid rgba(212, 160, 23, 0.35);
  color: var(--warn); border-radius: 14px; padding: 10px 12px; margin-bottom: 12px;
  font-size: 14px; font-weight: 700;
}
.log-sets { display: grid; gap: 12px; margin: 14px 0; }
.set-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.set-card.logged { border-color: rgba(60, 188, 122, 0.5); }
.set-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.set-head strong { font-size: 16px; }
.set-badge {
  font-size: 11px; font-weight: 800; color: var(--ok);
  background: rgba(60, 188, 122, 0.15); padding: 4px 8px; border-radius: 999px;
}
.stepper-row {
  display: flex; align-items: center; gap: 8px; margin: 8px 0;
}
.stepper-row .field-label { flex: 1; margin: 0; }
.step-btn {
  width: 48px; height: 48px; border-radius: 14px; border: 1px solid var(--line);
  background: #24362e; font-size: 22px; font-weight: 700; flex: 0 0 auto;
}
.step-val {
  min-width: 72px; text-align: center; font-weight: 800; font-size: 18px;
}
.step-val.tbc { color: var(--warn); }
.field-label {
  display: block; font-size: 12px; font-weight: 700; color: var(--muted);
  margin: 10px 0 6px;
}
.rpe-row, .score-row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chip {
  min-width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: #15201b; font-weight: 700; font-size: 14px;
}
.chip.on { background: var(--accent); border-color: transparent; color: #fff; }
.feel-input, textarea {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: #15201b; padding: 10px 12px; resize: vertical;
}
.set-save {
  margin-top: 12px;
}
.log-actions { display: grid; gap: 10px; margin-bottom: 24px; }

.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--bg-elev); border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(20px + var(--safe-b));
  display: grid; gap: 10px; max-width: 480px; margin: 0 auto;
  max-height: 85dvh; overflow: auto;
}
.sheet-panel h2 { margin: 0 0 4px; font-size: 20px; }
.swap-options { display: grid; gap: 8px; }
.swap-opt {
  text-align: left; padding: 14px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card);
}
.swap-opt strong { display: block; margin-bottom: 4px; }

.rest-timer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: #123028; border-top: 1px solid var(--accent);
  padding: 12px 16px calc(12px + var(--safe-b));
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  max-width: 480px; margin: 0 auto;
}
.rest-main { display: flex; flex-direction: column; }
.rest-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.rest-countdown { font-size: 28px; font-weight: 800; letter-spacing: 0.02em; }
.rest-controls { display: flex; gap: 8px; }

/* History */
.pr-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.pr-badge {
  background: rgba(43, 181, 142, 0.16);
  border: 1px solid rgba(43, 181, 142, 0.35);
  color: var(--accent-2);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
}
.pr-badge.muted-badge {
  background: rgba(155, 176, 166, 0.12);
  border-color: var(--line);
  color: var(--muted);
}
.hist-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.hist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 320px;
}
.hist-table th, .hist-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.hist-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hist-table tr:last-child td { border-bottom: none; }
.chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
}
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-legend {
  display: flex; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--muted);
}
.chart-legend span::before {
  content: ""; display: inline-block; width: 10px; height: 10px;
  border-radius: 2px; margin-right: 6px; vertical-align: -1px;
}
.chart-legend .top::before { background: #2bb58e; }
.chart-legend .e1rm::before { background: #d4a017; }
.kg-hint {
  font-size: 12px; color: var(--muted); margin: 0 0 8px; font-weight: 600;
}

.intro-note { margin: 0 0 12px; }
.body-form .grid-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.body-form .grid-fields label { display: block; }
.body-form input[type="number"],
.body-form input[type="date"],
.body-form input[type="text"],
.checkin-card input[type="text"],
.checkin-card textarea {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: #15201b; padding: 10px 12px;
}
.body-form .full { grid-column: 1 / -1; }
.checkin-banner {
  background: rgba(31, 138, 110, 0.18);
  border: 1px solid rgba(43, 181, 142, 0.4);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.checkin-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.goal-note {
  font-size: 12px; color: var(--muted); margin: 6px 0 0; font-weight: 600;
}

.lifestyle-block { margin-bottom: 14px; }
.supp-check {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; margin: 8px 0;
}
.supp-check input { width: 22px; height: 22px; flex: 0 0 auto; }
.supp-check .meta { flex: 1; min-width: 0; }
.supp-check .name { font-weight: 750; font-size: 15px; }
.supp-check .dose { font-size: 12px; color: var(--muted); }
.timing-pill {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--accent-2);
  background: rgba(43,181,142,0.14); padding: 4px 8px; border-radius: 999px;
  white-space: nowrap;
}
.cycle-only-tag { color: var(--warn); font-size: 11px; font-weight: 700; }
.sauna-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }

.lab-flag {
  display: inline-block; margin-top: 6px; padding: 6px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(212, 160, 23, 0.18); color: var(--warn);
}
.photo-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.photo-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
}
.photo-card img {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; background: #15201b;
}
.photo-card .cap { padding: 8px 10px; font-size: 12px; color: var(--muted); }
.compare-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px;
}
.compare-row img {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; background: #15201b;
}
.pose-tag {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  color: var(--accent-2); letter-spacing: 0.04em;
}

.prog-suggest {
  margin: 12px 0 4px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(43,181,142,0.35);
  background: rgba(31,138,110,0.16);
  font-size: 14px;
  line-height: 1.35;
}
.prog-suggest.hold {
  border-color: rgba(212,160,23,0.4);
  background: rgba(212,160,23,0.12);
}
.prog-suggest .k { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 4px; }
.summary-card .value { font-size: 18px; }
