/* Gym Log v2.5 — "Ledger · Deep Teal"
   Three faces, one job each: serif = names and titles, sans (the phone's own) = everything you read,
   mono = numbers. Sections sit in cards so each block reads as one thing. */

:root {
  --bg: oklch(0.968 0.004 240);
  --card: oklch(0.997 0.002 240);
  --cardBorder: oklch(0.91 0.006 240);
  --cardHi: oklch(0.945 0.008 240);
  --panel: oklch(0.945 0.008 240);
  --ink: oklch(0.25 0.015 250);
  --ink2: oklch(0.42 0.014 250);
  --ink3: oklch(0.5 0.014 250);
  --muted: oklch(0.55 0.012 250);
  --faint: oklch(0.68 0.01 250);
  --rule: oklch(0.89 0.006 240);
  --ruleLight: oklch(0.925 0.006 240);
  --accent: oklch(0.48 0.09 215);
  --onAccent: oklch(0.985 0.01 215);
  --accentPanel: oklch(0.985 0.012 215);
  --inputBg: oklch(0.997 0.002 240);
  --inputBorder: oklch(0.86 0.008 240);
  --chipBorder: oklch(0.88 0.008 240);
  --buttonBorder: oklch(0.8 0.01 240);
  --danger: oklch(0.55 0.12 25);
  --good: oklch(0.5 0.13 150);
  --warm: oklch(0.55 0.15 48);
  --warmFill: oklch(0.74 0.15 45);
  --onWarm: oklch(0.2 0.04 45);
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  /* the home indicator only needs part of its inset; the rest was dead space under the tabs */
  --tabPad: max(0px, calc(env(safe-area-inset-bottom) - 14px));
  --tabH: calc(50px + var(--tabPad));
  --phone: 520px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.185 0.012 250);
    --card: oklch(0.235 0.014 250);
    --cardBorder: oklch(0.28 0.014 250);
    --cardHi: oklch(0.29 0.016 250);
    --panel: oklch(0.225 0.014 250);
    --ink: oklch(0.94 0.006 245);
    --ink2: oklch(0.76 0.012 250);
    --ink3: oklch(0.7 0.012 250);
    --muted: oklch(0.64 0.014 250);
    --faint: oklch(0.5 0.014 250);
    --rule: oklch(0.3 0.014 250);
    --ruleLight: oklch(0.28 0.014 250);
    --accent: oklch(0.72 0.1 215);
    --onAccent: oklch(0.17 0.03 220);
    --accentPanel: oklch(0.22 0.025 215);
    --inputBg: oklch(0.22 0.014 250);
    --inputBorder: oklch(0.34 0.014 250);
    --chipBorder: oklch(0.34 0.014 250);
    --buttonBorder: oklch(0.4 0.014 250);
    --danger: oklch(0.7 0.12 25);
    --good: oklch(0.76 0.15 150);
    --warm: oklch(0.75 0.15 45);
    --warmFill: oklch(0.75 0.15 45);
    --onWarm: oklch(0.18 0.04 45);
  }
}

/* explicit theme choice overrides the OS preference; same token lists, duplicated (no preprocessor) */
:root[data-theme="light"] {
  --bg: oklch(0.968 0.004 240);
  --card: oklch(0.997 0.002 240);
  --cardBorder: oklch(0.91 0.006 240);
  --cardHi: oklch(0.945 0.008 240);
  --panel: oklch(0.945 0.008 240);
  --ink: oklch(0.25 0.015 250);
  --ink2: oklch(0.42 0.014 250);
  --ink3: oklch(0.5 0.014 250);
  --muted: oklch(0.55 0.012 250);
  --faint: oklch(0.68 0.01 250);
  --rule: oklch(0.89 0.006 240);
  --ruleLight: oklch(0.925 0.006 240);
  --accent: oklch(0.48 0.09 215);
  --onAccent: oklch(0.985 0.01 215);
  --accentPanel: oklch(0.985 0.012 215);
  --inputBg: oklch(0.997 0.002 240);
  --inputBorder: oklch(0.86 0.008 240);
  --chipBorder: oklch(0.88 0.008 240);
  --buttonBorder: oklch(0.8 0.01 240);
  --danger: oklch(0.55 0.12 25);
  --good: oklch(0.5 0.13 150);
  --warm: oklch(0.55 0.15 48);
  --warmFill: oklch(0.74 0.15 45);
  --onWarm: oklch(0.2 0.04 45);
}

:root[data-theme="dark"] {
  --bg: oklch(0.185 0.012 250);
  --card: oklch(0.235 0.014 250);
  --cardBorder: oklch(0.28 0.014 250);
  --cardHi: oklch(0.29 0.016 250);
  --panel: oklch(0.225 0.014 250);
  --ink: oklch(0.94 0.006 245);
  --ink2: oklch(0.76 0.012 250);
  --ink3: oklch(0.7 0.012 250);
  --muted: oklch(0.64 0.014 250);
  --faint: oklch(0.5 0.014 250);
  --rule: oklch(0.3 0.014 250);
  --ruleLight: oklch(0.28 0.014 250);
  --accent: oklch(0.72 0.1 215);
  --onAccent: oklch(0.17 0.03 220);
  --accentPanel: oklch(0.22 0.025 215);
  --inputBg: oklch(0.22 0.014 250);
  --inputBorder: oklch(0.34 0.014 250);
  --chipBorder: oklch(0.34 0.014 250);
  --buttonBorder: oklch(0.4 0.014 250);
  --danger: oklch(0.7 0.12 25);
  --good: oklch(0.76 0.15 150);
  --warm: oklch(0.75 0.15 45);
  --warmFill: oklch(0.75 0.15 45);
  --onWarm: oklch(0.18 0.04 45);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

input, textarea, select { user-select: text; -webkit-user-select: text; }

button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  padding: 0;
  text-align: inherit;
  cursor: pointer;
}

[data-action]:active, button:active { opacity: .7; }

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* numbers are the one thing in mono */
.num, .set b { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* a set: "100 kg × 8" with the numbers loud and the units quiet */
.set { white-space: nowrap; }
.set b { color: inherit; }
.set u, .set i {
  font-family: var(--sans);
  font-style: normal;
  font-weight: 400;
  text-decoration: none;
  font-size: 0.8em;
  color: var(--muted);
}
.set u { margin-left: 0.22em; }
.set i { margin: 0 0.3em; }

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

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.tabs-on #app { bottom: var(--tabH); }
/* on a computer the app stays a phone-width column in the middle of the screen */
#app, #tabs { max-width: var(--phone); margin: 0 auto; }
@media (min-width: 560px) {
  #app, #tabs { border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); }
}

#tabs {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--tabH);
  padding-bottom: var(--tabPad);
  background: var(--bg);
  border-top: 1px solid var(--rule);
  z-index: 5;
}
body.tabs-on #tabs { display: flex; }
.tabBtn {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.tabBtn.active { color: var(--ink); }
.tabBtn.active::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
#app.enter { animation: riseIn 160ms ease-out; }

.top {
  flex: none;
  padding: calc(16px + env(safe-area-inset-top)) 30px 0;
}
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 30px;
}
.bottom {
  flex: none;
  padding: 0 30px max(16px, env(safe-area-inset-bottom));
}

/* ---- shared text styles ---- */

/* the small context line above a title (gym · date) */
.eyebrow { font-size: 14px; font-weight: 500; color: var(--muted); }

.pageHead { padding-bottom: 10px; }
.pageTitle { font-family: var(--serif); font-size: 40px; line-height: 1.05; letter-spacing: -0.01em; }

.heading {
  font-family: var(--serif);
  font-size: 44px;
  line-height: 1.05;
  margin-top: 16px;
  letter-spacing: -0.01em;
}

.bigTitle {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.1;
  margin-top: 10px;
}

.muted { font-size: 14px; color: var(--muted); padding: 8px 0; }

.sectionTitle {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  padding: 24px 0 6px;
}
.sectionTitle::first-letter { text-transform: uppercase; }

.search {
  font-family: var(--sans);
  font-size: 16px;
  background: var(--inputBg);
  border: 1px solid var(--inputBorder);
  border-radius: 10px;
  padding: 12px 14px;
  width: 100%;
  color: var(--ink);
  margin-top: 6px;
  appearance: none;
  -webkit-appearance: none;
}

/* ---- chips (filters) and pills (actions) ---- */

.chip {
  flex: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink2);
  border: 1px solid var(--chipBorder);
  border-radius: 18px;
  padding: 7px 14px;
  background: var(--card);
  white-space: nowrap;
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .chipCount { font-family: var(--mono); font-size: 12px; margin-left: 6px; opacity: .65; }

.pill {
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--buttonBorder);
  border-radius: 18px;
  padding: 0 14px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink2);
  background: var(--panel);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill.accent { border-color: var(--accent); color: var(--accent); }
.pill.fill { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.pill.logSecondary { display: flex; margin: 12px auto 0; }

/* ---- generic list row (history / summary) ---- */

.listRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--ruleLight);
}
.listRowMain { flex: 1; min-width: 0; }
.listRowName { font-family: var(--serif); font-size: 21px; line-height: 1.2; }
.listRowSub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.sessionNote { font-size: 14px; color: var(--ink2); padding: 0 14px 10px; font-style: italic; }

.simpleHead { padding-bottom: 16px; display: flex; align-items: center; gap: 12px; }

.footerLinks { display: flex; gap: 12px; padding: 16px 14px 24px; }

/* ---- A. Arrive ---- */

.cityList { margin-top: 30px; padding-bottom: 24px; }
.addRow { padding: 18px 0; }
.addRow .inlineRow { padding: 0; }
.cityRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}
.cityRow.selected {
  background: var(--ink);
  border-radius: 10px;
  padding: 18px 20px;
  margin: 0 -20px;
  border-bottom: none;
}
.cityName { font-family: var(--serif); font-size: 30px; color: var(--ink2); }
.cityRow.selected .cityName { color: var(--bg); }
.cityMeta { font-size: 13px; color: var(--muted); }
.cityRow.selected .cityMeta { color: var(--bg); opacity: .7; }

.arriveHead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.arriveHead .eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill.go { background: var(--warmFill); border-color: var(--warmFill); color: var(--onWarm); font-weight: 600; }

/* ---- inline name input row (new gym / rename / new exercise) ---- */

.inlineRow { display: flex; align-items: center; gap: 8px; padding: 10px 0; }
.inlineInput {
  flex: 1;
  min-width: 0;
  font-family: var(--sans);
  font-size: 16px;
  background: var(--inputBg);
  border: 1px solid var(--inputBorder);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
}
.inlineGroupRow { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0 10px; }
.inlineActions { display: flex; gap: 10px; padding: 0 0 16px; }

/* ---- B. Today's plan ---- */

.planHead {
  padding-bottom: 6px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.planCount { font-size: 13px; color: var(--muted); padding-bottom: 6px; flex: none; }
.planCount .num { color: var(--ink); font-size: 15px; }

.dayPick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.1;
  margin-top: 6px;
  color: var(--ink);
}
.dayPickCaret { font-family: var(--sans); font-size: 18px; color: var(--muted); }
.dayMenuRow { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 30px 0; }

/* swipe to delete: the numbers step aside and the panel slides in with the finger */
.swipe { position: relative; overflow: hidden; }
.swipeBack {
  position: absolute;
  right: 0;
  top: 4px;
  bottom: 5px;
  width: 92px;
  border-radius: 10px;
  background: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  transform: translateX(calc(92px - min(92px, var(--reveal, 0px))));
}
.swipe.open .swipeBack, .swipe:has(.swipeRow.dragging) .swipeBack { visibility: visible; }
.swipe.open .swipeBack { transform: none; }
.swipeBack button {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}
.swipeRow {
  position: relative;
  transition: padding-right 160ms ease-out;
  touch-action: pan-y;
}
.swipeRow.dragging { transition: none; }
.swipe.open .swipeRow { padding-right: 108px; }
.swipe.open .tCells, .swipe:has(.swipeRow.dragging) .tCells { display: none; }
.swipe.open .tTitle, .swipe:has(.swipeRow.dragging) .tTitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* "New exercise" sits under the table as a row, not a button */
.addExRow { display: flex; align-items: center; justify-content: space-between; padding: 14px; }
.addExRow .tTitle { color: var(--muted); font-size: 21px; }
.addPlus { flex: none; font-size: 26px; line-height: 1; color: var(--accent); }
.planFooter { padding-top: 18px; display: flex; flex-direction: column; gap: 4px; }
.discardRow { display: flex; justify-content: center; margin-top: 8px; }

/* big buttons: sentence case, weight does the work */
.btnFilled, .btnAccent {
  padding: 17px 0;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}
/* the big buttons and today's target share the second colour (coral), so the blue stays for the set
   you're on. Light mode uses a deeper coral for text so it reads on white; buttons keep dark text. */
.btnFilled { display: block; width: 100%; background: var(--warmFill); color: var(--onWarm); }
.btnAccent { width: 100%; background: var(--warmFill); color: var(--onWarm); overflow: hidden; text-overflow: ellipsis; }

/* ---- the sets table: plan, summary and history session ---- */

.scroll.cards.tableScroll { padding-top: 10px; }
/* the sets table sits on the page itself: no card around it and no lines between rows, only space */
.tCard { padding: 0 14px; }
.tHead {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px 0 6px;
  background: var(--bg);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.tHeadLabel { flex: 1; min-width: 0; }
.tCells { flex: none; display: grid; grid-template-columns: repeat(var(--n), var(--cw)); column-gap: 3px; row-gap: 2px; justify-items: end; }
.tRow { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; padding: 12px 0; }
/* the plan: the next exercise to do sits raised, and the finished ones step back */
.tCard > .swipe.next { margin: 6px -14px; background: var(--card); border: 1px solid var(--cardBorder); border-radius: 14px; }
.swipe.next .tRow { padding: 14px; }
.tRow.done .tTitle, .tRow.done .tCell { opacity: .55; }
.tName { flex: 1; min-width: 0; }
.tTitle { font-family: var(--serif); font-size: 19px; line-height: 1.12; }
.tRow.done .tTitle { color: var(--ink3); }
.tTarget { color: var(--warm); font-weight: 600; }
.tTick { font-family: var(--sans); font-size: 15px; font-weight: 700; color: var(--good); margin-right: 5px; }
.tSub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tSub::first-letter { text-transform: uppercase; }
.tChange { display: flex; flex-wrap: wrap; column-gap: 6px; margin-top: 2px; font-size: 13px; font-weight: 600; }
.tChange span { white-space: nowrap; }
.tChange .up { color: var(--good); }
.tChange .down { color: var(--danger); }
.tNote { flex-basis: 100%; font-size: 13px; color: var(--muted); font-style: italic; margin-top: 4px; }
.tCell { font-family: var(--mono); font-size: 12.5px; font-weight: 500; letter-spacing: -0.02em; color: var(--ink); white-space: nowrap; }
.tCell i { font-family: var(--sans); font-size: 10px; font-style: normal; font-weight: 400; color: var(--faint); margin: 0 1px; }
.tCell u { text-decoration: none; font-weight: 400; color: var(--ink2); }

/* ---- C. Logging ---- */

.logHead { padding-bottom: 22px; }
.logMeta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.logName { font-family: var(--serif); font-size: 36px; line-height: 1.1; margin-top: 14px; }

.rx {
  background: var(--card);
  border: 1px solid var(--cardBorder);
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 14px;
}
.rxCells { display: flex; justify-content: space-between; gap: 12px; }
.rxCell { flex: 1; min-width: 0; }
.rxHist { margin: 12px -16px 0; padding: 10px 16px 0; border-top: 1px solid var(--ruleLight); }
.rxHist:first-child { margin: 0; padding: 0; border-top: 0; }
.rxHistHead { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.rxHistRow { display: flex; gap: 10px; align-items: baseline; padding: 3px 0; font-size: 15px; color: var(--ink); }
.rxHistRow.older { font-size: 13px; color: var(--muted); }
.rxHistDate { flex: none; width: 48px; font-size: 13px; color: var(--muted); }
.rxHistSets { display: flex; flex-wrap: wrap; column-gap: 12px; row-gap: 2px; min-width: 0; }
.rxValue { font-family: var(--mono); font-size: 19px; font-weight: 500; color: var(--warm); }
.rxLabel { font-size: 13px; color: var(--muted); margin-top: 2px; }
.rxLabel::first-letter { text-transform: uppercase; }

.setsArea { padding: 6px 30px; display: flex; flex-direction: column; }
/* the table of done sets: heads and rows share one grid, numbers right under their head */
.setGrid { display: grid; grid-template-columns: 30px 62px 52px 1fr; column-gap: 10px; align-items: baseline; }
.setGrid > :nth-child(n+2) { text-align: right; }
.colHeader { padding: 14px 0 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.setRow { padding: 12px 0; border-bottom: 1px solid var(--ruleLight); }
.setNum { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.setVal { font-family: var(--mono); font-size: 20px; font-weight: 500; }
.setChange { font-size: 13px; color: var(--muted); white-space: nowrap; }
.setChange .up { color: var(--good); font-weight: 600; }
.setChange .down { color: var(--danger); font-weight: 600; }

.activeCard {
  margin: 22px -12px 0;
  padding: 18px 12px;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: var(--accentPanel);
}
.activeCard.inPlace { margin: 6px -12px; }
.activeHead {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.activeHead span:last-child { font-weight: 400; }
.steppers { display: flex; gap: 14px; margin-top: 14px; }
.stepperCol { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.stepper {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--inputBorder);
  border-radius: 12px;
  padding: 8px 14px;
  background: var(--inputBg);
}
.stepperCaption { font-size: 13px; color: var(--muted); }
.stepper button { font-size: 24px; line-height: 1; color: var(--ink3); flex: none; padding: 4px; }
.stepperInput {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 26px;
  width: 4ch;
  min-width: 0;
  flex: none;
  text-align: center;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 0;
}

.editActions { display: flex; gap: 10px; margin-top: 14px; }

.logBottom { display: flex; flex-direction: column; }
.logBottom > .pill { align-self: center; margin-top: 10px; }

/* ---- D. Picker ---- */

.pickerHead { padding-bottom: 16px; display: flex; align-items: center; gap: 12px; }
.blockRule { font-size: 13px; color: var(--muted); padding: 8px 0; }
.swapKeepRow { display: flex; gap: 10px; padding: 4px 0 14px; }
.pickerRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--ruleLight);
  gap: 10px;
}
.pickerName { font-family: var(--serif); font-size: 21px; min-width: 0; }
.pickerBest { flex: none; font-size: 13px; line-height: 1.5; color: var(--muted); text-align: right; }
.pickerBest .set { color: var(--ink2); }
.pickerAdd { color: var(--accent); font-size: 15px; font-weight: 600; border-bottom: none; }

/* ---- G. Progress: headed sections, each in a card ---- */

.scroll.cards { padding: 0 16px; }
.sectionHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 28px 14px 10px;
}
.sectionHead h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.sectionMeta { font-size: 14px; color: var(--muted); }
.sectionHead.withControl { align-items: center; padding-bottom: 8px; }
.sectionHead .segmented.mini { margin: 0; padding: 2px; border-radius: 9px; }
.segmented.mini button { flex: none; padding: 4px 11px; font-size: 13px; border-radius: 7px; }

.card {
  background: var(--card);
  border: 1px solid var(--cardBorder);
  border-radius: 16px;
  padding: 14px;
}
.card.list { padding: 0 14px; }

/* the readout above a chart follows the selected point */
.readout { min-height: 72px; }
.readoutLabel { font-size: 13px; font-weight: 500; color: var(--muted); }
.readoutValue { font-size: 28px; line-height: 1.15; color: var(--ink); margin-top: 2px; }
.readoutValue u, .readoutValue i { font-size: 15px; }
.readoutValue > u { font-family: var(--sans); text-decoration: none; color: var(--muted); margin-left: 6px; }
.readoutSub { font-size: 13px; color: var(--muted); margin-top: 1px; }

.chart { display: block; width: 100%; height: auto; margin-top: 10px; touch-action: pan-y; overflow: visible; }
.chartGrid { stroke: var(--ruleLight); stroke-width: 1; }
.chartTick { stroke: var(--rule); stroke-width: 1; }
.chartAxis { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.chartAxis.num { font-family: var(--mono); font-size: 10px; font-weight: 400; }
.chartSlot { fill: var(--cardHi); }
.weekBlock { fill: var(--accent); }
.chartPlan { stroke: var(--faint); stroke-width: 1; }
.chartPlanLabel { font-family: var(--sans); font-size: 11px; font-weight: 600; fill: var(--muted); paint-order: stroke; stroke: var(--card); stroke-width: 4px; }
.chartArea { fill: var(--accent); opacity: .1; }
.chartLine { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chartDot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.chartSel { fill: none; stroke: var(--accent); stroke-width: 2; }
.chartCross { stroke: var(--rule); stroke-width: 1; }
.chartLabel { font-family: var(--mono); font-size: 11px; font-weight: 500; fill: var(--ink); paint-order: stroke; stroke: var(--card); stroke-width: 4px; }

/* two numbers under a chart, split by a hairline */
.cardStats { display: flex; margin: 14px -14px -14px; border-top: 1px solid var(--ruleLight); }
.cardStat { flex: 1; min-width: 0; padding: 12px 14px 13px; }
.cardStat + .cardStat { border-left: 1px solid var(--ruleLight); }
.cardStatValue { font-size: 22px; color: var(--ink); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cardStatValue.up { color: var(--good); }
.cardStatValue.down { color: var(--danger); }
.cardStatLabel { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* rows inside a list card */
.cardRow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--ruleLight);
}
.cardRow:last-child { border-bottom: 0; }
.rowMain { flex: 1; min-width: 0; }
.rowName { font-family: var(--serif); font-size: 21px; line-height: 1.15; }
.rowSub { font-size: 13px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rowSubLine { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.rowSubLine .rowSub { margin-top: 0; }
.rowRight { flex: none; text-align: right; }
.rowValue { font-size: 17px; color: var(--ink); display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.rowRight .rowSub { margin-top: 4px; }
.rowSub.good { color: var(--good); font-weight: 600; }

/* change markers: tinted, so up and down are seen before they are read */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 700;
}
.badge.up { color: var(--good); background: color-mix(in oklch, var(--good) 16%, transparent); }
.badge.down { color: var(--danger); background: color-mix(in oklch, var(--danger) 16%, transparent); }
.badge.best { font-size: 12px; font-weight: 600; }

.progSpark { flex: none; display: block; overflow: visible; }
.progSpark path { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.progSpark circle { fill: var(--accent); }

/* gym filter: one scrolling row, bleeding to the screen edge */
.chipScroller { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 30px; scrollbar-width: none; }
.chipScroller::-webkit-scrollbar { display: none; }

/* metric switch: a segmented control, so it reads as "how to show it", not another filter */
.segmented { display: flex; background: var(--panel); border-radius: 10px; padding: 3px; margin: 14px 0 10px; }
.segmented button {
  flex: 1;
  padding: 7px 0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}
.segmented button.on { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--cardBorder), 0 1px 3px oklch(0 0 0 / .08); }

.histRow {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--ruleLight);
}
.histRow:last-child { border-bottom: 0; }
.histDate { flex: none; width: 54px; font-size: 14px; font-weight: 600; color: var(--ink2); padding-top: 1px; }
.histMain { flex: 1; min-width: 0; }
.histSets { display: flex; flex-wrap: wrap; column-gap: 14px; row-gap: 3px; font-size: 15px; color: var(--ink); }
.histNote { font-size: 13px; color: var(--muted); margin-top: 4px; font-style: italic; }
.histRow .badge { flex: none; margin-top: -1px; }

.progFoot { font-size: 13px; color: var(--muted); padding: 16px 14px 32px; line-height: 1.45; }

/* ---- H. More ---- */

.moreSection { margin-top: 16px; }
.moreSection:first-child { margin-top: 8px; }
.moreSection > .sectionTitle { padding-top: 0; padding-bottom: 10px; font-size: 17px; font-weight: 700; }
.panelBlock { background: var(--card); border: 1px solid var(--cardBorder); padding: 16px 14px; border-radius: 16px; }
.cards > .muted { padding-left: 14px; padding-right: 14px; }
.themeRow { display: flex; gap: 8px; }

.programRow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.programName { font-family: var(--serif); font-size: 21px; }
.programPick { position: relative; display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.programPick select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; }
.rulesList { margin-top: 10px; }
.rulesList p { font-size: 14px; line-height: 1.5; color: var(--ink2); margin: 0 0 10px; }
.rulesList p:last-child { margin-bottom: 0; }

.moreRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--ruleLight);
  gap: 10px;
}
.moreRowName { font-family: var(--serif); font-size: 21px; }
.moreRowLinks { display: flex; gap: 8px; flex: none; }
.panelBlock > .pill { margin-top: 12px; }

.rowBtn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 1px solid var(--buttonBorder);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink2);
  margin-bottom: 10px;
  background: none;
}
.rowBtn.danger { color: var(--danger); border-color: var(--danger); }
.rowBtnArrow { color: var(--faint); font-size: 18px; }
.appName { padding-top: 16px; }

/* ---- toast: top edge, one line, so it never collides with footers or the tab bar ---- */

#toast {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  margin: 0 auto;
  width: calc(100% - 60px);
  max-width: calc(var(--phone) - 60px);
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  padding: 11px 16px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity .2s ease, transform .2s ease;
  z-index: 10;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#toast.on { opacity: 1; transform: translateY(0); }
#toast.withAction {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
#toast.withAction .pill { flex: none; }

/* focus rings in the accent, not the browser default */
input:focus, select:focus { outline: none; border-color: var(--accent) !important; }

/* exercise detail: title aligned with the card content; the stats card has no inner padding */
.exTitle { padding: 2px 14px 12px; }
.statsCard { padding: 0; }
.statsCard .cardStats { margin: 0; border-top: 0; }
.cards .segmented { margin: 0 0 10px; }

/* ---- Sync, at the top of Data in More ---- */

.syncRow { padding-top: 0; margin-bottom: 10px; }
.syncMain { display: flex; flex-direction: column; min-width: 0; }
.syncState { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.syncForm { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; margin-bottom: 12px; border-bottom: 1px solid var(--ruleLight); }
.syncForm .inlineInput { width: 100%; }
.syncActions { display: flex; gap: 8px; }

/* ---- the computer layout: a menu on the left, panes side by side, no logging ---- */

#side { display: none; }
body.desk #side {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 210px;
  padding: 18px 12px;
  border-right: 1px solid var(--rule);
  background: var(--bg);
  z-index: 6;
}
.sideBrand { font-family: var(--serif); font-size: 27px; line-height: 1.1; color: var(--ink); padding: 6px 12px 20px; }
.sideBtn { display: block; width: 100%; text-align: left; padding: 11px 12px; border-radius: 10px; font-size: 15px; font-weight: 600; color: var(--muted); }
.sideBtn:hover { color: var(--ink); }
.sideBtn.active { color: var(--ink); background: var(--card); box-shadow: inset 0 0 0 1px var(--cardBorder); }
.sideSync { margin-top: auto; padding: 0 12px 4px; font-size: 13px; color: var(--muted); }

body.desk #tabs { display: none; }
body.desk #app { left: 210px; bottom: 0; max-width: none; margin: 0; border: 0; }
.deskGrid { flex: 1; min-height: 0; display: grid; }
.deskThree { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.deskOne { grid-template-columns: minmax(0, 1fr); }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--rule); }
.pane:last-child { border-right: 0; }
.pane > .scroll:first-child { padding-top: 12px; }
body.desk .exHead + .scroll { padding-top: 30px; }

/* the side menu names the page, and a pane needs no Back or Edit */
body.desk .pageHead,
body.desk .exHead,
body.desk [data-action="backHistory"],
body.desk [data-action="editHistorySession"] { display: none; }

/* rows reach the card's edges, so the open one and the hovered one read as whole rows */
body.desk .listRow { margin: 0 -30px; padding-left: 30px; padding-right: 30px; cursor: pointer; }
body.desk .card.list .cardRow { margin: 0 -14px; padding-left: 14px; padding-right: 14px; cursor: pointer; }
body.desk .histRow { cursor: pointer; }
body.desk .listRow:hover, body.desk .card.list .cardRow:hover { background: var(--cardHi); }
body.desk .listRow.picked, body.desk .card.list .cardRow.picked { background: var(--accentPanel); box-shadow: inset 3px 0 0 var(--accent); }

/* without lines between rows the sets need to stay near the names, so the table stays narrow */
body.desk .tCard { max-width: 680px; }
body.desk .chipScroller { flex-wrap: wrap; overflow: visible; }
.moreCols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; align-items: start; max-width: 1100px; }

/* ---- one gym or every gym ---- */

/* the gym under a date when rows come from more than one gym */
.rxGym, .histGym { display: block; font-size: 11px; font-weight: 400; color: var(--faint); margin-top: 1px; }
/* "Last time anywhere" under the last times here */
.rxOther { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--ruleLight); }
/* the set that made a new best (History) */
.tCell.best, .tCell.best u, .tCell.best i { color: var(--good); }
.tCell.best { font-weight: 700; }

/* "Same weight at every gym" on an exercise's page */
.scopeRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 14px 14px; }
.scopeLabel { font-size: 14px; color: var(--ink2); }
.switch { flex: none; position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--cardHi); box-shadow: inset 0 0 0 1px var(--buttonBorder); }
.switch span { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink3); transition: transform 140ms ease-out; }
.switch.on { background: var(--accent); box-shadow: none; }
.switch.on span { transform: translateX(18px); background: var(--onAccent); }

/* the gym row at the top of Progress sets the whole page */
.progGyms { margin-top: 4px; margin-bottom: 4px; }

/* on a computer it runs across the first two columns, and the open exercise takes the full height */
.deskProg { grid-template-rows: auto minmax(0, 1fr); }
.deskFilter { grid-column: 1 / 3; grid-row: 1; padding-top: 18px; border-right: 1px solid var(--rule); }
.deskFilter .chipScroller { margin: 0; padding: 0 30px; flex-wrap: wrap; }
.deskProg > .pane { grid-row: 2; }
.deskProg > .deskDetail { grid-column: 3; grid-row: 1 / 3; }

/* History on a device with no sessions yet */
.emptyState { padding-top: 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
