/* Apricut — ported from mockups/apricut-mockup.html and reworked per phone
   testing feedback: no horizontal scroll, iOS-safe bottom nav, tile dashboard
   for the latest day, clearer timeline cells. */

:root {
  /* Deploy marker printed by the width diagnostic (main.js) — bump on any
     layout-relevant CSS change so an on-phone screenshot proves which CSS
     the client actually loaded (PWA/Pages caches serve stale for ~10 min). */
  --css-v: 'v13-beta-access-note';
  --bg: #fff6ec;
  --card: #ffffff;
  --ink: #211a2c;
  --ink-soft: #6b6478;
  --line: #f0e2d8;
  --brand: #ff6a3d;
  --brand2: #ffb020;
  --brand-dark: #e14f26;
  --good: #12b76a;
  --good-bg: #e7f8ef;
  --good-ink: #0a8a52;
  --bad: #f0453d;
  --bad-bg: #ffe9e6;
  --bad-ink: #c81e13;
  --amber: #f2a20d;
  --amber-bg: #fff3d9;
  --amber-ink: #b9790a;
  --blue: #2e90fa;
  --blue-bg: #e9f2fe;
  --blue-ink: #1263c4;
  --muted: #9a92a8;
  --muted-bg: #f2eef5;
  --chip-bg: #fdeee0;
  --purple: #7c4dff;
  --grad-brand: linear-gradient(135deg, var(--brand), var(--brand2));
}

* { box-sizing: border-box; }

/* Interactive controls built as <button> keep their custom look but gain native
   keyboard access; reset the UA button chrome. */
button.choice, button.subtab {
  font: inherit; -webkit-appearance: none; appearance: none;
}
/* Visible focus ring for keyboard users (accessibility). */
button:focus-visible, [role="button"]:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--brand-dark); outline-offset: 2px;
}

/* Horizontal scroll is allowed so nothing is ever unreachable if some element
   ends up wider than the viewport (still hunting the offender on-device via the
   ?diag banner). App background on html too so any bounce shows the app colour. */
/* Content provably fits the viewport (verified via the in-app diagnostic in
   BOTH Safari and the installed standalone app: docScrollW == clientW). The
   residual sideways movement is iOS elastic rubber-band, so suppressing
   horizontal overscroll can't make anything unreachable. Vertical stays
   untouched (pull-to-refresh in Safari). */
/* Pin text size: iOS Safari may otherwise auto-inflate text on pages it
   considers overflowing, which widens labels and amplifies any overflow. */
html { background: var(--bg); overscroll-behavior-x: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, #fff9f2 0%, var(--bg) 100%);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-x: none;
}

.hidden { display: none !important; }

/* ============ Logged-out landing / brand ============ */
.login-hero { text-align: center; padding: 18px 0 8px; }
.login-logo {
  display: block; width: 92px; height: auto; margin: 0 auto 5px;
  filter: drop-shadow(0 10px 18px rgba(225, 79, 38, .2));
}
.login-title {
  margin: 0; color: var(--ink); font-size: 36px; font-weight: 850;
  letter-spacing: -.04em; line-height: 1.05;
}
.login-subtitle { margin: 7px 0 16px; }
.beta-notice {
  margin: 0 0 18px; padding: 13px 14px; text-align: left;
  background: #fff0e3; border: 1px solid #ffc999; border-radius: 14px;
  box-shadow: 0 5px 14px rgba(109, 62, 24, .06);
}
.beta-pill {
  display: inline-block; margin-bottom: 6px; padding: 3px 9px;
  color: #fff; background: var(--brand-dark); border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
}
.beta-notice p { margin: 0; color: #70401b; font-size: 13px; line-height: 1.45; }

/* The page scrolls normally (so Safari's toolbar auto-hides and reveals the
   nav). Bottom padding clears the fixed nav + home indicator — sized to the
   nav's actual height so there's no empty gap below it. */
.screen {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px calc(74px + env(safe-area-inset-bottom));
}

/* Chart canvas must never force the layout wider than its container (a likely
   iOS overflow cause). */
canvas { max-width: 100%; }

/* ============ Titles (#3) ============ */
.top-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.title-block { min-width: 0; }
h1.page-title { font-size: 24px; margin: 4px 0 2px; font-weight: 800; letter-spacing: -0.01em; }
.page-title .title-accent { color: var(--brand-dark); }
.page-sub {
  display: inline-block; font-size: 12px; font-weight: 700; color: var(--brand-dark);
  background: var(--chip-bg); border: 1px solid #ffd9b8; padding: 2px 10px;
  border-radius: 999px; margin: 2px 0 16px;
}
.page-note { font-size: 13px; color: var(--ink-soft); margin: 0 0 16px; }
.login-access-note { margin-top: 14px; text-align: center; }
/* Cycle pill: a native <select> dressed as the phase pill — the historical
   viewer's time-travel control (My Log / Browse / Summary). */
.cycle-select {
  -webkit-appearance: none; appearance: none; display: inline-block;
  font-size: 12px; font-weight: 700; color: var(--brand-dark); font-family: inherit;
  background: var(--chip-bg); border: 1px solid #ffd9b8; padding: 2px 22px 2px 10px;
  border-radius: 999px; margin: 2px 0 16px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6'%3E%3Cpath d='M0 0l4 6 4-6z' fill='%23e14f26'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
/* Viewing a finished cycle: purple = "you're in history". */
.cycle-select.archived {
  color: #4a3d70; background-color: #efeaf8; border-color: #d9cdf0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6'%3E%3Cpath d='M0 0l4 6 4-6z' fill='%234a3d70'/%3E%3C/svg%3E");
}
.ro-banner {
  background: #efeaf8; border: 1px solid #d9cdf0; color: #4a3d70; border-radius: 12px;
  padding: 9px 12px; font-size: 12.5px; margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.signout {
  flex: 0 0 auto; font-size: 12px; color: var(--muted); cursor: pointer;
  text-decoration: underline; background: none; border: none; font-family: inherit; padding: 4px 0;
}
.section-title { font-size: 14px; font-weight: 700; margin: 20px 0 10px; color: var(--ink); }

/* ============ Cards & forms ============ */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"] {
  width: 100%; min-width: 0; border: 1px solid var(--line); background: #fbfaf7; border-radius: 10px;
  /* 16px min: iOS Safari auto-zooms to any focused input under 16px, which
     then scrolls the Save button off-screen. 16px keeps pinch-zoom working. */
  padding: 11px 12px; font-size: 16px; color: var(--ink); margin-bottom: 14px; font-family: inherit;
}
/* iOS renders native date controls with a wide intrinsic size that ignores
   width:100% and overlaps the next field — appearance:none makes it a normal
   box that respects its column. */
input[type="date"] { -webkit-appearance: none; appearance: none; text-align: left; }
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1 1 0; min-width: 0; }
.choice-group { display: flex; gap: 8px; margin-bottom: 14px; }
.choice {
  flex: 1; text-align: center; padding: 10px 4px; border-radius: 10px; border: 1px solid var(--line);
  background: #fbfaf7; font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer; user-select: none;
}
.choice.selected { background: var(--grad-brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 10px rgba(255, 106, 61, .35); }
.tri-toggle { display: flex; gap: 8px; margin-bottom: 14px; }
.tri-toggle .choice.selected.yes { background: var(--good); border-color: var(--good); color: #fff; }
.tri-toggle .choice.selected.no { background: var(--bad); border-color: var(--bad); color: #fff; }

.btn-primary {
  width: 100%; background: var(--grad-brand); color: #fff; border: none; border-radius: 12px;
  padding: 13px; font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px rgba(255, 106, 61, .4); font-family: inherit;
}
.btn-primary:active { filter: brightness(0.92); }
.btn-primary:disabled { opacity: .6; cursor: default; }
/* Destructive variant (Delete): compact, red, no lift. Pair with .btn-primary. */
.btn-danger { width: auto; padding: 8px 14px; background: var(--bad); box-shadow: none; }
.save-note { font-size: 12px; color: var(--good-ink); text-align: center; margin-top: 10px; }
.link-btn { background: none; border: none; color: var(--brand-dark); font-weight: 700; font-size: 13px; cursor: pointer; text-decoration: underline; padding: 0; font-family: inherit; }

/* Google sign-in button + "or" divider */
.btn-google {
  width: 100%; background: #fff; color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; font-size: 15px; font-weight: 700; cursor: pointer;
  font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-google:active { background: #f6f3ef; }
.btn-google:disabled { opacity: .6; cursor: default; }
.g-logo {
  font-weight: 800; font-size: 16px; color: #4285f4;
  font-family: Arial, sans-serif; line-height: 1;
}
.or-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.cooldown { font-size: 12px; color: var(--muted); text-align: center; margin-top: 10px; }
.banner { background: #fdf1e6; border: 1px solid #f2d6b8; color: #7a4a1c; font-size: 12px; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; }
/* Shared layout bits (were repeated inline): a space-between row (message +
   action), and the bold intro line inside a card. */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-lead { font-weight: 700; margin: 0 0 6px; }
.center-empty { text-align: center; padding: 48px 20px; color: var(--muted); font-size: 13px; }

/* ============ Timeline table (#8, #9, #10) ============ */
/* overscroll-behavior-x: contain — when the table's own sideways scroll hits
   its edge, the drag must NOT chain to the page (that chaining was the last
   source of the whole-page sideways yank in the standalone app). */
.table-wrap { position: relative; }
/* Right-edge fade — toggled by .has-overflow (JS) so it only shows when there
   are more columns to the right, and never permanently eats vertical space. */
.table-wrap::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 26px;
  background: linear-gradient(to left, var(--card), rgba(255, 255, 255, 0));
  pointer-events: none; opacity: 0; transition: opacity .15s ease; border-radius: 0 8px 8px 0;
}
.table-wrap.has-overflow::after { opacity: 1; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; overscroll-behavior-x: contain; }
table.timeline { width: 100%; border-collapse: separate; border-spacing: 0 4px; font-size: 12px; }
table.timeline th { text-align: center; color: var(--muted); font-weight: 600; padding: 4px 6px; font-size: 11px; }
table.timeline td { padding: 8px 6px; color: var(--ink); text-align: center; background: #fbfaf7; }
/* Sticky Date column: the day stays pinned while you scroll right to Gym /
   reactions, so rows never lose their date. Opaque backgrounds let the other
   cells slide underneath; z-index keeps it above them. (border-collapse is
   `separate` here, which is what makes sticky cells work on iOS.) */
table.timeline th:first-child, table.timeline td:first-child { position: sticky; left: 0; z-index: 2; }
table.timeline th:first-child { text-align: left; background: var(--card); }
table.timeline td:first-child { text-align: left; font-weight: 600; border-radius: 8px 0 0 8px; white-space: nowrap; }
/* A soft right edge on the pinned column only once you've scrolled sideways. */
.table-scroll.scrolled-x table.timeline th:first-child, .table-scroll.scrolled-x table.timeline td:first-child { box-shadow: 6px 0 8px -6px rgba(33, 26, 44, .18); }
table.timeline td:last-child { border-radius: 0 8px 8px 0; }
/* #9 — status cells are full-cell tinted, not floating pills */
.cell-good { background: var(--good-bg) !important; color: var(--good-ink); font-weight: 800; }
.cell-amber { background: var(--amber-bg) !important; color: var(--amber-ink); font-weight: 800; }
.cell-bad { background: var(--bad-bg) !important; color: var(--bad-ink); font-weight: 800; }
.cell-blue { background: var(--blue-bg) !important; color: var(--blue-ink); font-weight: 800; }
.num { font-variant-numeric: tabular-nums; }
.dash { color: var(--muted); }
/* Away/holiday marker after a flagged date on the timeline (0019). */
.away-flag {
  display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px;
  margin-left: 6px; border-radius: 50%; background: var(--amber-ink); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 1; vertical-align: middle;
}
.row-actions { display: flex; gap: 6px; justify-content: center; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; width: 26px; height: 26px; font-size: 12px; cursor: pointer; color: var(--ink-soft); }

/* ============ Chart ============ */
.chart-card { padding: 12px 14px 6px; }
.chart-wrap { position: relative; height: 168px; }

/* ============ My Log entry form (behind "Log today"/edit) ============ */
/* The questionnaire is now a stack of per-question cards on the screen bg,
   so the outer form is a plain transparent wrapper (ENTRY_UX_DESIGN.md §4). */
.log-entry-form { background: transparent; border: none; border-radius: 0; padding: 0; margin-bottom: 14px; }
/* One question per card: label left, control right; stack = chips full-width. */
.log-entry-form .q-card {
  /* Grid, not flex: iOS WebKit laid out this row's space-between as if the
     free space were the viewport's, drifting the control past the card edge
     (the chip-clipping bug, IMG_2240 — card backgrounds ended at 377px while
     the chips inside sat at 423–452). Two hard columns can't drift: the label
     column absorbs all slack (and wraps — the BP 🔒 note), the control column
     hugs the right edge. */
  display: grid; grid-template-columns: minmax(0, 1fr) max-content; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 13px;
  padding: 7px 13px; margin-bottom: 5px;
}
.log-entry-form .q-label { min-width: 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.log-entry-form .q-label .q-sub { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 5px; }
/* Control hugs its answer at natural width in the auto column, right-aligned,
   so every card's answers line up on the right. justify-content is insurance:
   if an engine ever stretches the control, the answers stay pinned inside
   the card's right edge instead of drifting past it. */
.log-entry-form .q-control { display: flex; justify-self: end; justify-content: flex-end; }
/* iOS WebKit track-sizing bug (IMG_2243 diagnostic): the on-device grid
   resolved the two columns' widths SWAPPED (cols=190.9/130.1 instead of
   131/190.9), squeezing the answer below its natural size — yet it placed the
   control's right edge correctly at the card edge. So: the answer must never
   shrink (flex-shrink 0) and always packs against that right edge
   (flex-end all the way down) — a wrongly-sized column then overflows
   harmlessly LEFT into the label's empty space, never off-screen. */
.log-entry-form .q-control > * { flex-shrink: 0; }
.log-entry-form .q-card .choice-group, .log-entry-form .q-card .tri-toggle { justify-content: flex-end; }
/* Compact number inputs inside a row card (override the full-width defaults). */
.log-entry-form .q-card .q-num { width: 92px; margin-bottom: 0; text-align: center; }
/* Chips/toggles sit flush in the card — drop their standalone bottom margins,
   and hug their content (right-aligned) rather than stretching full width. */
.log-entry-form .q-card .choice-group, .log-entry-form .q-card .tri-toggle { margin-bottom: 0; flex: 0 0 auto; }
/* Every answer chip (Diet/Steps/Cardio/Gym) is one compact, uniform box. */
.log-entry-form .q-card .choice { flex: 0 0 58px; min-width: 0; padding: 8px 4px; font-size: 12px; }
/* Jump-to-older-day tail under the strip. */
.log-entry-form .day-jump { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.log-entry-form .day-jump > span { font-size: 12px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.log-entry-form .day-jump input[type="date"] { margin-bottom: 0; padding: 7px 10px; font-size: 16px; }
.log-entry-form .form-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.log-entry-form .form-head b { font-size: 15px; }
/* Compressed density so the whole form fits one phone screen — scoped so the
   login and measurement forms (shared global label/input/.choice rules) are
   untouched. */
.log-entry-form input[type="text"], .log-entry-form input[type="email"],
.log-entry-form input[type="number"], .log-entry-form input[type="date"] {
  padding: 8px 10px; font-size: 16px; margin-bottom: 8px; /* 16px: no iOS focus-zoom */
}
.log-entry-form label { margin-bottom: 4px; }
.log-entry-form .choice-group, .log-entry-form .tri-toggle { margin-bottom: 8px; }
.log-entry-form .choice { padding: 7px 4px; }
.log-entry-form .form-hint { font-size: 12px; color: var(--muted); margin: 6px 0 8px; }
/* Day strip (ENTRY_UX_DESIGN.md §2): ≤6 day pills + paging chevrons. Green
   ✓ dot = day has an entry; outlined pill = the day being edited. */
/* Week caption above the fixed Mon–Sun day strip. */
.log-entry-form .week-cap { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 7px; }
.log-entry-form .wc-main { font-size: 13px; font-weight: 800; color: var(--brand-dark); }
.log-entry-form .wc-range { font-size: 11px; color: var(--muted); }
.log-entry-form .day-strip { display: flex; gap: 5px; align-items: stretch; margin-bottom: 10px; }
/* Round bordered button (clear tap target) with a large chevron. */
.log-entry-form .strip-arrow {
  flex: 0 0 auto; align-self: center; display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: 1.5px solid var(--line); border-radius: 50%;
  background: var(--card); color: var(--brand-dark); font-size: 24px; font-weight: 800;
  line-height: 1; padding: 0 0 3px; cursor: pointer; font-family: inherit;
}
.log-entry-form .strip-arrow:disabled { color: var(--muted); opacity: .4; cursor: default; }
.log-entry-form .day-pill {
  flex: 1; min-width: 0; text-align: center; background: var(--card); border: 1.5px solid var(--line);
  border-radius: 14px; padding: 6px 0 5px; cursor: pointer; font-family: inherit;
}
.log-entry-form .day-pill.sel { border-color: var(--brand-dark); background: #fff; box-shadow: 0 3px 10px rgba(255, 106, 61, .18); }
/* Out-of-range days (pre-challenge / future): greyed and non-interactive. */
.log-entry-form .day-pill.disabled { opacity: .4; cursor: default; background: #faf6f1; }
.log-entry-form .dp-dow { display: block; font-size: 9px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; }
.log-entry-form .dp-num { display: block; font-size: 15px; font-weight: 800; color: var(--ink); margin: 1px 0 3px; }
.log-entry-form .dp-dot {
  display: flex; align-items: center; justify-content: center; width: 15px; height: 15px;
  border-radius: 50%; margin: 0 auto; background: var(--muted-bg); color: #fff; font-size: 9px; font-weight: 800;
}
.log-entry-form .dp-dot.done { background: var(--good); }
/* Amber = an entry exists but a habit (diet/steps/cardio/gym) is still blank. */
.log-entry-form .dp-dot.partial { background: var(--amber-ink); }

/* Away/holiday flag — deliberately quiet + narrow (a secondary control; most
   days aren't away days). A slim row with a small switch; subtle amber tint only
   when on, so it never competes with the habit questions. */
.log-entry-form .holiday-card {
  display: flex; align-items: center; gap: 7px; padding: 9px 12px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer;
}
.log-entry-form .holiday-card.on { border-color: #f0cf9a; background: #fffaf1; }
.log-entry-form .holiday-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.log-entry-form .holiday-card.on .holiday-label { color: var(--ink); }
.log-entry-form .holiday-sub { font-size: 11px; font-weight: 400; color: var(--muted); }
.log-entry-form .toggle {
  position: relative; width: 38px; height: 22px; flex: 0 0 auto; margin-left: auto;
  border: 1px solid var(--line); border-radius: 999px; background: #ece4da;
  cursor: pointer; padding: 0; transition: background .15s;
}
.log-entry-form .toggle .knob {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .18); transition: left .15s;
}
.log-entry-form .toggle.on { background: var(--brand); border-color: var(--brand); }
.log-entry-form .toggle.on .knob { left: 17px; }

/* Cardio/Gym share one row; each pair is boxed with its label so the four
   Yes/No chips read as two units, not four floating buttons. */
.log-entry-form .pair-box {
  border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px 8px;
  background: #f5f1ec; text-align: center;
}
.log-entry-form .pair-box label { margin-bottom: 4px; }
.log-entry-form .pair-box .tri-toggle { margin-bottom: 0; }
.log-entry-form .pair-box .choice { background: #fff; }
/* Selected Diet/Steps chips take their meaning's colour, matching the
   Cardio/Gym Yes/No toggles: Perfect/10k green, Mid yellow, Bad/No red,
   15k blue. Day chips (Today/Yesterday) have no data-v and stay brand. */
.log-entry-form .choice.selected[data-v="perfect"],
.log-entry-form .choice.selected[data-v="achieved_10k"] {
  background: var(--good); border-color: var(--good); box-shadow: 0 4px 10px rgba(18, 183, 106, .35);
}
.log-entry-form .choice.selected[data-v="mid"] {
  background: var(--amber); border-color: var(--amber); box-shadow: 0 4px 10px rgba(242, 162, 13, .35);
}
.log-entry-form .choice.selected[data-v="bad"],
.log-entry-form .choice.selected[data-v="no"] {
  background: var(--bad); border-color: var(--bad); box-shadow: 0 4px 10px rgba(240, 69, 61, .35);
}
.log-entry-form .choice.selected[data-v="achieved_15k"] {
  background: var(--blue); border-color: var(--blue); box-shadow: 0 4px 10px rgba(46, 144, 250, .35);
}

/* ============ Browse (#11, #12, #13) ============ */
.participant-item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; margin-bottom: 10px; cursor: pointer; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff; flex: 0 0 auto; box-shadow: 0 3px 8px rgba(0, 0, 0, .15); }
.p-main { flex: 1 1 auto; min-width: 0; }
.p-name { font-size: 14px; font-weight: 700; }
.p-sub { font-size: 11px; color: var(--muted); }
.p-metrics { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.p-delta { font-size: 12px; font-weight: 800; }
.p-delta.down { color: var(--good-ink); }
.p-delta.up { color: var(--bad-ink); }
.p-delta.flat { color: var(--muted); }
.p-weight { font-weight: 800; font-size: 15px; min-width: 62px; text-align: right; }
.chev { color: var(--muted); font-size: 18px; flex: 0 0 auto; }
.self-tag { font-size: 10px; background: var(--grad-brand); color: #fff; font-weight: 700; padding: 2px 8px; border-radius: 6px; margin-left: 6px; }
.subtabs { display: flex; gap: 6px; margin-bottom: 14px; }
.subtab { flex: 1; text-align: center; padding: 9px 4px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 12.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.subtab.active { background: var(--grad-brand); color: #fff; border-color: var(--brand); }

/* ============ KPI dashboard ============ */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.kpi-grid.kpi-grid-wide { grid-template-columns: 1fr; }
.kpi-card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--purple); border-radius: 12px; padding: 10px 12px; }
.kpi-card.tone-good { border-color: #cfe4d4; border-left-color: var(--good); background: #f2fcf6; }
.kpi-card.tone-bad { border-color: #f0d3c4; border-left-color: var(--bad); background: #fff5f4; }
.kpi-label { font-size: 10.5px; color: var(--ink-soft); font-weight: 600; margin-bottom: 4px; }
.kpi-value { font-size: 16px; font-weight: 700; color: var(--ink); }
.kpi-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.kpi-arrow.down { color: var(--good); font-weight: 800; }
.kpi-arrow.up { color: var(--bad); font-weight: 800; }

/* ============ Summary (#14, #15) ============ */
.summary-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.summary-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 10.5px; }
.summary-table td { padding: 9px 4px; border-bottom: 1px solid var(--line); }
.summary-table tr:last-child td { border-bottom: none; }
.badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
/* Rankings badges: session-count heat badges stay compact; "Since wk 1"
   is the headline number and reads larger. */
.summary-table td .badge { font-size: 11px; padding: 2px 7px; }
.summary-table td .badge-wk { font-size: 14px; padding: 3px 8px; }
.summary-table .td-weight { font-weight: 800; }
/* Tappable column headers (Rankings): plain-looking but interactive. */
.summary-table th .th-sort {
  background: none; border: none; padding: 0; font: inherit; font-weight: 700;
  color: var(--muted); cursor: pointer; white-space: nowrap;
}
.summary-table th .th-sort.active { color: var(--brand-dark); }
/* Measurements grid (Rankings): tight, centred month columns; the pinned Name
   column stays left. cell-good/cell-bad shade each person's best/worst month;
   the trend arrow rides their newest value (green = improving, red = not). */
.summary-table.meas-grid th, .summary-table.meas-grid td { text-align: center; white-space: nowrap; padding-left: 1px; padding-right: 1px; }
.summary-table.meas-grid th:first-child, .summary-table.meas-grid td:first-child { text-align: left; padding-left: 2px; padding-right: 6px; }
.summary-table.meas-grid th .th-sort { padding: 0; } /* month headers are just "Jan" now — no side padding needed */
.meas-arrow { font-size: 10px; font-weight: 800; }
.meas-arrow.good { color: var(--good-ink); }
.meas-arrow.bad { color: var(--bad-ink); }
.p-delta-label { font-size: 10px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; }
/* The 3-day average is the number the group actually compares — headline it. */
table.timeline .cell-avg3 { font-weight: 800; font-size: 13px; }
.badge.good { background: var(--good-bg); color: var(--good-ink); }
.badge.amber { background: var(--amber-bg); color: var(--amber-ink); }
.badge.bad { background: var(--bad-bg); color: var(--bad-ink); }
.badge.muted { background: var(--chip-bg); color: var(--muted); }
.info-note { background: #eef4ff; border: 1px solid #d4e0f7; color: #3a4a6b; font-size: 12px; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }

/* ============ Reactions (👍🔥💪) ============ */
.react-bar { display: inline-flex; gap: 6px; }
.react-btn {
  display: inline-flex; align-items: center; gap: 3px;
  background: #fbfaf7; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; font-size: 14px; cursor: pointer; font-family: inherit;
  line-height: 1;
}
.react-btn.mine { background: var(--chip-bg); border-color: var(--brand); }
.react-btn:disabled { opacity: .6; }
.react-count { font-size: 11px; font-weight: 800; color: var(--brand-dark); min-width: 0; }
.react-bar.compact .react-btn { padding: 3px 7px; font-size: 12px; }
td.react-cell { white-space: nowrap; }
.react-pill {
  display: inline-block; background: var(--chip-bg); border: 1px solid #ffd9b8;
  border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700;
  color: var(--brand-dark); margin-right: 4px;
}
.react-received { white-space: nowrap; }
.react-received-line { font-size: 13px; color: var(--ink-soft); margin: 0 0 12px; }
/* Per-KPI 🔥 in the corner of Browse KPI cards */
.kpi-card { position: relative; }
.kpi-react { position: absolute; top: 8px; right: 8px; }

/* Phase "you are here" line under the Summary title */
.phase-info { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); margin: -4px 0 14px; }
.phase-day { font-weight: 800; color: var(--brand-dark); background: var(--chip-bg); border: 1px solid #ffd9b8; border-radius: 999px; padding: 1px 9px; font-size: 12px; }

/* ============ Rankings measurements ============ */
.m-note { font-size: 11px; color: var(--ink-soft); margin-top: 8px; }

/* ============ Photos tab ============ */
.up-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border: 2px dashed #ffd9b8; border-radius: 14px; background: #fffaf3; color: var(--brand-dark); font-weight: 800; font-size: 14px; cursor: pointer; }
.vis-row { display: flex; gap: 10px; margin-top: 12px; }
.vis-opt { flex: 1; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; font-size: 12px; font-weight: 700; background: #fff; cursor: pointer; }
.vis-opt .big { font-size: 18px; display: block; margin-bottom: 2px; }
.vis-opt.selected { border-color: var(--brand-dark); background: var(--chip-bg); }
.vis-sub { font-weight: 400; color: var(--muted); }
.vis-hint { font-size: 11px; color: var(--muted); margin-top: 8px; }
.preview { width: 100%; border-radius: 14px; margin-top: 12px; max-height: 420px; object-fit: contain; background: #f6ede2; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ph { position: relative; aspect-ratio: 3/4; border-radius: 12px; overflow: hidden; background: #efe0d0; cursor: pointer; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph.ph-broken::after { content: '🖼️'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.ph .tag { position: absolute; top: 6px; right: 6px; font-size: 12px; background: rgba(255,255,255,.85); border-radius: 8px; padding: 2px 5px; }
.ph .ph-date { position: absolute; bottom: 0; left: 0; right: 0; font-size: 10px; font-weight: 700; color: #fff; background: linear-gradient(transparent, rgba(33,26,44,.75)); padding: 14px 6px 5px; }
.ph .who { position: absolute; top: 6px; left: 6px; font-size: 10px; font-weight: 800; color: #fff; background: rgba(33,26,44,.55); border-radius: 8px; padding: 2px 7px; }
.photo-viewer { position: fixed; inset: 0; z-index: 1000; background: rgba(33,26,44,.7); display: flex; align-items: center; justify-content: center; padding: 16px; }
.viewer-card { background: var(--card); border-radius: 18px; padding: 14px; max-width: 480px; width: 100%; max-height: 92vh; overflow-y: auto; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.viewer-img { width: 100%; border-radius: 12px; background: #f6ede2; min-height: 120px; }
.viewer-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }

/* Install ("Add to Home Screen") card on the login screen. */
.install-card { border-color: #ffd9b8; background: #fffaf3; margin-top: 16px; }
.install-steps { font-size: 13px; color: var(--ink); line-height: 1.5; margin: 0; }

/* Offline banner — fixed at the top, clears the notch. */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: var(--ink); color: #fff; text-align: center;
  font-size: 12px; font-weight: 600;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
}
/* Push content clear of the fixed banner while offline. */
body.is-offline .screen { padding-top: calc(40px + env(safe-area-inset-top)); }

/* ============ Bottom nav — fixed, centered, clearing the home indicator.
   For a fully chrome-free experience, add the app to the Home Screen (it runs
   standalone with no Safari toolbar). ============ */
.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 10;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding: 8px 4px calc(10px + env(safe-area-inset-bottom));
}
.nav-item { flex: 1; min-width: 0; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 0; cursor: pointer; border-radius: 10px; text-decoration: none; }
.nav-item.active { color: #fff; background: var(--grad-brand); box-shadow: 0 4px 12px rgba(255, 106, 61, .35); }
.nav-icon { display: block; font-size: 17px; margin-bottom: 2px; }
/* Journal: delete the selected day's entry (shown only when one exists). */
.journal-delete { display: block; margin: 10px auto 0; }
/* My Log: metric toggle for the trend chart + latest-measurements card. */
.metric-toggle { margin: 8px 0 10px; }
.meas-card { padding: 11px 14px; }
.meas-head { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.meas-head .meas-sub { font-size: 11px; font-weight: 400; color: var(--ink-soft); }
.meas-row { display: flex; flex-wrap: wrap; gap: 14px; }
.meas-bit { font-size: 13px; color: var(--ink-soft); }
.meas-bit b { color: var(--ink); font-weight: 800; font-size: 14px; }
.meas-unit { font-size: 11px; color: var(--ink-soft); }
/* Journal monthly check-in: a labelled band above the girth cards. */
.monthly-wrap { margin-top: 18px; }
/* Big month + clear section title, so the monthly check-in reads as its own
   section rather than more daily rows. */
.monthly-head { font-size: 24px; font-weight: 800; letter-spacing: .02em; color: var(--blue-ink); margin: 6px 0 10px; }
.monthly-head span { font-size: 14px; color: var(--ink-soft); font-weight: 700; letter-spacing: 0; margin-left: 8px; }
/* Journal auto-save status: sticky above the nav, always visible and tappable
   while work is pending or retryable. */
.journal-save-bar {
  position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 5;
  margin-top: 12px;
}
.save-status {
  width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--ink-soft); font: inherit; font-weight: 750;
  box-shadow: 0 5px 16px rgba(49, 40, 78, .12); padding: 10px 14px;
}
.save-status:disabled { opacity: 1; cursor: default; }
.save-status.pending, .save-status.saving { color: var(--blue-ink); }
.save-status.deleting { color: var(--bad); }
.save-status.pending::before, .save-status.saving::before {
  content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 8px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  vertical-align: -2px; animation: save-spin .75s linear infinite;
}
@keyframes save-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .save-status.pending::before, .save-status.saving::before { animation: none; } }
.save-status.error { color: var(--bad); border-color: rgba(201, 51, 73, .35); cursor: pointer; }
.save-status.invalid, .save-status.empty-clear { color: var(--amber-ink); border-color: rgba(218, 143, 35, .4); }
.save-status.unknown { color: #5b3f86; border-color: rgba(91, 63, 134, .4); }
.monthly-section + .monthly-section { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
/* Blood pressure card: two small integer inputs, and a private cue. */
.log-entry-form .bp-pair { display: flex; align-items: center; gap: 6px; }
/* Needs the .q-card level to outrank the generic 92px .q-card .q-num rule. */
.log-entry-form .q-card .q-num.bp-num { width: 54px; }
.log-entry-form .bp-slash { color: var(--muted); font-weight: 800; }
.log-entry-form .q-label .bp-private { display: block; margin-left: 0; color: #4a3d70; font-weight: 600; }
