:root {
  --bg: #f2f2f2;
  --surface: #ffffff;
  --text: #1c1c1c;
  --text-secondary: #6b6b6b;
  --border: #d0d0d0;
  --accent: #007aff;
  --complete-bg: #00ff00;
  --miss-bg: #111114;
  --complete-text: #000000;
  --highlight-row: #e4e4e4;
  --highlight-col: rgba(0, 0, 0, 0.06);
  --total-bg: #5e5e5e;
  --total-border: #444444;
  --total-text: #ffffff;
  --progress-bg: rgba(0, 255, 0, 0.22);
  --week-divider: #a8a8a8;
  --header-text: #1c1c1c;
  --today-box-bg: #ffffff;
  --today-box-border: #1c1c1c;
  --today-box-text: #000000;
  --today-box-edge: #8a8a8a;
  --cell-gap: 2px;
  --header-lift: 0px;
  --header-pad-top: 0px;
  --footer-h: 84px;
  --hb: 74px;   /* the size of every header and footer button (they're square) */
}

/* Opened in a Safari tab (not installed): iOS only shrinks its address bar and toolbar when the page scrolls, and a
   new account's one-week grid is shorter than the screen. Make the page a little taller than the window so a swipe
   up collapses them. Installed copies have no browser bars, so they don't get this. */
@media not (display-mode: standalone) {
  body { min-height: calc(100vh + 120px); min-height: calc(100dvh + 120px); }
}

/* Installed on the home screen (touch devices): pull the sticky headers up into the status bar gap. */
@media (display-mode: standalone) and (pointer: coarse) {   /* phones and tablets only: a desktop app window has no status bar gap, and the lift would crop the header */
  :root { --header-lift: 24px; --header-pad-top: 15px; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --surface: #1e1e1e;
    --text: #e6e6e6;
    --text-secondary: #999999;
    --border: #333333;
    --accent: #4facfe;
    --complete-bg: #00ff00;
    --miss-bg: #0a0a0c;
    --complete-text: #000000;
    --highlight-row: #2b2b2b;
    --highlight-col: rgba(255, 255, 255, 0.07);
    --total-bg: rgba(255, 255, 255, 0.14);
    --total-border: rgba(255, 255, 255, 0.4);
    --total-text: #ffffff;
    --progress-bg: rgba(0, 255, 0, 0.22);
    --week-divider: #565656;
    --header-text: #ffffff;
    --today-box-bg: #505050;
    --today-box-border: rgba(255, 255, 255, 0.8);
    --today-box-text: #ffffff;
    --today-box-edge: #000000;
  }
}

:root[data-theme="dark"] {
  --bg: #121212;
  --surface: #1e1e1e;
  --text: #e6e6e6;
  --text-secondary: #999999;
  --border: #333333;
  --accent: #4facfe;
  --complete-bg: #00ff00;
  --miss-bg: #0a0a0c;
  --complete-text: #000000;
  --highlight-row: #2b2b2b;
  --highlight-col: rgba(255, 255, 255, 0.07);
  --total-bg: rgba(255, 255, 255, 0.14);
  --total-border: rgba(255, 255, 255, 0.4);
  --total-text: #ffffff;
  --progress-bg: rgba(0, 255, 0, 0.22);
  --week-divider: #565656;
  --header-text: #ffffff;
  --today-box-bg: #505050;
  --today-box-border: rgba(255, 255, 255, 0.8);
  --today-box-text: #ffffff;
  --today-box-edge: #000000;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Vertical scrolling only: no sideways scroll, drag or bounce. */
html {
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

/* The whole UI uses the OCR-A style monospace face (ocrab, SIL OFL: fonts/ocrab-OFL.txt), falling back to the
   system monospace until it loads. Only a regular weight exists, so bold is the browser's synthetic bold. */
:root { --font-sym: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif; }   /* the check mark isn't in the OCR face */
:root { --font-ui: "ocrab", ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
button, input, select, textarea { font-family: inherit; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(12px + var(--header-pad-top)) 16px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: calc(-1 * var(--header-lift));
  z-index: 10;
}

@font-face {
  font-family: "ocrab";
  src: url("/fonts/ocrab.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
.app-header h1, .login h1 {
  /* Three stacked lines in a monospace OCR face (ocrab: OCR-A letters, SIL OFL, see fonts/ocrab-OFL.txt), so the
     highlighted first letters line up in a column and read MWT down the side. */
  font-family: var(--font-ui);
  text-transform: uppercase;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.22;
}
.app-header h1, .login h1 { display: flex; flex-direction: column; gap: 4px; }
.app-header h1 .tl, .login h1 .tl { display: block; white-space: nowrap; }
.app-header h1 .tl b, .login h1 .tl b {
  background: var(--complete-bg);
  color: var(--complete-text);
  border-radius: 3px;
  padding: 0 0.1em;
  margin-right: 0.08em;
  font-weight: 400;
}

.settings-btn {
  width: 74px;
  height: 74px;
  flex: none;
  border: 2px solid var(--total-border);
  background: var(--total-bg);
  color: var(--total-text);
  font-size: 56px;
  line-height: 1;
  cursor: pointer;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.settings-btn:active { opacity: 0.6; }
#settingsBtn svg {
  width: 62%;
  height: 62%;
  fill: currentColor;
}
.jump-btn[hidden] { display: none; }
.jump-btn svg {
  width: 50%;
  height: 50%;
  transition: transform 0.2s ease;
}
.jump-btn.down svg { transform: rotate(180deg); }
/* Pulse via the separate `scale` property so it doesn't fight the rotate above. */
.jump-btn svg { animation: jump-pulse 1.8s ease-in-out infinite; }
@keyframes jump-pulse {
  0%, 100% { scale: 1; }
  50% { scale: 1.12; }
}

.app-header { --hdr-gap: 8px; }   /* one gap between every header box */
.header-right {
  position: relative;   /* the live sync dot sits in the settings button's top right corner */
  display: flex;
  align-items: center;
  gap: var(--hdr-gap);
}
.grand-totals {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--hdr-gap);
}
.total-box.grand-total-box {
  aspect-ratio: 1;
  width: 74px;
  height: 74px;
  padding: 0 3px;
  font-size: 21px;
  border-radius: 10px;
  position: relative;
}
/* Longer totals step the number down so the box stays square. */
.grand-total-box[data-digits="5"] { font-size: 17px; }
.grand-total-box[data-digits="6"] { font-size: 14px; }
.grand-total-box[data-digits="7"] { font-size: 12px; }
.total-box.grand-total-box {
  flex-direction: column;
  gap: 3px;
}
.grand-num {
  line-height: 1;
}
.grand-total-box .reps-label, .saver-btn .reps-label {   /* the clock button's DASH is the very same subtitle as MILES and LBS LOST */
  font-size: 10px;
}
/* The progress box: reps done over reps planned, like a fraction (2.4K over 8.5K), with the percent underneath. */
.stats-frac { display: flex; flex-direction: column; align-items: center; font-size: 19px; line-height: 1.05; }
.stats-frac .frac-bar { display: block; width: 100%; height: 2px; margin: 2px 0; background: currentColor; opacity: 0.45; border-radius: 1px; }

.grid-wrapper {
  padding: 6px 6px calc(var(--footer-h) + env(safe-area-inset-bottom) + 10px);   /* room for the fixed footer */
}

/* Weight button: sits left of the grand totals; blinks until today's weight is logged. */
.weight-btn {
  font: inherit;
  font-size: 21px;
  font-weight: 700;
  padding: 0 3px;
  cursor: pointer;
}
.weight-btn:active { opacity: 0.6; }
.weight-btn .grand-num { font-size: inherit; }
.weight-btn[data-digits="5"] { font-size: 17px; }
.weight-btn[data-digits="6"] { font-size: 14px; }
.weight-btn.due { animation: weight-blink 1.2s ease-in-out infinite; }
@keyframes weight-blink {
  0%, 100% { border-color: var(--total-border); }
  50% { border-color: var(--accent); background: var(--accent); color: #fff; }
}
.weight-note {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin: 0 0 14px;
  min-height: 1.3em;
}
.weight-history {
  margin-top: 14px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
/* each row: date, pounds, a two-tap delete */
.weight-history div { gap: 10px; align-items: center; }
.weight-history .wh-lb { margin-left: auto; }
.weight-history span { white-space: nowrap; }
.wh-del { min-width: 32px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-secondary); font: inherit; cursor: pointer; }
.wh-del.ask { background: #d9363e; border-color: #d9363e; color: #fff; }
.weight-history div {
  display: flex;
  justify-content: space-between;
  padding: 4px 2px;
  border-top: 1px solid var(--border);
}

.grid {
  display: grid;
  grid-template-columns: auto repeat(var(--ndays, 5), 1fr) auto;
  column-gap: 1px;
  row-gap: 4px;
  background: var(--week-divider);
  border-radius: 12px;
  overflow: clip;
  width: 100%;
}

.grid-header {
  background: var(--surface);
  position: sticky;
  top: calc(var(--app-header-h, 0px) - var(--header-lift));
  z-index: 5;
  box-shadow: 0 1px 0 var(--week-divider), 1px 0 0 var(--week-divider);
  padding: 12px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--header-text);
}
.corner-header {
  overflow: hidden;
  padding: 0;
  cursor: pointer;
}
/* Flip-card view: a finished day with a picture turns over (rotateY) and shows it on the back; the front's rows hide their back faces. */
.day-cell.has-photo {
  position: relative;
  transform-style: preserve-3d;
  transform: perspective(800px) rotateY(0deg);
  transition: transform 0.75s cubic-bezier(0.4, 0.15, 0.2, 1) var(--fd, 0s);
}
.day-cell.has-photo.flipped { transform: perspective(800px) rotateY(180deg); }
.day-cell.has-photo.instant { transition: none; }
.day-cell.has-photo > *:not(.day-photo) { backface-visibility: hidden; }
.day-photo {
  position: absolute;
  inset: 4px;   /* the cell's padding, so it sits exactly where the green X does */
  border-radius: 8px;   /* and has the same rounded corners */
  transform: rotateY(180deg);
  backface-visibility: hidden;
  overflow: hidden;
  background: #000;
}
.day-photo img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .day-cell.has-photo { transition: none; } }
/* Absolutely positioned so a longer label (e.g. "W12") never resizes the auto-width column. */
.corner-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.grid-header.today-col {
  background: linear-gradient(var(--highlight-col), var(--highlight-col)), var(--surface);
}

.week-label {
  background: var(--surface);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.week-label.current-week {
  background: var(--highlight-row);
}
.reps-box {
  cursor: pointer;
  position: relative;
}
.total-box.reps-box,
.week-totals .total-box {
  flex-direction: column;
  gap: calc(var(--box, 54px) * 0.04);
}
/* --box is the side-column box size, set by syncTotalBoxSize(). */
.reps-num {
  font-size: max(6px, calc(var(--box, 54px) * 0.38 - 1px));
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.5px;
}
.week-totals .total-box[data-digits="3"] .reps-num { font-size: max(6px, calc(var(--box, 54px) * 0.32 - 1px)); }
.week-totals .total-box[data-digits="4"] .reps-num { font-size: max(6px, calc(var(--box, 54px) * 0.25 - 1px)); }
.total-box.all-done .reps-label { color: rgba(0, 0, 0, 0.6); }
.reps-label {
  max-width: calc(100% - 4px);
  font-size: max(9px, calc(var(--box, 54px) * 0.16));
  font-weight: 600;
  letter-spacing: 0.3px;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.6);
  pointer-events: none;
}
.reps-box.overridden::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffcc00;
}
.week-reps-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.day-cell {
  background: var(--surface);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.day-cell.current-week {
  background: var(--highlight-row);
}
.day-cell.today-col {
  background: linear-gradient(var(--highlight-col), var(--highlight-col)), var(--surface);
}
.day-cell.current-week.today-col {
  background: linear-gradient(var(--highlight-col), var(--highlight-col)), var(--highlight-row);
}
.day-cell.today-cell {
  box-shadow: inset 0 0 22px rgba(0, 255, 0, 0.16);
  animation: today-glow 2.6s ease-in-out infinite;
}
@keyframes today-glow {
  0%, 100% { box-shadow: inset 0 0 14px rgba(0, 255, 0, 0.10); }
  50% { box-shadow: inset 0 0 30px rgba(0, 255, 0, 0.32); }
}
/* Today's open buttons: lifted, high-contrast, big numbers — the obvious thing to tap. */
.day-cell.today-cell .set-box:not(.completed) {
  background: var(--today-box-bg);
  border-color: var(--today-box-border);
  color: var(--today-box-text);
  font-size: max(8px, calc(var(--box, 54px) * 0.4));
  font-weight: 800;
  box-shadow: 0 3px 0 var(--today-box-edge), 0 0 10px rgba(255, 255, 255, 0.08);
}
.day-cell.today-cell .set-box:not(.completed):active {
  box-shadow: 0 0 0 var(--today-box-edge);
  transform: translateY(2px) scale(0.96);
}
/* Gentle pulse on the numbers of today's unchecked sets (the number is the ::after). */
.day-cell.today-cell .set-box:not(.completed):not(.rest)::after {
  animation: set-pulse 1.8s ease-in-out infinite;
}
@keyframes set-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  .day-cell.today-cell { animation: none; }
  .day-cell.today-cell .set-box::after { animation: none; }
  .jump-btn svg { animation: none; }
}
.day-cell.day-complete .exercise-row {
  display: none;
}
.day-cell.day-complete {
  cursor: pointer;
}
.day-complete-check,
.day-skipped-mark {
  font-family: var(--font-sym);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 0 auto;   /* at least square (aspect-ratio), and grows to fill the cell's height; the explicit width keeps it from growing sideways */
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 8px;
  color: #fff;
  font-size: calc(var(--box, 54px) * 2);
  font-weight: 700;
  line-height: 1;
}
.day-complete-check {
  font-family: var(--font-sym);
  background: var(--complete-bg);
  color: var(--complete-text);
  position: relative;
}
.day-skipped-mark {
  background: var(--miss-bg);
}
/* A small camera in the top-right corner of a green X: add a picture to that finished day. Quiet until you look for it. */
.day-cam {
  position: absolute;
  top: 3px;
  right: 3px;
  width: clamp(16px, calc(var(--box, 54px) * 0.42), 26px);
  height: clamp(16px, calc(var(--box, 54px) * 0.42), 26px);
  padding: 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--complete-text);
  opacity: 0.4;
  cursor: pointer;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
}
.day-cam:hover, .day-cam:focus-visible { opacity: 0.9; }
.day-cam:active { opacity: 1; background: rgba(0, 0, 0, 0.12); }
.day-skipped-mark::after {
  content: '';
  width: 54%;
  height: auto;
  aspect-ratio: 1;   /* stays a true circle when the box grows taller than it is wide */
  flex: 0 0 auto;
  border: calc(var(--box, 54px) * 0.18) solid #fff;
  border-radius: 50%;
  box-sizing: border-box;
}
.day-cell.day-skipped .exercise-row {
  display: none;
}

.exercise-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  flex: none;
}

.week-totals {
  background: var(--surface);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: center;
  min-width: 0;
}
.week-totals.current-week {
  background: var(--highlight-row);
}
.total-box {
  aspect-ratio: 1;
  background: var(--total-bg);
  border: 2px solid var(--total-border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--total-text);
  font-variant-numeric: tabular-nums;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.total-box.counting {
  transform: scale(1.12);
  border-color: var(--accent);
}
.total-box.all-done {
  background: var(--complete-bg);
  border-color: var(--complete-bg);
  color: var(--complete-text);
}

.sets-group {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.set-box {
  flex: 1 1 0;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.set-box.editable {
  touch-action: none;
}
.set-box:active {
  transform: scale(0.9);
}

.set-box.completed {
  background: var(--complete-bg);
  border-color: var(--complete-bg);
  color: var(--complete-text);
}

.set-box.completed::after {
  font-family: var(--font-sym);
  content: '\2717';
  font-size: min(40px, calc(var(--box, 54px) * 0.75));
  font-weight: 700;
}

.set-box:not(.completed)::after {
  content: attr(data-reps);
}

.set-box.rest {
  opacity: 0.35;
  border-style: dashed;
  cursor: default;
}
.set-box.rest::after {
  font-family: var(--font-sym);
  content: '–';
}

.set-box.missed:not(.completed) {
  background: var(--miss-bg);
  border-color: var(--miss-bg);
  color: #fff;
}
.set-box.missed:not(.completed)::after {
  content: '';
  width: 49.5%;
  height: 49.5%;
  border: max(2.25px, calc(var(--box, 54px) * 0.0846)) solid #fff;
  border-radius: 50%;
  box-sizing: border-box;
}

/* Settings Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 16px;
  overflow: hidden;
  touch-action: pan-y;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 620px;            /* wide enough that Settings needs much less scrolling */
  max-height: 94vh;
  overflow-x: hidden;          /* the modal only ever scrolls up and down, never sideways */
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.modal h2 {
  font-size: 22px;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}

.exercise-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exercise-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.exercise-input-row input { font-size: 14px; padding-left: 4px; padding-right: 4px; }
.exercise-input-row .ex-name { padding-left: 10px; padding-right: 6px; }
.exercise-input-row input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.exercise-input-row input[type=number]::-webkit-inner-spin-button, .exercise-input-row input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.exercise-input-row .ex-name { flex: 1; min-width: 0; }
.exercise-input-row .ex-short { width: 64px; text-align: center; text-transform: uppercase; }
.exercise-input-row .ex-reps { width: 54px; text-align: center; }
.exercise-input-row .ex-inc { width: 46px; text-align: center; }
.exercise-input-row .ex-wt { width: 64px; text-align: center; }
.exercise-input-row .ex-remove { flex-shrink: 0; width: 28px; height: 28px; padding: 0; border: 1px solid var(--border, #444); border-radius: 6px; background: transparent; color: var(--text-secondary); font-size: 18px; line-height: 1; cursor: pointer; }
.exercise-input-row .ex-remove[hidden] { display: none; }
.ex-add { margin-top: 8px; width: 100%; padding: 8px; border: 1px dashed var(--border, #444); border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.ex-add[hidden] { display: none; }
.exercise-input-row .ex-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  width: 20px;
  flex-shrink: 0;
}
.ex-header {
  display: flex;
  gap: 6px;
  padding-bottom: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ex-header span:first-child { width: 20px; flex-shrink: 0; }
.ex-header .eh-name { flex: 1; }
.ex-header .eh-short { width: 64px; text-align: center; }
.ex-header .eh-reps { width: 54px; text-align: center; }
.ex-header .eh-inc { width: 46px; text-align: center; }
.ex-header .eh-wt { width: 64px; text-align: center; }
.ex-header::after { content: ''; width: 28px; flex-shrink: 0; }

.number-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn:active { opacity: 0.7; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
}

.btn-danger {
  background: #ff3b30;
  color: #fff;
  margin-top: 12px;
  font-size: 14px;
  padding: 10px;
}

.app-header > .progress-fill {
  position: absolute;
  bottom: -1px;  /* covers the header's 1px bottom border */
  left: 0;
  width: 0;
  height: 10px;
  background: var(--complete-bg);
  transition: width 0.5s ease;
  pointer-events: none;
}
.app-header > :not(.progress-fill) {
  position: relative;
}
.app-version {
  /* The version is a real button (outside the title, so tapping it never reloads the page) that opens the change log. */
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  padding: 6px 10px;
  border: 2px solid var(--total-border);
  border-radius: 8px;
  background: var(--total-bg);
  color: var(--total-text);
  cursor: pointer;
  position: relative;
  z-index: 3;
  flex: none;
}
.app-version:active { opacity: 0.6; }
/* The live sync dot (js/live.js liveDot()): green = connected to WSS, amber = connecting or waiting to retry; hidden when live sync is off or signed out */
.live-dot { position: absolute; top: 7px; right: 7px; z-index: 2; pointer-events: none; width: 9px; height: 9px; border-radius: 50%; background: #ffb300; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45); transition: background 0.3s ease; }
.live-dot[hidden] { display: none; }
.live-dot.ok { background: #00e640; box-shadow: 0 0 6px 1px rgba(0, 230, 64, 0.55); }
.live-dot.ping { animation: live-dot-ping 0.7s ease-out; }
@keyframes live-dot-ping { 0% { transform: scale(1); } 35% { transform: scale(1.9); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .live-dot.ping { animation: none; } }
@media (max-width: 600px) { .live-dot { top: 5px; right: 5px; width: 8px; height: 8px; } }
.header-title {
  display: flex;
  align-items: flex-end;   /* the version button sits at the foot of the title, to its right */
  gap: 10px;
  min-width: 0;
}

/* Reps keypad */
.keypad-modal {
  max-width: 340px;
  padding: 20px;
}
.keypad-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}
.keypad-display {
  font-size: 56px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 2px;
  line-height: 1.1;
}
.keypad-display.fresh {
  color: var(--accent);
}
.keypad-default {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 16px;
}
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.keypad-grid button {
  height: 64px;
  border: none;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 26px;
  font-weight: 600;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.keypad-grid button:active {
  background: var(--accent);
  color: #fff;
}
.keypad-grid button.keypad-small {
  font-size: 15px;
}
.keypad-modal .btn-row {
  margin-top: 16px;
}
.btn:disabled {
  opacity: 0.4;
}

/* Settings: goal, lock, click sound */
.goal-row {
  display: flex;
  gap: 6px;
}
.goal-row select {
  flex: 1;
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}
.form-group input[type="date"] {
  /* iPhone Safari gives date fields their own intrinsic width and pushes them past the modal's edge; this pins it. */
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  min-height: 46px;
  text-align: left;
}
.form-group input[type="date"]::-webkit-date-and-time-value { text-align: left; min-width: 0; margin: 0; }
.form-group .goal-row input {
  width: 90px;
  flex: none;
  text-align: center;
}
.form-group .lock-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}
.form-group .lock-toggle input {
  width: 26px;
  height: 26px;
  padding: 0;
  flex: none;
  accent-color: var(--accent);
}
.sound-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
@media (min-width: 560px) {
  .sound-options { grid-template-columns: repeat(4, 1fr); }
}
.sound-option {
  padding: 12px 6px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.sound-option.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* Locked-edit feedback */
.locked-shake {
  animation: locked-shake 0.3s ease;
}
@keyframes locked-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.lock-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--footer-h) + env(safe-area-inset-bottom) + 12px);
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(30, 30, 30, 0.95);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
}
.lock-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 820px) {
  .set-box { font-size: 10px; border-width: 1.5px; }
  .app-header h1 { font-size: 19px; }
  .day-cell { padding: 3px; gap: 2px; }
  .exercise-row { gap: 2px; }
  .sets-group { gap: 2px; }
  .grid-wrapper { padding: 4px 4px calc(var(--footer-h) + env(safe-area-inset-bottom) + 10px); }   /* keep room for the footer */
  .grid { row-gap: 3px; }
  .reps-label { font-size: 8px; }
  .week-label, .week-totals { padding-top: 3px; padding-bottom: 3px; }
  .week-reps-col, .week-totals { gap: 2px; }
}

@media (max-width: 600px) {
  .app-header h1 { font-size: clamp(12px, 4vw, 16px); }
  .set-box { font-size: 8px; border-width: 1px; border-radius: 4px; }
  .total-box { font-size: 8px; border-width: 1px; border-radius: 4px; }
  .week-label { padding: 2px 2px 2px 3px; gap: 2px; }
  .reps-box.overridden::after { width: 4px; height: 4px; top: 1px; right: 1px; }
  .reps-label { display: none; }
  .total-box.grand-total-box { width: 38px; height: 46px; padding: 0 1px; font-size: 13px; border-radius: 6px; }
  .stats-frac { font-size: 10px; }
  .grand-total-box[data-digits="5"] { font-size: 11px; }
  .grand-total-box[data-digits="6"] { font-size: 9px; }
  .weight-btn { font-size: 14px; }
  .weight-btn[data-digits="5"] { font-size: 11px; }
  .weight-btn[data-digits="6"] { font-size: 9px; }
  .settings-btn { width: 38px; height: 46px; border-width: 1px; border-radius: 6px; font-size: 34px; }
  .app-header { --hdr-gap: 3px; }
  .header-title { flex: none; }
  .app-version { font-size: 11px; padding: 4px 7px; border-width: 1px; }
  .week-totals { padding: 2px; }
  .week-reps-col, .week-totals { gap: 2px; }
  .day-cell { padding: 2px; gap: 2px; }
  .grid-header { font-size: 11px; padding: 8px 2px; letter-spacing: 0; }
  .corner-header { min-width: 30px; }
}

@media (min-width: 1100px) {
  .set-box { font-size: 16px; }
}

/* Sign-in gate: covers everything until Google sign-in succeeds. */
.login {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;   /* anchored near the top, so opening "What is this?" doesn't move the sign-in controls */
  overflow-y: auto;
  padding-top: max(20px, 6vh) !important;
  gap: 12px;
  padding: 24px;
  text-align: center;
}
.login[hidden] { display: none; }
.login { overflow-x: hidden; touch-action: pan-y; }
.login-logo { width: 72px; height: 72px; border-radius: 22%; }
.login h1 { font-size: 22px; margin: 0; width: fit-content; text-align: left; }   /* same stacked MWT title as the header, bigger */
.login-error { color: #ff3b30; font-size: 14px; min-height: 1.2em; }
.login-request { flex: none; padding: 10px 24px; }
.login-request[hidden] { display: none; }
.login-note { max-width: 320px; font-size: 14px; line-height: 1.4; color: var(--text-secondary); }
/* "What is this?": a quiet link under the sign-in controls that opens a short explanation in place. */
.login-about { max-width: 520px; width: 100%; font-size: 13px; line-height: 1.5; }
.login-about .brand { text-transform: uppercase; color: var(--text); }
.login-about .brand b { background: var(--complete-bg); color: var(--complete-text); border-radius: 2px; padding: 0 0.1em; font-weight: 400; }
.login-about summary {
  list-style: none;
  cursor: pointer;
  text-align: center;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.login-about summary::-webkit-details-marker { display: none; }
.login-about-body {
  margin-top: 12px;
  padding: 14px 18px 4px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.login-about-body h2 { font-size: 15px; margin: 0 0 8px; }
.login-about-body p { margin: 0 0 10px; color: var(--text-secondary); }

/* Clock screen (screensaver): black, seven-segment time, this week's totals. Sizes use vw/vh/vmin so it
   fills an iPad in either orientation. */
.saver {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #000;
  color: #00ff00;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  --sg: 4.5vh;
  gap: var(--sg);
  padding: 6vh 8vw;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.saver[hidden] { display: none; }
/* On an iPad home-screen app the fixed clock screen can start a little below the very top, letting the page show through the status bar strip: a shadow the same width paints black above it */
.saver { box-shadow: 0 -160px 0 0 #000; }
/* Matrix rain (js/rain.js): behind everything on the clock screen, dim, never catching a tap */
.saver-rain { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; opacity: 0.55; }
.saver-rain[hidden] { display: none; }
/* Who just did sets: small cards at the top right of the clock screen that fade away on their own (js/team.js, teamSaverNotice) */
.family-help { font-size: 13px; color: var(--text-secondary); margin: 2px 0 8px; line-height: 1.4; }
.family-row { margin-bottom: 6px; }
.family-row .avatar { flex: none; }
.family-note { min-height: 18px; margin-top: 4px; font-size: 13px; color: var(--complete-bg); }
/* The family page of the clock screen: slides in over the clock when you swipe sideways. */
.saver-family { position: absolute; inset: 0; z-index: 2; background: #000; padding: 4vh 4vw 11vh; overflow-y: auto; transform: translateX(100%); visibility: hidden; transition: transform 0.35s ease, visibility 0s linear 0.35s; cursor: default; }
.saver-family.show { transform: none; visibility: visible; transition: transform 0.35s ease, visibility 0s; }
.fam-title { text-align: center; margin-bottom: 2.5vh; }
.fam-grid { display: flex; flex-direction: column; gap: 1.6vh; width: min(100%, 640px); margin: 0 auto; }   /* one card per line, stacked */
.fam-card { border: 1px solid #0a3d14; border-radius: 14px; padding: 1.6vh 1.6vw; background: #030a05; display: flex; flex-direction: column; gap: 0.9vh; }
.fam-card.done { border-color: #00ff00; }
.fam-head { display: flex; align-items: center; gap: 1.2vh; }
.fam-name { color: #fff; font-weight: 700; font-size: clamp(15px, 3vmin, 28px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.fam-check { flex: none; width: 1.6em; height: 1.6em; border-radius: 6px; background: #00ff00; color: #000; font-family: var(--font-sym, inherit); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.fam-bigs { display: flex; gap: 1.4vw; margin-bottom: 1.4vh; }   /* the two big numbers, each in its own box, with room below before the other stats */
.fam-big { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.8vh; padding: 1.2vh 1vh; border: 1px solid #0a3d14; border-radius: 12px; text-align: center; }
.fam-big .saver-lbl { text-align: center; }
.fam-line { display: flex; justify-content: space-between; gap: 1vh; }
.saver-dots { position: absolute; bottom: 0.9vh; left: 50%; transform: translateX(-50%); display: flex; gap: 1.4vh; z-index: 4; pointer-events: none; }
.saver-dots i { width: 1.2vh; height: 1.2vh; min-width: 8px; min-height: 8px; border-radius: 50%; background: #1b3a21; }
.saver-dots i.on { background: #00ff00; }
.saver-notices { z-index: 5; position: absolute; top: 1.5vh; right: 1.5vw; display: flex; flex-direction: column; align-items: flex-end; gap: 0.8vh; max-width: 36vw; pointer-events: none; }
.saver-notice { display: flex; align-items: center; gap: 1vh; padding: 0.7vh 1.2vh; border: 1px solid #00ff00; border-radius: 12px; background: #04140a; color: #fff; font-size: clamp(12px, 2.1vh, 20px); line-height: 1.25; animation: saver-notice-in 0.5s ease-out; transition: opacity 3s ease-in; }
.saver-notice > .avatar, .saver-notice > :first-child { flex: none; }
.saver-notice .sn-msg { display: flex; flex-direction: column; min-width: 0; }
.saver-notice.fade { opacity: 0; }
.saver-notice .sn-time { color: #00ff00; font-size: 0.8em; white-space: nowrap; }
.saver-notice b { font-weight: 700; }
@keyframes saver-notice-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .saver-notice { animation: none; } }
.saver .lcd { display: block; }
.saver .lcd svg { display: block; width: 100%; height: auto; overflow: visible; }
.saver .lcd .on { fill: #00ff00; }
.saver .lcd .off { fill: rgba(0, 255, 0, 0.075); }
.saver .lcd .colon { animation: saver-blink 2s steps(1) infinite; }
@keyframes saver-blink { 50% { opacity: 0.15; } }
@media (prefers-reduced-motion: reduce) { .saver .lcd .colon { animation: none; } }
.saver .lcd.h { height: var(--lh); width: auto; }
.saver .lcd.h svg { height: 100%; width: auto; }
.saver-lbl {
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7f8a7f;
  font-size: clamp(11px, 2.6vmin, 26px);
  line-height: 1.2;
  white-space: nowrap;
}
.saver-lbl.lit { color: #00ff00; }
.saver-time-row { display: flex; align-items: flex-end; gap: 2vmin; }
.saver-time-wrap { position: relative; width: min(66vw, 120vh); }
.saver-time { width: 100%; }
.saver-side { display: flex; flex-direction: column; gap: 1.2vh; padding-bottom: 1.4vh; }
.saver-stats {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), 1fr);
  width: min(84vw, 150vh);
  margin-top: 2vh;
}
.saver-stat { display: flex; flex-direction: column; align-items: center; gap: 1.2vh; padding: 1vh 0.8vw; min-width: 0; }
.saver-stat + .saver-stat { border-left: 1px solid #1c231c; }
.saver-foot { display: flex; flex-direction: column; gap: 1.4vh; width: min(84vw, 150vh); }
.saver-meta { display: flex; justify-content: space-between; gap: 2vw; }
.saver-bar { height: max(4px, 0.8vh); background: #0f160f; border-radius: 99px; overflow: hidden; }
.saver-bar i { display: block; height: 100%; width: 0; background: #00ff00; transition: width 0.6s ease; }
.saver-chart[hidden] { display: none; }
.saver-chart { margin-top: 1vh; }
.saver-chart-title {
  font-family: var(--font-ui);
  display: flex;
  justify-content: space-between;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: clamp(8px, 1.5vmin, 14px);
  line-height: 1;
  color: #2f3b2f;
  margin-bottom: 0.5vh;
}
.saver-chart-title.rule { padding-bottom: 0.5vh; border-bottom: 1px dotted rgba(0, 255, 0, 0.3); }
.saver-bars { position: relative; display: flex; align-items: flex-end; gap: 1.2%; height: min(5.5vh, 9vw); }
.saver-goal { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed rgba(0, 255, 0, 0.3); pointer-events: none; }
.saver-bar-gap { flex: 1 1 0; min-width: 0; }
.saver-bar-col {
  flex: 1 1 0;
  min-width: 0;
  background: rgba(0, 255, 0, 0.13);
  border-radius: 3px 3px 0 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;   /* keep the label its own height so it can be measured */
  padding-top: 3px;
  font-family: var(--font-ui);
  font-size: clamp(9px, 1.7vmin, 17px);
  line-height: 1;
  color: rgba(157, 255, 157, 0.5);
  position: relative;
}
/* A bar too short to hold its number shows it just above the bar instead. */
.saver-bar-col.short > span { position: absolute; left: 0; right: 0; bottom: 100%; padding-bottom: 2px; text-align: center; }
.saver-bar-col.last { background: rgba(0, 255, 0, 0.32); color: rgba(220, 255, 220, 0.8); }
.saver-hint { color: #232a23; }
.saver-hint[hidden] { display: none; }
/* Wide screens (a wall-mounted iPad) are short, so tighten the spacing and key the clock's size to the
   height; otherwise the charts run off the bottom. Portrait and phones keep the roomier spacing. */
@media (orientation: landscape) {
  .saver { --sg: 2vh; padding: 2vh 8vw; }
  .saver-time-wrap { width: min(66vw, 76vh); }
  .saver-stats { margin-top: 0; }
  .saver-stat { padding-block: 0.4vh; }
  .saver-foot { gap: 1vh; }
  .saver-chart { margin-top: 0.6vh; }
}
.idle-row { display: flex; gap: 8px; align-items: center; }
.idle-row input { flex: 1; min-width: 0; }
.idle-row .btn { flex: 0 0 auto; padding-inline: 18px; }

@media (max-width: 380px) {
  .total-box.grand-total-box, .settings-btn { width: 34px; }
  .settings-btn.jump-btn { width: 30px; }
  .stats-frac { font-size: 9px; }
  .app-version { display: none; }
}

/* First-run setup wizard: full screen, one question at a time, big buttons, no keyboard. */
.wizard {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.wizard[hidden] { display: none; }
.wizard { overflow: hidden; touch-action: pan-y; }
.wz-top { width: 100%; max-width: 560px; display: flex; align-items: center; gap: 12px; padding: 14px 16px 6px; flex: none; }
.wz-back { background: none; border: 0; color: var(--accent); font-size: 17px; padding: 8px 4px; cursor: pointer; min-width: 64px; text-align: left; }
.wz-dots { flex: 1; display: flex; gap: 4px; }
.wz-dots i { flex: 1; height: 5px; border-radius: 3px; background: var(--border); }
.wz-dots i.on { background: var(--complete-bg); }
.wz-count { font-size: 12px; color: var(--text-secondary); min-width: 40px; text-align: right; }
.wz-main { width: 100%; max-width: 560px; flex: 1; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 8px 16px 16px; -webkit-overflow-scrolling: touch; }
.wz-title { font-size: 24px; margin: 14px 0 6px; line-height: 1.2; }
.wz-sub { color: var(--text-secondary); font-size: 14px; line-height: 1.5; margin: 0 0 18px; }
.wz-text { font-size: 16px; line-height: 1.55; margin: 0 0 14px; }
.wz-h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-secondary); margin: 18px 0 8px; font-weight: 400; }
.wz-note { font-size: 14px; color: var(--text-secondary); margin: 14px 0 0; line-height: 1.5; }
.wz-body { display: flex; flex-direction: column; gap: 10px; }
.wz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.wz-grid3 { grid-template-columns: repeat(3, 1fr); }
.wz-grid4 { grid-template-columns: repeat(4, 1fr); }
.wz-opt {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 12px;
  height: 72px;              /* every choice button is exactly this tall, however much its text wraps */
  padding: 6px 8px;
  font-size: 16px;
  line-height: 1.2;
  overflow: hidden;
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wz-opt.selected { background: var(--complete-bg); border-color: var(--complete-bg); color: var(--complete-text); }
.wz-opt:disabled { opacity: 0.45; cursor: default; }
.wz-opt.wz-add { border-style: dashed; }
.wz-opt.nudge { animation: wz-nudge 0.6s ease 2; }
@keyframes wz-nudge { 50% { transform: scale(1.06); box-shadow: 0 0 0 4px rgba(0, 255, 0, 0.35); } }
.wz-addrow { display: flex; gap: 10px; margin-top: 4px; }
.wz-addrow input { flex: 1; min-width: 0; font-size: 16px; padding: 12px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); color: var(--text); }
.wz-link { background: none; border: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; cursor: pointer; padding: 10px 0; text-align: left; }
.wz-summary { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 6px 16px; }
.wz-row { padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 15px; line-height: 1.4; }
.wz-row:last-child { border-bottom: 0; }
.wz-foot { width: 100%; max-width: 560px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px)); flex: none; display: flex; flex-direction: column; gap: 2px; }
.wz-out { align-self: center; text-align: center; }
.wz-padwrap { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 5; }
.wz-pad { width: min(100%, 360px); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; }
.wz-pad-title { font-size: 14px; color: var(--text-secondary); text-align: center; line-height: 1.4; }
.wz-pad-display { font-size: 48px; font-weight: 700; text-align: center; margin: 6px 0 2px; min-height: 56px; }
.wz-pad-range { font-size: 12px; color: var(--text-secondary); text-align: center; margin-bottom: 12px; }
.wz-pad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.wz-pad-grid .wz-opt { height: 54px; font-size: 20px; padding: 6px; }
.wz-btns { display: flex; gap: 10px; }
.wz-prev { flex: 0 0 30%; height: 56px; font-size: 18px; }
.wz-next { flex: 1; min-height: 56px; font-size: 18px; }
.wz-next:disabled { opacity: 0.35; }
.wz-addrow .wz-opt { height: auto; min-height: 52px; }

/* Name and avatar (Settings, setup wizard) */
.avatar { --av: 40px; display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--av); height: var(--av);
  border-radius: 50%; overflow: hidden; background: var(--surface); border: 1px solid var(--border); font-size: calc(var(--av) * 0.55); line-height: 1; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.av-initial { background: var(--accent); color: #fff; font-size: calc(var(--av) * 0.5); font-weight: 700; border-color: transparent; }
.profile-row { display: flex; gap: 12px; align-items: center; }
.profile-row input { flex: 1; min-width: 0; }
.name-hint { margin-top: 6px; font-size: 13px; color: var(--danger, #ff453a); }
.link-btn { background: none; border: 0; padding: 8px 0 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; cursor: pointer; }
.avatar-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.av-choice { display: flex; align-items: center; justify-content: center; padding: 6px; border: 2px solid var(--border); border-radius: 12px; background: var(--bg); cursor: pointer; }
.av-choice.selected { border-color: var(--accent); background: var(--accent); }
.av-choice.selected .avatar { border-color: #fff; }
.av-choice.av-camera { font-size: 22px; line-height: 1; border-style: dashed; }
.av-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.wz-addrow .wz-me { display: inline-flex; align-items: center; }

/* Team: header line, button, screen, clock-screen line, celebration */
.app-header > .team-fill { position: absolute; bottom: -1px; left: 0; width: 0; height: 4px; background: var(--accent); transition: width 0.5s ease; pointer-events: none; z-index: 1; }
.app-header > .team-fill[hidden] { display: none; }
.app-header > .team-fill.full { background: #ffd600; }
.team-btn[hidden] { display: none; }
.team-btn svg { width: 62%; height: 62%; fill: currentColor; }
.team-modal { max-width: 860px; }
.modal-head { position: sticky; top: -24px; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -24px -24px 12px; padding: 16px 16px 10px 24px; background: var(--surface); }
.modal-head h2 { margin: 0; }
/* The close button on the Team, Settings and Trophy chest windows: big and square, like the header buttons. */
.modal-x { flex: none; width: 56px; height: 56px; border-radius: 10px; border: 2px solid var(--total-border); background: var(--total-bg); color: var(--total-text); font-size: 38px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.modal-x-float { position: sticky; top: 0; float: right; z-index: 3; margin: -6px -6px 6px 10px; }
.settings-head { position: static; margin: 0 0 10px; padding: 0; flex: none; }
@media (max-width: 600px) { .modal-x { width: 46px; height: 46px; font-size: 32px; } }
.modal-x:active { opacity: 0.7; }
.team-rule { border: 0; border-top: 1px solid var(--border); margin: 18px 0 14px; }
.team-check { flex: none; width: 22px; height: 22px; border-radius: 6px; background: var(--complete-bg); color: #000; font-family: var(--font-sym, inherit); font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-left: 6px; }
.team-row.done-today { border-color: var(--complete-bg); }
.team-name-line { display: flex; align-items: center; min-width: 0; }
.team-name-line .team-name { flex: 0 1 auto; min-width: 0; }
.team-goal { margin-bottom: 18px; }
.team-goal-name { font-size: 13px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-secondary); }
.team-count { margin: 6px 0 10px; }
.team-count-num { font-size: 40px; font-weight: 700; }
.team-count-of { font-size: 16px; color: var(--text-secondary); }
.team-bar { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--bg); border: 1px solid var(--border); }
.team-bar i { display: block; height: 100%; }
.team-pace { margin-top: 8px; font-size: 14px; color: var(--text-secondary); }
.team-pace.on, .team-pace.reached { color: var(--complete-bg); }
.team-pace.behind, .team-pace.missed { color: #4facfe; }   /* a friendly blue: never orange or red for a team that still has sets to go */
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.team-row.you { border-color: var(--accent); }
.team-rank { width: 18px; text-align: center; color: var(--text-secondary); font-size: 14px; }
.team-who { flex: 1; min-width: 0; }
.team-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-sub { font-size: 12px; color: var(--text-secondary); }
.team-reps { text-align: right; display: flex; flex-direction: column; }
.team-reps-num { font-weight: 700; }
.team-reps-lbl { font-size: 11px; color: var(--text-secondary); }
.team-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.team-section { margin: 18px 0 8px; font-size: 13px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-secondary); }
.team-trophies { display: flex; gap: 6px; }
.team-trophy { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); opacity: 0.6; }
.team-trophy.hit { opacity: 1; border-color: #ffd600; }
.team-trophy-icon { font-size: 22px; line-height: 1.2; }
.team-trophy-lbl { font-size: 10px; color: var(--text-secondary); }
.team-note { margin-top: 10px; font-size: 13px; color: var(--text-secondary); }
.saver-team { display: flex; flex-direction: column; gap: 0.6vh; }
.team-celebrate { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center; text-align: center;
  background: rgba(0, 0, 0, 0.92); color: #fff; cursor: pointer; padding: 24px; touch-action: pan-y; }
.team-celebrate[hidden] { display: none; }
.tc-body { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 640px; }
.tc-trophy { font-size: min(22vw, 26vh); line-height: 1; animation: tc-pop 0.7s ease both; }
.tc-title { font-size: 14px; letter-spacing: 1px; text-transform: uppercase; color: #aaa; }
.tc-big { font-size: min(9vw, 9vh); font-weight: 700; color: #ffd600; }
.tc-total { font-size: 18px; }
.tc-faces { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.tc-hint { margin-top: 16px; font-size: 13px; color: #888; }
@keyframes tc-pop { 0% { transform: scale(0.3); opacity: 0; } 70% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .tc-trophy { animation: none; } }

/* Phones: the Team button joins an already full header, so everything gets a little narrower and the version label steps aside. */
@media (max-width: 600px) {
  .total-box.grand-total-box, .settings-btn { width: 36px; }
  .settings-btn.team-btn { width: 28px; }
}
@media (max-width: 480px) {
  .app-version { display: none; }
}
@media (max-width: 380px) {
  .total-box.grand-total-box, .settings-btn { width: 33px; }
  .settings-btn.team-btn { width: 26px; }
  .settings-btn.jump-btn { width: 30px; }
}
@media (max-width: 480px) {
  .team-row { gap: 8px; padding: 8px; }
  .team-reps-lbl, .team-dot { display: none; }
  .team-count-num { font-size: 34px; }
}

/* Admin page */
.admin-page { overflow-y: auto; -webkit-user-select: text; user-select: text; }
.admin { max-width: 640px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); }
.admin-top { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.admin-top h1 { margin: 0; font-size: 28px; }
.admin-back { color: var(--accent); font-size: 15px; text-decoration: none; }
.admin-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.admin-card h2 { margin: 0 0 6px; font-size: 18px; }
.admin-help { margin: 0 0 12px; font-size: 13px; color: var(--text-secondary); }
.admin-status { min-height: 20px; margin-bottom: 8px; font-size: 14px; }
.admin-status.good { color: var(--complete-bg); }
.admin-status.bad { color: #ff9f0a; }
.admin-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.admin-row { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.admin-who { flex: 1; min-width: 0; }
.admin-name { font-weight: 700; overflow-wrap: anywhere; }
.admin-sub { font-size: 12px; color: var(--text-secondary); overflow-wrap: anywhere; }
.admin-badge { flex: none; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--accent); color: #fff; }
.btn.admin-small { flex: none; width: auto; padding: 8px 14px; font-size: 14px; }
.admin-add, .admin-goal { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-add input, .admin-goal input { flex: 1 1 160px; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; background: var(--bg); color: var(--text); }
.admin-goal input[type="number"] { flex: 0 1 140px; }
.admin-add .btn, .admin-goal .btn { flex: none; width: auto; padding-inline: 22px; }

/* Walk-through tour: a dimmed spotlight over the real screen plus a card. The full-screen layer swallows taps. */
.tour { position: fixed; inset: 0; z-index: 380; touch-action: none; }
.tour[hidden] { display: none; }
.tour-spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.75), 0 0 0 3px var(--accent); transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease; pointer-events: none; }
.tour-card { position: fixed; width: min(340px, calc(100vw - 24px)); box-sizing: border-box; background: var(--surface); color: var(--text); border: 2px solid var(--accent); border-radius: 14px; padding: 16px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); }
.tour-card h3 { margin: 0 0 6px; font-size: 18px; }
.tour-card p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; color: var(--text-secondary); }
.tour-dots { display: flex; gap: 5px; margin-bottom: 12px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.tour-dots i.on { background: var(--accent); }
.tour-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.tour-skip { margin-right: auto; background: none; border: 0; color: var(--text-secondary); font: inherit; font-size: 14px; padding: 10px 4px; cursor: pointer; }
.tour-btn { padding: 10px 16px; min-width: 0; }

/* Settings tabs: a fixed-height modal with the tab bar on top and Save/Cancel pinned underneath, so each group fits
   on one screen. Only the pane scrolls (vertically), and only if a small phone can't fit it. */
.modal.settings-modal { display: flex; flex-direction: column; height: min(720px, 96vh); max-height: 96vh; overflow: hidden; padding: 18px 24px; }
.settings-modal h2 { margin-bottom: 12px; flex: none; }
.settings-tabs { display: flex; gap: 4px; flex: none; border-bottom: 2px solid var(--border); margin-bottom: 14px; }
.settings-tab { flex: 1; background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: 10px 4px; color: var(--text-secondary); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.settings-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.settings-body { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.settings-pane[hidden] { display: none; }
.settings-pane[data-pane="account"] { display: flex; flex-direction: column; gap: 12px; }
.settings-pane[data-pane="account"][hidden] { display: none; }
.settings-pane[data-pane="account"] #resetBtn { margin-top: 12px; }
.settings-modal > .btn-row { flex: none; margin-top: 12px; }
.settings-modal .tab-arrow { flex: 0 0 48px; padding: 0; display: flex; align-items: center; justify-content: center; }
.settings-modal .tab-arrow svg { width: 22px; height: 22px; }
.settings-modal .tab-arrow:disabled { opacity: 0.3; cursor: default; }
.settings-modal .form-group { margin-bottom: 12px; }
.settings-modal .sound-options { grid-template-columns: repeat(5, 1fr); gap: 6px; }
.settings-modal .sound-option { padding: 9px 4px; font-size: 14px; }
@media (max-width: 480px) {
  .modal.settings-modal { padding: 16px; }
  .settings-modal .sound-options { grid-template-columns: repeat(3, 1fr); }
  .settings-tab { font-size: 13px; padding: 10px 2px; }
}
.settings-modal .number-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.settings-modal .number-row .form-group { min-width: 0; }

/* Phones: Settings fills the whole screen and scrolls as one page (tabs stay at the top, Save and Cancel stay at the
   bottom), so it's easy to use with a thumb. Bigger screens keep the centred window. The landscape rule
   catches a phone turned sideways, which is wider than 600px but very short. */
@media (max-width: 600px), (max-height: 500px) {
  #modalOverlay { padding: 0; align-items: stretch; overflow: hidden; }
  .modal.settings-modal { max-width: none; width: 100%; height: 100%; max-height: none; border-radius: 0;
    overflow-x: hidden; overflow-y: auto; display: flex; flex-direction: column; padding: 16px 16px 0; -webkit-overflow-scrolling: touch; }
  .settings-modal .settings-tabs { position: sticky; top: -16px; z-index: 3; background: var(--surface); margin: 0 -16px 14px; padding: 8px 16px 0; }
  .settings-modal .settings-body { overflow: visible; flex: none; }
  /* Save and Cancel sit at the bottom of the screen: pushed down when the tab is short, and stuck there (still in
     the scroll) while a long tab scrolls under them. */
  .settings-modal > .btn-row { position: sticky; bottom: 0; z-index: 3; margin: auto -16px 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border); }
}

/* Big check-off window (js/daypad.js). It reuses .set-box, so the boxes look like the grid's, only bigger. On a
   phone it fills the screen; elsewhere it's a centred window with boxes about an inch across (--pb, set by the JS). */
.daypad-overlay { position: fixed; inset: 0; z-index: 330; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(0, 0, 0, 0.6); overflow: hidden; touch-action: pan-y; }
.daypad-overlay[hidden] { display: none; }
.daypad { --dg: 6px; background: var(--surface); color: var(--text); width: min(100%, max(320px, calc((var(--sets) + 1) * var(--pb) + var(--sets) * var(--dg) + 34px))); max-height: 90vh; max-height: 90dvh; border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); animation: dp-in 0.18s ease; }
@keyframes dp-in { from { transform: scale(0.92); opacity: 0; } }
.daypad-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 6px; flex: none; }
.daypad-title { font-size: 22px; }
.daypad-sub { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.daypad-close { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--border); background: var(--bg); color: var(--text); font-size: 20px; cursor: pointer; }
.daypad-bar { flex: none; height: 5px; margin: 0 16px; border-radius: 3px; background: var(--border); overflow: hidden; }
.daypad-bar i { display: block; height: 100%; width: 0; background: var(--complete-bg); transition: width 0.25s ease; }
.daypad-body { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 6px 16px 16px; display: flex; flex-direction: column; gap: var(--dg); -webkit-overflow-scrolling: touch; }
.dp-row { display: grid; grid-template-columns: repeat(calc(var(--sets) + 1), var(--pb)); gap: var(--dg); justify-content: center; }
.set-box.pad-box { width: var(--pb); height: var(--pb); flex: none; border-width: 3px; border-radius: 14px; touch-action: manipulation;
  font-size: calc(var(--pb) * 0.4); font-weight: 800; background: var(--today-box-bg); border-color: var(--today-box-border); color: var(--today-box-text);
  box-shadow: 0 4px 0 var(--today-box-edge), 0 0 10px rgba(255, 255, 255, 0.08); }
.set-box.pad-box:active { box-shadow: 0 0 0 var(--today-box-edge); transform: translateY(3px) scale(0.96); }
.set-box.pad-box.completed { background: var(--complete-bg); border-color: var(--complete-bg); color: var(--complete-text); box-shadow: none; }
.set-box.pad-box.completed::after { font-size: calc(var(--pb) * 0.7); }
.set-box.pad-box.missed:not(.completed) { background: var(--miss-bg); border-color: var(--miss-bg); color: #fff; box-shadow: none; }
.set-box.pad-box.rest { box-shadow: none; background: transparent; }
.daypad.exploding { animation: dp-out 0.42s ease-in forwards; pointer-events: none; }
@keyframes dp-out { 0% { transform: scale(1); opacity: 1; filter: none; } 35% { transform: scale(1.08); filter: brightness(2.2); }
  100% { transform: scale(1.5); opacity: 0; filter: brightness(3) blur(6px); } }

/* The cheer: dark backdrop, the pixel burst on a canvas, and a random message from json/celebration-messages.json. */
.day-cheer { position: fixed; inset: 0; z-index: 335; display: flex; align-items: center; justify-content: center; text-align: center;
  background: rgba(0, 0, 0, 0); color: #fff; cursor: pointer; padding: 24px; touch-action: pan-y; transition: background 0.4s ease; }
.day-cheer[hidden] { display: none; }
.day-cheer.show { background: rgba(0, 0, 0, 0.88); }
.day-cheer canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cheer-body { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 640px; opacity: 0; transform: scale(0.6); }
.day-cheer.show .cheer-body { animation: cheer-pop 0.6s 0.25s cubic-bezier(0.2, 1.4, 0.4, 1) forwards; }
.cheer-msg { font-size: min(9vw, 8vh, 56px); line-height: 1.15; font-weight: 700; color: var(--complete-bg); text-shadow: 0 0 24px rgba(0, 255, 0, 0.55); }
.cheer-stat { font-size: 18px; color: #fff; }
.cheer-hint { margin-top: 10px; font-size: 13px; color: #888; }
@keyframes cheer-pop { to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .daypad, .daypad.exploding { animation: none; } .daypad.exploding { opacity: 0; } .day-cheer.show .cheer-body { animation: none; opacity: 1; transform: none; } }

@media (max-width: 600px), (max-height: 500px) {
  .daypad-overlay { padding: 0; align-items: stretch; }
  .daypad { width: 100%; max-height: none; height: 100%; border-radius: 0; }
  .daypad-body { justify-content: flex-end; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }   /* keys at the bottom, within thumb reach */
}

/* Milestone takeover (js/milestone.js): gold, bigger and longer than the day cheer. */
.milestone { position: fixed; inset: 0; z-index: 345; display: flex; align-items: center; justify-content: center; text-align: center;
  background: rgba(0, 0, 0, 0); color: #fff; cursor: pointer; padding: 24px; touch-action: pan-y; transition: background 0.5s ease; }
.milestone[hidden] { display: none; }
.milestone.show { background: rgba(0, 0, 0, 0.9); }
.milestone canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ms-body { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 680px; opacity: 0; transform: scale(0.5); }
.milestone.show .ms-body { animation: ms-pop 0.7s 0.2s cubic-bezier(0.2, 1.5, 0.4, 1) forwards; }
.ms-icon { font-size: min(24vw, 22vh); line-height: 1; filter: drop-shadow(0 0 24px rgba(255, 214, 0, 0.7)); }
.milestone.show .ms-icon { animation: ms-spin 1.1s 0.3s ease-out both; }
.ms-kicker { font-size: 14px; letter-spacing: 0.35em; text-transform: uppercase; color: #ffd600; }
.ms-num { font-size: min(26vw, 24vh); line-height: 1; font-weight: 700; color: #ffd600; text-shadow: 0 0 30px rgba(255, 214, 0, 0.6), 0 0 70px rgba(255, 145, 0, 0.45); font-variant-numeric: tabular-nums; }
.ms-num.long { font-size: min(19vw, 22vh); }
.ms-ex { font-size: min(7vw, 6vh, 34px); letter-spacing: 0.12em; text-transform: uppercase; }
.ms-msg { margin-top: 8px; font-size: min(5.2vw, 4.5vh, 24px); line-height: 1.3; color: #d8ffd8; max-width: 560px; }
.ms-hint { margin-top: 14px; font-size: 13px; color: #888; }
@keyframes ms-pop { to { opacity: 1; transform: scale(1); } }
@keyframes ms-spin { from { transform: scale(0.2) rotate(-200deg); opacity: 0; } 70% { transform: scale(1.15) rotate(8deg); opacity: 1; } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .milestone.show .ms-body, .milestone.show .ms-icon { animation: none; } .milestone.show .ms-body { opacity: 1; transform: none; } }

/* Miles tracker (js/miles.js): a header button beside the weight button, and a log pad. */
.miles-btn[hidden] { display: none; }
.miles-modal { max-width: 420px; max-height: 94vh; max-height: 94dvh; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.miles-stats { display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); gap: 6px; margin: 10px 0 12px; }
.miles-stat { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 2px; text-align: center; min-width: 0; }
.miles-stat b { display: block; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.miles-stat span { display: block; font-size: 10px; color: var(--text-secondary); letter-spacing: 0.3px; text-transform: uppercase; margin-top: 2px; }
.miles-kind { display: flex; gap: 8px; margin-bottom: 4px; }
.miles-kind .sound-option { flex: 1; }
.miles-kind .sound-option.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.miles-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 4px 0 12px; }
.miles-chip { padding: 8px 12px; border: 2px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.miles-chip:active { background: var(--accent); border-color: var(--accent); color: #fff; }
.miles-modal .keypad-grid button { height: 54px; }
.miles-modal .keypad-display { font-size: 44px; margin: 4px 0 8px; }
.miles-date { margin: 14px 0 0; }
.miles-modal .btn-row { margin-top: 14px; }
.miles-history { margin-top: 16px; font-size: 14px; font-variant-numeric: tabular-nums; }
.miles-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px; border-top: 1px solid var(--border); }
.miles-when { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.miles-what { color: var(--text-secondary); width: 3.2em; }
.miles-mi { width: 5.5em; text-align: right; }
.miles-sub { text-align: center; font-size: 14px; color: var(--text-secondary); margin: 4px 0 2px; }
.miles-sub[hidden], .miles-pace[hidden], .miles-stats[hidden], .miles-kind[hidden], .miles-chips[hidden], .miles-history[hidden], .miles-date[hidden], .miles-modal .btn[hidden] { display: none; }   /* these have their own display, which would beat [hidden] */
.miles-pace { text-align: center; font-size: 15px; font-weight: 600; min-height: 22px; margin: -2px 0 10px; color: var(--accent); font-variant-numeric: tabular-nums; }
.miles-pace.bad { color: #ff6b6b; font-weight: 400; }
.miles-timebtn { flex: none; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 12px; padding: 5px 8px; cursor: pointer; font-variant-numeric: tabular-nums; white-space: nowrap; }
.miles-timebtn.empty { color: var(--text-secondary); border-style: dashed; }
.miles-modal .btn-row { flex-wrap: wrap; }
.miles-del { flex: none; width: 34px; height: 34px; border: 0; border-radius: 8px; background: var(--bg); color: var(--text-secondary); font-size: 14px; cursor: pointer; }
.miles-empty { color: var(--text-secondary); text-align: center; padding: 8px 0; border-top: 1px solid var(--border); }
@media (max-width: 600px), (max-height: 500px) {
  #milesOverlay { padding: 0; align-items: stretch; }
  .miles-modal { max-width: none; width: 100%; height: 100%; max-height: none; border-radius: 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
  .miles-modal .keypad-grid button { height: 60px; }
}

/* The stats (each exercise's lifetime total and the progress box) live in a footer that stays put while you scroll;
   the buttons (arrow, team, miles, weight, settings) stay in the header. */
.app-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; background: var(--surface); border-top: 1px solid var(--border);
  height: calc(var(--footer-h) + env(safe-area-inset-bottom)); padding: 0 12px env(safe-area-inset-bottom); box-sizing: border-box; display: flex; align-items: center; }
.footer-inner { width: 100%; max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 8px; }
.app-footer .grand-totals { flex: 1 1 auto; min-width: 0; gap: 8px; }
.app-footer .total-box.grand-total-box { width: auto; height: 62px; aspect-ratio: auto; min-width: 0; font-size: 26px; padding: 0 4px; border-radius: 10px; }
.app-footer .grand-total-box[data-digits="5"] { font-size: 21px; }
.app-footer .grand-total-box[data-digits="6"] { font-size: 17px; }
.app-footer .grand-total-box[data-digits="7"] { font-size: 14px; }
.app-footer .grand-total-box .reps-label { display: block; font-size: 11px; }
.app-footer .stats-box { flex: 0 0 auto; width: 92px; }
.app-footer .stats-frac { font-size: 16px; }
.app-footer .stats-box { gap: 1px; }
@media (max-width: 600px) {
  .app-footer { padding-left: 8px; padding-right: 8px; }
  .app-footer .total-box.grand-total-box { height: 58px; font-size: 22px; }
  .app-footer .grand-total-box[data-digits="5"] { font-size: 18px; }
  .app-footer .grand-total-box[data-digits="6"] { font-size: 14px; }
  .app-footer .stats-box { width: 72px; }
  .app-footer .stats-frac { font-size: 13px; }
  .app-footer .grand-total-box .reps-label { font-size: 10px; }
}

/* Totals inside the big check-off window: today's reps and lifetime reps as tiles, plus each exercise's lifetime total. */
.daypad-stats { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 16px 8px; }
.dp-tile { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 5px 6px; display: flex; align-items: baseline; justify-content: center; gap: 8px; min-width: 0; transition: transform 0.2s ease, border-color 0.2s ease; }
.dp-tile b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.dp-tile span { display: block; font-size: 10px; color: var(--text-secondary); letter-spacing: 0.4px; text-transform: uppercase; }
.dp-tile.counting { transform: scale(1.06); border-color: var(--complete-bg); }
.dp-tile.counting b { color: var(--complete-bg); }

/* One size for every button: header buttons are all the same square (--hb). In the footer, boxes are the same square on an
   iPad or computer, and on a phone they split the footer's width evenly (--fcols is set by renderGrandTotals). */
.header-right .settings-btn, .header-right .total-box.grand-total-box { width: var(--hb); height: var(--hb); aspect-ratio: 1; }
.app-footer .footer-inner { justify-content: center; }
.app-footer .grand-totals { flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: var(--hb); gap: 8px; }
.app-footer .total-box.grand-total-box { width: var(--hb); height: var(--hb); aspect-ratio: 1; font-size: 21px; padding: 0 3px; }
.app-footer .grand-total-box[data-digits="5"] { font-size: 17px; }
.app-footer .grand-total-box[data-digits="6"] { font-size: 14px; }
.app-footer .grand-total-box[data-digits="7"] { font-size: 12px; }
.app-footer .stats-box { flex: none; width: var(--hb); }
@media (max-width: 600px) {
  :root { --hb: clamp(30px, calc((100vw - 160px) / 6), 42px); }   /* six header buttons can show at once (the arrow only sometimes) */
  .app-footer .footer-inner { display: grid; grid-template-columns: repeat(var(--fcols, 4), minmax(0, 1fr)); gap: 6px; max-width: none; }
  .app-footer .grand-totals { display: contents; }
  .app-footer .total-box.grand-total-box, .app-footer .stats-box { width: auto; height: 58px; aspect-ratio: auto; font-size: 22px; }
  .app-footer .grand-total-box[data-digits="5"] { font-size: 18px; }
  .app-footer .grand-total-box[data-digits="6"] { font-size: 14px; }
  .app-footer .grand-total-box[data-digits="7"] { font-size: 12px; }
}

/* Totals in the big check-off window: a total at the right end of each row, the sets' totals along the bottom, and the day's total in the corner. */
.dp-cell { width: var(--pb); height: var(--pb); box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: 14px; border: 3px solid var(--total-border); background: var(--total-bg); color: var(--total-text); min-width: 0;
  transition: transform 0.2s ease, border-color 0.2s ease; }
.dp-cell b { font-size: calc(var(--pb) * 0.32); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.dp-cell span { font-size: max(8px, calc(var(--pb) * 0.12)); letter-spacing: 0.4px; text-transform: uppercase; opacity: 0.75; }
.dp-cell.counting { transform: scale(1.08); border-color: var(--complete-bg); }
.dp-sumrow { margin-top: 2px; }
.dp-corner { background: var(--complete-bg); border-color: var(--complete-bg); color: var(--complete-text); }
.dp-corner span { opacity: 0.8; }

/* Calculator keypad: no titles between rows, the exercise's short name sits inside each square under the number, and
   the keys are packed close (--dg). */
.set-box.pad-box { flex-direction: column; gap: calc(var(--pb) * 0.04); border-radius: 12px; }
.set-box.pad-box::before { content: attr(data-name); order: 2; font-size: max(9px, calc(var(--pb) * 0.14)); font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; opacity: 0.7; line-height: 1; }
.set-box.pad-box.completed::before { content: none; }   /* a finished key is just the green box with its X */
.set-box.pad-box.completed::after { font-size: calc(var(--pb) * 0.7); line-height: 1; }
.set-box.pad-box::after { line-height: 1; }
.dp-cell { border-radius: 12px; }
.dp-sumrow { margin-top: 0; }

/* The row and set totals are solid black, so they read as readouts rather than buttons (the green Day key stays). */
.dp-cell:not(.dp-corner) { background: #000; border-color: #000; color: #fff; }

/* Share the app, at the bottom of the Team screen. */
.team-share { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.team-share .team-section { align-self: flex-start; }
.team-share-btn { width: 100%; flex: none; }
.team-qr { width: min(200px, 60%); background: #fff; border-radius: 12px; padding: 6px; line-height: 0; }
.team-qr svg { width: 100%; height: auto; display: block; }
.team-qr-cap { margin: 0; }
.team-link { display: flex; align-items: center; gap: 10px; max-width: 100%; }
.team-link-url { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-link-copy { flex: none; background: none; border: 2px solid var(--border); border-radius: 8px; color: var(--accent); font: inherit; font-size: 13px; padding: 4px 10px; cursor: pointer; }
.team-share-note { min-height: 1.3em; font-size: 13px; color: var(--complete-bg); }

/* Settings > Help: an FAQ of collapsible answers, with the install steps first. */
.faq-h { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); margin: 14px 0 8px; font-weight: 600; }
.faq-h:first-of-type { margin-top: 4px; }
.faq details { border: 1px solid var(--border); border-radius: 12px; background: var(--bg); margin-bottom: 8px; }
.faq summary { list-style: none; cursor: pointer; padding: 14px 40px 14px 14px; font-size: 15px; font-weight: 600; position: relative; min-height: 20px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 20px; color: var(--text-secondary); }
.faq details[open] summary::after { content: '\2212'; }
.faq details[open] summary { border-bottom: 1px solid var(--border); }
.faq details > ol, .faq details > ul { margin: 12px 14px 4px 34px; padding: 0; font-size: 14px; line-height: 1.5; }
.faq details li { margin-bottom: 6px; }
.faq details p { margin: 10px 14px 14px; font-size: 14px; line-height: 1.5; color: var(--text-secondary); }
.faq details > ol + p, .faq details > ul + p { margin-top: 8px; }
.faq b { color: var(--text); font-weight: 600; }
.changelog-modal { max-width: 640px; }
.changelog { font-size: 14px; line-height: 1.5; }
.cl-entry { padding: 10px 0; border-bottom: 1px solid var(--border); }
.cl-entry:last-child { border-bottom: 0; }
.cl-head { display: flex; align-items: baseline; gap: 10px; }
.cl-v { font-weight: 700; color: var(--complete-bg); }
.cl-date { font-size: 12px; color: var(--text-secondary); }
.cl-now { font-size: 11px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--complete-bg); color: var(--complete-bg); }
.cl-text { margin-top: 2px; color: var(--text-secondary); }
.whatsnew details { margin-bottom: 8px; }
.wn-v { display: inline-block; min-width: 44px; margin-right: 6px; font-size: 12px; color: var(--complete-bg); }
.wn-more { width: 100%; margin: 2px 0 6px; }
.faq .whatsnew + .faq-h { margin-top: 20px; }
.faq-installed { display: none; padding: 10px 12px; margin-bottom: 8px; border-radius: 10px; background: var(--progress-bg); font-size: 14px; }
@media (display-mode: standalone) { .faq-installed { display: block; } }

/* Admin: the reminder job's address. */
.admin-job { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin: 6px 0 10px; -webkit-user-select: text; user-select: text; }
.admin-btns { margin-bottom: 8px; }
.admin-help code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--bg); padding: 2px 5px; border-radius: 4px; word-break: break-all; }

/* Workout reminders: the Remind tab, the banner that drops in on an open screen, and the notifications block. */
.remind-extra { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.remind-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border: 2px solid var(--border); border-radius: 999px; background: var(--bg); font-size: 14px; }
.remind-chip button { border: 0; background: none; color: var(--text-secondary); font-size: 13px; padding: 2px 6px; cursor: pointer; }
.remind-push { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.remind-push-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.remind-push-text { margin: 8px 0 10px; font-size: 14px; line-height: 1.5; }
.remind-push-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.remind-push-btns .btn { flex: 1 1 140px; padding: 10px 12px; font-size: 15px; }
.remind-push-msg { margin-top: 8px; font-size: 13px; color: var(--text-secondary); min-height: 1.2em; }
.wz-push { margin-top: 6px; }
.remind-banner { position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 50%; transform: translate(-50%, -140%); z-index: 340; width: min(560px, calc(100vw - 24px)); box-sizing: border-box;
  background: var(--surface); color: var(--text); border: 3px solid var(--complete-bg); border-radius: 16px; padding: 16px 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55), 0 0 30px rgba(0, 255, 0, 0.25); transition: transform 0.35s cubic-bezier(0.2, 1.2, 0.4, 1); }
.remind-banner[hidden] { display: none; }
.remind-banner.show { transform: translate(-50%, 0); animation: remind-pulse 1.6s ease-in-out 3; }
.remind-title { font-size: 13px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--complete-bg); margin-bottom: 4px; }
.remind-text { font-size: 20px; line-height: 1.3; margin-bottom: 12px; }
.remind-btns { display: flex; gap: 10px; }
.remind-btns .btn { padding: 12px; }
@keyframes remind-pulse { 50% { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55), 0 0 44px rgba(0, 255, 0, 0.6); } }
@media (prefers-reduced-motion: reduce) { .remind-banner, .remind-banner.show { transition: none; animation: none; } }
@media (max-width: 480px) { .settings-tab { font-size: 12px; } }

/* Admin alert: a header button with the number of people waiting to be let in (admins only, only while there are some). */
.admin-alert-btn[hidden] { display: none; }
.admin-alert-btn { position: relative; border-color: #ff9100; }
/* The header clock button is a normal header button (same font and size as MILES and LBS LOST) showing the time; its colon blinks. */
.saver-btn { flex-direction: column; gap: 5px; font: inherit; font-size: 19px; font-weight: 700; padding: 0 3px; }
.saver-btn .grand-num { line-height: 1; white-space: nowrap; }
.saver-btn[data-wide="1"] { font-size: 16px; }   /* 10:00 to 12:59 has four digits, so the type steps down a little to keep it from feeling crowded */
/* On a phone the button is too small for the time: just the blinking colon is left (the aria-label still has the time). */
@media (max-width: 600px) { .saver-btn .hdr-digits { display: none; } .saver-btn .hdr-colon { font-size: 30px; } }
.saver-btn .hdr-colon { animation: hdr-colon-blink 1s steps(1) infinite; }
@keyframes hdr-colon-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .saver-btn .hdr-colon { animation: none; } }
.admin-alert-btn svg { width: 58%; height: 58%; fill: currentColor; }
.admin-alert-count { position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; box-sizing: border-box; padding: 0 5px; border-radius: 10px; background: #ff3b30; color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; font-family: var(--font-ui); }
.admin-alert-btn { animation: admin-alert-pulse 2.4s ease-in-out infinite; }
@keyframes admin-alert-pulse { 50% { box-shadow: 0 0 0 4px rgba(255, 145, 0, 0.35); } }
@media (prefers-reduced-motion: reduce) { .admin-alert-btn { animation: none; } }
@media (max-width: 600px) {
  .has-admin-alert { --hb: clamp(28px, calc((100vw - 150px) / 7), 42px); }
  .admin-alert-count { top: -6px; right: -6px; min-width: 17px; height: 17px; line-height: 17px; font-size: 11px; }
}

/* The Team button doubles as a gauge: the numbers under the people icon and a fill that rises with the team's progress. */
.team-btn { position: relative; flex-direction: column; gap: 1px; overflow: hidden; --tb-pct: 0%; --tb-color: transparent; }
.team-btn::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: var(--tb-pct); background: var(--tb-color); opacity: 0.55; transition: height 0.5s ease; pointer-events: none; }
.team-btn > * { position: relative; }
.team-btn svg { width: 46%; height: 46%; }
.team-btn.team-on { --tb-color: #00c853; border-color: #00c853; }
.team-btn.team-behind { --tb-color: #4facfe; border-color: #4facfe; }
.team-btn.team-reached { --tb-color: #ffd600; border-color: #ffd600; }
.team-btn.team-missed { --tb-color: #4facfe; border-color: #4facfe; }
.team-btn-num { font-family: var(--font-ui); font-size: 11px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.team-btn-num .tb-short { display: none; }
@media (max-width: 600px) {
  .team-btn-num { font-size: 9px; }
  .team-btn-num .tb-full { display: none; }
  .team-btn-num .tb-short { display: inline; }
  .team-btn svg { width: 52%; height: 52%; }
}
@media (prefers-reduced-motion: reduce) { .team-btn::before { transition: none; } }

/* Live team feedback: the Team button rings and its numbers count up when a teammate does sets; their row on the Team screen flashes. */
.team-btn.counting { transform: scale(1.1); }
.team-btn { transition: transform 0.2s ease, border-color 0.3s ease; }
.team-btn.team-ping { animation: team-ping 1.2s ease-out 2; }
@keyframes team-ping { 0% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.85); } 100% { box-shadow: 0 0 0 16px rgba(0, 230, 118, 0); } }
.team-row.bump { animation: team-bump 2.2s ease-out; }
.team-row.bump .team-reps-num { display: inline-block; animation: team-num-pop 0.8s ease-out 2; }
@keyframes team-bump { 0%, 30% { background: rgba(0, 230, 118, 0.3); border-color: #00e676; } 100% { background: var(--bg); } }
@keyframes team-num-pop { 40% { transform: scale(1.5); color: #00e676; } }
@media (prefers-reduced-motion: reduce) { .team-btn.team-ping, .team-row.bump, .team-row.bump .team-reps-num { animation: none; } .team-btn.counting { transform: none; } }

/* Daily team awards: the trophy shelf on the Team screen, and the winner's celebration. */
.award-shelf { margin-top: 4px; }
.award-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.award-card { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); min-width: 0; }
.award-card.you { border-color: var(--accent); }
.award-card.leading { border-style: dashed; opacity: 0.9; }
.award-emoji { font-size: 28px; line-height: 1; flex: none; }
.award-body { min-width: 0; }
.award-title { font-size: 14px; font-weight: 700; }
.award-tag { margin-left: 6px; font-size: 10px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: #ff9100; }
.award-who { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; min-width: 0; }
.award-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.award-detail { margin-top: 3px; font-size: 12px; color: var(--text-secondary); }
@media (max-width: 480px) { .award-grid { grid-template-columns: 1fr; } }
.award-cheer { position: fixed; inset: 0; z-index: 342; display: flex; align-items: center; justify-content: center; text-align: center; background: rgba(0, 0, 0, 0); color: #fff; cursor: pointer; padding: 24px; touch-action: pan-y; transition: background 0.4s ease; }
.award-cheer[hidden] { display: none; }
.award-cheer.show { background: rgba(8, 4, 24, 0.92); }
.award-cheer canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ac-body { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 620px; opacity: 0; transform: scale(0.6); }
.award-cheer.show .ac-body { animation: ac-pop 0.65s 0.15s cubic-bezier(0.2, 1.5, 0.4, 1) forwards; }
.ac-emoji { font-size: min(26vw, 22vh); line-height: 1; filter: drop-shadow(0 0 24px rgba(179, 136, 255, 0.8)); }
.award-cheer.show .ac-emoji { animation: ms-spin 1s 0.25s ease-out both; }
.ac-kicker { font-size: 13px; letter-spacing: 0.35em; text-transform: uppercase; color: #b388ff; }
.ac-title { font-size: min(11vw, 9vh, 56px); line-height: 1.1; font-weight: 700; color: #d1c4ff; text-shadow: 0 0 28px rgba(124, 77, 255, 0.7); }
.ac-detail { font-size: 18px; color: #fff; }
.ac-blurb { font-size: 15px; color: #b9b3d6; max-width: 480px; }
.ac-msg { margin-top: 6px; font-size: min(5vw, 4.2vh, 22px); line-height: 1.3; color: #e8f5e9; max-width: 520px; }
.ac-hint { margin-top: 12px; font-size: 13px; color: #888; }
@keyframes ac-pop { to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .award-cheer.show .ac-body, .award-cheer.show .ac-emoji { animation: none; } .award-cheer.show .ac-body { opacity: 1; transform: none; } }

/* Trophy chest: the footer box with your latest trophy, and the chest every player's awards live in. */
.trophy-box[hidden] { display: none; }
.trophy-box { cursor: pointer; font: inherit; }
.trophy-box:active { opacity: 0.6; }
.trophy-emoji { font-size: 30px; line-height: 1; }
.trophy-box.empty .trophy-emoji { filter: grayscale(1); opacity: 0.45; }
.trophy-box .reps-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.trophy-box.pop { animation: trophy-pop 1.6s ease-out; }
@keyframes trophy-pop { 0% { transform: scale(0.6); box-shadow: 0 0 0 0 rgba(255, 214, 0, 0.9); } 30% { transform: scale(1.2); } 100% { transform: none; box-shadow: 0 0 0 18px rgba(255, 214, 0, 0); } }
@media (max-width: 600px) { .app-footer .trophy-emoji { font-size: 26px; } .app-footer .trophy-box { font-size: 9px; } }
@media (prefers-reduced-motion: reduce) { .trophy-box.pop { animation: none; } }
.team-trophies-n { margin-left: 6px; font-size: 12px; color: #ffd600; font-weight: 600; }
.team-row.has-chest { cursor: pointer; }
.team-row.has-chest:active { opacity: 0.7; }
.chest-modal { max-width: 560px; border: 2px solid #b8860b; background: linear-gradient(180deg, rgba(184, 134, 11, 0.16), transparent 140px), var(--surface); }
.chest-head { display: flex; align-items: center; gap: 12px; }
.chest-name { font-size: 20px; font-weight: 700; }
.chest-total { font-size: 14px; color: #ffd600; margin-top: 2px; }
.chest-hint { min-height: 2.6em; margin: 12px 0 4px; padding: 8px 10px; border-radius: 10px; background: var(--bg); font-size: 13px; line-height: 1.4; color: var(--text-secondary); }
.chest-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.chest-slot { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 8px; border: 2px dashed var(--border); border-radius: 12px; background: var(--bg); color: var(--text); font: inherit; cursor: pointer; min-width: 0; }
.chest-slot .chest-emoji { font-size: 30px; line-height: 1; filter: grayscale(1); opacity: 0.3; }
.chest-slot .chest-title { font-size: 10px; line-height: 1.15; text-align: center; color: var(--text-secondary); }
.chest-slot.won { border: 2px solid #d4a017; background: linear-gradient(180deg, rgba(255, 214, 0, 0.16), var(--bg)); }
.chest-slot.won .chest-emoji { filter: none; opacity: 1; }
.chest-slot.won .chest-title { color: var(--text); font-weight: 600; }
.chest-count { position: absolute; top: -8px; right: -6px; min-width: 22px; height: 22px; box-sizing: border-box; padding: 0 5px; border-radius: 11px; background: #d4a017; color: #000; font-size: 12px; font-weight: 700; line-height: 22px; text-align: center; font-family: var(--font-ui); }
.chest-recent { display: flex; flex-direction: column; }
.chest-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-top: 1px solid var(--border); font-size: 14px; }
.chest-row-emoji { font-size: 20px; width: 26px; text-align: center; }
.chest-row-title { flex: 1; min-width: 0; }
.chest-row-date { color: var(--text-secondary); font-size: 12px; }
@media (max-width: 480px) { .chest-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px), (max-height: 500px) {
  #chestOverlay { padding: 0; align-items: stretch; }
  .chest-modal { max-width: none; width: 100%; height: 100%; max-height: none; border-radius: 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}
@media (max-width: 600px) { .app-footer .trophy-box .reps-label { font-size: 8px; letter-spacing: 0; } }

/* Exercise picker opened from the Plan tab's name fields (openExPicker() in app.js) */
#exPickOverlay { z-index: 110; }   /* above Settings */
.expick-modal { max-width: 560px; display: flex; flex-direction: column; gap: 14px; }
.expick-modal h2 { margin-bottom: 0; }
.expick-modal .wz-note { margin: 0; }
.exercise-input-row .ex-name { cursor: pointer; }
@media (max-width: 600px), (max-height: 500px) {
  #exPickOverlay { padding: 0; align-items: stretch; }
  .expick-modal { max-width: none; height: 100%; max-height: none; border-radius: 0; }
}

.saver-family { text-align: center; }
.saver-family .fam-grid { text-align: left; }
.fam-card.me { border-style: dashed; }

/* ---- Admin window: footer button, tabs, and the Activity feed (js/adminpanel.js) ---- */
/* Specific enough to beat the .total-box rules (which set position), so it really sits at the footer's right-hand end, vertically centred in the footer's content height. */
.app-footer .total-box.admin-foot-btn { position: absolute; right: max(12px, env(safe-area-inset-right)); top: calc((var(--footer-h) - var(--hb)) / 2); transform: none; cursor: pointer; }
.app-footer .total-box.admin-foot-btn[hidden] { display: none; }
.admin-foot-badge { position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 5px; box-sizing: border-box; border-radius: 10px; background: #ff3b30; color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.admin-foot-badge[hidden] { display: none; }
.admin-foot-icon { font-size: 26px; line-height: 1; }
@media (max-width: 600px) { .app-footer .total-box.admin-foot-btn { position: static; } }   /* the phone footer is an even grid, so the button is one of its cells */
.admin-modal { max-width: 860px; height: min(94vh, 920px); display: flex; flex-direction: column; overflow: hidden; padding-bottom: 14px; }
.admin-modal .modal-head { position: static; flex: none; }
.admin-modal .settings-tabs { flex: none; }
.admin-pane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.admin-pane[hidden] { display: none; }
#adminFrame { flex: 1; width: 100%; border: 0; border-radius: 12px; background: transparent; }
body.embedded .admin-top { display: none; }
@media (max-width: 600px), (max-height: 500px) {
  #adminOverlay { padding: 0; align-items: stretch; }
  .admin-modal { max-width: none; height: 100%; max-height: none; border-radius: 0; padding: 16px 14px calc(12px + env(safe-area-inset-bottom)); }
  .admin-modal .modal-head { margin: -16px -14px 8px; padding: 10px 10px 6px 14px; }
}

.act-bar { flex: none; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.act-bar select { font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); color: var(--text); max-width: 100%; }
.act-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.act-filter { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--border); background: none; color: var(--text-secondary); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.act-filter.on { border-color: var(--complete-bg); color: var(--text); background: rgba(0, 200, 80, 0.13); }
.act-meta { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 2px 14px; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
#actStatus { margin-right: auto; }
#actNote { color: var(--complete-bg); }
.act-link { background: none; border: 0; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; padding: 6px 0; }
.act-feed { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.act-day-head { position: sticky; top: 0; z-index: 2; background: var(--surface); padding: 10px 2px 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.act-daylist { display: flex; flex-direction: column; gap: 6px; padding: 8px 0 12px; }
.act-row { --act: var(--border); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-left: 4px solid var(--act); border-radius: 12px; background: rgba(127, 127, 127, 0.06); }
.act-set { --act: #2fbf5b; } .act-day { --act: #19a34a; } .act-plan { --act: #3b9cff; } .act-health { --act: #a66bff; }
.act-version { --act: #f0b429; background: rgba(240, 180, 41, 0.1); } .act-people { --act: #8a94a6; } .act-undo { --act: #8a94a6; opacity: 0.8; }
.act-lead { position: relative; flex: none; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; }
.act-lead .avatar { --av: 34px; }
.act-icon { position: absolute; right: -7px; bottom: -6px; width: 21px; height: 21px; font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); }
.act-icon.big { position: static; width: 38px; height: 38px; font-size: 22px; background: rgba(240, 180, 41, 0.16); border-color: transparent; }
.act-icon.solo { position: static; width: 26px; height: 26px; font-size: 15px; border-color: transparent; background: none; }
.act-line { font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.act-line b { font-weight: 700; }
.act-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.act-chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.act-chip.soft { color: var(--text-secondary); }
.act-when { font-size: 12px; color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.act-when.est { font-style: italic; opacity: 0.8; }
.act-changes { display: flex; flex-direction: column; gap: 3px; margin-top: 5px; }
.act-change { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 7px; font-size: 13px; }
.ac-label { color: var(--text-secondary); }
.ac-from { color: var(--text-secondary); text-decoration: line-through; text-decoration-thickness: 1px; }
.ac-arrow { color: var(--text-secondary); }
.ac-to { font-weight: 700; color: var(--complete-bg); }
.act-note { margin-top: 3px; font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.act-group { border-radius: 12px; }
.act-group > summary { cursor: pointer; list-style: none; grid-template-columns: auto minmax(0, 1fr) auto auto; }
.act-group > summary::-webkit-details-marker { display: none; }
.act-group > summary::after { content: '\203A'; font-size: 20px; line-height: 1; color: var(--text-secondary); transition: transform 0.15s ease; }
.act-group[open] > summary::after { transform: rotate(90deg); }
.act-group-rows { display: flex; flex-direction: column; gap: 4px; padding: 6px 0 2px 18px; }
.act-row.in-group { padding: 5px 8px; gap: 8px; border-left-width: 2px; background: none; }
.act-row.in-group .act-line { font-size: 14px; }
.act-empty { text-align: center; padding: 40px 16px; color: var(--text-secondary); }
.act-empty-icon { font-size: 44px; }
.act-empty-title { font-size: 18px; font-weight: 700; color: var(--text); margin: 8px 0 4px; }
.act-empty-text { font-size: 14px; line-height: 1.5; max-width: 380px; margin: 0 auto; }
.act-more { display: block; margin: 8px auto 16px; }
.act-end { text-align: center; font-size: 12px; color: var(--text-secondary); padding: 10px 0 18px; }
@media (max-width: 600px) {
  .act-row { grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; }
  .act-row .act-when { grid-column: 2; margin-top: -2px; }
  .act-group > summary { grid-template-columns: auto minmax(0, 1fr) auto; }
  .act-group > summary::after { grid-column: 3; grid-row: 1; }
  .act-line { font-size: 14px; }
  .act-filter { font-size: 12px; padding: 4px 10px; }
  .act-chip { font-size: 11px; }
  .act-lead { width: 34px; }
  .act-lead .avatar { --av: 30px; }
}

/* A box with its own number (held in the big check-off window; js/app.js markSetBox) gets a lime corner flag. On a finished (green) box the
   flag turns dark so it still shows. */
.set-box .set-flag { position: absolute; top: 0; right: 0; width: 36%; height: 36%; background: var(--complete-bg); clip-path: polygon(0 0, 100% 0, 100% 100%); pointer-events: none; }
.set-box.completed .set-flag { background: var(--complete-text); }
.set-box.pad-box { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }   /* holding a box must not select text or show the iOS callout */
#keypadOverlay { z-index: 340; }   /* above the big check-off window (330), which it opens from */

/* Extra sets in the big check-off window: a dashed column added with "+ Extra set". They never count against finishing the day. */
.set-box.pad-box.extra { border-style: dashed; }
.set-box.pad-box.extra:not(.completed) { background: transparent; box-shadow: none; }
.dp-cell.extra { border-style: dashed; }
.dp-ctl { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 2px; }
.dp-ctl-btn { background: none; border: 2px solid var(--border); color: var(--text-secondary); border-radius: 10px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.dp-ctl-btn:disabled { opacity: 0.4; cursor: default; }
.dp-ctl-btn:not(:disabled):active { opacity: 0.7; }
.dp-ctl-btn.armed { border-color: #ff453a; color: #ff453a; }

/* ---- Celebration pictures (js/photo.js) and the Day report ---- */
.photo-overlay { position: fixed; inset: 0; z-index: 360; background: rgba(0, 0, 0, 0.86); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: hidden; touch-action: pan-y; }
.photo-overlay[hidden] { display: none; }
.photo-card { width: min(100%, 480px); max-height: 100%; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; align-items: stretch; gap: 12px; text-align: center; }
.photo-emoji { font-size: 48px; line-height: 1; }
.photo-title { font-size: 20px; font-weight: 700; line-height: 1.25; }
.photo-text { font-size: 14px; color: var(--text-secondary); line-height: 1.45; }
.photo-error { font-size: 13px; color: #ff6b6b; }
.photo-frame { position: relative; width: min(100%, 62vh); aspect-ratio: 1; margin: 0 auto; overflow: hidden; border-radius: 14px; background: #000; border: 2px solid var(--border); }
.photo-frame video, .photo-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }   /* the frame is square, so what shows is exactly what is kept */
.photo-frame.mirror video { transform: scaleX(-1); }   /* the viewfinder is a mirror; the picture itself is not flipped */
.photo-count { position: absolute; z-index: 3; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 96px; font-weight: 800; color: #fff; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7); pointer-events: none; }
.photo-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.photo-row .btn { flex: 1 1 0; min-width: 0; }
.photo-shutter { flex: none; width: 72px; height: 72px; border-radius: 50%; border: 5px solid var(--text); background: var(--complete-bg); cursor: pointer; padding: 0; }
.photo-shutter:active { transform: scale(0.92); }
.photo-pick { display: block; cursor: pointer; }
.photo-link { background: none; border: 0; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; padding: 8px 0; }
.photo-link.danger { color: #ff6b6b; }
.photo-toast { position: fixed; left: 50%; bottom: calc(var(--footer-h) + env(safe-area-inset-bottom) + 24px); transform: translate(-50%, 10px); z-index: 400; background: var(--surface); color: var(--text); border: 2px solid var(--complete-bg); border-radius: 12px; padding: 10px 16px; font-size: 14px; max-width: 90vw; text-align: center; opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease; pointer-events: none; }
.photo-toast.show { opacity: 1; transform: translate(-50%, 0); }

.report-modal { max-width: 860px; }
.rep-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.rep-step { flex: none; width: 52px; height: 52px; border-radius: 10px; border: 2px solid var(--total-border); background: var(--total-bg); color: var(--total-text); font-size: 30px; line-height: 1; cursor: pointer; }
.rep-step:disabled { opacity: 0.3; cursor: default; }
.rep-when { flex: 1; text-align: center; }
#repDate { font-size: 20px; font-weight: 700; }
#repSummary { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.rep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.rep-tile { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 2px solid var(--border); border-radius: 14px; background: rgba(127, 127, 127, 0.06); min-width: 0; }
.rep-tile.complete { border-color: var(--complete-bg); }
.rep-tile.started { border-color: #ffd600; }
.rep-pic { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: #000; display: flex; align-items: center; justify-content: center; }
.rep-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.rep-pic.avatar-only { background: rgba(127, 127, 127, 0.14); }
.rep-pic .avatar { --av: 96px; }
.rep-check { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 8px; background: var(--complete-bg); color: var(--complete-text); display: flex; align-items: center; justify-content: center; font-family: var(--font-sym, inherit); font-weight: 700; }
.rep-name { font-weight: 700; font-size: 15px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-sets { font-size: 13px; color: var(--text-secondary); text-align: center; }
.rep-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.rep-actions .photo-link { font-size: 12px; padding: 2px 0; }
.rep-empty { grid-column: 1 / -1; text-align: center; color: var(--text-secondary); padding: 30px 10px; }
@media (max-width: 600px), (max-height: 500px) {
  #reportOverlay { padding: 0; align-items: stretch; }
  .report-modal { max-width: none; width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .rep-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.act-thumb { display: block; width: 64px; height: 64px; margin-top: 6px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: #000; }
.act-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* The clock screen's footer navigation: Family (flips to the family page and back), Day report, Trophy chest. It is pinned to the bottom of the
   screen above the family page, and while it shows the screen reserves room for it (and takes the same room back from the spacing and, in
   landscape, the clock) so nothing has to scroll. It replaces the "tap anywhere" hint. */
@media (orientation: landscape) {
}
#teamOverlay { z-index: 308; }   /* above the clock screen (300), which opens it */
#reportOverlay, #chestOverlay { z-index: 310; }   /* above the clock screen and the Team screen, which open them */

/* In profile-picture mode the square frame shows the circle the picture will appear in. */
.photo-frame.round::after { content: ''; position: absolute; inset: 6%; border: 3px dashed rgba(255, 255, 255, 0.85); border-radius: 50%; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35); pointer-events: none; }
.form-group select.team-scope { display: block; width: 100%; min-width: 0; padding: 10px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; background: var(--bg); color: var(--text); }

/* Settings > Plan > Workout days */
.day-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.day-chip { min-width: 48px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--text-secondary); font: inherit; cursor: pointer; }
.day-chip.on { background: var(--accent, #4caf50); border-color: var(--accent, #4caf50); color: #000; font-weight: bold; }
.field-note { margin: 6px 0 0; font-size: 13px; color: var(--text-secondary); }

/* a weigh-in just arrived from the scale */
#weightBtn.pop { animation: weigh-pop 1.6s ease-out; }
@keyframes weigh-pop { 0% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(79, 172, 254, 0.9); } 30% { transform: scale(1.12); } 100% { transform: none; box-shadow: 0 0 0 18px rgba(79, 172, 254, 0); } }
@media (prefers-reduced-motion: reduce) { #weightBtn.pop { animation: none; } }

/* The Body screen (admins, with the Withings scale) */
.body-modal { max-width: 860px; width: 100%; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.weight-body-btn { width: 100%; margin-top: 10px; }
.body-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 6px 0 14px; }
.body-tile { border: 2px solid var(--border); border-radius: 12px; padding: 8px 10px; background: rgba(127, 127, 127, 0.06); min-width: 0; }
.body-tile-title { font-size: 12px; color: var(--text-secondary); letter-spacing: 0.04em; text-transform: uppercase; }
.body-tile-val { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.body-tile-delta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.body-tile-delta.good { color: #37d67a; }
.body-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 12px; margin-bottom: 8px; }
.body-chart { border: 2px solid var(--border); border-radius: 12px; padding: 8px 10px 4px; background: rgba(127, 127, 127, 0.06); min-width: 0; }
.body-chart-head { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; }
.body-chart-range { font-weight: 400; font-size: 12px; color: var(--text-secondary); }
.body-svg { width: 100%; height: auto; display: block; }
.body-empty { padding: 24px 0; text-align: center; color: var(--text-secondary); font-size: 13px; }
@media (max-width: 600px), (max-height: 500px) {
  #bodyOverlay { padding: 0; align-items: stretch; }
  .body-modal { max-width: none; height: 100%; border-radius: 0; }
  .body-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===== Navigation redesign (v1.142): the header holds only the title and Settings. The footer has two rows: a flat, read-only stats
   strip (no borders, nothing to tap) above a row of labelled navigation buttons (every boxed thing you can tap lives in the nav). ===== */
:root { --footer-h: 136px; }
.app-header .header-right .settings-btn { width: 56px; height: 56px; }
.app-footer { flex-direction: column; justify-content: center; gap: 8px; padding-top: 6px; }
.app-footer .footer-inner { gap: 4px 14px; justify-content: center; flex: none; }
.app-footer .grand-totals { gap: 14px; grid-auto-columns: auto; }
.app-footer .total-box.grand-total-box, .app-footer .stats-box {
  width: auto; min-width: 54px; height: auto; aspect-ratio: auto; background: none; border: 0; border-radius: 0; padding: 0 2px; gap: 3px;
  flex-direction: column; font-size: 24px; color: var(--text);
}
.app-footer .total-box.counting { transform: scale(1.1); color: var(--complete-bg); }
.app-footer .grand-total-box .reps-label, .stat-label { display: block; font-size: 10px; letter-spacing: 0.6px; color: var(--text-secondary); font-weight: 600; }
.app-footer .stats-frac { font-size: 18px; }
.stat-strip-extra { display: flex; align-items: center; gap: 14px; }
.stat-flat { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 54px; font-variant-numeric: tabular-nums; }
.stat-flat[hidden] { display: none; }
.stat-num { font-family: var(--font-ui); font-size: 24px; font-weight: 700; line-height: 1; color: var(--text); }
.stat-num .tb-goal { font-size: 14px; opacity: 0.7; }
.stat-bar { display: block; width: 100%; height: 3px; border-radius: 2px; background: var(--border); overflow: hidden; }
.stat-bar::after { content: ''; display: block; height: 100%; width: var(--tb-pct, 0%); background: var(--tb-color, var(--accent)); transition: width 0.5s ease; }
.stat-flat.team-on { --tb-color: #00c853; }
.stat-flat.team-behind, .stat-flat.team-missed { --tb-color: #4facfe; }
.stat-flat.team-reached { --tb-color: #ffd600; }
.stat-flat:not(#teamStat) .stat-bar { display: none; }
#teamStat .stat-bar { display: block; }
.stat-flat.counting .stat-num { color: var(--complete-bg); }
.app-nav { display: flex; justify-content: center; gap: 8px; width: 100%; max-width: 720px; margin: 0 auto; }
.nav-btn {
  position: relative; flex: 1 1 0; min-width: 0; max-width: 112px; height: 50px; box-sizing: border-box; padding: 0 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: inherit; color: var(--total-text); background: var(--total-bg); border: 2px solid var(--total-border); border-radius: 12px; cursor: pointer;
}
.nav-btn[hidden] { display: none; }
.nav-btn:active { opacity: 0.6; }
.nav-ico { font-size: 20px; line-height: 1; }
.nav-label { font-family: var(--font-ui); font-size: 10px; font-weight: 700; letter-spacing: 0.5px; line-height: 1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-btn.due { animation: weight-blink 1.2s ease-in-out infinite; }
.nav-btn.pop { animation: trophy-pop 1.6s ease-out; }
#teamBtn.team-ping { animation: team-ping 1.2s ease-out 2; }
.app-nav .trophy-box { font-size: inherit; }
.app-nav .trophy-emoji { font-size: 20px; }
.app-nav .trophy-box .nav-label { font-size: 9px; }
.app-nav .admin-foot-btn { position: relative; }
.app-nav .admin-foot-icon { font-size: 20px; }
.admin-alert-btn .nav-ico { filter: none; }
.corner-header { cursor: pointer; }
.tot-header { cursor: pointer; user-select: none; }
.tot-header .tot-arrow { display: none; width: 22px; height: 22px; }
.tot-header.away .tot-text { display: none; }
.tot-header.away .tot-arrow { display: block; animation: tot-blink 1s ease-in-out infinite; }
.tot-header.away.down .tot-arrow { transform: rotate(180deg); }
.tot-header.flip-on .tot-text { text-decoration: underline; text-underline-offset: 4px; }
@keyframes tot-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { .tot-header.away .tot-arrow { animation: none; } }
@media (max-width: 600px) {
  :root { --footer-h: 124px; }
  .app-header .header-right .settings-btn { width: 40px; height: 40px; }
  .app-footer { gap: 6px; }
  .app-footer .footer-inner { display: flex; flex-wrap: nowrap; gap: 6px; grid-template-columns: none; max-width: none; width: 100%; }
  .app-footer .grand-totals, .stat-strip-extra { display: flex; gap: 6px; min-width: 0; }
  .app-footer .total-box.grand-total-box, .app-footer .stats-box { width: auto; min-width: 0; height: auto; font-size: 15px; padding: 0; }
  .app-footer .grand-total-box[data-digits="5"] { font-size: 13px; }
  .app-footer .grand-total-box[data-digits="6"] { font-size: 11px; }
  .app-footer .grand-total-box[data-digits="7"] { font-size: 9px; }
  .app-footer .stats-frac { font-size: 12px; }
  .app-footer .grand-total-box .reps-label, .stat-label { font-size: 8px; letter-spacing: 0; white-space: nowrap; }
  .stat-flat { min-width: 0; }
  .stat-num { font-size: 15px; white-space: nowrap; }
  .stat-num .tb-goal { font-size: 10px; }
  .app-nav { gap: 5px; }
  .nav-btn { height: 46px; border-radius: 10px; max-width: none; }
  .nav-ico { font-size: 18px; }
  .nav-label { font-size: 9px; letter-spacing: 0.2px; }
}

/* Tighter header (v1.143): the title runs on one line and the bar is shorter. */
.app-header { padding: calc(16px + var(--header-pad-top)) 16px 26px; }   /* the 10px progress bar covers the bottom, so the title row sits centred in what shows */
.app-header h1 { flex-direction: row; align-items: center; gap: 0.5em; font-size: 22px; line-height: 1.1; white-space: nowrap; }
.app-header .header-title { align-items: center; }
.app-header .header-right .settings-btn { width: 46px; height: 46px; }
@media (max-width: 820px) { .app-header h1 { font-size: clamp(13px, 3.6vw, 20px); } }
@media (max-width: 600px) {
  .app-header { padding-left: 10px; padding-right: 10px; }
  .app-header h1 { font-size: clamp(11px, 4.3vw, 17px); gap: 0.4em; }
  .app-header .header-right .settings-btn { width: 36px; height: 36px; }
}

/* Me and Family screens (v1.145) */
#meOverlay { z-index: 310; }
#meOverlay .me-modal { }
.me-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.me-tile { flex: 1 1 90px; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.me-tile b { font-family: var(--font-ui); font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.me-tile span { font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-secondary); text-align: center; }
.me-actions { margin: 6px 0; justify-content: flex-start; }
.me-actions[hidden] { display: none; }
@media (max-width: 600px) { #meOverlay { padding: 0; align-items: stretch; } .me-modal { max-width: none; width: 100%; height: 100%; max-height: none; border-radius: 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); } }
.family-overlay { position: fixed; inset: 0; z-index: 310; background: #000; padding: 4vh 4vw 6vh; overflow-y: auto; display: none; text-align: center; box-sizing: border-box; }
.family-overlay.open { display: block; }
.family-overlay .fam-grid { text-align: left; }
.family-overlay .modal-x-float { position: sticky; top: 0; float: right; margin: 0 0 0 10px; }
.family-overlay .lcd { display: block; }
.family-overlay .lcd svg { display: block; width: 100%; height: auto; overflow: visible; }
.family-overlay .lcd .on { fill: #00ff00; }
.family-overlay .lcd .off { fill: rgba(0, 255, 0, 0.075); }
.family-overlay .lcd.h { height: var(--lh); width: auto; }
.family-overlay .lcd.h svg { height: 100%; width: auto; }

/* v1.148: no progress bar in the header (progress and team sets are in the stats strip). Equal room above and below the title row, the
   Settings button the same distance from the top, right and bottom edges, and a 5px lime line between the header and the grid. */
.app-header { padding: calc(14px + var(--header-pad-top)) 14px 14px; border-bottom: 5px solid var(--complete-bg); align-items: center; }
.app-header .header-right .settings-btn { width: 46px; height: 46px; }
@media (max-width: 600px) { .app-header { padding: calc(10px + var(--header-pad-top)) 10px 10px; } }

/* v1.149: the stats float over the grid in their own translucent boxes (outside the footer's bar), and the footer is just a row of
   square buttons. Progress and the team gauge no longer show here (their elements stay hidden so the code that updates them still works). */
:root { --footer-h: 92px; --float-h: 78px; }
#statsBox, #teamStat { display: none !important; }
.app-footer { height: calc(var(--footer-h) + env(safe-area-inset-bottom)); gap: 0; padding: 0 12px env(safe-area-inset-bottom); }
.grid-wrapper { padding-bottom: calc(var(--footer-h) + var(--float-h) + env(safe-area-inset-bottom) + 6px); }
.lock-toast { bottom: calc(var(--footer-h) + var(--float-h) + env(safe-area-inset-bottom) + 12px); }
.app-footer .footer-inner {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); width: auto; max-width: none; margin: 0;
  display: flex; justify-content: center; align-items: stretch; gap: 8px; padding: 0 12px; box-sizing: border-box; pointer-events: none; flex: none;
}
.app-footer .grand-totals, .stat-strip-extra { display: contents; }
.app-footer .total-box.grand-total-box, .app-footer .stat-flat {
  flex: 1 1 0; min-width: 0; max-width: 104px; width: auto; height: auto; aspect-ratio: auto; box-sizing: border-box; padding: 8px 4px 7px; gap: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(24, 24, 24, 0.74); border: 1px solid var(--border); border-radius: 12px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); color: var(--text);
}
.app-footer .stat-flat[hidden] { display: none; }
.app-footer .nav-btn { flex: 1 1 0; max-width: 74px; width: auto; height: auto; aspect-ratio: 1; min-height: 0; border-radius: 12px; }
.app-nav { gap: 8px; align-items: center; }
@media (max-width: 600px) {
  :root { --footer-h: 72px; --float-h: 66px; }
  .app-footer { padding: 0 8px env(safe-area-inset-bottom); }
  .app-footer .footer-inner { gap: 5px; padding: 0 8px; }
  .app-footer .total-box.grand-total-box, .app-footer .stat-flat { padding: 6px 2px 5px; border-radius: 10px; }
  .app-nav { gap: 5px; }
  .app-footer .nav-btn { height: auto; border-radius: 10px; }
}

/* v1.150: bigger emoji and more room between the emoji and the label on the footer buttons */
.nav-btn { gap: 7px; }
.nav-ico { font-size: 28px; }
.app-nav .admin-foot-icon { font-size: 28px; }
@media (max-width: 600px) { .app-footer .nav-btn { max-width: 58px; } .nav-btn { gap: 4px; } .nav-ico { font-size: 22px; } .app-nav .admin-foot-icon { font-size: 22px; } }

/* v1.150: a see-through dark band behind the floating stats, so the boxes stand out from the green grid behind them. Change the 0.5 to taste. */
:root { --float-h: 94px; }
.app-footer .footer-inner { bottom: 100%; padding: 8px 12px; background: rgba(0, 0, 0, 0.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@media (max-width: 600px) { :root { --float-h: 82px; } .app-footer .footer-inner { padding: 8px; } }

/* v1.151: the Team button opens the Day report (badges for the day's awards in each square), and the Share screen has its own button. */
.rep-badges { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; }
.rep-badge { font-size: 20px; line-height: 1; padding: 3px 5px; border-radius: 8px; border: 1px solid #b8860b; background: rgba(184, 134, 11, 0.18); cursor: pointer; }
.rep-tile.has-badge.you { box-shadow: 0 0 0 2px rgba(184, 134, 11, 0.55); }
#repTeam { font-size: 13px; color: var(--text); margin-top: 2px; }
#repTeam:empty { display: none; }
.rep-hint { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 14px; color: var(--text-secondary); min-height: 20px; }
.share-modal { max-width: 460px; }

/* v1.152: a tighter team report. Tiles are just the picture (name and sets on a gradient stripe at the top, awards under the avatar or along the
   bottom of a photo), and the header is one short row: title, back, date and summary, forward, close. */
.report-modal { padding-top: 10px; }
.rep-head { gap: 10px; margin-bottom: 8px; align-items: center; }
.rep-head h2 { font-size: 16px; margin: 0; }
.rep-head .rep-nav { flex: 1; margin: 0; gap: 8px; min-width: 0; }
.rep-head .rep-step { width: 40px; height: 40px; font-size: 24px; }
.rep-head .modal-x { width: 40px; height: 40px; font-size: 28px; }
.rep-head #repDate { font-size: 16px; line-height: 1.15; }
.rep-head #repSummary, .rep-head #repTeam { font-size: 11px; line-height: 1.25; margin: 0; }
.rep-grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; }
.rep-tile { padding: 3px; gap: 0; border-radius: 12px; }
.rep-pic { border-radius: 9px; flex-direction: column; gap: 6px; }
.rep-pic.avatar-only { padding-top: 30px; gap: 4px; justify-content: center; box-sizing: border-box; }
.rep-top { position: absolute; top: 0; left: 0; right: 0; padding: 6px 8px 14px; background: linear-gradient(to bottom, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0)); text-align: left; z-index: 1; pointer-events: none; }
.rep-tile.complete .rep-top { padding-right: 34px; }
.rep-top .rep-name { color: #fff; font-size: 12px; text-align: left; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); }
.rep-top .rep-sets { color: rgba(255, 255, 255, 0.85); font-size: 11px; text-align: left; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); }
.rep-pic .rep-badges { position: static; }
.rep-pic:not(.avatar-only) .rep-badges { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 4px 5px; background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0)); z-index: 1; }
.rep-pic .avatar { --av: 56px; }
.rep-check { top: 5px; right: 5px; width: 24px; height: 24px; z-index: 2; }
.rep-badge { font-size: 17px; padding: 2px 4px; }
@media (max-width: 600px), (max-height: 500px) { .rep-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* v1.153: the team report fills the whole screen (not a window), with roomier card-shaped tiles (about four across) and big, centred header buttons. */
#reportOverlay { padding: 0; align-items: stretch; justify-content: stretch; background: var(--surface); }
#reportOverlay .report-modal { max-width: none; width: 100%; height: 100%; max-height: none; margin: 0; border: 0; border-radius: 0; box-shadow: none; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.rep-head { flex: none; padding: calc(14px + env(safe-area-inset-top)) 14px 14px; margin: 0; gap: 12px; border-bottom: 5px solid var(--complete-bg); align-items: center; }
.rep-head h2 { font-size: 20px; }
.rep-head .rep-nav { gap: 12px; align-items: center; }
.rep-head .rep-step, .rep-head .rep-close { width: 56px; height: 56px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 10px; }
.rep-step svg, .rep-close svg { width: 46%; height: 46%; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.rep-head #repDate { font-size: 22px; }
.rep-head #repSummary, .rep-head #repTeam { font-size: 13px; }
#reportOverlay .rep-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; align-content: start; padding: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
#reportOverlay .rep-hint { flex: none; margin: 0; border-radius: 0; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.rep-tile { padding: 4px; }
.rep-pic { aspect-ratio: 3 / 4; }
.rep-pic.avatar-only { padding-top: 54px; }
.rep-pic .avatar { --av: 96px; }
.rep-top { padding: 8px 10px 22px; }
.rep-top .rep-name { font-size: 16px; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.15; }
.rep-top .rep-sets { font-size: 13px; }
.rep-tile.complete .rep-top { padding-right: 44px; }
.rep-check { width: 32px; height: 32px; top: 7px; right: 7px; font-size: 18px; }
.rep-badge { font-size: 22px; padding: 3px 6px; }
@media (max-width: 600px), (max-height: 500px) {
  .rep-head { gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 10px 10px; }
  .rep-head h2 { display: none; }
  .rep-head .rep-step, .rep-head .rep-close { width: 46px; height: 46px; }
  .rep-head #repDate { font-size: 17px; }
  .rep-head #repSummary, .rep-head #repTeam { font-size: 11px; }
  #reportOverlay .rep-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px; }
  .rep-pic.avatar-only { padding-top: 46px; }
  .rep-pic .avatar { --av: 72px; }
  .rep-top .rep-name { font-size: 14px; }
}

.rep-head #repDate { line-height: 1.25; margin-bottom: 2px; }

/* v1.154: awards always sit along the bottom of the card (so they line up across a row) and the avatar circle fills most of the card. */
.rep-pic { container-type: inline-size; }
.rep-pic.avatar-only { padding: 52px 0 46px; box-sizing: border-box; justify-content: center; }
.rep-pic .avatar { --av: 70cqw !important; }
.rep-pic .rep-badges, .rep-pic:not(.avatar-only) .rep-badges { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 4px 7px; z-index: 1; }
.rep-pic:not(.avatar-only) .rep-badges { background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0)); padding-top: 16px; }
@media (max-width: 600px), (max-height: 500px) { .rep-pic.avatar-only { padding: 46px 0 40px; } .rep-pic .avatar { --av: 72cqw !important; } }

/* v1.155: one size for every icon button (close, back, forward, the Settings gear), with the Lucide icon exactly centred. --ib is the size. */
:root { --ib: 52px; }
@media (max-width: 600px), (max-height: 500px) { :root { --ib: 44px; } }
.ico { display: block; width: 50%; height: 50%; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.modal-x, .rep-step, .rep-head .modal-x, .rep-head .rep-step, .rep-head .rep-close, .app-header .header-right .settings-btn {
  width: var(--ib) !important; height: var(--ib) !important; padding: 0 !important; display: flex !important; align-items: center; justify-content: center;
  line-height: 0; font-size: 0; border-radius: 10px; box-sizing: border-box;
}
#settingsBtn svg { width: 56%; height: 56%; }
.settings-modal .tab-arrow { flex: 0 0 var(--ib); height: var(--ib); }
.settings-modal .tab-arrow .ico { width: 50%; height: 50%; }
#repTitle { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-secondary); line-height: 1.2; }
.rep-head .rep-nav { align-items: center; }

/* v1.157: the footer buttons stay on top of the Team and Family reports so you can hop between them. */
body.report-open .app-footer { z-index: 320; }
body.report-open .app-footer .footer-inner { display: none; }
#reportOverlay .report-modal { padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom)); box-sizing: border-box; }
.nav-btn.active { border-color: var(--complete-bg); box-shadow: 0 0 0 2px var(--complete-bg) inset; }

/* v1.159: the Me screen: the same full-screen frame as the Team and Family reports, a row of day cards, and a dark clock-style stats board. */
#meOverlay { padding: 0; align-items: stretch; justify-content: stretch; background: var(--surface); z-index: 310; }
#meOverlay .report-modal { max-width: none; width: 100%; height: 100%; max-height: none; margin: 0; border: 0; border-radius: 0; box-shadow: none; padding: 0 0 calc(var(--footer-h) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; overflow: hidden; box-sizing: border-box; background: var(--surface); }
#meTitle { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-secondary); line-height: 1.2; }
#meDate { font-size: 22px; font-weight: 700; line-height: 1.25; margin-bottom: 2px; }
#meSummary { font-size: 13px; color: var(--text-secondary); line-height: 1.25; }
.me-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px; }
.me-days { display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); gap: 12px; }
.me-day.future { opacity: 0.5; }
.me-day.today { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25); }
.me-day .rep-pic { aspect-ratio: 3 / 4; }
.me-board { margin-top: 16px; background: #000; border: 1px solid #0a3d14; border-radius: 16px; padding: 16px; }
.me-stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.me-stat { border: 1px solid #0a3d14; border-radius: 12px; padding: 14px 14px 12px; background: #030a05; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.me-stat-lbl { font-family: var(--font-ui); text-transform: uppercase; letter-spacing: 0.14em; color: #7f8a7f; font-size: 12px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-stat-note { font-family: var(--font-ui); color: #00ff00; font-size: 13px; line-height: 1.25; }
.me-board .lcd { display: block; }
.me-board .lcd svg { display: block; width: 100%; height: auto; overflow: visible; }
.me-board .lcd .on { fill: #00ff00; }
.me-board .lcd .off { fill: rgba(0, 255, 0, 0.075); }
.me-board .lcd.h { height: var(--lh); width: auto; }
.me-board .lcd.h svg { height: 100%; width: auto; }
.me-links { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 14px; }
.me-link { background: none; border: 0; padding: 4px 0; font: inherit; font-size: 13px; color: #7f8a7f; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
@media (max-width: 600px), (max-height: 500px) {
  .me-scroll { padding: 10px; }
  .me-days { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: minmax(150px, 1fr); overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
  .me-days::-webkit-scrollbar { display: none; }
  .me-board { padding: 12px; }
  .me-stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  #meDate { font-size: 17px; }
  #meSummary { font-size: 11px; }
}

.nav-ico .ico { width: 1em; height: 1em; stroke-width: 2; }
@media (max-width: 420px) { .nav-label { font-size: 8px; letter-spacing: 0; } }

.me-day.today { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35); }

/* v1.162: the team report's cards can be square (the toggle in the report footer); tall stays the default */
#reportOverlay .rep-foot { flex: none; display: flex; align-items: center; border-top: 1px solid var(--border); }
#reportOverlay .rep-foot .rep-hint { flex: 1 1 auto; border-top: 0; min-width: 0; }
.rep-shape { flex: none; margin: 0 12px; }
#repGrid.square .rep-pic { aspect-ratio: 1; }
#repGrid.square .rep-pic.avatar-only { padding: 40px 0 34px; }
#repGrid.square .rep-pic .avatar { --av: 50cqw !important; }
/* gold, silver and bronze for the first three to finish: a medal on a thick red, white and blue ribbon across the bottom of the card (js/photo.js medalEl()); the tick stays */
.rep-medal { position: absolute; left: -2px; right: -2px; bottom: -2px; transform: translateY(28.9%); z-index: 4; pointer-events: none; line-height: 0; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.55)); }   /* the card's bottom edge is 39 of the artwork's 135 units above its foot, so the medal (more than half of it) hangs outside the frame */
.photo-frame .rep-medal.photo-medal-guide { opacity: 0.85; z-index: 2; }   /* the selfie guide: the medal as it will hang on the card (js/photo.js photoMedalGuide) */
.photo-medal-note { font-size: 13px; margin-top: 8px; }
.rep-medal svg { display: block; width: 100%; height: auto; overflow: visible; }
.rep-tile.has-medal { position: relative; }   /* the medal hangs below the frame and may overlap whatever is underneath */
@media (max-width: 600px) { .me-days { padding-bottom: 48px; margin-bottom: -40px; position: relative; z-index: 1; } }   /* this row scrolls sideways, which would clip a hanging medal; give it room without pushing the stats down */
.rep-pic.has-medal .rep-badges { position: absolute; top: 40px; right: 5px; left: auto; bottom: auto; flex-direction: column; align-items: flex-end; flex-wrap: nowrap; background: none; padding: 0; z-index: 3; }   /* the day's award badges stack down the right edge, clear of the face and the medal */
@media (min-width: 601px) { .rep-pic.has-medal .rep-badges { top: 46px; } }
.rep-sets .rep-mi { margin-left: 8px; white-space: nowrap; }

/* v1.164: Me's stat tiles are centred in their boxes */
.me-stat { align-items: center; text-align: center; }
.me-stat-lbl { max-width: 100%; }
.me-stat .lcd.h { max-width: 100%; }

/* v1.165: Me's trophy row and buttons */
.me-trophy-row { margin-top: 14px; display: flex; align-items: center; gap: 14px; border: 1px solid #0a3d14; border-radius: 12px; background: #030a05; padding: 10px 14px; }
.me-trophy-icons { display: flex; gap: 4px; font-size: 26px; line-height: 1; flex: none; }
.me-trophy-ico.dim { opacity: 0.35; }
.me-trophy-txt { flex: 1 1 auto; min-width: 0; font-family: var(--font-ui); }
.me-trophy-n { color: #00ff00; font-size: 14px; }
.me-trophy-last { color: #7f8a7f; font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-btn { flex: none; font-family: var(--font-ui); font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: #e8ece8; background: #1c1f1c; border: 2px solid #3a3d3a; border-radius: 10px; padding: 12px 16px; cursor: pointer; }
.me-btn:active { opacity: 0.7; }
@media (max-width: 600px) { .me-trophy-row { flex-wrap: wrap; } .me-trophy-txt { flex-basis: 40%; } .me-trophy-row .me-btn { width: 100%; } .me-trophy-icons { font-size: 22px; } }

/* v1.166: Settings > Account layout, the Withings window, the upload tile */
.acct-who { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; }
.acct-who-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acct-who-lbl { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-secondary); }
.acct-who-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-who-email { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-signout { flex: none; width: auto; padding-left: 18px; padding-right: 18px; }
.acct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.acct-grid .btn { width: 100%; margin: 0; }
.acct-danger { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; justify-content: flex-start; }
.acct-danger .btn { width: auto !important; flex: none !important; padding-left: 22px; padding-right: 22px; }
#withingsOverlay { z-index: 345; }
.wi-status { margin: 4px 0 14px; line-height: 1.4; }
.wi-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.wi-actions .btn { width: auto; flex: 1 1 140px; margin: 0; }
.wi-msg { min-height: 1.4em; margin: 12px 0 0; color: var(--text-secondary); font-size: 14px; }
.av-choice.av-camera .ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* v1.167: your picture in the Account tab's signed-in box */
.acct-avatar { flex: none; width: 56px; height: 56px; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; }
.acct-who { justify-content: flex-start; }
.acct-who-txt { flex: 1 1 auto; }
.acct-change { align-self: flex-start; margin-top: 4px; padding: 0; border: 0; background: none; font: inherit; font-size: 13px; color: var(--accent, #4aa3ff); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* v1.170: teammate cards on every screen (same cards as the clock screen's, floating above the footer) */
.live-notices { position: fixed; right: 12px; bottom: calc(var(--footer-h, 100px) + env(safe-area-inset-bottom, 0px) + 12px); z-index: 500; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: min(360px, 80vw); pointer-events: none; }
.live-notices .saver-notice { font-size: 15px; gap: 10px; padding: 8px 12px; }
.live-notices:empty { display: none; }

/* v1.171: Gains (body measurements) entry window */
#gainsOverlay { z-index: 345; }
#gainsChips2 { justify-content: center; margin-bottom: 8px; }
