/* ==========================================================================
   PROGRESS TAB — band system (css/progress.css)
   --------------------------------------------------------------------------
   Deliberately a separate sheet from analytics.css (2,122 lines, and the
   roadmap already flags its specificity as a risk). Every selector here is
   `pg-*`, so the new surface and the old hub can coexist while the redesign
   rolls out, and reverting a phase cannot collide with the legacy chrome.

   Rules:
   - tokens only (css/styles.css), no hard-coded colours except documented
     light-mode overrides
   - dark first; light overrides live together at the bottom
   - 44px minimum on anything tappable
   - no hover-only affordances
   ========================================================================== */

/* ---------------------------------------------------------------- 1. BAND */
.pg-band {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 14px 13px;
  margin-bottom: 12px;
}

.pg-band__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.pg-band__headline {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pg-band__eyebrow {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.pg-band__value {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.pg-band__unit {
  margin-left: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.pg-band__chip {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--overlay-md);
  color: var(--text-secondary);
  font-size: 0.56rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.pg-band__sub {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.pg-band__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pg-band__action {
  max-width: 100%;
  min-height: 44px;
  padding: 0 4px;
  white-space: normal;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--color-cyan);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}

.pg-band__action:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; border-radius: 8px; }

/* --------------------------------------------------------------- 2. STATES */
.pg-state {
  margin-top: 12px;
}

.pg-state--loading {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Reserved geometry: the skeleton must occupy the space its data will, or
     every visit jumps when the real chart lands. */
  min-height: var(--pg-state-h, 180px);
}

.pg-skeleton {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg,
    var(--overlay-sm),
    var(--overlay-md),
    var(--overlay-sm));
  background-size: 200% 100%;
  animation: pg-sheen 1.4s ease-in-out infinite;
}

.pg-skeleton--title { width: 45%; height: 14px; }
.pg-skeleton--chart { width: 100%; height: calc(var(--pg-state-h, 180px) - 76px); }
.pg-skeleton--row { width: 70%; height: 12px; }

@keyframes pg-sheen {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.pg-state__message {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.pg-state--empty { padding: 10px 0 4px; }
.pg-state--empty .pg-band__action { padding: 0 12px; }

.pg-state--error {
  border: 1px solid var(--color-red);
  border-radius: 10px;
  padding: 12px;
  background: var(--red-alpha);
}

.pg-state--error .pg-state__message { color: var(--text-primary); }

.pg-state__detail {
  margin-top: 6px;
  font-size: 0.66rem;
  color: var(--text-secondary);
}

.pg-state--offline .pg-state__message,
.pg-state--stale { font-size: 0.62rem; color: var(--text-secondary); }

.pg-state--stale {
  margin: 6px 0 0;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .pg-skeleton { animation: none; }
}

/* ------------------------------------------------------------- 3. DATA TABLE */
.pg-data {
  margin-top: 10px;
  border-top: 1px solid var(--overlay-sm);
  padding-top: 8px;
}

.pg-data > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--text-secondary);
  cursor: pointer;
}

.pg-data__wrap { overflow-x: auto; max-width: 100%; }
/* Chromium still measures a closed <details>' wide table in scrollWidth at
   200% text, which made the page 6px wider than the viewport. Hide the content
   explicitly until the disclosure opens. */
.pg-data:not([open]) > .pg-data__wrap { display: none; }

.pg-data__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
}

.pg-data__table th,
.pg-data__table td {
  padding: 5px 6px;
  text-align: left;
  border-bottom: 1px solid var(--overlay-sm);
  white-space: nowrap;
}

.pg-data__table th { color: var(--text-secondary); font-weight: 800; }

/* ----------------------------------------------------------------- 4. LEGEND */
.pg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.pg-legend__item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pg-legend__item.is-muted .pg-legend__swatch { opacity: 0.4; }

.pg-legend__swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--overlay-xl);
  flex: 0 0 8px;
}

/* ------------------------------------------------------------------ 5. ROWS */
.pg-rows {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.pg-row { margin: 0; }

.pg-row__hit {
  display: grid;
  grid-template-columns: 78px 1fr 30px 54px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

button.pg-row__hit { cursor: pointer; min-height: 44px; }
button.pg-row__hit:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; border-radius: 8px; }

.pg-row__name {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pg-row__track {
  height: 7px;
  border-radius: 999px;
  background: var(--overlay-md);
  overflow: hidden;
}

.pg-row__bar {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--color-cyan);
}

.pg-row__value {
  font-size: 0.66rem;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pg-row__status {
  font-size: 0.55rem;
  font-weight: 700;
  text-align: right;
  color: var(--text-secondary);
}

/* ------------------------------------------------------- 6. PULSE SPECIFICS */
.pg-rail {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.pg-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.pg-day__mark {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--overlay-md);
  display: block;
}

.pg-day.is-trained .pg-day__mark { background: var(--color-cyan); }

.pg-day.is-today .pg-day__mark {
  box-shadow: inset 0 0 0 2px var(--color-cyan);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.pg-day.is-trained.is-today .pg-day__mark {
  background: var(--color-cyan);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

.pg-day.is-future .pg-day__mark { opacity: 0.45; }

.pg-day__label {
  font-size: 0.56rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.pg-pulse__summary {
  margin: 12px 0 0;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.pg-pulse__delta {
  margin: 6px 0 0;
  font-size: 0.68rem;
  font-weight: 700;
}

.pg-pulse__delta--up { color: var(--color-green); }
.pg-pulse__delta--down { color: var(--color-amber); }
.pg-pulse__delta--flat { color: var(--text-secondary); }

/* ------------------------------------------------------- READINESS BAND */
/* The band is TODAY-scoped, so it never borrows the hub's range label. */
.pg-readiness__status {
  margin: 8px 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}
/* A status hue is never the text colour on its own tint — use the warning-ink
   token so "Sleep is limiting" stays readable on the card. */
.pg-readiness__hint { color: var(--warning-text); }
.pg-readiness__signals {
  margin: 5px 0 0;
  font-size: 0.68rem;
  color: var(--text-secondary);
}
.pg-readiness__done {
  margin: 7px 0 0;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* --------------------------------------------------- 7. COLLAPSED BAND ROW */
.pg-band--collapsed { padding: 0; }

.pg-collapsed {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 0 13px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.pg-collapsed:focus-visible { outline: 2px solid var(--color-blue); outline-offset: -2px; border-radius: 14px; }

.pg-collapsed__value {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.pg-collapsed__delta {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--color-green);
}

.pg-collapsed__cue {
  margin-left: auto;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--color-cyan);
}

/* --------------------------------------------------------- 8. WIDE LAYOUT */
@media (min-width: 600px) {
  .pg-band { padding: 16px 16px 14px; }
  /* Two columns inside a band, never a wider chart. */
  .pg-band--wide .pg-band__body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
  }
}

/* ------------------------------------------------------- 9. LIGHT OVERRIDES */
html[data-theme="light"] .pg-band {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

html[data-theme="light"] .pg-band__eyebrow,
html[data-theme="light"] .pg-band__sub,
html[data-theme="light"] .pg-pulse__summary,
html[data-theme="light"] .pg-state__message,
html[data-theme="light"] .pg-row__status,
html[data-theme="light"] .pg-legend__item,
html[data-theme="light"] .pg-day__label {
  /* 5.35:1 on white — measured, same precedent as the bodyweight chart. */
  color: #475569;
}

html[data-theme="light"] .pg-band__value,
html[data-theme="light"] .pg-row__name,
html[data-theme="light"] .pg-collapsed__value { color: #0f172a; }

html[data-theme="light"] .pg-band__action,
html[data-theme="light"] .pg-collapsed__cue { color: #0e7490; }

html[data-theme="light"] .pg-day__mark { background: rgba(15, 23, 42, 0.08); }
html[data-theme="light"] .pg-day.is-trained .pg-day__mark { background: #0e7490; }
html[data-theme="light"] .pg-day.is-today .pg-day__mark { box-shadow: inset 0 0 0 2px #0e7490; }
html[data-theme="light"] .pg-row__track { background: rgba(15, 23, 42, 0.08); }
html[data-theme="light"] .pg-state--error { background: color-mix(in srgb, var(--danger) 6%, transparent); }

/* ------------------------------------------------- 10. RANGE + FOCUS CHIPS */
.pg-controls { margin: 0 0 14px; }

/* -------------------------------------------------- PERIOD SUMMARY ROW */
/* Four cells, one row, no invented duration: a session without a recorded time
   is named under the row instead of being counted as zero. */
.pg-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin: 0 0 12px;
  padding: 8px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 12px;
}
.pg-summary__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
}
.pg-summary__cell b {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pg-summary__cell span {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.pg-summary__cell--action { min-height: 44px; border-radius: 8px; cursor: pointer; }
.pg-summary__cell--action:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pg-summary__note {
  margin: -6px 0 12px;
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* One-muscle focus. A native select keeps 19 options usable on a 320px phone;
   a chip wall was the failure the Plans redesign already removed. */
.pg-muscle-pick { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.pg-muscle-pick > span {
  flex: 0 0 auto; font-size: 0.60rem; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-secondary);
}
.pg-muscle-select {
  flex: 1; min-width: 0; min-height: var(--touch-target);
  padding: 0 10px; border-radius: 12px;
  border: 1px solid var(--border-medium);
  background: var(--bg-input); color: var(--text-primary);
  font: inherit; font-size: 0.78rem; font-weight: 700;
}
.pg-muscle-select:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.pg-muscle-meta { margin: 6px 4px 0; font-size: 0.60rem; color: var(--text-muted); }
html[data-theme="light"] .pg-muscle-select { color: #0f172a; }
html[data-theme="light"] .pg-muscle-meta { color: var(--text-3); }

.pg-range {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: var(--overlay-sm);
}

.pg-range__chip {
  flex: 1;
  /* 44px, not a 36px pill: the range is a primary control and the browser
     check measures it. */
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}

.pg-range__chip.is-selected {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--color-cyan);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.pg-range__chip:focus-visible,
.pg-focus__chip:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }

/* Deliberately lighter than the range bar: two equal segmented rows stacked on
   a 390px screen read as two competing navigations. */
.pg-focus {
  display: flex;
  gap: 18px;
  margin: 12px 4px 0;
}

.pg-focus__chip {
  min-height: 44px;
  padding: 0 0 4px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.64rem;
  font-weight: 800;
  cursor: pointer;
}

.pg-focus__chip.is-selected {
  color: var(--text-primary);
  border-bottom-color: var(--color-cyan);
}

/* ------------------------------------------------------- 11. BALANCE BAND */
.pg-split {
  display: flex;
  gap: 2px;
  height: 14px;
  margin-top: 14px;
  border-radius: 4px;
  overflow: hidden;
}

.pg-split__seg { display: block; height: 100%; }
.pg-split__seg--strength { background: var(--color-violet); }
.pg-split__seg--endurance { background: var(--color-cyan); }

.pg-balance__delta {
  margin: 10px 0 0;
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.pg-balance__excluded {
  margin: 5px 0 0;
  font-size: 0.62rem;
  color: var(--text-muted);
}

html[data-theme="light"] .pg-range { background: rgba(15, 23, 42, 0.04); }
html[data-theme="light"] .pg-range__chip { color: #475569; }
html[data-theme="light"] .pg-range__chip.is-selected { color: var(--accent-pressed); }
html[data-theme="light"] .pg-focus__chip { color: #475569; }
html[data-theme="light"] .pg-focus__chip.is-selected { color: #0f172a; border-bottom-color: #0e7490; }

/* ------------------------------------------------- 12. MUSCLES: GROUP + STACK */
.pg-segment { display: flex; gap: 6px; margin-top: 12px; }

.pg-segment__chip {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.62rem;
  font-weight: 800;
  cursor: pointer;
}

.pg-segment__chip.is-selected {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--color-cyan);
}

.pg-segment__chip:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }

.pg-stack {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.pg-stack__bucket {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 30px;
}

.pg-stack__bar {
  display: flex;
  /* column-reverse puts the first series at the BOTTOM of the stack, which is
     how a time-series bar reads. */
  flex-direction: column-reverse;
  width: 20px;
  height: 132px;
  position: relative;
}

.pg-stack__seg { display: block; width: 100%; }
/* The previous equal-length period's total, as a reference line behind the
   stack. It is a total on purpose: a 19-muscle ghost stack would invent detail. */
.pg-stack__ghost {
  position: absolute;
  left: -3px;
  right: -3px;
  border-top: 2px dashed var(--text-muted);
  opacity: 0.7;
  pointer-events: none;
}
.pg-stack__ghost-note {
  margin: 6px 0 0;
  font-size: 0.58rem;
  color: var(--text-muted);
}

/* Twelve calendar weeks of sessions in Review → Month. The table below is the
   exact data; this is the shape, and it counts sessions (never "of N planned"
   against a historical week). */
.wrev-bars {
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 92px;
  margin: 0 0 4px;
}
.wrev-bars__col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.wrev-bars__track { flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.wrev-bars__bar { width: 100%; max-width: 18px; background: var(--data-2); border-radius: 3px 3px 0 0; }
.wrev-bars__label { font-size: 0.5rem; text-align: center; color: var(--text-muted); white-space: nowrap; }
.wrev-bars__caption { margin: 0 0 10px; font-size: 0.62rem; color: var(--text-secondary); }

.pg-stack__label {
  font-size: 0.54rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

html[data-theme="light"] .pg-segment__chip { color: #475569; border-color: rgba(15, 23, 42, 0.12); }
html[data-theme="light"] .pg-segment__chip.is-selected { color: #155e75; }

/* ---------------------------------------------------- 13. MAIN EXERCISE ROWS */
.pg-ex-list { list-style: none; margin: 12px 0 0; padding: 0; }

.pg-ex { border-top: 1px solid var(--overlay-sm); }
.pg-ex:first-child { border-top: 0; }

.pg-ex__hit {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  min-height: 56px;
  padding: 10px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.pg-ex__hit:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; border-radius: 8px; }

.pg-ex__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pg-ex__name { font-size: 0.74rem; font-weight: 800; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Decorative weekly e1RM shape; the row's delta/meta are the text evidence. */
.pg-ex__spark { flex: 0 0 auto; width: 44px; height: 16px; margin-left: auto; }
.pg-ex__spark path { fill: none; stroke: var(--text-secondary); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.pg-ex__pr { margin-left: 4px; padding: 1px 5px; border-radius: 999px; background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--color-green); font-size: 0.5rem; font-weight: 800; }
.pg-ex__delta { font-size: 0.64rem; font-weight: 800; white-space: nowrap; }
.pg-ex__meta { font-size: 0.6rem; color: var(--text-secondary); }
.pg-ex__spark { width: 100%; max-width: 120px; }
.pg-ex__spark .an-spark { height: 18px; }

html[data-theme="light"] .pg-ex__name { color: #0f172a; }
html[data-theme="light"] .pg-ex__meta { color: #475569; }

/* ---------------------------------------------------- 14. ENDURANCE BAND */
.pg-stack__pair { display: flex; align-items: flex-end; gap: 3px; height: 132px; }
.pg-stack__col { display: block; width: 11px; border-radius: 2px 2px 0 0; }
.pg-stack__col--walk { width: 6px; }
/* The previous equal-length period: a muted bar behind the current pair. */
.pg-stack__col--prev { width: 6px; background: var(--text-muted); opacity: 0.45; }

.pg-statrow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 8px;
  margin-top: 14px;
}

.pg-statrow div { display: flex; flex-direction: column; gap: 2px; }
.pg-statrow b { font-size: 0.86rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pg-statrow span { font-size: 0.56rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-secondary); }

.pg-days { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin-top: 14px; }
.pg-days__week { display: grid; grid-template-rows: repeat(7, 7px); gap: 2px; }
.pg-daycell { display: block; border-radius: 2px; background: var(--overlay-md); }
.pg-daycell.is-run { background: var(--color-blue); }
.pg-daycell.is-walk { background: transparent; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--text-3) 50%, transparent); }

html[data-theme="light"] .pg-daycell { background: rgba(15, 23, 42, 0.08); }
html[data-theme="light"] .pg-daycell.is-run { background: var(--accent-pressed); }
html[data-theme="light"] .pg-statrow b { color: #0f172a; }
html[data-theme="light"] .pg-statrow span { color: #475569; }

/* --------------------------------------------------------- 15. BODY BAND */
.pg-body__chart { margin-top: 12px; }
.pg-sites { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin: 14px 0 0; padding: 0; list-style: none; }
.pg-site { display: flex; min-width: 0; }
.pg-site__btn {
  display: flex; align-items: baseline; gap: 4px; width: 100%; min-height: var(--touch-target);
  padding: 4px 6px; border: 0; border-radius: 10px; background: transparent;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.pg-site__btn:hover { background: var(--overlay-sm); }
.pg-site__btn:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.pg-site__label { font-size: 0.58rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); }
.pg-site__value { font-size: 0.82rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pg-site small { font-size: 0.52rem; color: var(--text-secondary); }
.pg-site__delta { margin-left: auto; font-size: 0.56rem; font-weight: 700; color: var(--text-secondary); }
.pg-sites__note { margin: 6px 6px 0; font-size: 0.58rem; line-height: 1.4; color: var(--text-muted); }
html[data-theme="light"] .pg-sites__note { color: var(--text-3); }
.pg-body__fat { margin: 12px 0 0; font-size: 0.68rem; color: var(--text-secondary); }
.pg-body__fat b { color: var(--text-primary); }
.pg-body__fat small { font-size: 0.54rem; }

html[data-theme="light"] .pg-site__value { color: #0f172a; }

/* ------------------------------------------------------- 16. FASTING BAND */
.pg-fast-chart { position: relative; margin-top: 14px; }
.pg-fast__goal {
  position: absolute;
  top: 0; bottom: 4px;
  left: calc(var(--pg-goal) * 1);
  border-left: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
}
.pg-fast { display: grid; grid-template-columns: 52px 1fr 44px; align-items: center; gap: 8px; height: 20px; }
.pg-fast small { font-size: 0.54rem; font-weight: 700; color: var(--text-secondary); }
.pg-fast__track { height: 8px; border-radius: 99px; background: var(--overlay-md); overflow: hidden; }
.pg-fast__track i { display: block; height: 100%; border-radius: 99px; background: var(--color-violet); }
.pg-fast.is-short .pg-fast__track i { background: color-mix(in srgb, var(--warning) 75%, transparent); }
.pg-fast b { font-size: 0.56rem; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

html[data-theme="light"] .pg-fast b, html[data-theme="light"] .pg-fast small { color: #475569; }

/* ------------------------------------------------------ 17. PHOTO STRIP */
.pg-photos-block { margin-top: 14px; }

.pg-photos__head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 0 0 8px;
  font-size: 0.56rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-secondary);
}

.pg-photos { display: flex; gap: 8px; margin: 0; padding: 0 0 2px; list-style: none; overflow-x: auto; scrollbar-width: thin; }

.pg-photo { position: relative; flex: 0 0 auto; width: 72px; height: 84px; }

.pg-photo__open {
  display: flex; flex-direction: column; gap: 3px;
  width: 100%; height: 100%; padding: 0;
  border: 0; border-radius: 10px; background: transparent;
  color: inherit; font: inherit; cursor: pointer;
}

.pg-photo__open:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }

.pg-photo__img {
  width: 100%; height: 60px; object-fit: cover; display: block;
  border-radius: 10px; background: var(--overlay-md);
}

.pg-photo__date { font-size: 0.52rem; font-weight: 700; color: var(--text-secondary); }

.pg-photo--add { border: 1px dashed var(--border-strong); border-radius: 10px; }
.pg-photo__add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; height: 100%; min-height: 44px;
  color: var(--text-secondary); font-size: 0.52rem; font-weight: 700;
  text-align: center; cursor: pointer; border-radius: 10px;
}
.pg-photo__plus { font-size: 1.05rem; line-height: 1; }
.pg-photo__addlabel { letter-spacing: 0.03em; }
.pg-photo__add:focus-within { outline: 2px solid var(--color-blue); outline-offset: -4px; }

/* Full-screen viewer. Delete lives here, not on the tile. */
.pv {
  position: fixed; inset: 0; z-index: 320;
  display: none; padding: calc(var(--safe-top, 0px) + 12px) 12px calc(var(--safe-bottom, 0px) + 12px);
  background: rgba(2, 4, 8, 0.94);
}
.pv.active { display: block; }
.pv__panel { display: flex; flex-direction: column; gap: 10px; height: 100%; max-width: 620px; margin: 0 auto; }
.pv__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pv__date { font-size: 0.72rem; font-weight: 800; color: var(--text-primary); }
.pv__close, .pv__delete {
  min-height: 44px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border-default);
  background: var(--overlay-md);
  color: var(--text-primary); font: inherit; font-size: 0.7rem; font-weight: 800; cursor: pointer;
}
.pv__delete { border-color: color-mix(in srgb, var(--danger) 50%, transparent); color: var(--color-red); }
.pv__frame { flex: 1; min-height: 0; display: grid; place-items: center; }
.pv__frame[hidden] { display: none; }
.pv__img { max-width: 100%; max-height: 100%; border-radius: 12px; object-fit: contain; }
.pv__missing {
  margin: 12px; padding: 12px 14px; border-radius: 12px; max-width: 34ch;
  border: 1px solid var(--border-medium);
  background: var(--overlay-md);
  color: var(--text-secondary); font-size: 0.72rem; line-height: 1.5; text-align: center;
}
.pv__missing[hidden] { display: none; }
.pv__actions { display: flex; justify-content: flex-end; }

html[data-theme="light"] .pv { background: rgba(248, 250, 252, 0.97); }
html[data-theme="light"] .pv__close { color: #0f172a; }

/* The Measures screen's Add-picture tile is a BUTTON (it opens the entry sheet)
   reusing the real file-input label's paint, so the two must not look different. */
button.pg-photo__add { border: 0; background: transparent; }

/* Compare two photos side by side. The picker is the only control: choosing a
   date shows both, choosing "Single photo" returns. */
.pv__compare { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pv__compare[hidden] { display: none; }
.pv__slot { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; min-height: 0; }
.pv__slot .pv__img { flex: 1; min-height: 0; width: 100%; }
.pv__cap { font-size: 0.6rem; font-weight: 800; color: var(--text-secondary); text-align: center; }
.pv__picker { display: flex; align-items: center; gap: 10px; }
.pv__picker[hidden] { display: none; }
.pv__picklabel { font-size: 0.66rem; font-weight: 800; color: var(--text-secondary); }
.pv__select {
  flex: 1; min-height: 44px; border-radius: 10px; padding: 0 10px;
  border: 1px solid var(--border-default);
  background: var(--bg-input); color: var(--text-primary); font: inherit;
  font-size: 0.72rem; font-weight: 700;
}
.pv__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.pv__edit {
  min-height: 44px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border-default);
  background: var(--overlay-md);
  color: var(--text-primary); font: inherit; font-size: 0.7rem; font-weight: 800; cursor: pointer;
}
.pv__edit[hidden] { display: none; }
html[data-theme="light"] .pv__edit { color: #0f172a; }

/* ------------------------------------------------------ 17b. MEASURES */
.ms-screen__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ms-screen__intro { min-width: 0; }
.ms-screen__title { margin: 0; }
.ms-screen__sub { margin: 2px 0 12px; color: var(--text-secondary); font-size: 0.72rem; line-height: 1.4; }
.ms-screen__actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.ms-screen__add,
.ms-screen__gear,
.ms-screen__seeall {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--touch-target); min-height: var(--touch-target);
  padding: 0 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border-medium);
  background: var(--overlay-md);
  color: var(--text-primary); font: inherit; font-size: 0.72rem; font-weight: 800;
}
.ms-screen__add { font-size: 1.15rem; line-height: 1; }
/* Export/Import live beside the library, not on a band that can be absent. */
.ms-screen__tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.ms-screen__tool {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--touch-target); padding: 0 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border-medium);
  background: var(--overlay-md);
  color: var(--text-primary); font: inherit; font-size: 0.72rem; font-weight: 800;
}
.ms-screen__tool:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
html[data-theme="light"] .ms-screen__tool { color: #0f172a; }
.ms-screen__notice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 14px; border-radius: 14px; border: 1px solid var(--border-medium);
  color: var(--text-secondary); font-size: 0.76rem; line-height: 1.5;
}
.ms-screen__notice p { margin: 0; }
.ms-screen__add:focus-visible,
.ms-screen__gear:focus-visible,
.ms-screen__seeall:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
html[data-theme="light"] .ms-screen__add,
html[data-theme="light"] .ms-screen__gear,
html[data-theme="light"] .ms-screen__seeall { color: #0f172a; }

/* One measured site over time: the read path behind the dated entry list. */
.ms-trend {
  margin: 0 0 14px; padding: 12px;
  border: 1px solid var(--border-subtle); border-radius: 14px;
  background: var(--overlay-md);
}
.ms-trend__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ms-trend__headline { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ms-trend__label { font-size: 0.60rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-secondary); }
.ms-trend__value { font-size: 1.35rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ms-trend__delta { margin: 4px 0 0; font-size: 0.66rem; line-height: 1.4; color: var(--text-secondary); text-align: right; }
.ms-trend__outside { margin: 6px 0 0; font-size: 0.60rem; line-height: 1.4; color: var(--text-muted); }
.ms-trend__pick { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.ms-trend__pick > span { flex: 0 0 auto; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-secondary); }
.ms-trend__select {
  flex: 1; min-width: 0; min-height: var(--touch-target);
  padding: 0 10px; border-radius: 12px;
  border: 1px solid var(--border-medium);
  background: var(--bg-input); color: var(--text-primary);
  font: inherit; font-size: 0.78rem; font-weight: 700;
}
.ms-trend__select:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.ms-trend__range { margin-top: 10px; }
.ms-trend__chart { margin: 10px 0 0; }
.ms-trend__empty {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  margin-top: 10px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--border-subtle); color: var(--text-secondary);
  font-size: 0.74rem; line-height: 1.5;
}
.ms-trend__empty p { margin: 0; }
html[data-theme="light"] .ms-trend__select { color: #0f172a; }
html[data-theme="light"] .ms-trend__delta,
html[data-theme="light"] .ms-trend__pick > span { color: #475569; }
html[data-theme="light"] .ms-trend__outside { color: var(--text-3); }

.ms-entries { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ms-entry {
  display: flex; align-items: stretch; gap: 4px;
  border: 1px solid var(--border-subtle); border-radius: 14px;
  background: var(--overlay-md); overflow: hidden;
}
.ms-entry__open {
  flex: 1; min-width: 0; min-height: var(--touch-target);
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.ms-entry__open:focus-visible { outline: 2px solid var(--color-blue); outline-offset: -2px; }
.ms-entry__thumb {
  flex: 0 0 auto; width: 48px; height: 56px; border-radius: 10px; overflow: hidden;
  display: grid; place-items: center; background: var(--bg-input);
}
.ms-entry__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ms-entry__thumb--none { color: var(--text-muted); font-size: 1rem; font-weight: 700; }
.ms-entry__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ms-entry__date { font-size: 0.76rem; font-weight: 800; color: var(--text-primary); }
.ms-entry__stats { font-size: 0.68rem; color: var(--text-secondary); }
.ms-entry__stats b { color: var(--text-primary); font-size: 0.76rem; }
.ms-entry__sites { font-size: 0.64rem; color: var(--text-muted); overflow-wrap: anywhere; }
.ms-entry__delete {
  flex: 0 0 auto; min-width: var(--touch-target); min-height: var(--touch-target);
  padding: 0 10px; border: 0; border-left: 1px solid var(--border-subtle);
  background: transparent; color: var(--color-red);
  font: inherit; font-size: 0.62rem; font-weight: 800; cursor: pointer;
}
.ms-entry__delete:focus-visible { outline: 2px solid var(--color-blue); outline-offset: -2px; }

.ms-library { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ms-library__item { min-width: 0; }
.ms-library__open {
  display: flex; flex-direction: column; gap: 4px; width: 100%;
  min-height: var(--touch-target); padding: 0;
  border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.ms-library__open:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.ms-library__img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block;
  border-radius: 12px; background: var(--overlay-md);
}
.ms-library__date { font-size: 0.58rem; font-weight: 700; color: var(--text-secondary); text-align: center; }
html[data-theme="light"] .ms-library__date { color: #475569; }

/* ------------------------------------------- 18. CUSTOMIZE SHEET EXTRAS */
.customize-row--sub { padding-left: 18px; }
.customize-row--sub .customize-row__label { font-size: 0.72rem; font-weight: 700; opacity: 0.9; }
.customize-order { display: flex; gap: 2px; }
.customize-order__btn {
  width: 44px; height: 44px;
  border: 0; border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
}
.customize-order__btn:disabled { opacity: 0.3; cursor: default; }
.customize-order__btn:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
html[data-theme="light"] .customize-order__btn { color: #475569; }
.hub-head__actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* ------------------------------------------- 19. LIVE-APP CORRECTIONS
   Found by looking at the rendered tab, not at the mockup:
   - the shared body map is sized for Home's day recap and was ~800px tall inside
     a band, pushing every other card below the fold;
   - the fixed bottom nav covered the last band's footer.                        */
.pg-band .session-map { margin-top: 14px; }
.pg-band .session-map__views { max-width: 190px; margin-inline: auto; gap: 10px; }
.pg-band .session-map__view svg { width: auto; height: 156px; max-height: 156px; }
.pg-band .session-map__label { font-size: 0.52rem; }

/* The hub owns its own bottom breathing room so the last band clears the nav. */
#analytics-hub { padding-bottom: calc(96px + var(--safe-bottom, 0px)); }

/* Pulse: rail + heat map side by side (see view-pulse.js). */
.pg-pulse__top { display: grid; grid-template-columns: minmax(0, 1fr) 124px; gap: 10px; align-items: start; }
/* Grid children default to min-width:auto, so the rail's content and the map's
   intrinsic width could push the track past the band by a couple of pixels at
   390px — intermittently, because it depended on rounding. */
.pg-pulse__top > * { min-width: 0; }
.pg-pulse__top .session-map { max-width: 124px; }
.pg-pulse__top .pg-rail { margin-top: 14px; }
.pg-pulse__top .session-map { margin-top: 10px; }
.pg-pulse__top .session-map__views { max-width: 124px; gap: 6px; }
.pg-pulse__top .session-map__view svg { height: 104px; max-height: 104px; }
.pg-pulse__top .session-map__legend { display: none; }
@media (max-width: 360px) {
  .pg-pulse__top { grid-template-columns: 1fr; }
  .pg-pulse__top .session-map__views { max-width: 170px; }
}

/* ------------------------------------------------------------ 20. REPORTS */
.pg-reports { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.pg-reports__row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 56px; padding: 10px 12px;
  border: 1px solid var(--border-default); border-radius: 10px;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.pg-reports__row:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.pg-reports__copy { display: flex; flex-direction: column; gap: 2px; }
.pg-reports__title { font-size: 0.74rem; font-weight: 800; color: var(--text-primary); }
.pg-reports__desc { font-size: 0.6rem; color: var(--text-secondary); }
.pg-reports__arrow { color: var(--color-cyan); font-weight: 800; }
html[data-theme="light"] .pg-reports__title { color: #0f172a; }

/* ------------------------------------------- 20. BAND DRILLDOWN + HEADER
   Every band header with a detail is one 44px control. The affordance is text,
   not an icon-only chevron, so "Details" is readable and announced.            */
.pg-band__head--detail {
  width: 100%;
  min-height: 44px;
  margin: -2px 0 0;
  padding: 2px 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  align-items: center;
  cursor: pointer;
}
.pg-band__head--detail:active { opacity: 0.88; }
.pg-band__head--detail:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 3px; }
.pg-band__details {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--color-cyan);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* History and "how this is calculated" are header icons, not footer links. */
.hub-icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--overlay-sm);
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
}
.hub-icon-btn::-webkit-details-marker { display: none; }
.hub-icon-btn:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.hub-head { flex-wrap: wrap; }
.hub-head > div:first-child { flex: 1 1 140px; min-width: 0; }
.hub-head__actions {
  flex: 1 1 100%;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
  min-width: 0;
}
@media (min-width: 560px) {
  .hub-head__actions { flex: 0 0 auto; }
}
.hub-customize-btn { max-width: 100%; }
.pg-method { position: relative; }
.pg-method__panel {
  position: absolute;
  right: 0;
  top: calc(44px + 6px);
  z-index: 30;
  width: min(340px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--border-default);
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.45;
}
.pg-method__panel p { margin: 0 0 8px; }
.pg-method__panel p:last-child { margin-bottom: 0; }
.pg-method__panel strong { color: var(--text-primary); }

/* One Reviews row: Week | Month | Year. */
.pg-reviews {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.pg-reviews__seg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--overlay-sm);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.pg-reviews__seg:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.pg-reviews__title { color: var(--text-primary); font-size: 0.8rem; font-weight: 800; }
.pg-reviews__desc { color: var(--text-muted); font-size: 0.58rem; line-height: 1.3; }
@media (max-width: 340px) {
  .pg-reviews__desc { display: none; }
}

/* The inherited range on a band detail. */
.an-topline { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.an-topline .subview-back-btn { margin-bottom: 0; }
.an-range-chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--overlay-md);
  color: var(--text-secondary);
  font-size: 0.66rem;
  font-weight: 700;
}

/* ------------------------------------------- 21. CUSTOMIZE PROGRESS GRID
   Same x for the reorder arrows on every row, and a fixed Open chevron track. */
.customize-row--progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px 44px 48px;
  gap: 4px;
  align-items: center;
}
.customize-order--empty { display: block; width: 88px; height: 1px; }
.customize-row__open {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
}
.customize-row__open:disabled { opacity: 0.3; cursor: default; }
.customize-row__open:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.customize-row__open--empty { pointer-events: none; }
.customize-row--progress .s-switch { min-width: 48px; }
.customize-row__status { color: var(--color-amber); font-weight: 700; }

html[data-theme="light"] .pg-band__details { color: #0e7490; }
html[data-theme="light"] .hub-icon-btn { color: #475569; }
html[data-theme="light"] .an-range-chip { color: #475569; }
html[data-theme="light"] .pg-method__panel { box-shadow: 0 18px 48px rgba(15, 23, 42, 0.16); }
