/* Bren Gym — mobile-first, warm + calm. Big targets, zero clutter. */

:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #241d16;
  --muted: #8b7f72;
  --line: #e9e2d8;
  --line-strong: #d7c9b6;   /* firmer than --line, used where a border/mark must read as tappable at a glance */
  --accent: #c2503b;        /* terracotta */
  --accent-soft: #f7e3de;
  --sage: #5f7d6c;
  --sage-soft: #e4ece7;
  --amber-soft: #f7ecd8;
  --amber-ink: #8a6014;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 3px rgba(36, 29, 22, 0.06), 0 4px 16px rgba(36, 29, 22, 0.05);
  --nav-h: 62px;
}

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

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 16px calc(var(--nav-h) + 90px + env(safe-area-inset-bottom));
}

h1 { font-size: 26px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h3 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }
.muted { color: var(--muted); }
a { color: inherit; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

/* ---------- layout blocks ---------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 2px 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

/* ---------- buttons ---------- */

button { font: inherit; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 20px;
  border: none;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--line-strong); color: var(--ink); }
.btn-finish { background: var(--sage); color: #fff; min-height: 44px; border: none; border-radius: 12px; padding: 8px 18px; font-weight: 650; font-size: 15px; cursor: pointer; }
.btn-text {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 6px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}
.btn-back { background: none; border: none; font-size: 17px; font-weight: 600; padding: 6px 10px 6px 0; cursor: pointer; color: var(--muted); }

/* ---------- home ---------- */

.start-card { text-align: center; padding: 24px 18px 14px; }
.start-card .btn { margin-top: 14px; }
.resume-card { text-align: center; padding: 22px 18px 12px; }
.resume-card .btn { margin-top: 12px; }

.recovery-banner { background: var(--amber-soft); box-shadow: none; }
.recovery-banner summary { cursor: pointer; color: var(--amber-ink); font-size: 14.5px; }
.recovery-banner summary strong { color: var(--amber-ink); }
.recovery-banner ul { margin: 10px 0 2px; padding-left: 20px; color: var(--amber-ink); font-size: 14.5px; }
.recovery-banner li { margin-bottom: 4px; }

.note-card { background: transparent; box-shadow: none; border: 1.5px dashed var(--line); font-size: 14.5px; }

.stat-row { display: flex; gap: 10px; margin-bottom: 14px; }
.stat {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-num { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; }
.stat-label { font-size: 11.5px; color: var(--muted); line-height: 1.25; }

.core-card { background: var(--sage-soft); box-shadow: none; }
.sync-chip { color: var(--accent); font-size: 20px; line-height: 1; padding-top: 8px; }

/* ---------- chips ---------- */

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 8px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
}
.chip-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.chip-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- workout ---------- */

.workout-head { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 2px; margin: -4px -2px 12px; }

.ex-card { padding: 14px 14px 8px; }
.ex-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ex-name { font-size: 17px; font-weight: 700; text-decoration: none; }
.ex-info { color: var(--muted); font-size: 14px; font-weight: 400; }
.ex-target { font-size: 13px; color: var(--muted); white-space: nowrap; font-weight: 600; }
.bump { color: var(--sage); font-weight: 700; }

.set-row {
  display: grid;
  grid-template-columns: 22px 1fr 1fr 48px;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.set-row:first-of-type { border-top: none; }
.set-n { color: var(--muted); font-size: 13px; font-weight: 700; text-align: center; }
.set-done .stepper-val { color: var(--sage); }

.stepper {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.stepper button {
  border: none;
  background: none;
  font-size: 22px;
  font-weight: 600;
  color: var(--muted);
  height: 44px;
  cursor: pointer;
}
.stepper button:active { background: var(--line); }
.stepper-val { text-align: center; font-size: 16.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper-val small { font-size: 10.5px; color: var(--muted); font-weight: 600; display: block; line-height: 1; margin-top: 1px; }

.check {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: var(--surface);
  color: transparent; /* glyph stays in the DOM but only shows once checked, so the idle ring never fights itself for contrast */
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.12s ease;
}
.check.checked { background: var(--sage); border-color: var(--sage); color: #fff; }
.check:active { transform: scale(0.92); border-color: var(--accent); }

.ex-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.caution {
  background: var(--amber-soft);
  color: var(--amber-ink);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  margin-bottom: 10px;
}
.workout-bottom-space { height: 40px; }

input[type='text'] {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  font: inherit;
  background: var(--surface);
  margin-top: 6px;
}
input[type='text']:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* ---------- exercise guide ---------- */

.ex-title { margin: 0 2px 2px; }
.ex-meta { margin: 0 2px 14px; text-transform: capitalize; }
.guide-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.guide-imgs figure { margin: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.guide-imgs img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.guide-imgs figcaption { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0 8px; font-weight: 600; }
.cue-list { margin: 0; padding-left: 20px; }
.cue-list li { margin-bottom: 8px; }
.mistake-list { margin: 0; padding-left: 20px; color: var(--muted); }
.mistake-list li { margin-bottom: 6px; }
.locked-card { background: var(--amber-soft); color: var(--amber-ink); box-shadow: none; }
.guide-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 16px; }

/* ---------- history ---------- */

.session-card summary {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}
.session-card summary::-webkit-details-marker { display: none; }
.session-letter {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.session-date { font-weight: 650; }
.session-ex { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0 0; font-size: 14.5px; }
.session-ex-name { color: var(--muted); }
.session-ex-sets { font-variant-numeric: tabular-nums; text-align: right; }
.session-card[open] { padding-bottom: 14px; }
.session-card[open] .session-ex:first-of-type { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.session-note { margin-top: 10px; font-style: italic; color: var(--muted); font-size: 14.5px; }

/* ---------- charts ---------- */

.chart { width: 100%; height: auto; display: block; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: var(--accent); }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-target { stroke: var(--sage); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-bar { fill: var(--line-strong); }
.chart-axis { stroke: var(--line-strong); stroke-width: 1; }
.chart-bar-hit { fill: var(--sage); }
.chart-label { font-size: 10.5px; fill: var(--muted); font-family: inherit; }
.chart-value { font-size: 12px; font-weight: 700; fill: var(--ink); font-family: inherit; }
.chart-note { font-size: 13px; margin-top: 8px; }
.chart-empty { text-align: center; padding: 24px 0; }

/* ---------- login ---------- */

.login { display: flex; flex-direction: column; align-items: center; padding-top: 8vh; }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo {
  width: 74px;
  height: 74px;
  border-radius: 22px;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  letter-spacing: -0.02em;
}
.pin-dots { display: flex; gap: 14px; margin-bottom: 6px; min-height: 16px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); }
.pin-dot.filled { background: var(--ink); border-color: var(--ink); }
.pin-error { color: var(--accent); font-size: 14px; min-height: 20px; margin: 6px 0 10px; }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; }
.key {
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 24px;
  font-weight: 600;
  cursor: pointer;
}
.key:active { background: var(--line); }
.key-ghost { background: transparent; box-shadow: none; font-size: 20px; }
.key-go { background: var(--sage); color: #fff; font-size: 17px; font-weight: 700; }

/* ---------- splash ---------- */

.splash { text-align: center; padding-top: 24vh; display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ---------- timer bar ---------- */

#timerbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom));
  max-width: 456px;
  margin: 0 auto;
  background: var(--ink);
  color: #fff;
  border-radius: 16px;
  padding: 12px 14px;
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 20;
  box-shadow: 0 8px 28px rgba(36, 29, 22, 0.35);
}
#timerbar.timer-visible { display: flex; }
#timerbar.timer-done { background: var(--sage); }
.timer-track { flex: 1; height: 6px; background: rgba(255, 255, 255, 0.25); border-radius: 3px; overflow: hidden; }
.timer-fill { height: 100%; width: 0; background: #fff; border-radius: 3px; transition: width 0.25s linear; }
.timer-text { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
#timer-skip {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
}

/* ---------- bottom nav ---------- */

#bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 15;
}
#bottomnav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  text-decoration: none;
}
#bottomnav a.active { color: var(--accent); }
body[data-route='login'] #bottomnav,
body[data-route='workout'] #bottomnav { display: none; }
body[data-route='workout'] #timerbar { bottom: calc(14px + env(safe-area-inset-bottom)); }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 14.5px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 30;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
