/* Fitness Coach — application styles.
 *
 * Design tokens are taken verbatim from the approved prototype
 * (docs/design/fitness-coach-convergencia.css) so the implementation and the
 * reference stay recognisably the same product. The prototype's own `lab-*`
 * chrome (device switcher, preview frame) is prototype furniture and is not
 * carried over.
 *
 * Theme: resolved client-side into `[data-theme]` on <html>. An inline script
 * in the page head applies it before first paint, so a dark-mode visitor never
 * sees a white flash. With no JavaScript the document stays in the light theme,
 * which is why the light values are the defaults here.
 */

:root {
  --bg: #f7f9f5;
  /* The frame: the page sits on this, one shade darker than the content, which
     is what gives the app its outline in the approved design. It is separate
     from --bg on purpose — the content area has to keep its own colour. */
  --frame: #e9edea;
  --surface: #fff;
  --surface-alt: #f1f6f0;
  --text: #203b2d;
  --muted: #75897a;
  --line: #dce8dc;
  --accent: #285d40;
  --accent-ink: #fff;
  --accent-soft: #e7f2e8;
  --run: #ce674e;
  --lift: #7565ac;
  --danger: #b3452c;
  --danger-soft: #fbecea;
  --shadow: 0 10px 26px #24542b0c;
  /* The metric families (#58): the colour of a summary value says what kind of
     thing it is, not which metric it is — so ten metrics stay legible instead of
     becoming a rainbow. Derived from what the project already uses (the distance
     blue is `--mod-walk`/`--mod-cycle`'s neighbour, energy and the heart reuse
     `--danger`, climbing is the walk green), promoted to a role of its own. Every
     one clears a 3:1 contrast on the card, in both themes — checked, not eyeballed:
     on #f1f6f0 light / #254349 dark, the lowest is 3.16 (light tempo) and the
     rest sit above 3.5. The dark value is the same hue, lightened, which is how
     every other pair in this file works. */
  --metric-time: #8a6d1f;
  --metric-distance: #3d7fb5;
  --metric-energy: #b3452c;
  --metric-heart: #a83a5a;
  --metric-climb: #3f7d5a;
}

html[data-theme="dark"] {
  --bg: #14282d;
  /* The dark frame is the same hue, deeper, so the content still reads as a
     raised surface against it. */
  --frame: #0d1c21;
  --surface: #1d363b;
  --surface-alt: #254349;
  --text: #eaf4ed;
  --muted: #a1bbb0;
  --line: #38565a;
  --accent: #99dfb8;
  --accent-ink: #16302b;
  --accent-soft: #2b4b43;
  --run: #f19b7d;
  --lift: #b4a8e8;
  --danger: #f0a48c;
  --danger-soft: #3a2a26;
  --shadow: 0 12px 30px #071b2250;
  /* The metric families (#58) on the dark theme. Same hues, lightened to hold a
     3:1 contrast against the dark card — the lowest here is 3.64, and the rest
     are above 4.7. */
  --metric-time: #e0c268;
  --metric-distance: #8fc0e6;
  --metric-energy: #f0a48c;
  --metric-heart: #ef9ab0;
  --metric-climb: #7fc79b;
}

* { box-sizing: border-box; }

html {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  background: var(--frame);
  color: var(--text);
  transition: background .2s, color .2s;
  /* The frame is the space around the app. The prototype gives it 24px on top
     and 40px below, and the app is centred within it. */
  min-height: 100vh;
  padding: 24px 16px 40px;
}

/* The app is the raised surface: header and page share it, which is what puts
   the header inside the frame instead of beside it. The minimum height is the
   prototype's, so a short month still fills the surface. */
.app {
  max-width: 1280px;
  min-height: 760px;
  margin: 0 auto;
  background: var(--bg);
  border-radius: 18px;
  box-shadow: 0 23px 65px #1835252e;
  overflow: hidden;
}

@media (max-width: 760px) {
  .app { min-height: 740px; }
}

button { font: inherit; cursor: pointer; }
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #e3a767;
  outline-offset: 2px;
}

.eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--accent);
  font-weight: 850;
  margin: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  letter-spacing: -.05em;
  font-weight: 850;
}
.brand b { font-weight: 500; }
.brand-mark {
  width: 33px;
  height: 33px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 23px;
}

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px 40px;
}

.auth-card {
  width: min(390px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 30px 28px 26px;
}

.auth-card .brand { margin-bottom: 26px; }
.auth-card h1 {
  font-size: 30px;
  letter-spacing: -.05em;
  margin: 8px 0 10px;
  font-weight: 790;
}
.auth-note {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 22px;
}

.auth-card label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 7px;
}

.auth-card input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
  margin-bottom: 18px;
}
.auth-card input:focus { border-color: var(--accent); }

.auth-card button[type="submit"] {
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -.01em;
  padding: 13px 16px;
  margin-top: 4px;
}
.auth-card button[type="submit"]:hover { filter: brightness(1.06); }

/* --------------------------------------------------------------------------
   Application shell — the header and page frame the calendar (#18) plugs into
   -------------------------------------------------------------------------- */

.app-header {
  height: 89px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 31px;
}

/* Every button in the header shares this shape. */
.header-button {
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  min-height: 38px;
  min-width: 4.6em;
}
.header-button:hover { border-color: var(--accent); }

.main-nav { display: flex; gap: 18px; }
/* The areas are links: they change the page, and a link can be bookmarked,
   opened in a new tab and followed without JavaScript. Styled to look like the
   buttons the design draws. */
.main-nav a,
.main-nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 720;
  padding: 10px 1px;
  text-decoration: none;
}
.main-nav a.active,
.main-nav button.active {
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

@media (max-width: 760px) {
  .app-header {
    height: auto;
    min-height: 60px;
    display: grid;
    /* Two rows on a phone: the identity line and the areas. The avatar went back
       to sitting on the first row once the theme toggle left the header (#48) —
       that freed ~44px, which is what pays for the avatar growing to 32px. There
       were three rows while the toggle was here and the avatar needed a row of its
       own; with the toggle gone, one row holds both. */
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    padding: 12px 14px;
  }
  /* Row 1: the brand, the avatar, then logout. */
  .app-header .brand { grid-column: 1; }
  .app-header .private { grid-column: 2; }
  .app-header form { grid-column: 3; }
  /* The avatar alone, without the pill: no name beside it to justify the
     background, and the circle is the whole element. */
  .app-header .private {
    margin-left: 0;
    background: none;
    padding: 0;
  }
  .app-header .private-name { display: none; }
  .app-header .private .avatar-initials { font-size: 13px; }
  .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: var(--surface-alt);
    border-radius: 10px;
    padding: 4px;
  }
  .main-nav a,
  .main-nav button { text-align: center; padding: 10px; }
  .main-nav a.active,
  .main-nav button.active {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }
}

.page {
  max-width: 1280px;
  margin: auto;
  padding: 29px 30px 47px;
}

@media (max-width: 760px) {
  .page { padding: 20px 13px 30px; }
}
.page h1 {
  font-size: 35px;
  letter-spacing: -.06em;
  line-height: 1.08;
  margin: 7px 0 18px;
  font-weight: 790;
}

.page-intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 22px;
}
.page-intro p:last-child { font-size: 12px; color: var(--muted); margin: 0; }

/* --------------------------------------------------------------------------
   Calendar (#18)
   The two grids share one set of measurements with the approved prototype. The
   month grid is the default; below 760px — the prototype's own preview width —
   the week grid takes over and the month one is hidden.
   -------------------------------------------------------------------------- */

.body-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, .85fr);
  gap: 16px;
  align-items: start;
}

.calendar-panel,
.selected-day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: var(--shadow);
}
.calendar-panel { padding: 21px; }
.selected-day { padding: 22px; min-height: 470px; }

.calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 13px;
}
.calendar-head h2 { font-size: 21px; letter-spacing: -.04em; margin: 5px 0 0; }

.calendar-controls {
  display: flex;
  gap: 5px;
  align-items: center;
  color: var(--text);
}
.calendar-controls .period-title {
  font-size: 13px;
  text-transform: capitalize;
  white-space: nowrap;
  margin-right: 4px;
  /* The range is drawn as a month ("23–29 de novembro") in one week and
     abbreviated ("30 nov – 6 dez") when it crosses months — a swing of ~40px.
     Reserved here so the arrows beside it do not slide sideways every time the
     week turns (#56). 128px fits the longest label measured. */
  display: inline-block;
  min-width: 128px;
}
.calendar-controls button {
  height: 29px;
  min-width: 29px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
}
.calendar-controls button:hover { background: var(--accent-soft); }
.calendar-controls .today { font-size: 10px; padding: 0 8px; font-weight: 750; }
/* `hidden` alone does not hide a flex container: a `display` declared by an
   author rule overrides the browser's `[hidden] { display: none }`. The arrow
   pair for the inactive mode therefore stayed on screen, and the narrow layout
   showed two of them side by side. */
.arrows[hidden] { display: none; }
.arrows { display: flex; gap: 4px; }

.legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 12px;
  /* The key is drawn after the read answers, so an empty legend would be 0px
     tall and its nine modalities would push the whole grid down once they
     arrive — the same "jump" the marker slot causes. The height is reserved
     here. Two lines are allowed for on a narrow screen, where the items wrap. */
  min-height: 11px;
  flex-wrap: wrap;
}
.legend span { display: flex; align-items: center; gap: 6px; }
/* The dot in the key is the same element as a marker, at the base size, so a
   colour in the legend is the colour on the grid by construction. */
.legend-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* -- month grid -- */

.column-labels {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) 76px;
  border-bottom: 1px solid var(--line);
}
.column-labels span {
  text-align: center;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 7px 0;
}

.month-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  border-bottom: 1px solid var(--line);
}
.month-row:last-child { border-bottom: 0; }
.row-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }

/* Hover is a colour change and nothing else. The prototype also lifted the cell
   by 1px and animated the lift, which reads as the cell's content jumping under
   the cursor — the owner asked for the highlight without the movement. Keeping
   any transform out also means hovering cannot shift a neighbouring cell. */
.day-cell {
  min-width: 0;
  min-height: 75px;
  text-align: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 7px 2px;
  border-radius: 8px;
  transition: background .18s;
}
.day-cell:hover { background: var(--surface-alt); }
/* A day outside the month being shown, as in the prototype. */
.day-cell.outside { opacity: .34; }
.day-cell.selected { background: var(--accent); color: var(--accent-ink); }
/* Today keeps its own mark, separate from the selection. */
.day-cell.today-day strong { text-decoration: underline; text-underline-offset: 3px; }
.day-cell .cell-weekday { display: none; }
.day-cell strong { display: block; font-size: 11px; }

.activity-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
  margin: 8px auto 0;
  /* Height is reserved whether or not the day has markers. The slot is filled
     after the API answers, so a day that grows from empty to occupied would
     resize its cell and shift the whole grid — the visible "jump" when a day is
     clicked. Both values cover the tallest case: a 13px dot on the month grid
     and the smaller one on the week grid. */
  min-height: 14px;
}

.activity-dot {
  display: inline-block;
  width: var(--diameter, 8px);
  height: var(--diameter, 8px);
  min-width: 7px;
  min-height: 7px;
  border-radius: 50%;
  /* The ring separates two dots that touch, and keeps a dot readable against
     the selected day's accent background. */
  box-shadow: 0 0 0 1px var(--dot-ring);
}

/* One colour per modality, so a day can be read without consulting the legend.
   Values are set as pairs: the light theme above, the dark one below, where the
   same hues are lifted for contrast against the dark surface. `other` is the
   grey for sessions the source did not classify. */
:root {
  --mod-run: #ce674e;
  --mod-strength: #7565ac;
  --mod-walk: #4a8f6a;
  --mod-cycle: #3d7fb5;
  --mod-swim: #2f9aa8;
  --mod-hike: #8a7a3f;
  --mod-elliptical: #b06a9b;
  --mod-stair_climbing: #b3803a;
  --mod-other: #8b9490;
  --dot-ring: #ffffff9c;
}

[data-theme="dark"] {
  --mod-run: #f19b7d;
  --mod-strength: #b4a8e8;
  --mod-walk: #7fc79b;
  --mod-cycle: #7ab5e0;
  --mod-swim: #6fc9d6;
  --mod-hike: #d3c07a;
  --mod-elliptical: #dd9ec9;
  --mod-stair_climbing: #e0b170;
  --mod-other: #9aa5a1;
  --dot-ring: #14282da6;
}

/* The heart-rate zones (#80), on the convention a person reads on a watch: cool
   for the easy bands, hot for the hard ones, so the ramp means "how hard" before
   the label is read. The `< Z1` bar is deliberately outside the ramp — it is not
   a zone — and takes a neutral tone so it never reads as zone zero. Set as
   pairs, like the modalities above. */
:root {
  --zone-below: #8b9490;
  --zone-1: #6d9dc5;
  --zone-2: #5aa06a;
  --zone-3: #c9a83a;
  --zone-4: #d2762f;
  --zone-5: #c0413a;
}

[data-theme="dark"] {
  --zone-below: #9aa5a1;
  --zone-1: #8fc0e6;
  --zone-2: #7fc79b;
  --zone-3: #e0c268;
  --zone-4: #eda15f;
  --zone-5: #e07a72;
}

.activity-dot.run { background: var(--mod-run); }
.activity-dot.strength { background: var(--mod-strength); }
.activity-dot.walk { background: var(--mod-walk); }
.activity-dot.cycle { background: var(--mod-cycle); }
.activity-dot.swim { background: var(--mod-swim); }
.activity-dot.hike { background: var(--mod-hike); }
.activity-dot.elliptical { background: var(--mod-elliptical); }
.activity-dot.stair_climbing { background: var(--mod-stair_climbing); }
.activity-dot.other { background: var(--mod-other); }

/* -- selected day panel (#20) -- */

/* The panel is a heading plus one card per session. The prototype's layout is
   kept: a heading that names the date and counts the sessions, then the
   workouts, each opening with its own modality and time. */
.selected-day { padding: 22px; min-height: 470px; }
.selected-heading {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 16px;
}
.selected-heading h2 {
  font-size: 22px;
  letter-spacing: -.04em;
  text-transform: capitalize;
  margin: 7px 0 4px;
}
.selected-heading span { color: var(--muted); font-size: 11px; }

/* One card per session. The prototype highlights only the first and lists the
   rest smaller, but a day with two sessions gives no reason to prefer one —
   every session gets the same card. */
.workout-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  /* The left edge carries the modality colour, so the card is matched to its
     dot in the grid at a glance. */
  border-left: 3px solid var(--mod-other);
  border-radius: 12px;
  padding: 15px 16px;
  margin-bottom: 9px;
  color: var(--text);
}
.workout-card:last-child { margin-bottom: 0; }
.workout-card.run { border-left-color: var(--mod-run); }
.workout-card.strength { border-left-color: var(--mod-strength); }
.workout-card.walk { border-left-color: var(--mod-walk); }
.workout-card.cycle { border-left-color: var(--mod-cycle); }
.workout-card.swim { border-left-color: var(--mod-swim); }
.workout-card.hike { border-left-color: var(--mod-hike); }
.workout-card.elliptical { border-left-color: var(--mod-elliptical); }
.workout-card.stair_climbing { border-left-color: var(--mod-stair_climbing); }

.workout-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.workout-modality {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 9px;
  font-weight: 850;
  color: var(--muted);
}
.workout-modality i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mod-other);
}
.workout-modality.run i { background: var(--mod-run); }
.workout-modality.strength i { background: var(--mod-strength); }
.workout-modality.walk i { background: var(--mod-walk); }
.workout-modality.cycle i { background: var(--mod-cycle); }
.workout-modality.swim i { background: var(--mod-swim); }
.workout-modality.hike i { background: var(--mod-hike); }
.workout-modality.elliptical i { background: var(--mod-elliptical); }
.workout-modality.stair_climbing i { background: var(--mod-stair_climbing); }

.workout-time { font-size: 11px; color: var(--muted); }
.workout-name {
  display: block;
  font-size: 15px;
  letter-spacing: -.02em;
  margin: 7px 0 0;
  font-weight: 700;
}
.workout-figures { display: flex; gap: 24px; margin-top: 12px; }
.workout-figures span { display: block; }
.workout-figures strong { display: block; font-size: 19px; letter-spacing: -.05em; }
.workout-figures small { font-size: 9px; color: var(--muted); }

/* A day with nothing in it says so. Blank panel space would read as a failure
   to load rather than an empty day. */
.empty-day {
  text-align: center;
  padding: 54px 8px;
  color: var(--muted);
  font-size: 11px;
}
.empty-day span { font-size: 27px; display: block; margin-bottom: 12px; }
.empty-day b { display: block; color: var(--text); font-size: 13px; }
.empty-day p { margin: 5px 0; }

@media (max-width: 760px) {
  .selected-day { padding: 18px; min-height: 0; }
  .selected-heading { padding-bottom: 12px; margin-bottom: 13px; }
  .selected-heading h2 { font-size: 20px; }
}

.row-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--line);
  color: var(--muted);
  padding: 0 4px;
}
.row-total b { color: var(--text); font-size: 17px; line-height: 1.1; }
.row-total small {
  font-size: 9px;
  text-align: center;
  margin-top: 2px;
  line-height: 1.25;
}
/* The week that holds the selected day, so it stands out among the five or six
   on screen. The prototype tints only the total cell. */
.active-row .row-total { background: var(--surface-alt); }

/* -- week grid -- */

/* The viewport clips the strip; the strip draws a week either side of the window
   so the finger has somewhere to travel (#56). */
.week-viewport {
  overflow: hidden;
  /* The slide is horizontal; vertical stays the browser's scroll. Without this
     the browser withholds the move events and treats every drag as a pan, so
     the gesture never reaches the handler. */
  touch-action: pan-y;
}
.week-calendar {
  display: grid;
  /* The strip draws the seven-day window plus `MARGIN_DAYS` either side; the
     component states the total in `--days`. Each column is an equal share of the
     strip, so seven of them fill exactly one viewport and the window's seven sit
     in the middle. Deriving both from `--days` keeps the count and the width from
     drifting apart, which is what pushed the window off its edge. No `gap`: the
     columns must divide the strip exactly, or the days would not land on the cell
     width; the breathing room is inside each cell. */
  grid-template-columns: repeat(var(--days, 27), calc(100% / var(--days, 27)));
  width: calc(100% * var(--days, 27) / 7);
  /* `--base` puts the window's first day at the left edge; `--drag` is the
     finger's share, written straight to the element on every move. Composing
     them here is what keeps the slide smooth: the movement costs no render. */
  transform: translateX(calc(var(--base, 0%) + var(--drag, 0px)));
}
.week-calendar .week-cell.outside { opacity: .35; }
.week-cell {
  min-width: 0;
  min-height: 80px;
  /* Half the old 4px grid gap on each side, so the boxes look the same apart. */
  margin: 0 2px;
  padding: 7px 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text);
  text-align: center;
}
.week-cell.selected {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  box-shadow: 0 5px 12px #0e49302a;
}
.week-cell.today-day:not(.selected) strong {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.week-cell small,
.week-cell strong { display: block; }
.week-cell small {
  font-size: 8px;
  opacity: .7;
  text-transform: uppercase;
}
.week-cell strong { font-size: 13px; margin: 5px 0 7px; }
.week-cell .activity-dots { margin: 0; min-height: 9px; gap: 2px; }

@media (max-width: 760px) {
  .body-grid { display: block; }
  .calendar-panel { padding: 17px 11px; margin-bottom: 11px; }
  .calendar-head { display: block; margin-bottom: 12px; }
  .calendar-head h2 { font-size: 19px; }
  .calendar-controls { margin-top: 11px; justify-content: space-between; }
  .calendar-controls .period-title { font-size: 12px; }
  .column-labels { display: none; }
  .week-cell { min-height: 76px; }
  .selected-day { padding: 18px; min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .day-cell { transition: none; }
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: var(--shadow);
}
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 850;
}
.profile-card h2 { font-size: 20px; margin: 0 0 4px; }
.profile-card p { color: var(--muted); font-size: 11px; line-height: 1.5; margin: 0; }
.private {
  margin-left: auto;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 99px;
  font-size: 12px;
  font-weight: 750;
  /* A pill around the name with the avatar inside it, at its left (#76). Sized for
     a 32px avatar: the avatar is what the owner enlarged, and the pill grew with it
     so the circle is not cramped by its own frame. */
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 4px 4px;
}
/* The avatar inside the pill. Same circle as the account card draws, at the size
   the pill gives it — the picture is positioned by the shared `layout()`, so the
   frame set in the card is the frame shown here. */
.private .avatar { flex: none; }
.private .avatar-initials { font-size: 14px; }
.private-name { white-space: nowrap; }

.mock-note { font-size: 11px; color: var(--muted); margin: 18px 0 0; }

@media (max-width: 700px) {
  .app-header { height: auto; min-height: 60px; padding: 12px 14px; }
  .page { padding: 20px 13px 30px; }
  .page h1 { font-size: 28px; }
}

.auth-alert {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 12px;
  line-height: 1.5;
  margin: 0 0 20px;
}
.auth-alert i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  flex: 0 0 auto;
  margin-top: 5px;
}

.device-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 16px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--muted);
}
.device-note i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
  margin-top: 5px;
}

@media (max-width: 420px) {
  .auth-card { padding: 24px 20px 22px; }
  .auth-card h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
}

/* --------------------------------------------------------------------------
   Settings — the account page (#43) and the source status it carries (#22)
   -------------------------------------------------------------------------- */

.account-page { display: block; }
/* The section, as a list of categories and the open one (#62). One column of
   seven cards was ~2,700px on the desktop and nearly four screens on a phone,
   with no index, so reaching "Senha" meant scrolling past everything.

   Two widths, one structure:
     narrow  the list is the page; a category replaces it (`/conta/<id>`)
     from 761px  the list is a 240px column and the category sits beside it

   The breakpoint is the one already in the file. The 240px column fits in the
   space measured empty beside the old 820px stack (230px on each side at
   1280px), so the cards keep their width. */
.settings-layout {
  display: block;
  max-width: 1080px;
  margin: 0 auto;
}

/* ---------- the list of categories (a nav, so it looks like one) ---------- */
.settings-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.settings-nav-link {
  display: block;
  padding: 13px 16px;
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.02em;
  text-decoration: none;
}
.settings-nav-link:hover { background: var(--accent-soft); }
.settings-nav-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The current category, marked the way a nav marks one: a filled surface and an
   accent bar at the left edge. This is the state a nav cannot omit. */
.settings-nav-link.is-active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.settings-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

/* The way back on a phone, where a category is the whole page. On the desktop
   both parts are on screen at once, so "back" would mean nothing — hidden
   there. */
.settings-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 6px 2px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.settings-back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-back span { font-size: 17px; line-height: 1; }

/* Narrow: with a category open, the list gives way to it. Keeping the five names
   between the header and the content is the scrolling this change removes, and
   the back link above is how the person returns to them. On the phone the list
   is only the page at `/conta` itself. */
@media (max-width: 760px) {
  .settings-layout.has-group .settings-nav { display: none; }
}

/* Nothing open: `/conta` on a desktop, where the list is a column and the
   content area has to say something rather than sit blank. Small and quiet —
   it is a pointer, not a message. */
.settings-empty {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  padding: 4px 2px;
}

@media (min-width: 761px) {
  .settings-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    column-gap: 28px;
    align-items: start;
  }
  /* The list follows the scroll, so it stays reachable in a long category. */
  .settings-nav {
    position: sticky;
    top: 88px;              /* clears the fixed site header */
    padding-top: 2px;
  }
  /* Both parts are on screen here, so the phone's back link is meaningless and
     the empty-state line is redundant (the first category opens by default). */
  .settings-back { display: none; }
  .settings-empty { display: none; }
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin: 0;
}
.account-page .page-intro { margin-bottom: 22px; }
.settings-card h2,
.settings-card h3 {
  font-size: 17px;
  letter-spacing: -.04em;
  margin: 0 0 6px;
}
.settings-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  margin: 0 0 16px;
  max-width: 46em;
}
.settings-list { margin: 0; }
.settings-list > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.settings-list > div:first-child { border-top: 0; }
.settings-list dt { color: var(--muted); margin: 0; }
.settings-list dd { margin: 0; font-weight: 650; }

.settings-card label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}
/* Fields are stacked in the personal and weight forms (#59), so a label needs
   room above it — the field before it has no bottom margin of its own. The
   first label in a form sits under the card's note and needs none. */
.settings-card label:not(:first-child) { margin-top: 14px; }
.settings-card select,
.settings-card input[type="password"],
.settings-card input[type="date"],
.settings-card input[type="number"],
.settings-card input[type="text"],
.settings-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 11px;
  font-size: 13px;
}
/* The textarea is the person's own text: it may run to two lines of a bio, and
   it should not be resized into something the card was not laid out for. */
.settings-card textarea { resize: vertical; min-height: 46px; font-family: inherit; }
/* A reading beside a value, a shade quieter than the value itself. */
.settings-when { color: var(--muted); font-size: 11px; }

/* The date field (#59): a text input a person types into, with the picker behind
   the button beside it. The visible input and the button share a row; the native
   picker is out of flow so it cannot stretch the row it is not shown in. */
.date-field { position: relative; display: flex; gap: 6px; align-items: stretch; }
.date-field input[type="text"] { flex: 1; }
.date-pick {
  flex: none;
  width: 38px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--muted);
  border-radius: 9px;
  font-size: 12px;
}
.date-pick:hover { background: var(--accent-soft); }
/* The native input sits under the button, invisible: it exists so the browser's
   calendar can be asked for, and it never shows its own format on screen. */
.date-native {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  pointer-events: none;
}

/* The weight over time (#59). The card stacks a value, the history line and the
   chart, so the chart needs air above it — it is a separate reading, not the tail
   of the sentence before it. */
.weight-chart { margin: 14px 0 18px; }
.weight-chart .recharts-surface { overflow: visible; }
/* Password fields (#40). Same box as the select, plus the spacing between the
   stacked fields that the single-field timezone form does not need. */
.settings-card input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 11px;
  font-size: 13px;
  margin-bottom: 14px;
}
.settings-card input[type="password"]:last-of-type { margin-bottom: 0; }
/* A short rule under a field, told apart from `.settings-note` by sitting
   inside the form rather than above it.

   No negative top margin. It was there to pull the hint up against its field,
   but the right amount depends on the field's height and margin, so it was
   either a gap or — with -4px — the text ended up *inside* the box: the hint's
   top measured 628 against a field ending at 632. The field carries no bottom
   margin of its own, so the hint simply follows it at a fixed small step. */
.field-hint {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  margin: 5px 0 16px;
}
.settings-save {
  display: inline-block;
  margin-top: 14px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 99px;
  padding: 9px 18px;
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}
.settings-save:hover { filter: brightness(1.06); }

/* The profile photo (#60): the picture, and the avatar of initials that stands
   in for it. One size, drawn as a circle — the card, the header and a future
   place that shows it all read the same silhouette. */
.photo-current { margin: 4px 0 14px; }
.avatar {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-alt);
}
/* The initials are text, not an image: centred in the same circle, sized to be
   read at a glance rather than to fill it. */
.avatar-initials {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -.03em;
  user-select: none;
}

/* The framing editor (#60 follow-up). The framing itself is react-easy-crop —
   the drag, the pinch, the wheel and the round mask are the library's — so what
   is styled here is only our own arrangement around it. */
.crop-editor {
  display: grid;
  /* Both columns are the size of what they hold: the picture's column must NOT
     be `1fr`, or it stretches to fill the panel and leaves the slider sitting
     hundreds of pixels away from a picture that stopped growing at its own
     maximum. `justify-content: start` keeps the pair against the left edge
     instead of spreading when the panel is wider than the two of them. */
  grid-template-columns: auto auto;
  justify-content: start;
  align-items: start;
  gap: 14px;
  margin: 4px 0 14px;
}
/* The stage is the cropper's own box, square and as wide as the column. The
   library draws the picture, the mask and the grid inside it. */
.crop-stage {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: #0d1117;
  touch-action: none;
  /* The library drags the picture, so the native image drag has to stay off:
     without this the browser offers to drag the picture out of the page, which
     is the "drawing the whole picture" gesture that was reported. */
  -webkit-user-drag: none;
}
.crop-stage img { user-select: none; }

/* The zoom, vertical and to the right of the picture. `writing-mode` turns the
   horizontal range into a vertical one without a second control, so the slider
   keeps its keyboard and screen-reader behaviour instead of being simulated. */
.crop-zoom-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  align-self: stretch;
}
.crop-zoom-column .crop-zoom-label { margin-bottom: 0; }
.crop-zoom-label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.crop-zoom {
  flex: 1;
  width: auto;
  min-height: 110px;
  max-height: 100%;
  accent-color: var(--accent);
  writing-mode: vertical-lr;
  direction: rtl;          /* up is more zoom, which is how a hand expects it */
}
.crop-below { grid-column: 1 / -1; }
.crop-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.crop-actions .settings-save { margin-top: 0; }

/* On a phone the column is narrow enough that the slider beside the picture
   would crowd it, so the pair stacks and the slider goes back to horizontal. */
@media (max-width: 760px) {
  .crop-editor { grid-template-columns: 1fr; }
  .crop-zoom-column {
    flex-direction: row;
    align-self: auto;
    gap: 8px;
  }
  .crop-zoom {
    width: 100%;
    min-height: 0;
    writing-mode: horizontal-tb;
    direction: ltr;
  }
}
/* Cancelling is not a kind of saving: quieter than the button it sits beside. */
.settings-cancel {
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  border-radius: 99px;
  padding: 9px 18px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}
.settings-cancel:hover { color: var(--text); border-color: var(--text); }

/* The card's two actions, below the picture and side by side (#60 follow-up
   owner's call). One door to change the photo, and — when there is one — the way
   back to the initials. */
.photo-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.photo-actions .settings-save { margin-top: 0; }
.photo-actions form { margin: 0; }
/* Removing is not a kind of saving: quieter than the button beside it, so it
   does not compete with the action it sits next to. */
.settings-remove {
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  border-radius: 99px;
  padding: 8px 16px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}
.settings-remove:hover { color: var(--text); border-color: var(--text); }

/* The file picker (#60). The visible control is a label styled as a button, and
   the real input is off-screen but in the tab order — the only way to choose the
   wording, since the browser writes its own inside its button. */
.file-field {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
/* The two selectors, so this outranks `.settings-card label` — which would
   otherwise give the button the field-label treatment: ALL CAPS, and a 7px gap
   under it that belongs to a label sitting above its field. */
.settings-card label.file-button,
label.file-button {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0;
}
.file-button:hover { border-color: var(--accent); }
/* The focus ring belongs on the label, because that is what is seen. The input
   keeps the focus; this shows it. */
.sr-only:focus-visible + .file-button {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.file-name {
  color: var(--muted);
  font-size: 11px;
  /* A long file name must not push the button off the card. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
/* Visible to a screen reader, not to the eye — and still focusable, which is why
   this is not `display: none`. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* The outcome of a save. Announced politely, so a screen reader hears it
   without the message stealing focus from the form. */
.settings-feedback {
  font-size: 11px;
  border-radius: 9px;
  padding: 10px 12px;
  margin: 0 0 14px;
}
.settings-feedback.is-ok {
  background: var(--accent-soft);
  color: var(--accent);
}
.settings-feedback.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* A source of workouts, with what its own mechanism can prove. */
.source-row {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}
.source-row:first-child { border-top: 0; padding-top: 0; }
.source-row:last-child { padding-bottom: 0; }
.source-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.source-main strong { font-size: 13px; }
.source-headline { font-size: 11px; font-weight: 650; }
.source-row.is-ok .source-headline { color: var(--accent); }
.source-row.is-warning .source-headline { color: var(--danger); }
.source-row.is-idle .source-headline { color: var(--muted); }
.source-method,
.source-facts {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  margin: 4px 0 0;
}

.not-found {
  max-width: 34em;
  padding: 40px 0;
}
.not-found h1 {
  font-size: 28px;
  letter-spacing: -.05em;
  margin: 8px 0 10px;
}
.not-found p { color: var(--muted); font-size: 12px; line-height: 1.6; }

@media (max-width: 760px) {
  .settings-card { padding: 18px; }
  .settings-list > div { flex-direction: column; gap: 3px; }
}

/* --------------------------------------------------------------------------
   Summary strip (#23) — four numbers about the current week
   -------------------------------------------------------------------------- */

/* The prototype's four-block bar. Four columns on a wide screen, two on a
   narrow one, with the dividers drawn as borders between cells. */
.stat-strip {
  display: grid;
  /* The column count is set inline by the strip, from how many numbers the
     account chose (#64). Four columns were right only while there were always
     four. Three remain here as the floor for a client that has not set it. */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 19px;
}
.stat-strip > div {
  padding: 16px 20px;
  border-right: 1px solid var(--line);
  min-width: 0;
}
/* Every divider but the last, however many there are: the count is known only
   at runtime, so the rule cannot name the child (#64). */
.stat-strip > div:last-child { border-right: 0; }
.stat-strip span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 8px;
}
.stat-strip strong {
  display: block;
  font-size: 26px;
  letter-spacing: -.06em;
  white-space: nowrap;
}
.stat-strip small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 760px) {
  .stat-strip {
    /* Two columns while there are two or more, one when there is a single
       number — a lone card stranded in a two-column grid reads as a defect.
       The count comes from the strip itself (`data-count`), not from a fixed
       assumption of four (#64). */
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    margin-bottom: 12px;
  }
  .stat-strip[data-count="1"] { grid-template-columns: minmax(0, 1fr) !important; }
  .stat-strip[data-count="3"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  .stat-strip > div { padding: 14px 15px; }

  /* Dividers, by position rather than by a fixed four-cell layout. Every cell
     but the last of its row keeps the right border; every row but the first
     carries the bottom border. With two columns that is "odd cells of a row". */
  .stat-strip > div:nth-child(odd) { border-right: 1px solid var(--line); }
  .stat-strip > div:nth-child(even),
  .stat-strip[data-count="1"] > div { border-right: 0; }
  /* The bottom border belongs to every cell except those in the last row.
     With two columns, that is the cells of the first row: two of them for
     counts 3 and 4, none for 1 and 2 (which are a single row). */
  .stat-strip[data-count="3"] > div:nth-child(-n+2),
  .stat-strip[data-count="4"] > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  /* Three in two columns: the third sits alone on the second row. */
  .stat-strip[data-count="3"] > div:nth-child(3) { border-right: 0; }

  .stat-strip strong { font-size: 23px; }
}

/* --------------------------------------------------------------------------
   Objective in the calendar intro (#66)
   The account's objective, drawn where it is seen: the main screen, in place of
   the intro's filler sentence. Rendered as text, never as HTML — it is what the
   person wrote. The frame matches the summary strip's card vocabulary (surface,
   line, radius, shadow) so it reads as part of the page, not bolted on.
   -------------------------------------------------------------------------- */

.objective-intro {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px 18px;
  max-width: 420px;
}
.objective-intro-title {
  font-size: 12px;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}
.objective-intro-text {
  font-size: 15px;
  margin: 0;
  /* The person's own line breaks are kept; nothing else is interpreted. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* The prompt is not an objective — dim it so it reads as an invitation. */
.objective-intro-text.is-empty { color: var(--muted); }
.objective-intro-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  /* The accent, not the browser's default link blue: on the dark surface the
     default blue is too low-contrast to read. The accent is the colour the rest
     of the interface uses for an actionable element, and it is defined per
     theme. */
  color: var(--accent);
  font-weight: 600;
}
.objective-intro-link:hover { text-decoration: none; }
.objective-intro-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 760px) {
  /* On a phone the intro stacks, so the card takes the full width. */
  .objective-intro { max-width: none; }

  /* And the two parts stack too: side by side, the 35px heading is squeezed
     into the space the card leaves and breaks onto two lines. The intro used to
     hold its text inside the heading's own block, so the flex row never had a
     second child to compete with; the card is one, and it pushes the heading
     off its line. Stacking gives the heading the full width back (#66). */
  .page-intro { flex-direction: column; align-items: stretch; gap: 12px; }
}

/* --------------------------------------------------------------------------
   Summary strip picker (#64)
   Up to four of the catalog, in the order ticked. A plain list of checkboxes
   with the position beside each ticked one: the order is a fact about the
   choice, so it is shown, not guessed at from the DOM order.
   -------------------------------------------------------------------------- */

.stat-choice {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}
.stat-choice li + li { border-top: 1px solid var(--line); }
.stat-choice label {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "box label" ". help";
  gap: 2px 10px;
  align-items: center;
  padding: 10px 0;
  cursor: pointer;
}
.stat-choice input[type="checkbox"] { grid-area: box; }
.stat-choice-label {
  grid-area: label;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.stat-choice-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.stat-choice-help {
  grid-area: help;
  font-size: 12px;
  color: var(--muted);
}
/* A refused tick (the limit is reached) reads as unavailable, not as an error. */
.stat-choice input[type="checkbox"]:disabled + .stat-choice-label { color: var(--muted); }

/* ---------------------------------------------------------------------------
   Workout detail (#52)
   The screen behind a day's card. It is adaptive by modality: the metrics row
   and the sections are built from what the workout has, so nothing absent is
   ever drawn as a zero. Wide screens open it over the calendar; narrow screens
   give it its own page (see .workout-page).
   --------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay);
  backdrop-filter: blur(4px);
}
html[data-theme="light"], :root { --overlay: #0f1f1733; }
html[data-theme="dark"] { --overlay: #04100c99; }

.detail-shell {
  position: relative;
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
}

.detail {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 26px 22px;
  box-shadow: var(--shadow);
}
.detail-loading {
  color: var(--muted);
  font-size: 13px;
  padding: 24px;
  text-align: center;
}

.close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}

.detail-head h2 { font-size: 26px; letter-spacing: -.04em; margin: 6px 0; }
.detail-head > div > span { font-size: 12px; color: var(--muted); }

/* Renaming a workout (#71).

   The pencil sits beside the title and is the only thing that opens the field;
   the field then REPLACES the title in the same slot ("prefiro a edição in
   place, por cima do label"). Nothing says where the current name came from —
   the owner does not want that ("Nunca — não preciso saber a origem, só quero
   poder corrigir"), so no provenance badge is rendered anywhere.

   The two actions are a check and an x, not words: the owner's choice, and it
   keeps the row narrow enough to sit where the title sat. */
.detail-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.detail-name h2 {
  min-width: 0;
  overflow-wrap: anywhere;
}
.name-edit {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.name-edit:hover { color: var(--accent); background: var(--accent-soft); }
.name-edit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  color: var(--accent);
}

/* The field takes the title's place. `flex-wrap` keeps the two round buttons
   from being squeezed to nothing on a phone. */
.name-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
  flex: 1 1 auto;
  min-width: 0;
}
.name-input {
  flex: 1 1 180px;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  /* The placeholder is the name the screen is showing now — the translated one,
     not the text the source sent — because saving an empty field restores it. */
  font-family: inherit;
  font-size: 22px;
  letter-spacing: -.04em;
}
.name-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.name-input::placeholder { color: var(--muted); opacity: .7; }
/* Both actions are one glyph in a circle, of the same size, so the pair reads as
   a unit rather than a primary button with something beside it. */
.name-save,
.name-cancel {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.name-save {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
.name-cancel {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
.name-save:disabled,
.name-cancel:disabled { opacity: .6; cursor: default; }
.name-save:focus-visible,
.name-cancel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.name-error {
  flex: 1 1 100%;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}

/* The metrics summary: one card, two columns (#58).

   It used to be a box per metric, laid out by `auto-fit`. That left the last row
   incomplete — 7 metrics gave 5 columns and a second row of 2 with the right
   third of the panel empty on the desktop, and one orphan box on the phone. The
   fix is the Apple Fitness shape, which the owner asked for: a single card whose
   surface fills whatever the grid leaves, so an incomplete row has no hole to
   show, and a lone last metric spans the full width instead of half of it. */
.detail-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 18px;
  row-gap: 14px;
  background: var(--surface-alt);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 22px 0;
  /* The card spans the width of what it sits in, like the title above it — the
     Apple Fitness panel does the same, and it is what makes an incomplete row
     read as closed: the surface fills what the grid leaves, so there is no gap to
     see. An earlier attempt capped this at 420px to keep the two columns from
     sitting far apart; that pulled the card out of line with the heading, which is
     the defect the owner saw. The columns sitting at half-width apart is the
     intended shape, not a gap. */
}
.detail-metrics > div {
  /* The label sits above the value, both left-aligned, with no box of its own:
     the card is what draws the boundary, not each metric. */
  display: block;
  min-width: 0;
}
/* The lone metric of the last row takes the whole width — the rule that makes
   the row close instead of leaving a gap. `:last-child:nth-child(odd)` is exactly
   "there is an odd item and it is the last one", which is the condition, so it
   holds for 3, 5, 7, 9 metrics without counting them. */
.detail-metrics > div:last-child:nth-child(odd) { grid-column: 1 / -1; }

.detail-metrics small,
.detail-metrics strong { display: block; }
.detail-metrics small {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.detail-metrics strong { font-size: 19px; letter-spacing: -.03em; }

/* The value carries the colour of its family (#58): what kind of number it is,
   not which one. The label stays muted so the colour reads as the figure's own. */
.detail-metrics > div[data-family="time"]     strong { color: var(--metric-time); }
.detail-metrics > div[data-family="distance"] strong { color: var(--metric-distance); }
.detail-metrics > div[data-family="energy"]   strong { color: var(--metric-energy); }
.detail-metrics > div[data-family="heart"]    strong { color: var(--metric-heart); }
.detail-metrics > div[data-family="climb"]    strong { color: var(--metric-climb); }

.detail-section { margin-top: 22px; }
.detail-section h3 { font-size: 13px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* A section that folds away (#55). The heading is the button: title, an
   optional summary that keeps the gist while folded, and a chevron. */
.collapsible h3 { margin: 0; }
.collapse-toggle {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 6px 0;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  cursor: pointer;
  text-align: left;
}
.collapse-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.collapse-title { color: var(--muted); min-width: 0; }
/* The summary is the reason a folded section is not a blank: count and average
   stay readable without expanding. */
.collapse-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  /* The summary reads as one unit: it must not wrap into a column of single
     words when a long title squeezes it (owner's review of #68 on a phone). */
  flex: none;
  white-space: nowrap;
}
.collapse-count { color: var(--text); }
.collapse-avg { color: var(--muted); }
/* The chevron points down when open, right when folded. */
.collapse-chevron {
  flex: none;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .2s ease;
  align-self: center;
}
.collapsible:not(.is-open) .collapse-chevron { transform: rotate(-45deg); }

/* Height animation without measuring: the body is a grid row that goes from 0fr
   to 1fr, so it works for any number of rows inside. */
.collapse-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .24s ease;
}
.collapsible.is-open .collapse-body { grid-template-rows: 1fr; }
.collapse-inner { overflow: hidden; min-height: 0; }

/* Reduced motion: no slide, no chevron turn. The fold still works, instantly. */
@media (prefers-reduced-motion: reduce) {
  .collapse-body { transition: none; }
  .collapse-chevron { transition: none; }
}

/* Strength: exercises and their sets. Each exercise folds (#68) — the heading
   reads as the old `.exercise-head`, the sets sit behind it. */
.exercise { border-top: 1px solid var(--line); padding: 10px 0; }
.exercise:first-child { border-top: 0; }
.exercise .collapse-heading { margin: 0; font-size: inherit; font-weight: inherit; }
.exercise .collapse-toggle {
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  padding: 3px 0;
}
.exercise .collapse-title { color: var(--text); font-weight: 600; }
.exercise-notes { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.set-list { list-style: none; margin: 9px 0 0; padding: 0; }
.set-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
  font-size: 13px;
  border-top: 1px solid var(--line);
}
.set-row:first-child { border-top: 0; }
.set-row.is-warmup { color: var(--muted); }
.set-index {
  min-width: 18px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.set-value { flex: 1; }
.set-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
}
.set-tag.is-failure { color: var(--danger); border-color: var(--danger); }

/* Cardio: per-km splits, heart rate as a proportional bar. */
.splits-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.splits-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
  padding: 0 8px 8px 0;
}
.splits-table td { padding: 8px 8px 8px 0; border-top: 1px solid var(--line); }
/* The kilometre column is a small fixed width so it stays the same for every
   row; the pace column takes the slack. A trailing partial carries its distance
   beside the pace, where there is room, instead of widening the km column. */
.splits-table th:first-child, .splits-table td:first-child { width: 40px; padding-right: 12px; }
.split-index { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.split-extra {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin-left: 10px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.split-pace { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* The cell lays the bar and the number on one line (see .split-hr), so no row
   grows taller for a longer bar. No fixed row height is needed. */
.split-hr { min-width: 140px; }
/* The bar and the number share the cell on one line: the bar takes the space
   that is left and the number has a fixed width, so a high heart rate (a long
   bar) can no longer push the number onto a second line. */
.split-hr {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hr-bar-wrap {
  flex: 1;
  min-width: 0;
  height: 8px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
}
.hr-bar {
  display: block;
  height: 8px;
  width: var(--pct, 0%);
  background: var(--mod-run);
  border-radius: 4px;
}
.hr-value {
  flex: none;
  width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
}

.detail-source {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

/* The date line and the weather pill on one row (#87). The pill sits BESIDE the
   date, because that is what it is: context for the day the session happened —
   not a footnote about the record. Wrapping is allowed so a phone does not push
   either of them off the card. */
.detail-date {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* The weather the session happened in (#87): temperature and humidity in one pill.
   The pill's BACKGROUND carries the heat-index category and the text is chosen per
   category against it, because that is what makes the colour readable at a glance —
   the owner's words: "as cores não estão super claras... não entendo direito que cores
   são". Colouring only the TEXT forced every category darker until it passed 4.5:1 on
   the app's light surface, which turned the caution yellow into an olive and the
   orange into brick: legible and unrecognisable. With the colour on the fill, the
   category stays saturated (measured 0.74-1.00) and the text clears the floor on the
   fill itself (10.2 / 7.6 / 6.9 / 4.8).

   The four fills follow the NWS heat-index scale — light yellow, dark yellow, orange,
   red — which is the scale weather services already use for exactly this scale of
   danger. The dark theme is given its own set: the same fills are near-black text on
   a dark card, so they keep the fill and lift the text. */
.detail-weather {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-alt);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.detail-weather .weather-part {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.detail-weather .weather-icon {
  flex: none;
  /* The icon follows the figure's colour, so the pair reads as one token. */
  color: inherit;
}

/* The heat band: the FILL is the colour, the text is picked against it, and the "i"
   carries the rule. The scale reads blue (mildest) -> yellow -> orange -> red -> purple
   (heaviest), the bands being the account's own fifths (see `app/weather.py`).

   Each fill was measured: saturation >= 0.5 so the colour is recognisable rather than
   mud, and the text clears 4.5:1 against the fill it sits on. The dark theme has its own
   set, because the near-black ink the light fills take would be invisible on a dark card. */
.detail-weather[data-category="blue"] {
  background: #4aa8e8; border-color: #3b8fc9; color: #072a45;
}
.detail-weather[data-category="yellow"] {
  background: #ffe08a; border-color: #e8c25c; color: #3a2f14;
}
.detail-weather[data-category="orange"] {
  background: #ff9d2e; border-color: #db8320; color: #3a1e00;
}
.detail-weather[data-category="red"] {
  background: #d42b1f; border-color: #b32318; color: #fff;
}
.detail-weather[data-category="purple"] {
  background: #8f2fa8; border-color: #76258c; color: #fff;
}

html[data-theme="dark"] .detail-weather[data-category="blue"] {
  background: #123a5c; border-color: #1d5480; color: #bfe0fb;
}
html[data-theme="dark"] .detail-weather[data-category="yellow"] {
  background: #6b5a1c; border-color: #8a7526; color: #ffeaa8;
}
html[data-theme="dark"] .detail-weather[data-category="orange"] {
  background: #8a4405; border-color: #ad5708; color: #ffd0a8;
}
html[data-theme="dark"] .detail-weather[data-category="red"] {
  background: #8f231b; border-color: #b32d23; color: #ffd9d5;
}
html[data-theme="dark"] .detail-weather[data-category="purple"] {
  background: #702a91; border-color: #8d35b5; color: #eac4f7;
}

/* Explains the colour without a tooltip. The owner's words: "o tooltip nao funciona no
   mobile... é muito longo no desktop", and the rule needed its origin named. So the pill
   carries the rule's NAME as a link to the page that explains it — which works on a
   finger and does not depend on hover. It follows the pill's text colour. */
.detail-weather .weather-info {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-style: normal;
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: .9;
  white-space: nowrap;
}
.detail-weather .weather-info:hover { opacity: 1; }

/* The heat bands, listed in the card that explains them (#87). A swatch per row so the
   colour is shown while it is being named, which is the whole point of the page: the
   person arrives from a coloured pill wanting to know what the colour meant. */
.heat-bands {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.heat-bands li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.heat-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex: none;
  border: 1px solid var(--line);
}

/* The same fills the pill uses, so the swatch and the workout agree. Kept in step with
   `.detail-weather[data-category=...]` above — one palette read twice. */
.heat-swatch[data-category="blue"]   { background: #4aa8e8; border-color: #3b8fc9; }
.heat-swatch[data-category="yellow"] { background: #ffe08a; border-color: #e8c25c; }
.heat-swatch[data-category="orange"] { background: #ff9d2e; border-color: #db8320; }
.heat-swatch[data-category="red"]    { background: #d42b1f; border-color: #b32318; }
.heat-swatch[data-category="purple"] { background: #8f2fa8; border-color: #76258c; }

.heat-range { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 108px; }
.heat-name { color: var(--text); }

/* The hint that a card opens. */
.workout-open {
  display: block;
  margin-top: 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  font-weight: 700;
}

/* The phone's own detail page (#52). */
.workout-page { padding-top: 16px; }
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 16px;
}
.workout-page .detail { border: 0; box-shadow: none; padding: 0; }

/* On the phone the card keeps its surface colour but has no border, no shadow
   and no inset — so the content sits against the wall of a box that is still
   visible (#77). The room is the page's own side padding, which was room *for
   the card*, not for the content inside it: it moves inward and becomes the
   card's padding, widening the card by the same amount. Nothing is pushed down.
   This is the phone's defect only — on a wide screen the card is laid out inside
   its parent, which is what aligns it with the header, so this rule stays inside
   the breakpoint and changes nothing above it. */
@media (max-width: 760px) {
  .workout-page { padding: 16px 0 30px; }
  .workout-page .detail { padding: 16px; }
  .detail-head h2 { font-size: 23px; }
  /* The pencil grows on a phone (#71, the owner: "o lapis esta MUITO pequeno no
     mobile"). 30px is a comfortable mouse target and not a comfortable thumb
     one, so under this breakpoint it takes the size a finger needs. The glyph
     grows with the hit area, or the target is large and the icon still looks
     lost in it. */
  .name-edit { width: 44px; height: 44px; font-size: 21px; }
  /* Same for the pair inside the open field: they are thumb targets too. */
  .name-save,
  .name-cancel { width: 44px; height: 44px; font-size: 20px; }
}

.split-partial-tag {
  display: inline-block;
  margin-left: 7px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ---------------------------------------------------------------------------
   Heart rate over time (#54)
   The series lives in heartRateData; it is irregular, so the card falls back to
   the summary numbers when there are too few samples to draw a line.
   --------------------------------------------------------------------------- */

.hr-section { margin-top: 22px; }

.hr-chart { margin: 0; }
/* Recharts builds the figure in SVG inside a wrapper div. The wrapper takes the
   card styling; `touch-action: pan-y` keeps the page scrollable through the
   chart, which a horizontal drag marks instead. */
.hr-chart .recharts-wrapper {
  background: var(--surface-alt);
  border-radius: 10px;
  touch-action: pan-y;
  cursor: crosshair;
}
.hr-chart .recharts-surface { border-radius: 10px; }

/* Gridlines and axis labels: the reference the numbers are read against.
   Recharts sets its own defaults; these override them with the theme. */
.hr-chart .recharts-cartesian-grid line {
  stroke: var(--line);
  opacity: .45;
}
.hr-chart .recharts-cartesian-axis-tick-value {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.hr-chart .hr-axis-y .recharts-cartesian-axis-tick-value { font-weight: 600; }

/* The gradient under the curve, from the line down toward the axis. The stops
   read the theme variables, so the fill follows the dark/light switch. */
.hr-fill-top { stop-color: var(--mod-run); stop-opacity: .28; }
.hr-fill-bottom { stop-color: var(--mod-run); stop-opacity: .02; }

/* The average, as a dashed reference across the plot. A warmer tone and a
   heavier dash than anything else on the figure, so it never reads as the
   pointer's guide line (which is solid) nor hides inside the grid. */
.hr-avg-line {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 7 5;
  opacity: 1;
}

/* The dot that rides the value under the pointer. */
.hr-dot {
  fill: var(--mod-run);
  stroke: var(--surface);
  stroke-width: 2;
}

/* The tooltip. Recharts renders it in HTML, so its size is a real pixel size —
   the point of moving off hand-drawn SVG, where the type shrank with the
   figure and vanished on a phone. It is pinned to the top-left of the plot
   (see the Tooltip props), not to the pointer: a finger would cover it. */
.hr-tip {
  display: flex;
  align-items: baseline;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  box-shadow: var(--shadow);
}
.hr-tip strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.hr-tip small {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
/* The tooltip wrapper is positioned by an inline `transform`/`left` from
   Recharts; on the phone the box is pinned to the top-right so the reading does
   not cover the y-axis on the left. `width: auto` keeps the wrapper hugging the
   box instead of spanning the figure (its default), which is what lets `right`
   anchor it. */
.hr-chart.is-narrow .recharts-tooltip-wrapper {
  width: auto !important;
  left: auto !important;
  right: 8px;
  transform: translateY(4px) !important;
}

.hr-chart figcaption {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.hr-sparse {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 16px;
  margin: 0;
  text-align: center;
}

.hr-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 10px;
}
.hr-summary > div { background: var(--surface-alt); border-radius: 10px; padding: 11px 13px; }
.hr-summary small, .hr-summary strong { display: block; }
.hr-summary small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.hr-summary strong { font-size: 18px; letter-spacing: -.03em; }

/* Heart-rate zones (#80). Shares the heart-rate card's surface and axis styling;
   only what is genuinely different lives here. */
.zone-section { margin-top: 22px; }
.zone-chart { margin: 0; }
.zone-chart .recharts-wrapper {
  background: var(--surface-alt);
  border-radius: 10px;
  touch-action: pan-y;
}
.zone-chart .recharts-surface { border-radius: 10px; }
.zone-chart .recharts-cartesian-grid line { stroke: var(--line); opacity: .45; }
.zone-chart .recharts-cartesian-axis-tick-value {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.zone-chart .hr-axis-y .recharts-cartesian-axis-tick-value { font-weight: 600; }

/* One tone per zone, on the convention a person reads on a watch: cool for the
   easy bands, hot for the hard ones. The `< Z1` bar is outside that ramp — it is
   not a zone — and takes the neutral tone, so it never reads as zone zero. */
.zone-bar { fill: var(--zone-1); }
.zone-bar[data-zone="1"] { fill: var(--zone-1); }
.zone-bar[data-zone="2"] { fill: var(--zone-2); }
.zone-bar[data-zone="3"] { fill: var(--zone-3); }
.zone-bar[data-zone="4"] { fill: var(--zone-4); }
.zone-bar[data-zone="5"] { fill: var(--zone-5); }
.zone-bar.is-below { fill: var(--zone-below); opacity: .55; }

.zone-chart figcaption {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.zone-chart figcaption .zone-in { font-variant-numeric: tabular-nums; }

/* The estimate warning, under the bars: the same honesty the zones card carries
   in Minha conta (#63, rule 4). Five bars read as fact, so the margin is said
   here too and not only on the screen that configures the zones. */
.zone-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
  margin: 10px 0 0;
}

.zone-tip {
  display: grid;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: var(--shadow);
}
.zone-tip strong { font-size: 13px; color: var(--text); }
.zone-tip small {
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.zone-tip span {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.hr-legend { display: inline-flex; align-items: center; gap: 5px; }
.hr-legend-avg {
  display: inline-block;
  width: 16px;
  height: 0;
  border-top: 1.5px dashed var(--accent);
}

/* Training zones (#63).
 *
 * A table, because the content is a table: five rows of the same three facts.
 * Not a chart — there is no measurement to plot, only boundaries, and five
 * coloured bands would look like data the person collected.
 *
 * The bpm column carries the zone's meaning in a smaller line, so the numbers
 * are readable at a glance and the words are there for anyone who wants them.
 */
.zones-table {
  width: 100%;
  margin: 14px 0 4px;
  border-collapse: collapse;
  font-size: 13px;
}
.zones-table th,
.zones-table td {
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.zones-table thead th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.zones-table tbody th {
  font-weight: 600;
  width: 3.5em;
}
.zones-table .zones-pct {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 5.5em;
}
.zones-table .zones-bpm {
  font-variant-numeric: tabular-nums;
}
/* The meaning of the zone, on its own line under the numbers: the bpm is what
   the person reads, the words are what tells them what it is for. */
.zones-table .zones-bpm .settings-when {
  display: block;
  margin-top: 1px;
}

/* A secondary action — "back to the default" is not the thing the card is for,
   and it must not look like the primary save next to it. */
.settings-save.is-secondary {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.settings-save.is-secondary:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* Stacked forms inside one card.
 *
 * Measured, not guessed: the save button of one form was 0px from the label of the
 * next, so "Salvar repouso" read as belonging to the field below it. Two forms with
 * no gap between them are one form as far as the eye is concerned.
 *
 * The margin lives on the form rather than on its button, because the button is not
 * the last thing in the form's box — its own bottom margin would collapse into the
 * next element's top margin and could still end up at zero.
 *
 * **`:not()` is load-bearing.** Without it the rule also matched the second field of
 * the side-by-side pair and pushed it 18px down, which is exactly the misalignment
 * it was written to prevent, from the other direction. Measured: `#resting-form`
 * carried `margin-top: 18px` while both forms were 92px tall, so the offset was the
 * margin and not the grid.
 */
.settings-card form + form:not(.zones-pair form) {
  margin-top: 18px;
}
/* The card's own seam, so a card never starts flush against the control above it.
   The settings stack already spaces the cards; this is the floor inside one. */
.settings-card > *:last-child {
  margin-bottom: 0;
}
/* A hint that must stay short: one line of explanation, not a paragraph. Used where
   the full reasoning lives in the card's opening note instead. */
.field-hint.is-tight {
  margin: 4px 0 12px;
}

/* The heart-rate inputs (#63): the maximum and the resting rate, side by side.
 *
 * Side by side because they are one thought — the person reads both to understand
 * the bands below — and stacked they cost twice the height for two short numbers.
 *
 * **One grid with two columns and three fixed rows, each form set into a column.**
 * The failure this replaces: two independent grids put the second column 18px lower
 * as soon as its content differed (measured: label and input 18px out), which reads
 * as a broken row.
 *
 * Two attempts that did NOT work, kept here so they are not retried: `subgrid`
 * shares the rows but is unsupported in older Safari; and `display: contents` on the
 * forms drops them from the box tree, so the grid places every part in DOM order and
 * the two fields end up scrambled across the columns — visibly worse than the
 * defect. What works with no version floor is to keep the forms as boxes and give
 * their *contents* the same geometry in both: same row heights, same margins, so
 * the parts land on the same lines.
 */
.zones-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
  margin-bottom: 6px;
  /* Both fields start at the top of their cell. Without this the grid stretches
     each item within its row and centres/offsets the shorter column — the second
     field's label measured 18px below the first's. This one declaration is the
     fix; `subgrid` and `display: contents` were both tried and neither was needed. */
  align-items: start;
}
/* The pair stays side by side at every width: two short numbers, and stacking them
   costs exactly the height this card was built to save. The fields shrink instead —
   the columns are `minmax(0, 1fr)`, so a narrow viewport divides the width it has.
 */
/* The three rows of a field, identical in both columns: the label occupies one
   fixed line, the input the next, the button the third. Because the row heights are
   declared here and not derived from content, the two fields cannot get out of step
   — whichever value is typed into either one.
 */
.zones-pair form {
  margin-top: 0;
  display: grid;
  grid-template-rows: 1.2em auto auto;
  align-content: start;
}
.zones-pair label {
  margin-top: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.zones-pair .settings-save {
  margin-top: 8px;
  font-size: 12px;
  padding: 6px 14px;
}

/* One zone: the box, and the band and meaning beside it. */
.zone-row {
  display: grid;
  grid-template-columns: 2.5em 5.5em 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.zone-row label {
  margin: 0;
  font-weight: 600;
}
.zone-row input {
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.zone-row .zone-meaning {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

/* The card's closing explanation, told apart from a field's hint by the box around
   it: it is not attached to any one control.
 *
 * `max-width: none` because `.settings-note` caps its text at 46em for readability,
 * and at the 11px this inherits that is 506px — the box stopped there while the
 * fields above ran to 774px, so it read as a panel that had come up short. A boxed
 * block is part of the card's frame and has to span it; the line-length rule is for
 * unboxed prose.
 */
#zones-about {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  margin: 16px 0 0;
  font-size: 11px;
  line-height: 1.5;
  max-width: none;
  width: 100%;
  box-sizing: border-box;
}


/* The timezone field: a search box with its suggestions, and the zone it
   resolved to (#61).
 *
 * The field sits in the flow of the card like any other input, and the result
 * list is anchored to it rather than pushing the card down as it fills — a
 * dropdown that reflows the page under the finger is how a click lands on the
 * wrong row.
 */
.zone-field {
  position: relative;
  display: block;
}

.zone-field input[type="text"] {
  width: 100%;
  box-sizing: border-box;
}

.zone-results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  /* Flush against the input's bottom border, with no gap: a click in the couple
     of pixels between the two would land on the card behind and close the list. */
  top: 100%;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.28);
}

.zone-results button {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 7px 9px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.zone-results button:hover,
.zone-results button[aria-selected="true"] {
  background: var(--accent-soft);
}

.zone-country {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.zone-offset {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* The zone that will be saved, in full, before it is written. This is what the
   confirmation step is for: a match the person did not mean is caught here. */
/* Where the person is, and the hour the app reads from it (#61 follow-up).
 *
 * Two labelled lines, not one row: the place is what the person chose and the
 * zone is derived from it, so running them together made two different kinds of
 * fact read as one value. A definition list is what this is, and it gives the
 * label column a shared width for free — the values line up without a grid.
 */
.zone-chosen {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  column-gap: 10px;
  row-gap: 3px;
  margin: 12px 0 0;
  font-size: 11px;
}

.zone-chosen dt {
  color: var(--muted);
}

.zone-chosen dd {
  margin: 0;
  word-break: break-word;
}

.zone-chosen code {
  font-size: 12px;
  color: var(--accent);
  word-break: break-all;
}

/* Attribution for the place data the search is built on (GeoNames, CC BY 4.0).
   Quiet, and last in the card — it is a licence requirement, not content.
 *
 * `16px` and not less: it follows the save button, and 16px is this project's
 * floor between a control and what comes after it. Measured at 12px first, which
 * read as the credit belonging to the button rather than to the card. */
.zone-credit {
  margin: 16px 0 0;
  font-size: 10px;
  color: var(--muted);
}

.zone-credit a {
  color: inherit;
}
