/* Gym Log: dark, mobile-first, big tap targets. */
:root {
  color-scheme: dark;
  --bg: #0b0b0b;
  --surface: #161616;
  --surface-2: #202020;
  --surface-3: #2a2a2a;
  --line: #2e2e2e;
  --text: #efefef;
  --text-2: #9c9c9c;
  --accent: #d4ff3d;        /* buttons, bars */
  --accent-ink: #0b0b0b;
  --good: #53c556;
  --warn: #fbb315;
  --danger: #eb5a5b;
  --radius: 18px;
  --tap: 56px;
  --tabbar-h: 64px;

  /* Muscle colours: fixed order, validated categorical palette (dark steps). */
  --m-chest: #338ced;
  --m-back: #e76624;
  --m-shoulders: #00a888;
  --m-biceps: #d28e05;
  --m-triceps: #e24d8b;
  --m-legs: #0aac23;
  --m-glutes: #9887ef;
  --m-core: #eb6263;
  --m-other: #7d7d7d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; }
h1, h2, p { margin: 0; }
h1 { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 700; }
.muted { color: var(--text-2); }
.small { font-size: 14px; }
.center { text-align: center; }
.pad { padding: 16px; }
.hint { color: var(--text-2); padding: 8px 0; }
.link { color: var(--accent); text-decoration: none; }

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 96px);
}

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(16, 16, 16, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-2); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--accent); }

/* ---------- page header ---------- */
.page-head { padding: 4px 4px 16px; }
.page-head p { margin-top: 2px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-head .center { flex: 1; }

/* ---------- common bits ---------- */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; margin-right: 8px; vertical-align: 0; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card-title { font-size: 17px; margin-bottom: 12px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  font-size: 22px; color: var(--text-2); flex: none;
}
.icon-btn:active { background: var(--surface-3); }
.icon-btn.nav { font-size: 34px; line-height: 1; color: var(--text); background: var(--surface); }
.icon-btn:disabled { opacity: 0.25; }

.btn {
  min-height: 48px; padding: 0 18px; border-radius: 14px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.08s, filter 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.big { min-height: var(--tap); font-size: 17px; }
.btn.wide { width: 100%; }
.btn.grow { flex: 1; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: #3a1616; color: #ff8a8a; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.file-btn { cursor: pointer; }

/* ---------- Today ---------- */
.cards { display: flex; flex-direction: column; gap: 10px; }
.ex-card { margin: 0; padding: 0; scroll-margin-top: 12px; }
.ex-head { display: flex; align-items: center; gap: 8px; padding: 14px 8px 14px 16px; min-height: 64px; cursor: pointer; }
.ex-title { flex: 1; min-width: 0; }
.ex-name { font-size: 18px; font-weight: 700; }
.ex-sub { color: var(--text-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-card:not(.open) .count {
  min-width: 36px; height: 36px; border-radius: 12px; background: var(--surface-2);
  display: grid; place-items: center; font-weight: 700; margin-right: 8px;
}
.ex-card.open { outline: 1px solid var(--surface-3); }

.last { margin: 0 16px; padding: 10px 12px; background: var(--surface-2); border-radius: 12px; }
.last-label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 2px; }
.last-sets { display: flex; flex-wrap: wrap; gap: 4px 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.last-sets .next { color: var(--accent); }

.sets { list-style: none; margin: 10px 0 0; padding: 0 8px; }
.set-row {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 10px;
  border-radius: 12px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.set-row:active, .set-row.editing { background: var(--surface-2); }
.set-row.editing { outline: 2px solid var(--accent); }
.set-n {
  width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3);
  display: grid; place-items: center; font-size: 14px; font-weight: 700; color: var(--text-2);
}
.set-v { flex: 1; font-size: 20px; font-weight: 700; }
.set-v small { font-size: 14px; color: var(--text-2); font-weight: 500; }
.set-v .x { color: var(--text-2); font-weight: 500; padding: 0 2px; }
.cmp { font-size: 14px; width: 24px; text-align: center; }
.cmp.up { color: var(--good); }
.cmp.down { color: var(--text-2); }
.cmp.same { color: var(--text-2); }

.logger { padding: 12px 16px 16px; }
.edit-note { color: var(--accent); font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stepper label { display: block; font-size: 13px; color: var(--text-2); margin: 0 0 4px 4px; }
.stepper-row { display: flex; align-items: stretch; background: var(--surface-2); border-radius: 14px; overflow: hidden; height: 60px; }
.step { width: 48px; font-size: 26px; color: var(--text); flex: none; }
.step:active { background: var(--surface-3); }
.num {
  flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; text-align: center;
  font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; outline: none;
}
.num::placeholder { color: #555; }
.logger .btn.wide { margin-top: 10px; }
.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.empty { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 18vh 0 0; color: var(--text-2); }
.big-plus, .fab {
  background: var(--accent); color: var(--accent-ink); font-weight: 400; border-radius: 50%;
  display: grid; place-items: center; box-shadow: 0 6px 24px rgba(212, 255, 61, 0.18);
}
.big-plus { width: 120px; height: 120px; font-size: 64px; }
.fab {
  position: fixed; z-index: 9; width: 68px; height: 68px; font-size: 40px;
  right: max(18px, calc(50% - 262px)); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
.big-plus:active, .fab:active { transform: scale(0.94); }

/* ---------- sheets ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; }
.scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); opacity: 0; transition: opacity 0.2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: 88dvh; overflow-y: auto; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.22s ease-out;
}
.overlay.open .scrim { opacity: 1; }
.overlay.open .sheet { transform: none; }
.overlay.full .sheet { top: 0; max-height: none; border-radius: 0; padding-top: calc(env(safe-area-inset-top) + 10px); display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.confirm-msg { font-size: 18px; font-weight: 600; padding: 6px 4px; }

.picker { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.picker-top { display: flex; gap: 8px; align-items: center; }
.search, .text-input {
  flex: 1; height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2);
  padding: 0 16px; font-size: 18px; outline: none; width: 100%;
}
.search:focus, .text-input:focus { border-color: var(--accent); }
.picker-list { flex: 1; overflow-y: auto; margin-top: 8px; }
.pick-row {
  width: 100%; display: flex; align-items: center; min-height: 60px; padding: 0 12px;
  border-bottom: 1px solid var(--line); text-align: left;
}
.pick-row:active { background: var(--surface-2); }
.pick-name { flex: 1; font-size: 18px; font-weight: 600; }
.pick-meta { color: var(--text-2); font-size: 14px; }
.add-row { color: var(--accent); border-bottom: 0; }
.add-row .plus { width: 26px; font-size: 26px; margin-right: 4px; }
.ask { font-size: 18px; margin-bottom: 14px; }

.muscle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.muscle-btn {
  min-height: 60px; border-radius: 14px; background: var(--surface-2); font-weight: 650;
  display: flex; align-items: center; justify-content: center; padding: 0 6px; border: 2px solid transparent;
}
.muscle-btn:active { background: var(--surface-3); }
.muscle-btn.selected { border-color: var(--accent); }
.field-label { display: block; color: var(--text-2); font-size: 14px; margin: 12px 0 6px; }

.day-body { margin-bottom: 14px; }
.day-ex { padding: 10px 0; border-bottom: 1px solid var(--line); }
.day-ex:last-child { border-bottom: 0; }
.day-ex-head { display: flex; align-items: center; }
.day-ex-name { flex: 1; font-weight: 700; font-size: 17px; }
.day-sets { margin: 6px 0 0 18px; padding-left: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.day-sets li { padding: 2px 0; }
.day-sets li::marker { color: var(--text-2); }

.toast {
  position: fixed; z-index: 100; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 100px);
  background: #f3f3f3; color: #111; border-radius: 14px; padding: 6px 6px 6px 16px;
  display: flex; align-items: center; gap: 12px; font-weight: 600; max-width: calc(100vw - 32px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); min-height: 52px;
}
.toast button { color: #4a6b00; font-weight: 800; padding: 10px 14px; border-radius: 10px; }

/* ---------- Calendar ---------- */
.cal { background: var(--surface); border-radius: var(--radius); padding: 10px; }
.cal-wd, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd span { text-align: center; color: var(--text-2); font-size: 13px; font-weight: 600; padding: 4px 0 8px; }
.cal-cell {
  aspect-ratio: 1 / 1.12; border-radius: 12px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums;
}
.cal-cell.blank { visibility: hidden; }
.cal-n { font-size: 16px; font-weight: 600; }
.cal-cell.future .cal-n { color: #5a5a5a; }
.cal-cell.has { background: var(--surface-3); }
.cal-cell.has .cal-n { font-weight: 800; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell:active { background: #333; }
.stripe { position: absolute; left: 5px; right: 5px; bottom: 5px; height: 7px; display: flex; gap: 2px; }
.stripe i { background: var(--c); border-radius: 4px; min-width: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 14px 6px; color: var(--text-2); font-size: 14px; }
.legend-item { display: inline-flex; align-items: center; }

/* ---------- Week ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 14px 12px; display: flex; flex-direction: column; }
.stat b { font-size: 26px; font-weight: 800; }
.stat span { color: var(--text-2); font-size: 13px; }

.bars { display: flex; flex-direction: column; gap: 2px; }
.bar-row { padding: 8px 8px 12px; border-radius: 12px; }
.bar-row.under { background: rgba(251, 179, 21, 0.08); }
.bar-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.bar-label { font-size: 15px; font-weight: 650; display: flex; align-items: center; flex: 1; }
.bar-val { font-variant-numeric: tabular-nums; font-size: 15px; }
.bar-status { font-size: 13px; font-weight: 700; white-space: nowrap; min-width: 64px; text-align: right; }
.bar-track { position: relative; height: 12px; background: var(--surface-2); border-radius: 4px; }
.bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; min-width: 4px; }
.target { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; box-shadow: 0 0 0 2px var(--surface); }
.status.good { color: var(--good); }
.status.warn { color: var(--warn); }
.callout { border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 15px; }
.callout.warn { background: rgba(251, 179, 21, 0.1); color: #ffd36b; }
.callout.info { background: var(--surface-2); color: var(--text); }
.callout.good { background: rgba(83, 197, 86, 0.1); color: var(--good); }

.day-row {
  width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 4px; min-height: 56px; border-bottom: 1px solid var(--line); text-align: left;
}
.day-row:last-child { border-bottom: 0; }
.day-row-date { font-weight: 700; }
.day-row-m { color: var(--text-2); font-size: 14px; display: flex; align-items: center; flex-wrap: wrap; }
.day-row-m .dot { width: 8px; height: 8px; margin-right: 3px; }
.day-row-m .dot:last-of-type { margin-right: 8px; }

/* ---------- Settings ---------- */
.ex-group { margin-bottom: 8px; }
.ex-group-head { display: flex; align-items: center; color: var(--text-2); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 4px 4px; }
.list-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between; min-height: 52px;
  padding: 0 8px 0 22px; border-radius: 12px; text-align: left; font-size: 17px;
}
.list-row:active { background: var(--surface-2); }
.chev { color: var(--text-2); font-size: 22px; }
.target-row { display: flex; align-items: center; justify-content: space-between; min-height: 56px; border-bottom: 1px solid var(--line); }
.target-row:last-child { border-bottom: 0; }
.target-label { display: flex; align-items: center; font-weight: 600; }
.mini-stepper { display: flex; align-items: center; background: var(--surface-2); border-radius: 12px; }
.step.sm { width: 48px; height: 44px; font-size: 22px; border-radius: 12px; }
.tval { min-width: 36px; text-align: center; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }

@media (min-width: 600px) {
  .view { padding-top: 32px; }
}
